~ubuntu-branches/ubuntu/quantal/openerp6.1/quantal-proposed

« back to all changes in this revision

Viewing changes to openerp/addons/document/test_cindex.py

  • Committer: Package Import Robot
  • Author(s): Yolanda Robla
  • Date: 2012-09-20 15:29:00 UTC
  • Revision ID: package-import@ubuntu.com-20120920152900-woyy3yww8z6acmsk
Tags: upstream-6.1-1+dfsg
ImportĀ upstreamĀ versionĀ 6.1-1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import sys
 
4
import os
 
5
import glob
 
6
import time
 
7
import logging
 
8
 
 
9
from optparse import OptionParser
 
10
 
 
11
logging.basicConfig(level=logging.DEBUG)
 
12
 
 
13
parser = OptionParser()
 
14
parser.add_option("-q", "--quiet",
 
15
                  action="store_false", dest="verbose", default=True,
 
16
                  help="don't print status messages to stdout")
 
17
 
 
18
parser.add_option("-C", "--content",
 
19
                  action="store_true", dest="docontent", default=False,
 
20
                  help="Disect content, rather than the file.")
 
21
 
 
22
parser.add_option("--delay",
 
23
                  action="store_true", dest="delay", default=False,
 
24
                  help="delay after the operation, to inspect child processes")
 
25
 
 
26
(options, args) = parser.parse_args()
 
27
 
 
28
import content_index, std_index
 
29
 
 
30
from content_index import cntIndex
 
31
 
 
32
for fname in args:
 
33
    try:
 
34
        if options.docontent:
 
35
            fp = open(fname,'rb')
 
36
            content = fp.read()
 
37
            fp.close()
 
38
            res = cntIndex.doIndex(content, fname, None, None, True)
 
39
        else:
 
40
            res = cntIndex.doIndex(None, fname, None, fname,True)
 
41
 
 
42
        if options.verbose:
 
43
            for line in res[:5]:
 
44
                print line
 
45
        if options.delay:
 
46
            time.sleep(30)
 
47
    except Exception,e:
 
48
        import traceback
 
49
        tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback))
 
50
    except KeyboardInterrupt:
 
51
        print "Keyboard interrupt"
 
52
 
 
53
#eof
 
54
 
 
55
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: