summaryrefslogtreecommitdiff
path: root/wikicvt.py
diff options
context:
space:
mode:
Diffstat (limited to 'wikicvt.py')
-rw-r--r--wikicvt.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/wikicvt.py b/wikicvt.py
index 418ec26..d45a61f 100644
--- a/wikicvt.py
+++ b/wikicvt.py
@@ -21,16 +21,21 @@ from wiki2html import *
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)
def main():
verbose_flag = 0
html = 1
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:
usage(1)
@@ -43,16 +48,24 @@ def main():
html = 0
if o in ("-l", "--lang"):
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:
usage(1)
+ kwdict['lang']=lang
if html:
- markup = HtmlWiktionaryMarkup(filename=inputfilename, lang=lang)
+ markup = HtmlWiktionaryMarkup(**kwdict)
else:
- markup = TextWiktionaryMarkup(filename=inputfilename, lang=lang)
+ markup = TextWiktionaryMarkup(**kwdict)
markup.parse()
print str(markup)

Return to:

Send suggestions and report system problems to the System administrator.