import cfgtools

from typing import (
    Any,
    Dict,
    Optional,
    Union,
)


class Modifier(object):
    def __init__(
        self,
        key,                # type: Any[Union[cfgtools.Key, Dict]]
        from_tuple=False,   # type: Optional[bool]
    ):
        # type: (...) -> Modifier

        self.name = ''
        self.description = 0

        self.parse_modifier(
            modifier_key=key,
            from_tuple=from_tuple,
        )

    def parse_modifier(
        self,
        modifier_key,   # type: Any[Union[cfgtools.Key, Dict]]
        from_tuple,     # type: bool
    ):
        # type: (...) -> None

        self.name = modifier_key[0] if from_tuple else modifier_key.name
        self.description = modifier_key[1] if from_tuple else modifier_key.values[0]
