Mercurial > hg > lxmldump
changeset 16:285b0820d2c6
Cleanup.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 11 May 2021 14:47:01 +0300 |
parents | 2f86537ff1f7 |
children | 6fa24c711f86 |
files | lxmldump.py |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lxmldump.py Tue May 11 14:00:34 2021 +0300 +++ b/lxmldump.py Tue May 11 14:47:01 2021 +0300 @@ -93,13 +93,13 @@ ## Format "Ptr" node as text def pkk_ptr_to_text(pnode): - return "PTR: <{}>{}</>".format( + return "<PTR:{}>{}</PTR>".format( pnode.attrib["{http://www.w3.org/TR/xlink}href"], ("".join(pnode.itertext())).strip()) ## Get text inside a given node -def pkk_get_text(lnode): +def pkk_node_to_text(lnode): stmp = "" for pnode in lnode.iter(): if pnode.tag == "Ptr": @@ -121,7 +121,7 @@ ## Simple recursive dump starting at given node def pkk_dump_recursive(indent, lnode): if lnode.tag in ["Example"]: - stmp = pkk_get_text(lnode) + stmp = pkk_node_to_text(lnode) pkk_printi(indent, "{} \"{}\"\n".format(lnode.tag, stmp)) else: if isinstance(lnode.text, str): @@ -144,7 +144,7 @@ ## Output item under given node def pkk_output_subs_fmt(indent, dnode, dsub, dname, dfmt): for qnode in dnode.findall(dsub): - pkk_printi(indent, dfmt.format(dname, pkk_get_text(qnode))) + pkk_printi(indent, dfmt.format(dname, pkk_node_to_text(qnode))) def pkk_output_subs_prefix(indent, dnode, dsub, dname): @@ -156,13 +156,13 @@ pkk_output_subs_prefix(indent, dnode, "./Definition", "defn") for wnode in dnode.findall("./ExampleBlock/ExampleCtn"): - sstr = pkk_get_text(wnode.find("./Example")) + sstr = pkk_node_to_text(wnode.find("./Example")) lstr = "" if pkk_verbosity(1): ltmp = [] for qnode in wnode.findall("./FreeTopic[@type='levikki']/GeographicalUsage"): - ltmp.append("{} [{}]".format(pkk_get_text(qnode), qnode.attrib["class"])) + ltmp.append("{} [{}]".format(pkk_node_to_text(qnode), qnode.attrib["class"])) if len(ltmp) > 0: lstr = " ({})".format(", ".join(ltmp))