Mercurial > hg > lxmldump
changeset 35:5aafa87dbec2
Some Anki-related stuff, not finalized and thus hidden.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 25 May 2021 13:28:24 +0300 |
parents | 73f2f98e3eef |
children | 4c8aafff8c5f |
files | lxmldump.py |
diffstat | 1 files changed, 16 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lxmldump.py Tue May 25 13:04:30 2021 +0300 +++ b/lxmldump.py Tue May 25 13:28:24 2021 +0300 @@ -28,18 +28,21 @@ PKK_MODE_NORMAL = 0 PKK_MODE_DUMP = 1 PKK_MODE_XML = 2 +PKK_MODE_ANKI = 3 pkk_modes_list = { PKK_MODE_NORMAL: "normal", PKK_MODE_DUMP: "dump", PKK_MODE_XML: "xml", +# PKK_MODE_ANKI: "anki", } # Default Ptr URL format strings pkk_ptr_url_fmt = { PKK_MODE_NORMAL: u"<PTR:{href}>{text}</PTR>", + PKK_MODE_ANKI: u"<a href='https://kaino.kotus.fi/cgi-bin/kks/karjala.cgi?a={href}'>{text}</a>", } @@ -47,6 +50,7 @@ pkk_element_annotation_map = { "Fragment" : { PKK_MODE_NORMAL: ["<", ">"], + PKK_MODE_ANKI: ["<", ">"], }, } @@ -274,6 +278,12 @@ action="store_const", const=PKK_MODE_XML, help="output as XML") +optparser.add_argument("-A", "--anki", + dest="mode", + action="store_const", const=PKK_MODE_ANKI, + help=argparse.SUPPRESS) +# help="output Anki compatible") + optparser.add_argument("--ptr-url-fmt", dest="ptr_url_fmt", type=str, @@ -297,17 +307,17 @@ action="store_true", help="annotate strings") -optparser.add_argument("-p", "--debug", - dest="debug", - action="store_true", - help=argparse.SUPPRESS) - optparser.add_argument("-i", "--indent", dest="indent", type=int, choices=range(0, 32), default=4, metavar="n", help='indent output by <n> characters (default: %(default)s)') +optparser.add_argument("-p", "--debug", + dest="debug", + action="store_true", + help=argparse.SUPPRESS) + ### Show help if needed pkk_cfg = optparser.parse_args() @@ -339,7 +349,7 @@ if pkk_cfg.debug and dnode.attrib["identifier"] not in pkk_debug_list: continue - if pkk_cfg.mode == PKK_MODE_NORMAL: + if pkk_cfg.mode in [PKK_MODE_NORMAL, PKK_MODE_ANKI]: try: pkk_output_node(0, dnode) except Exception as e: