Mercurial > hg > lxmldump
changeset 59:d52696972bf2
Better way(?) of removing trailing "."
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 31 May 2021 13:28:48 +0300 |
parents | de06d98f82a1 |
children | cbed8ee15701 |
files | lxmldump.py |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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