changeset 21:7ef08e05a5bf

Cleanup.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 11 May 2021 18:37:53 +0300
parents f274504eafd0
children 76856fc4e5fa
files lxmldump.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lxmldump.py	Tue May 11 17:13:38 2021 +0300
+++ b/lxmldump.py	Tue May 11 18:37:53 2021 +0300
@@ -38,6 +38,12 @@
 ]
 
 
+# Operation modes
+PKK_MODE_NORMAL     = 0
+PKK_MODE_DUMP       = 1
+PKK_MODE_XML        = 2
+
+
 ###
 ### Misc. helper functions, etc
 ###
@@ -216,11 +222,11 @@
     type=str, metavar="filename", help="XML filename(s)")
 
 optparser.add_argument("-d", "--dump",
-    action="store_const", const=1, default=0,
+    action="store_const", const=PKK_MODE_DUMP, default=PKK_MODE_NORMAL,
     dest="mode", help="output as simple dump")
 
 optparser.add_argument("-x", "--xml",
-    action="store_const", const=2,
+    action="store_const", const=PKK_MODE_XML,
     dest="mode", help="output as XML")
 
 optparser.add_argument("-n", "--normalize",
@@ -264,16 +270,16 @@
             if pkk_cfg.debug and dnode.attrib["identifier"] not in pkk_debug_list:
                 continue
 
-            if pkk_cfg.mode == 0:
+            if pkk_cfg.mode == PKK_MODE_NORMAL:
                 try:
                     pkk_output_node(0, dnode)
                 except Exception as e:
                     pkk_dump_recursive(0, dnode)
                     print(str(e))
                     sys.exit(0)
-            elif pkk_cfg.mode == 1:
+            elif pkk_cfg.mode == PKK_MODE_DUMP:
                 pkk_dump_recursive(0, dnode)
-            elif pkk_cfg.mode == 2:
+            elif pkk_cfg.mode == PKK_MODE_XML:
                 pkk_print(str(xmlET.tostring(dnode, encoding="utf8")) + "\n")
             else:
                 pkk_fatal("Invalid operation mode?")