# HG changeset patch # User Matti Hamalainen # Date 1620735134 -10800 # Node ID 6fa24c711f867149598b2ab925859f4aa83beeb9 # Parent 285b0820d2c609b97000d76ebfd1a10e9db93cd8 Add some comments. diff -r 285b0820d2c6 -r 6fa24c711f86 lxmldump.py --- a/lxmldump.py Tue May 11 14:47:01 2021 +0300 +++ b/lxmldump.py Tue May 11 15:12:14 2021 +0300 @@ -141,20 +141,23 @@ pkk_dump_recursive(indent + 1, qnode) -## Output item under given node +## Output item(s) under given node with given format string def pkk_output_subs_fmt(indent, dnode, dsub, dname, dfmt): for qnode in dnode.findall(dsub): pkk_printi(indent, dfmt.format(dname, pkk_node_to_text(qnode))) - +## Output item(s) under given node with a prefixed name string def pkk_output_subs_prefix(indent, dnode, dsub, dname): pkk_output_subs_fmt(indent, dnode, dsub, dname, "{0} \"{1}\"\n") +## Output a main "Headword" or "Sense" node under it def pkk_output_sense(indent, dnode): + # Search form and definition pkk_output_subs_prefix(indent, dnode, "./SearchForm", "srch") pkk_output_subs_prefix(indent, dnode, "./Definition", "defn") + # Examples for wnode in dnode.findall("./ExampleBlock/ExampleCtn"): sstr = pkk_node_to_text(wnode.find("./Example")) lstr = "" @@ -170,6 +173,7 @@ pkk_printi(indent + 1, "{} \"{}\"{}\n".format("exmp", sstr, lstr)) +## Output one "DictionaryEntry" node def pkk_output_node(indent, dnode): for wnode in dnode.findall("./HeadwordCtn"):