Exemplo n.º 1
0
def decode_entity(match):
    what = match.group(0)
    return unescape(what)
Exemplo n.º 2
0
def decode_entity(match):
    what = match.group(0)
    return unescape(what)
Exemplo n.º 3
0
    def info(self, msg, *args):
        log.info(msg, *args)

    def warn(self, msg, *args):
        log.warn(msg, *args)


# This pattern matches a character entity reference (a decimal numeric
# references, a hexadecimal numeric reference, or a named reference).
entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub


def decode_entity(match):
    what = match.group(0)
<<<<<<< HEAD
    return unescape(what)
=======
    return html.unescape(what)
>>>>>>> 7e5c5fbd6c824de4d4c2b62da3f7cae87d462119


def htmldecode(text):
    """
    Decode HTML entities in the given text.

    >>> htmldecode(
    ...     'https://../package_name-0.1.2.tar.gz'
    ...     '?tokena=A&amp;tokenb=B">package_name-0.1.2.tar.gz')
    'https://../package_name-0.1.2.tar.gz?tokena=A&tokenb=B">package_name-0.1.2.tar.gz'
    """
    return entity_sub(decode_entity, text)