Mercurial > hg > lxmldump
comparison lxmldump.py @ 24:8c8e8e4504bb
Remove verbosity option as it is not really used.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 25 May 2021 10:50:02 +0300 |
parents | 3ef1c5463b8f |
children | 8a6738f67106 |
comparison
equal
deleted
inserted
replaced
23:3ef1c5463b8f | 24:8c8e8e4504bb |
---|---|
69 ## Print string with indentation | 69 ## Print string with indentation |
70 def pkk_printi(indent, smsg): | 70 def pkk_printi(indent, smsg): |
71 pkk_print((" " * pkk_cfg.indent * indent) + smsg) | 71 pkk_print((" " * pkk_cfg.indent * indent) + smsg) |
72 | 72 |
73 | 73 |
74 ## Check value against current verbosity level | |
75 def pkk_verbosity(lvl): | |
76 return pkk_cfg.verbosity >= lvl | |
77 | |
78 | |
79 ## Fatal error handler | 74 ## Fatal error handler |
80 def pkk_fatal(smsg): | 75 def pkk_fatal(smsg): |
81 print(u"ERROR: "+ smsg) | 76 print(u"ERROR: "+ smsg) |
82 sys.exit(1) | 77 sys.exit(1) |
83 | 78 |
163 # Examples | 158 # Examples |
164 for wnode in dnode.findall("./ExampleBlock/ExampleCtn"): | 159 for wnode in dnode.findall("./ExampleBlock/ExampleCtn"): |
165 sstr = pkk_node_to_text(wnode.find("./Example")) | 160 sstr = pkk_node_to_text(wnode.find("./Example")) |
166 lstr = "" | 161 lstr = "" |
167 | 162 |
168 if pkk_verbosity(1): | 163 ltmp = [] |
169 ltmp = [] | 164 for qnode in wnode.findall("./FreeTopic[@type='levikki']/GeographicalUsage"): |
170 for qnode in wnode.findall("./FreeTopic[@type='levikki']/GeographicalUsage"): | 165 ltmp.append("{} [{}]".format(pkk_node_to_text(qnode), qnode.attrib["class"])) |
171 ltmp.append("{} [{}]".format(pkk_node_to_text(qnode), qnode.attrib["class"])) | 166 |
172 | 167 if len(ltmp) > 0: |
173 if len(ltmp) > 0: | 168 lstr = " ({})".format(", ".join(ltmp)) |
174 lstr = " ({})".format(", ".join(ltmp)) | |
175 | 169 |
176 pkk_printi(indent + 1, "{} \"{}\"{}\n".format("exmp", sstr, lstr)) | 170 pkk_printi(indent + 1, "{} \"{}\"{}\n".format("exmp", sstr, lstr)) |
177 | 171 |
178 | 172 |
179 ## Output one "DictionaryEntry" node | 173 ## Output one "DictionaryEntry" node |
243 | 237 |
244 optparser.add_argument("-a", "--annotate", | 238 optparser.add_argument("-a", "--annotate", |
245 dest="annotate", | 239 dest="annotate", |
246 action="store_const", const=True, default=False, | 240 action="store_const", const=True, default=False, |
247 help="annotate strings") | 241 help="annotate strings") |
248 | |
249 optparser.add_argument("-v", "--verbosity", | |
250 dest="verbosity", | |
251 type=int, choices=range(0, 4), default=3, | |
252 metavar="n", | |
253 help='set verbosity level (0-3, default: %(default)s)') | |
254 | 242 |
255 optparser.add_argument("-p", "--debug", | 243 optparser.add_argument("-p", "--debug", |
256 dest="debug", action="store_const", const=True, default=False, | 244 dest="debug", action="store_const", const=True, default=False, |
257 help=argparse.SUPPRESS) | 245 help=argparse.SUPPRESS) |
258 | 246 |