diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2015-07-23 14:28:24 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2015-07-23 14:33:08 +0300 |
commit | ad4e807c77cda717a74083cdd9a36250027bd096 (patch) | |
tree | be1ac178b08923c387f6d9d142d29e5135c48a96 /bin/wikitrans | |
parent | 32be559549aab3d71bee6be566782eef6594442d (diff) | |
download | wikitrans-ad4e807c77cda717a74083cdd9a36250027bd096.tar.gz wikitrans-ad4e807c77cda717a74083cdd9a36250027bd096.tar.bz2 |
Use JSON for printable representation of tokens and nodes.
* WikiTrans/wikidump.py: New file.
* WikiTrans/__init__.py: Update
* WikiTrans/wiki2html.py: Minor change
* WikiTrans/wiki2texi.py: Likewise.
* WikiTrans/wikimarkup.py (BaseWikiMarkup.__createWikiNode): New
method; use it instead of invoking constructors directly throughout
the code.
(token_class): New attribute. A dictionary of token classes for each
specific node type.
* WikiTrans/wikitoken.py: Use JSON for printable representation of
nodes.
* bin/wikitrans: Update
Diffstat (limited to 'bin/wikitrans')
-rwxr-xr-x | bin/wikitrans | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/bin/wikitrans b/bin/wikitrans index 7f9789f..0b2d867 100755 --- a/bin/wikitrans +++ b/bin/wikitrans @@ -26,15 +26,7 @@ from WikiTrans.wiki2html import HtmlWikiMarkup, HtmlWiktionaryMarkup from WikiTrans.wiki2text import TextWikiMarkup, TextWiktionaryMarkup from WikiTrans.wiki2texi import TexiWikiMarkup from WikiTrans.wikimarkup import WikiMarkup - -class DumpWikiMarkup (WikiMarkup): - def __str__(self): - if self.tree: - s = StringIO() - self.dump(self.tree, s) - return s.getvalue() - else: - return "" +from WikiTrans.wikidump import DumpWikiMarkup handlers = { 'dump': { @@ -112,6 +104,8 @@ def main(): options.kwdict['lang'] = options.lang # FIXME + if options.otype == 'dump' and not 'indent' in options.kwdict: + options.kwdict['indent'] = 2 if options.otype in handlers: if options.itype in handlers[options.otype]: markup = handlers[options.otype][options.itype](**options.kwdict) |