# Path: src/html5_parser/encoding_names.py



import string
from .encoding_names import encodings

from __future__ import (absolute_import, division, print_function, unicode_literals)



space_chars = frozenset(("\t", "\n", "\u000C", " ", "\r"))
space_chars_bytes = frozenset(item.encode("ascii") for item in space_chars)
ascii_letters_bytes = frozenset(item.encode("ascii") for item in string.ascii_letters)
ascii_uppercase_bytes = frozenset(item.encode("ascii") for item in string.ascii_uppercase)
spaces_angle_brackets = space_chars_bytes | frozenset((b">", b"<"))
skip1 = space_chars_bytes | frozenset((b"/", ))


PYTHON_NAMES = {
    'iso-8859-8-i': 'iso-8859-8',
    'x-mac-cyrillic': 'mac-cyrillic',
    'macintosh': 'mac-roman',
    'windows-874': 'cp874'}


def codec_name(encoding):
    """Return the python codec name corresponding to an encoding or None if the
    string doesn't correspond to a valid encoding."""
    if isinstance(encoding, bytes):
        try:
            encoding = encoding.decode("ascii")
        except UnicodeDecodeError:
            return
    if encoding:
        encoding = encoding.strip('\t\n\f\r ')

# Path: src/html5_parser/encoding_names.py



# Path: src/html5_parser/encoding_parser.py
import string
from .encoding_names import encodings


from __future__ import (absolute_import, division, print_function, unicode_literals)



space_chars = frozenset(("\t", "\n", "\u000C", " ", "\r"))
space_chars_bytes = frozenset(item.encode("ascii") for item in space_chars)
ascii_letters_bytes = frozenset(item.encode("ascii") for item in string.ascii_letters)
ascii_uppercase_bytes = frozenset(item.encode("ascii") for item in string.ascii_uppercase)
spaces_angle_brackets = space_chars_bytes | frozenset((b">", b"<"))
skip1 = space_chars_bytes | frozenset((b"/", ))


PYTHON_NAMES = {
    'iso-8859-8-i': 'iso-8859-8',
    'x-mac-cyrillic': 'mac-cyrillic',
    'macintosh': 'mac-roman',
    'windows-874': 'cp874'}


def codec_name(encoding):
    """Return the python codec name corresponding to an encoding or None if the
    string doesn't correspond to a valid encoding."""
    if isinstance(encoding, bytes):
        try:
            encoding = encoding.decode("ascii")
        except UnicodeDecodeError:
            return
    if encoding:
        encoding = encoding.strip('\t\n\f\r ')

        enc = encodings.get(encoding)