osv: Improve the translation logic for the osv.check wrapper
[odoo/odoo.git] / addons / document / test_cindex.py
1 #!/usr/bin/python
2
3 import sys
4 import os
5 import glob
6
7 from optparse import OptionParser
8
9 parser = OptionParser()
10 parser.add_option("-q", "--quiet",
11                   action="store_false", dest="verbose", default=True,
12                   help="don't print status messages to stdout")
13
14 parser.add_option("-C", "--content",
15                   action="store_true", dest="docontent", default=False,
16                   help="Disect content, rather than the file.")
17
18 (options, args) = parser.parse_args()
19
20 import content_index, std_index
21
22 from content_index import cntIndex
23
24 for fname in args:
25     try:
26         if options.docontent:
27             fp = open(fname,'rb')
28             content = fp.read()
29             fp.close()
30             res = cntIndex.doIndex(content, fname, None, None, True)
31         else:
32             res = cntIndex.doIndex(None, fname, None, fname,True)
33
34         if options.verbose:
35             for line in res[:5]:
36                 print line
37     except Exception,e:
38         import traceback
39         tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback))
40         
41
42 #eof