diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-11-27 13:41:14 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-11-27 13:41:14 +0200 |
commit | cfe445a92d11e206c63a4e73588cced065df104f (patch) | |
tree | 990d914bab3e5ef64b3d88f09c68ac1af1f05d9e /wikicvt.py | |
parent | 6508bd65f006d7ca1cdaa0d177341ddfe72334a9 (diff) | |
download | wikitrans-cfe445a92d11e206c63a4e73588cced065df104f.tar.gz wikitrans-cfe445a92d11e206c63a4e73588cced065df104f.tar.bz2 |
Minor changes.
* wiki2text.py: The constructor keyword argument markup allows to
inhibit any markup
* wikicvt.py: New command line option -o (--option).
Admit - as input file name.
Diffstat (limited to 'wikicvt.py')
-rw-r--r-- | wikicvt.py | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -23,3 +23,6 @@ from wiki2text import * def usage(code=0): - print "usage: " + sys.argv[0] + "[-hvt] [-l lang] [--lang=lang] [--text] [--help] [--verbose] file\n" + print """ +usage: %s [-hvt] [-l lang] [-o kw=val] [--lang=lang] [--option kw=val] + [--text] [--help] [--verbose] file +""" % (sys.argv[0]) sys.exit(code) @@ -30,5 +33,7 @@ def main(): lang = "pl" + kwdict = {} try: - opts, args = getopt.getopt(sys.argv[1:], "hl:tv", - ["help", "lang=", "text", "verbose" ]) + opts, args = getopt.getopt(sys.argv[1:], "hl:o:tv", + ["help", "lang=", "option=", + "text", "verbose" ]) except getopt.GetoptError: @@ -45,5 +50,12 @@ def main(): lang = a + if o in ("-o", "--option"): + (kw,sep,val) = a.partition('=') + if val != '': + kwdict[kw] = eval(val) if len(args) == 1: - inputfilename = args[0] + if args[0] == '-': + kwdict['file'] = sys.stdin + else: + kwdict['filename'] = args[0] else: @@ -51,6 +63,7 @@ def main(): + kwdict['lang']=lang if html: - markup = HtmlWiktionaryMarkup(filename=inputfilename, lang=lang) + markup = HtmlWiktionaryMarkup(**kwdict) else: - markup = TextWiktionaryMarkup(filename=inputfilename, lang=lang) + markup = TextWiktionaryMarkup(**kwdict) |