forked from maximilianh/pubMunch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pubDictCompile
executable file
·36 lines (30 loc) · 1.37 KB
/
pubDictCompile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# load default python packages
import sys, logging, optparse, os, glob, zipfile, types, re, tempfile, shutil, codecs
from os.path import *
# add <scriptDir>/lib/ to package search path
progFile = os.path.abspath(sys.argv[0])
progDir = os.path.dirname(progFile)
pubToolsLibDir = os.path.join(progDir, "lib")
sys.path.insert(0, pubToolsLibDir)
# now load our own libraries
import fastFind, pubGeneric
# === COMMAND LINE INTERFACE, OPTIONS AND HELP ===
parser = optparse.OptionParser("""usage: %prog [options] gzTabFile - precompile dictionary in format identifier<tab>name1|name2|name3|... (one per line)
""")
#parser.add_option("-p", "--prefer", dest="prefer", action="store", help="prefer a certain type of system, e.g. server (redis) or disk (sqlite)")
#parser.add_option("-n", "--newDb", dest="newDb", action="store_true", help="delete the old db before writing data to it")
parser.add_option("", "--case", dest="keepCase", action="store_true", help="keep case of keywords. Default is to lowercase the dictionary.")
pubGeneric.addGeneralOptions(parser)
(options, args) = parser.parse_args()
if len(args)==0:
parser.print_help()
sys.exit(0)
# ----------- MAIN --------------
# only for debugging
pubGeneric.setupLogging(progFile, options)
fname = args[0]
if args==[]:
parser.print_help()
exit(1)
fastFind.compileDict(fname, toLower=(not options.keepCase))