# Path: infi/pyutils/python_compat.py
# _PYTHON_VERSION = platform.python_version()
# _IS_PYTHON_3 = _PYTHON_VERSION >= '3'
# _IS_BELOW_PYTHON_2_7 = _PYTHON_VERSION < '2.7'
# def get_underlying_function(f):
# def _get_underlying_classmethod_function(f):
#     def create_bound_method(func, self):
#     class TemporaryClass(object):


from packaging.version import Version, parse
from .python_compat import OrderedDict, itervalues
    >>> avg.as_version('2.0') == 'Average'
    True    
    
    """
    def __init__(self, key, list_or_dict=None, default_version=ALL, **kwargs):
        super(Value, self).__init__(default_version)
        if isinstance(key, Value):
            key = str(key)
        self._key = str(key)
        if list_or_dict is None:
            list_or_dict = []
        if isinstance(list_or_dict, dict):
            self._construct_from_dict(list_or_dict)
        else:
            if 'aliases' in kwargs:
                # For backwards compatibility with old non versioned enums
                list_or_dict = kwargs.get('aliases')
            self._construct_from_list(list_or_dict)

    def _construct_from_list(self, values):
        converted_values = [self._key]
        for value in values:
            if isinstance(value, Value):
                converted_values.extend(value.get_values())
            else:
                converted_values.append(value)
        self._construct_from_dict({ALL:converted_values})
        self.bind_to_version(ALL)

    def _construct_from_dict(self, values):

# Path: infi/pyutils/python_compat.py
# _PYTHON_VERSION = platform.python_version()
# _IS_PYTHON_3 = _PYTHON_VERSION >= '3'
# _IS_BELOW_PYTHON_2_7 = _PYTHON_VERSION < '2.7'
# def get_underlying_function(f):
# def _get_underlying_classmethod_function(f):
#     def create_bound_method(func, self):
#     class TemporaryClass(object):


# Path: infi/pyutils/enums.py
from packaging.version import Version, parse
from .python_compat import OrderedDict, itervalues

    >>> avg.as_version('2.0') == 'Average'
    True    
    
    """
    def __init__(self, key, list_or_dict=None, default_version=ALL, **kwargs):
        super(Value, self).__init__(default_version)
        if isinstance(key, Value):
            key = str(key)
        self._key = str(key)
        if list_or_dict is None:
            list_or_dict = []
        if isinstance(list_or_dict, dict):
            self._construct_from_dict(list_or_dict)
        else:
            if 'aliases' in kwargs:
                # For backwards compatibility with old non versioned enums
                list_or_dict = kwargs.get('aliases')
            self._construct_from_list(list_or_dict)

    def _construct_from_list(self, values):
        converted_values = [self._key]
        for value in values:
            if isinstance(value, Value):
                converted_values.extend(value.get_values())
            else:
                converted_values.append(value)
        self._construct_from_dict({ALL:converted_values})
        self.bind_to_version(ALL)

    def _construct_from_dict(self, values):

        self._values = OrderedDict((_convert(k), values[k]) for k in reversed(sorted(values.keys())))