summaryrefslogtreecommitdiff
path: root/wikicvt.py
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-11-26 09:52:15 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2008-11-26 09:52:27 +0200
commitbd79a17ca5082789d4cf82f62a6afc0baaca90e8 (patch)
tree40c002caaab88586c2c8649bc9cd3ffe2b18bd69 /wikicvt.py
parent5dc93e466efaaa243e6490961b6e545eaa65f06c (diff)
downloadwikitrans-bd79a17ca5082789d4cf82f62a6afc0baaca90e8.tar.gz
wikitrans-bd79a17ca5082789d4cf82f62a6afc0baaca90e8.tar.bz2
Implement plain text conversion.
* wiki2html.py (HtmlWikiMarkup): Move lang, html_base, image_base, media_base, langtab, str_nil, str_text, fmtok, __str__ to WikiMarkup * wikimarkup.py: See above. * wiki2plain.py: Remove. * wiki2text.py: New file (instead of the above) * wikicvt.py: Implement new options.
Diffstat (limited to 'wikicvt.py')
-rw-r--r--wikicvt.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/wikicvt.py b/wikicvt.py
index 7d22c2e..5b8e5a0 100644
--- a/wikicvt.py
+++ b/wikicvt.py
@@ -18,16 +18,19 @@
import sys
import getopt
from wiki2html import *
+from wiki2text import *
def usage(code=0):
- print "usage: " + sys.argv[0] + "[-hv] [--help] [--verbose] file\n"
+ print "usage: " + sys.argv[0] + "[-hvt] [-l lang] [--lang=lang] [--text] [--help] [--verbose] file\n"
sys.exit(code)
def main():
verbose_flag = 0
+ html = 1
+ lang = "pl"
try:
- opts, args = getopt.getopt(sys.argv[1:], "hv",
- ["help", "verbose" ])
+ opts, args = getopt.getopt(sys.argv[1:], "hl:tv",
+ ["help", "lang", "text", "verbose" ])
except getopt.GetoptError:
usage(1)
@@ -36,13 +39,21 @@ def main():
usage()
if o in ("-v", "--verbose"):
verbose_flag = verbose_flag + 1
+ if o in ("-t", "--text"):
+ html = 0
+ if o in ("-l", "--lang"):
+ lang = a
if len(args) == 1:
inputfilename = args[0]
else:
usage(1)
- markup = HtmlWiktionaryMarkup(filename=inputfilename, lang="pl")
+ if html:
+ markup = HtmlWiktionaryMarkup(filename=inputfilename, lang=lang)
+ else:
+ markup = TextWiktionaryMarkup(filename=inputfilename, lang=lang)
+
markup.parse()
print str(markup)
if verbose_flag > 0:

Return to:

Send suggestions and report system problems to the System administrator.