Esempio n. 1
0
def _parse_color(key: str, value: str) -> Any:
    if key in _COLOR_INT:
        return int(value)
    if key in _COLOR_BOOL:
        return _bool(value)
    if key == _COLOR_FLOAT:
        return _maybefloat(value)
    if key == _COLOR_HSV:
        return HSV.from_string(value)
    if key == _COLOR_PLAYER:
        return PlayerColor(int(value))
    return value
Esempio n. 2
0
def _parse_color(n: int, v: str):
    if n in _COLOR_INT:
        return int(v)
    if n in _COLOR_BOOL:
        return _bool(v)
    if n == _COLOR_FLOAT:
        return _maybefloat(v)
    if n == _COLOR_HSV:
        return HSV.from_string(v)
    if n == _COLOR_PLAYER:
        return PlayerColor(int(v))
    return v
Esempio n. 3
0
def _from_str(key: str, value: str) -> Any:
    if key in _INT:
        return int(value)
    if key in _BOOL:
        return _bool(value)
    if key in _FLOAT:
        return _maybefloat(value)
    if key == _GROUPS:
        return _ints_from_str(value)
    if key in _HSV:
        return HSV.from_string(value)
    if key in _ENUMS:
        return _ENUMS[key](int(value))
    if key == _TEXT:
        return _b64_failsafe(value, encode=False)
    return value
Esempio n. 4
0
def _from_str(n: int, v: str):
    if n in _INT:
        return int(v)
    if n in _BOOL:
        return _bool(v)
    if n in _FLOAT:
        return _maybefloat(v)
    if n == _GROUPS:
        return _ints_from_str(v)
    if n in _HSV:
        return HSV.from_string(v)
    if n in _ENUMS:
        return _ENUMS[n](int(v))
    if n == _TEXT:
        return _b64_failsafe(v, encode=False)
    return v