# HG changeset patch # User Matti Hamalainen # Date 1621938504 -10800 # Node ID 5aafa87dbec25772616a70d56ce29acdcd5eecae # Parent 73f2f98e3eef4e258097c977ddafacd771b9b42d Some Anki-related stuff, not finalized and thus hidden. diff -r 73f2f98e3eef -r 5aafa87dbec2 lxmldump.py --- 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"{text}", + PKK_MODE_ANKI: u"{text}", } @@ -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 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: