# HG changeset patch # User Matti Hamalainen # Date 1646133789 -7200 # Node ID 5c7913c838cbdf792d65fa3b70e7893f45c591f4 # Parent 1e1d478f4845e813d36ac3b576b86c8f46d774a1 Cleanups. diff -r 1e1d478f4845 -r 5c7913c838cb lxmldump.py --- a/lxmldump.py Mon Feb 28 14:46:29 2022 +0200 +++ b/lxmldump.py Tue Mar 01 13:23:09 2022 +0200 @@ -206,7 +206,7 @@ ## Handler for SIGINT signals def pkk_signal_handler(signal, frame): - print(u"\nQuitting due to SIGINT / Ctrl+C!") + print("\nQuitting due to SIGINT / Ctrl+C!") sys.exit(1) @@ -559,14 +559,14 @@ if pkk_cfg.list_values: if pkk_cfg.mode in [PKK_MODE_NORMAL, PKK_MODE_ANKI]: - print(u"Available format strings and values (mode '{}'):".format( + print("Available format strings and values (mode '{}'):".format( pkk_modes_list[pkk_cfg.mode])) for mid in pkk_mode_defaults: stmp = pkk_get_value(mid).replace("\\", "\\\\").replace("\n", "\\n") - print(u" {:22s} : '{}'".format(mid, stmp)) + print(" {mid:22s} : '{stmp}'") else: - print(u"Mode '{}' does not use format strings.".format( + print("Mode '{}' does not use format strings.".format( pkk_modes_list[pkk_cfg.mode])) sys.exit(0) @@ -580,7 +580,7 @@ try: uxml = xmlET.parse(filename) except Exception as e: - pkk_fatal(u"SVG/XML parsing failed: {0}".format(str(e))) + pkk_fatal(f"SVG/XML parsing failed: {str(e)}") # Dump output try: @@ -604,7 +604,7 @@ elif pkk_cfg.mode == PKK_MODE_XML: pkk_print(xmlET.tostring(dnode, encoding="utf8").decode("utf8") + "\n\n") else: - pkk_fatal("Invalid operation mode?") + pkk_fatal(f"Invalid operation mode '{pkk_cfg.mode}'.") except (BrokenPipeError, IOError) as e: sys.stderr.close()