

def _GetElementByTagName(e, ns, tag_name):
    'Retrieves a unique element from a DOM subtree by name.\n\n  Convenience wrapper for the case where the format\n  dictates exactly-once semantics.\n\n  Args:\n    e: Root element of DOM subtree.\n    ns: Namespace of desired element.\n    tag_name: Name of desired element.\n  Raises:\n    ValueError: If the element was not unique or not found.\n  Returns:\n    The desired element.\n  '
    seq = e.getElementsByTagNameNS(unicode(ns), unicode(tag_name))
    if (seq.length == 0):
        raise ValueError(('Element %s not found' % tag_name))
    if (seq.length > 1):
        raise ValueError(('Element %s appears multiple times' % tag_name))
    return seq.item(0)

dataset/ETHPy150Open mimecuvalo/helloworld/packages/magicsig/__init__.py _GetElementByTagName/original