# Path: colr/codes.py
# def _build_code_nums() -> Dict[str, Dict[str, int]]:
# def _build_code_nums_reverse() -> Dict[str, Dict[int, str]]:
# def _build_codes() -> Dict[str, Dict[str, str]]:
# def _build_codes_reverse(
#         codes: Dict[str, Dict[str, str]]) -> Dict[str, Dict[str, str]]:
# def _add_alias_names(d: Dict[str, Dict[str, str]]) -> None:
# 
# Path: colr/name_data.py
# def create_term_name_c_array(name=None):
# def create_name_data_c_array(
#         name=None, struct=None, no_members=False, no_hex=False):
#     def create_elem_def(knownname, info):
#     def create_full_elem_def(knownname, info):
# def get_x11_rgb(fix_names=False):


import re
    import sys
from types import GeneratorType
from typing import (
    Any,
    Optional,
    Tuple,
    Union,
    cast,
)
from .codes import (
    code_nums,
    code_nums_reverse,
)
from .name_data import names as name_data
        and the other codes are automatically generated and made available
        through the attributes:
            code   : Terminal code number as a string.
            hexval : Nearest matching hex value.
            rgb    : Tuple of nearest matching (Red, Green, Blue) values.
    """
    __slots__ = ('code', 'hexval', 'rgb', 'rgb_mode', 'name')

    def __init__(
            self,
            code: Optional[Any] = None,
            rgb_mode: Optional[bool] = False) -> None:
        self.rgb = (0, 0, 0)  # type: RGB
        self.hexval = None  # type: Optional[str]
        self.code = None  # type: Optional[str]
        self.name = None  # type: Optional[str]
        self.rgb_mode = rgb_mode  # type: Optional[bool]
        # Init tries to be smart about converting code types.
        typeerrmsg = 'Expecting hex, term-code, or rgb. Got: {}'.format(
            getattr(code, '__name__', type(code).__name__)
        )
        if isinstance(code, (list, tuple, GeneratorType)):
            try:
                # cast is only needed to satisfy mypy. 'code' would work fine.
                r, g, b = cast(RGB, code)
            except ValueError:
                raise TypeError(typeerrmsg)
            self._init_rgb(r, g, b)
        elif isinstance(code, str):
            code = code.lower().strip()

# Path: colr/codes.py
# def _build_code_nums() -> Dict[str, Dict[str, int]]:
# def _build_code_nums_reverse() -> Dict[str, Dict[int, str]]:
# def _build_codes() -> Dict[str, Dict[str, str]]:
# def _build_codes_reverse(
#         codes: Dict[str, Dict[str, str]]) -> Dict[str, Dict[str, str]]:
# def _add_alias_names(d: Dict[str, Dict[str, str]]) -> None:
# 
# Path: colr/name_data.py
# def create_term_name_c_array(name=None):
# def create_name_data_c_array(
#         name=None, struct=None, no_members=False, no_hex=False):
#     def create_elem_def(knownname, info):
#     def create_full_elem_def(knownname, info):
# def get_x11_rgb(fix_names=False):


# Path: colr/trans.py
import re
    import sys
from types import GeneratorType
from typing import (
    Any,
    Optional,
    Tuple,
    Union,
    cast,
)
from .codes import (
    code_nums,
    code_nums_reverse,
)
from .name_data import names as name_data

        and the other codes are automatically generated and made available
        through the attributes:
            code   : Terminal code number as a string.
            hexval : Nearest matching hex value.
            rgb    : Tuple of nearest matching (Red, Green, Blue) values.
    """
    __slots__ = ('code', 'hexval', 'rgb', 'rgb_mode', 'name')

    def __init__(
            self,
            code: Optional[Any] = None,
            rgb_mode: Optional[bool] = False) -> None:
        self.rgb = (0, 0, 0)  # type: RGB
        self.hexval = None  # type: Optional[str]
        self.code = None  # type: Optional[str]
        self.name = None  # type: Optional[str]
        self.rgb_mode = rgb_mode  # type: Optional[bool]
        # Init tries to be smart about converting code types.
        typeerrmsg = 'Expecting hex, term-code, or rgb. Got: {}'.format(
            getattr(code, '__name__', type(code).__name__)
        )
        if isinstance(code, (list, tuple, GeneratorType)):
            try:
                # cast is only needed to satisfy mypy. 'code' would work fine.
                r, g, b = cast(RGB, code)
            except ValueError:
                raise TypeError(typeerrmsg)
            self._init_rgb(r, g, b)
        elif isinstance(code, str):
            code = code.lower().strip()

            if (code in code_nums['fore']) or (code in name_data):