Added debug function timer.
[jblite.git] / jblite / main.py
blob85dfab98a14f56c4546fddc47579dcde2c9fa6d9
1 #!/usr/bin/env python
3 """Script for converting KANJIDIC2 to SQLite."""
5 import optparse
6 from jblite.kd2 import KD2Converter
7 from jblite.jmdict import JMdictConverter
8 import gettext
9 gettext.install("jblite")
12 def parse_args():
13 usage="usage: %prog [options] <xml_src> <sqlite_dest>"
14 op = optparse.OptionParser(usage)
15 op.add_option("-v", "--verbose", action="store_true",
16 help=_("Display verbose output (default: %default)"))
17 op.add_option("-f", "--format",
18 help=_("Format of database file (kanjidic2, jmdict) "
19 "(default: %default)"))
20 op.set_defaults(verbose=False,
21 format="kanjidic2")
22 return op.parse_args()
24 def main():
25 (options, args) = parse_args()
26 src_fname, dest_fname = args[:2]
27 formats = {
28 "kanjidic2": KD2Converter,
29 "jmdict": JMdictConverter,
31 cls = formats[options.format]
32 converter = cls(src_fname, dest_fname, verbose=options.verbose)
33 converter.run()
35 if __name__ == "__main__":
36 main()