Skip to content

Commit

Permalink
fix: remove oboleted code not needed any more
Browse files Browse the repository at this point in the history
  • Loading branch information
ssato committed Mar 17, 2024
1 parent 6edf55e commit 00f8e10
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions src/anyconfig/backend/xml/etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,35 +78,16 @@
_ET_NS_RE = re.compile(r"^{(\S+)}(\S+)$")


def _iterparse(xmlfile):
"""Override ElementTree.iterparse to avoid bug in python 3.{2,3}.
.. seealso:: http://bugs.python.org/issue9257.
:param xmlfile: XML file or file-like object
"""
try:
return ElementTree.iterparse(xmlfile, events=("start-ns", ))
except TypeError:
return ElementTree.iterparse(xmlfile, events=(b"start-ns", ))


def flip(tpl):
"""Flip arguments.
>>> flip((1, 2))
(2, 1)
"""
return (tpl[1], tpl[0])


def _namespaces_from_file(xmlfile):
"""Get the namespace str from file.
:param xmlfile: XML file or file-like object
:return: {namespace_uri: namespace_prefix} or {}
"""
return dict(flip(t) for _, t in _iterparse(xmlfile))
return {
url: prefix for _, (prefix, url)
in ElementTree.iterparse(xmlfile, events=("start-ns", ))
}


def _tweak_ns(tag, **options):
Expand Down

0 comments on commit 00f8e10

Please sign in to comment.