[Zope-CVS] CVS: Products/ZCTextIndex/tests - mailtest.py:1.8

Tim Peters tim.one@comcast.net
Sun, 19 May 2002 14:38:42 -0400


Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv3917/tests

Modified Files:
	mailtest.py 
Log Message:
Gave it a "-c NNN" context argument (how many leading lines of result
msgs to display).  Changed the module docstring to separate the index-
generation args from the query args.


=== Products/ZCTextIndex/tests/mailtest.py 1.7 => 1.8 ===
 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.
@@ -149,8 +154,6 @@
         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
@@ -179,18 +182,19 @@
     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)
@@ -213,6 +217,8 @@
             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':