Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
d9c0428f
Commit
d9c0428f
authored
May 16, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Produce HTML output instead of text output
parent
8f30adc2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
lib/python/Products/ZCTextIndex/tests/queryhtml.py
lib/python/Products/ZCTextIndex/tests/queryhtml.py
+24
-5
No files found.
lib/python/Products/ZCTextIndex/tests/queryhtml.py
View file @
d9c0428f
...
@@ -14,8 +14,19 @@ QUERIES = ["nested recursive functions",
...
@@ -14,8 +14,19 @@ QUERIES = ["nested recursive functions",
"articulate information"
,
"articulate information"
,
"import default files"
,
"import default files"
,
"gopher ftp http"
,
"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
):
def
main
(
rt
):
index
=
rt
[
"index"
]
index
=
rt
[
"index"
]
files
=
rt
[
"files"
]
files
=
rt
[
"files"
]
...
@@ -28,21 +39,29 @@ def main(rt):
...
@@ -28,21 +39,29 @@ def main(rt):
t0
=
clock
()
t0
=
clock
()
results
,
num
=
index
.
query
(
query
)
results
,
num
=
index
.
query
(
query
)
t1
=
clock
()
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
key
=
query
if
i
==
0
:
if
i
==
0
:
print
"<ol>"
for
docid
,
score
in
results
:
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
continue
l
=
times
.
setdefault
(
key
,
[])
l
=
times
.
setdefault
(
key
,
[])
l
.
append
(
t1
-
t0
)
l
.
append
(
t1
-
t0
)
l
=
times
.
keys
()
l
=
times
.
keys
()
l
.
sort
()
l
.
sort
()
print
print
"<hr>"
for
k
in
l
:
for
k
in
l
:
v
=
times
[
k
]
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__"
:
if
__name__
==
"__main__"
:
import
sys
import
sys
...
@@ -65,7 +84,7 @@ if __name__ == "__main__":
...
@@ -65,7 +84,7 @@ if __name__ == "__main__":
FSPATH
=
v
FSPATH
=
v
fs
=
FileStorage
(
FSPATH
,
read_only
=
1
)
fs
=
FileStorage
(
FSPATH
,
read_only
=
1
)
db
=
ZODB
.
DB
(
fs
)
db
=
ZODB
.
DB
(
fs
,
cache_size
=
10000
)
cn
=
db
.
open
()
cn
=
db
.
open
()
rt
=
cn
.
root
()
rt
=
cn
.
root
()
main
(
rt
)
main
(
rt
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment