def decode_entity(match): what = match.group(1) if what.startswith('#x'): what = int(what[2:], 16) elif what.startswith('#'): what = int(what[1:]) else: what = name2codepoint.get(what, match.group(0)) return uchr(what)
<<<<<<< HEAD if c>255: return unichr(c) ======= if c>255: return six.unichr(c) >>>>>>> 54eef0be98b1b67c8507db91f4cfa90b64991027 return chr(c) def decode_entity(match): what = match.group(1) if what.startswith('#x'): what = int(what[2:], 16) elif what.startswith('#'): what = int(what[1:]) else: <<<<<<< HEAD what = name2codepoint.get(what, match.group(0)) ======= what = six.moves.html_entities.name2codepoint.get(what, match.group(0)) >>>>>>> 54eef0be98b1b67c8507db91f4cfa90b64991027 return uchr(what) def htmldecode(text): """Decode HTML entities in the given text.""" return entity_sub(decode_entity, text) def socket_timeout(timeout=15): def _socket_timeout(func): def _socket_timeout(*args, **kwargs): old_timeout = socket.getdefaulttimeout() socket.setdefaulttimeout(timeout) try: