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

Commit

Permalink
Gave it a "-c NNN" context argument (how many leading lines of result
Browse files Browse the repository at this point in the history
msgs to display).  Changed the module docstring to separate the index-
generation args from the query args.
  • Loading branch information
Tim Peters committed May 19, 2002
1 parent dc5dad8 commit 3700aeb
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tests/mailtest.py
Expand Up @@ -4,14 +4,19 @@
options:
-v -- verbose
-n NNN -- max number of messages to read from mailbox
-q query
Index Generation
-i mailbox
-n NNN -- max number of messages to read from mailbox
-t NNN -- commit a transaction every NNN messages (default: 1)
-p NNN -- pack <data.fs> every NNN messages (default: 500), and at end
-p 0 -- don't pack at all
-b NNN -- return the NNN best matches (default: 10)
-x -- exclude the message text from the data.fs
-t NNN -- commit a transaction every NNN messages (default: 1)
Queries
-q query
-b NNN -- return the NNN best matches (default: 10)
-c NNN -- context; if -v, show the first NNN lines of results (default: 5)
The script either indexes or queries depending on whether -q or -i is
passed as an option.
Expand Down Expand Up @@ -149,8 +154,6 @@ def query(rt, query_str):
print "docid %4d score %2d" % (docid, score)
if VERBOSE:
msg = docs[docid]
# print 3 lines of context
CONTEXT = 5
ctx = msg.text.split("\n", CONTEXT)
del ctx[-1]
print "-" * 60
Expand Down Expand Up @@ -179,18 +182,19 @@ def main(fs_path, mbox_path, query_str):
import getopt

NUM = 0
BEST = 10
VERBOSE = 0
PACK_INTERVAL = 500
EXCLUDE_TEXT = 0
CACHE_SIZE = 10000
TXN_SIZE = 1
BEST = 10
CONTEXT = 5
query_str = None
mbox_path = None
profile = None
old_profile = None
try:
opts, args = getopt.getopt(sys.argv[1:], 'vn:p:i:q:b:xt:',
opts, args = getopt.getopt(sys.argv[1:], 'vn:p:i:q:b:c:xt:',
['profile=', 'old-profile='])
except getopt.error, msg:
usage(msg)
Expand All @@ -213,6 +217,8 @@ def main(fs_path, mbox_path, query_str):
EXCLUDE_TEXT = 1
elif o == '-t':
TXN_SIZE = int(v)
elif o == '-c':
CONTEXT = int(v)
elif o == '--profile':
profile = v
elif o == '--old-profile':
Expand Down

0 comments on commit 3700aeb

Please sign in to comment.