# HG changeset patch # User Matti Hamalainen # Date 1622456928 -10800 # Node ID d52696972bf2f4397ef4ccfcf83a5351ab13d1d8 # Parent de06d98f82a12d4ccf3758e5c9a39e41b5bb95a7 Better way(?) of removing trailing "." diff -r de06d98f82a1 -r d52696972bf2 lxmldump.py --- a/lxmldump.py Mon May 31 12:52:44 2021 +0300 +++ b/lxmldump.py Mon May 31 13:28:48 2021 +0300 @@ -275,7 +275,7 @@ def pkk_ptr_to_text(pnode): pfmt = pkk_get_fmt("ptr_fmt") return pfmt.format( - text=("".join(pnode.itertext())).strip().rstrip("."), + text=re.sub(r'\.$', '', ("".join(pnode.itertext())).strip()), href=pnode.attrib["{http://www.w3.org/TR/xlink}href"]) @@ -292,7 +292,7 @@ if isinstance(pnode.tail, str): stmp += pkk_str_clean(pnode.tail) - return stmp.strip() + return re.sub(r'\.$', '', stmp.strip()) ## Simple recursive dump starting at given node