Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Produce HTML output instead of text output
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Hylton committed May 16, 2002
1 parent a69f7ac commit 294f0de
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions tests/queryhtml.py
Expand Up @@ -14,8 +14,19 @@
"articulate information",
"import default files",
"gopher ftp http",
"documentation",
]

def path2url(p):
# convert the paths to a python.org URL
# hack: only works for the way Jeremy indexed his copy of python.org
marker = "www.python.org/."
i = p.find(marker)
if i == -1:
return p
i += len(marker)
return "http://www.python.org" + p[i:]

def main(rt):
index = rt["index"]
files = rt["files"]
Expand All @@ -28,21 +39,29 @@ def main(rt):
t0 = clock()
results, num = index.query(query)
t1 = clock()
print num, query, t1 - t0
print "<p>Query: \"%s\"" % query
print "<br>Num results: %d" % num
print "<br>time.clock(): %s" % (t1 - t0)
key = query
if i == 0:
print "<ol>"
for docid, score in results:
print score, files[docid]
url = path2url(files[docid])
fmt = '<li><a href="%s">%s</A> score = %s'
print fmt % (url, url, score)
print "</ol>"
continue
l = times.setdefault(key, [])
l.append(t1 - t0)

l = times.keys()
l.sort()
print
print "<hr>"
for k in l:
v = times[k]
print min(v), k, " ".join(map(str, v))
print "<p>Query: \"%s\"" % k
print "<br>Min time: %s" % min(v)
print "<br>All times: %s" % " ".join(map(str, v))

if __name__ == "__main__":
import sys
Expand All @@ -65,7 +84,7 @@ def main(rt):
FSPATH = v

fs = FileStorage(FSPATH, read_only=1)
db = ZODB.DB(fs)
db = ZODB.DB(fs, cache_size=10000)
cn = db.open()
rt = cn.root()
main(rt)

0 comments on commit 294f0de

Please sign in to comment.