<commit_before># Copyright (C) 2019 OpenMotics BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
Generic module that houses various enums
"""
from functools import reduce

if False:  # MYPY
    from typing import Literal


class BaseEnum(object):
    _key_elements = None
    _value_elements = None

    @classmethod
    def _check_elements_initialized(cls):
        if cls._key_elements is not None and cls._value_elements is not None:
            return
        try:
            cls._key_elements = []
            cls._value_elements = []
            for elem, value in cls.__dict__.items():
                if not elem.startswith('_') and not callable(getattr(cls, elem)):
                    cls._key_elements.append(elem)
                    cls._value_elements.append(value)
        except Exception:
            cls._key_elements = None
            cls._values_elements = None
            raise

    @classmethod
    def get_keys(cls):
        """ Returns the list of the key attributes of the BaseEnum class"""
        cls._check_elements_initialized()
        return cls._key_elements

    @classmethod
    def get_values(cls):
        """ Returns the list of the values of the BaseEnum class"""
        cls._check_elements_initialized()
        return cls._value_elements

    @classmethod
    def contains(cls, item):
        """ Checks if the item is in the keys or values of the defined BaseEnum """
        cls._check_elements_initialized()
        return item in cls._key_elements or item in cls._value_elements


class ShutterEnums(object):
    class Direction(object):
        UP = 'UP'
        DOWN = 'DOWN'
        STOP = 'STOP'

    class State(object):
        GOING_UP = 'going_up'
        GOING_DOWN = 'going_down'
        STOPPED = 'stopped'
        UP = 'up'
        DOWN = 'down'


class ScreenEnums(object):
    class State(object):
        OPEN = 'open'
        CLOSED = 'closed'
        OPENING = 'opening'
        CLOSING = 'closing'
        STOPPED = 'stopped'
        UNKNOWN = 'unknown'

    STATES = [State.OPEN, State.OPENING,
              State.CLOSED, State.CLOSING,
              State.STOPPED, State.UNKNOWN]

    class Type(object):
        # Vertical is e.g. a shutter that moves up/down where the `blades` (if any) are horizontal
        VERTICAL_TRANSLATIONAL = 'vertical_translational'
        VERTICAL_ROTATIONAL = 'vertical_rotational'
        VERTICAL_TRANSLATIONAL_ROTATIONAL = 'vertical_translational_rotational'
        # Horizontal is e.g. a curtain that moves left/right where the `blades` (if any) are vertical
        HORIZONTAL_TRANSLATIONAL = 'horizontal_translational'
        HORIZONTAL_ROTATIONAL = 'horizontal_rotational'
        HORIZONTAL_TRANSLATIONAL_ROTATIONAL = 'horizontal_translational_rotational'
        # Roof is e.g. a patio cover that moves flat in respect to the ground where the blades (if any) rotate from standing up to laying flat
        ROOF_TRANSLATIONAL = 'roof_translational'
        ROOF_ROTATIONAL = 'roof_rotational'
        ROOF_TRANSLATIONAL_ROTATIONAL = 'roof_translational_rotational'

    TYPES = [Type.VERTICAL_TRANSLATIONAL, Type.VERTICAL_ROTATIONAL, Type.VERTICAL_TRANSLATIONAL_ROTATIONAL,
             Type.HORIZONTAL_TRANSLATIONAL, Type.HORIZONTAL_ROTATIONAL, Type.HORIZONTAL_TRANSLATIONAL_ROTATIONAL,
             Type.ROOF_TRANSLATIONAL, Type.ROOF_ROTATIONAL, Type.ROOF_TRANSLATIONAL_ROTATIONAL]

    class Action(object):
        GOTO_POSITION = 'goto_position'
        OPEN = 'open'
        CLOSE = 'close'
        STOP = 'stop'

    class CallbackAction(object):
        REGISTER = 'register'
        REPORT_STATUS = 'report_status'
        LOAD_SCREENS = 'load_screens'
        GOTO_POSITION = 'goto_position'
        OPEN = 'open'
        CLOSE = 'close'
        STOP = 'stop'


class MetricsEnums(object):
    class Action(object):
        DELIVER_METRICS = 'deliver_metrics'
        GET_DEFINITIONS = 'get_definitions'

    class CallbackAction(object):
        DELIVER_METRICS = 'deliver_metrics'
        SUBSCRIBE_METRICS = 'subscribe_metrics'


class VentilationEnums(object):
    class Action(object):
        SET_AUTO = 'set_auto'
        SET_MANUAL = 'set_manual'

    class CallbackAction(object):
        REGISTER = 'register'
        REPORT_STATUS = 'report_status'


class UserEnums(object):
    class AuthenticationErrors(object):
        INVALID_CREDENTIALS = 'invalid_credentials'
        TERMS_NOT_ACCEPTED = 'terms_not_accepted'

    class DeleteErrors(object):
        LAST_ACCOUNT = 'Cannot delete last user account'


class ThermostatMode(object):
    COOLING = 'cooling'  # type: Literal['cooling']
    HEATING = 'heating'  # type: Literal['heating']


class ThermostatState(object):
    ON = 'on'  # type: Literal['on']
    OFF = 'off'  # type: Literal['off']


class IndicateType(object):
    OUTPUT = 0
    INPUT = 1
    SENSOR = 2


class SensorEnums(object):

    class PhysicalQuantities(object):
        TEMPERATURE = 'temperature'
        HUMIDITY = 'humidity'
        BRIGHTNESS = 'brightness'
        SOUND = 'sound'
        DUST = 'dust'
        COMFORT_INDEX = 'comfort_index'
        AQI = 'aqi'
        CO2 = 'co2'
        VOC = 'voc'
        ELECTRIC_POTENTIAL = 'electric_potential'
        ELECTRIC_CURRENT = 'electric_current'
        FREQUENCY = 'frequency'
        ENERGY = 'energy'
        POWER = 'power'

    ALL_PHYSICAL_QUANTITIES = [PhysicalQuantities.TEMPERATURE, PhysicalQuantities.HUMIDITY,
                               PhysicalQuantities.BRIGHTNESS, PhysicalQuantities.SOUND,
                               PhysicalQuantities.DUST, PhysicalQuantities.COMFORT_INDEX,
                               PhysicalQuantities.AQI, PhysicalQuantities.CO2, PhysicalQuantities.VOC,
                               PhysicalQuantities.ELECTRIC_POTENTIAL, PhysicalQuantities.ELECTRIC_CURRENT,
                               PhysicalQuantities.FREQUENCY, PhysicalQuantities.ELECTRIC_CURRENT,
                               PhysicalQuantities.POWER]

    class Units(object):
        NONE = 'none'
        CELCIUS = 'celcius'
        PERCENT = 'percent'
        DECIBEL = 'decibel'
        LUX = 'lux'
        MICRO_GRAM_PER_CUBIC_METER = 'micro_gram_per_cubic_meter'
        PARTS_PER_MILLION = 'parts_per_million'
        VOLT = 'volt'
        AMPERE = 'ampere'
        HERTZ = 'hertz'
        KILO_WATT_HOUR = 'kilo_watt_hour'
        JOULE = 'joule'
        WATT = 'watt'

    ALL_UNITS = [Units.NONE, Units.CELCIUS, Units.PERCENT, Units.DECIBEL, Units.LUX,<commit_msg>Added missing enum value<commit_after># Copyright (C) 2019 OpenMotics BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
Generic module that houses various enums
"""
from functools import reduce

if False:  # MYPY
    from typing import Literal


class BaseEnum(object):
    _key_elements = None
    _value_elements = None

    @classmethod
    def _check_elements_initialized(cls):
        if cls._key_elements is not None and cls._value_elements is not None:
            return
        try:
            cls._key_elements = []
            cls._value_elements = []
            for elem, value in cls.__dict__.items():
                if not elem.startswith('_') and not callable(getattr(cls, elem)):
                    cls._key_elements.append(elem)
                    cls._value_elements.append(value)
        except Exception:
            cls._key_elements = None
            cls._values_elements = None
            raise

    @classmethod
    def get_keys(cls):
        """ Returns the list of the key attributes of the BaseEnum class"""
        cls._check_elements_initialized()
        return cls._key_elements

    @classmethod
    def get_values(cls):
        """ Returns the list of the values of the BaseEnum class"""
        cls._check_elements_initialized()
        return cls._value_elements

    @classmethod
    def contains(cls, item):
        """ Checks if the item is in the keys or values of the defined BaseEnum """
        cls._check_elements_initialized()
        return item in cls._key_elements or item in cls._value_elements


class ShutterEnums(object):
    class Direction(object):
        UP = 'UP'
        DOWN = 'DOWN'
        STOP = 'STOP'

    class State(object):
        GOING_UP = 'going_up'
        GOING_DOWN = 'going_down'
        STOPPED = 'stopped'
        UP = 'up'
        DOWN = 'down'


class ScreenEnums(object):
    class State(object):
        OPEN = 'open'
        CLOSED = 'closed'
        OPENING = 'opening'
        CLOSING = 'closing'
        STOPPED = 'stopped'
        UNKNOWN = 'unknown'

    STATES = [State.OPEN, State.OPENING,
              State.CLOSED, State.CLOSING,
              State.STOPPED, State.UNKNOWN]

    class Type(object):
        # Vertical is e.g. a shutter that moves up/down where the `blades` (if any) are horizontal
        VERTICAL_TRANSLATIONAL = 'vertical_translational'
        VERTICAL_ROTATIONAL = 'vertical_rotational'
        VERTICAL_TRANSLATIONAL_ROTATIONAL = 'vertical_translational_rotational'
        # Horizontal is e.g. a curtain that moves left/right where the `blades` (if any) are vertical
        HORIZONTAL_TRANSLATIONAL = 'horizontal_translational'
        HORIZONTAL_ROTATIONAL = 'horizontal_rotational'
        HORIZONTAL_TRANSLATIONAL_ROTATIONAL = 'horizontal_translational_rotational'
        # Roof is e.g. a patio cover that moves flat in respect to the ground where the blades (if any) rotate from standing up to laying flat
        ROOF_TRANSLATIONAL = 'roof_translational'
        ROOF_ROTATIONAL = 'roof_rotational'
        ROOF_TRANSLATIONAL_ROTATIONAL = 'roof_translational_rotational'

    TYPES = [Type.VERTICAL_TRANSLATIONAL, Type.VERTICAL_ROTATIONAL, Type.VERTICAL_TRANSLATIONAL_ROTATIONAL,
             Type.HORIZONTAL_TRANSLATIONAL, Type.HORIZONTAL_ROTATIONAL, Type.HORIZONTAL_TRANSLATIONAL_ROTATIONAL,
             Type.ROOF_TRANSLATIONAL, Type.ROOF_ROTATIONAL, Type.ROOF_TRANSLATIONAL_ROTATIONAL]

    class Action(object):
        GOTO_POSITION = 'goto_position'
        OPEN = 'open'
        CLOSE = 'close'
        STOP = 'stop'

    class CallbackAction(object):
        REGISTER = 'register'
        REPORT_STATUS = 'report_status'
        LOAD_SCREENS = 'load_screens'
        GOTO_POSITION = 'goto_position'
        OPEN = 'open'
        CLOSE = 'close'
        STOP = 'stop'


class MetricsEnums(object):
    class Action(object):
        DELIVER_METRICS = 'deliver_metrics'
        GET_DEFINITIONS = 'get_definitions'

    class CallbackAction(object):
        DELIVER_METRICS = 'deliver_metrics'
        SUBSCRIBE_METRICS = 'subscribe_metrics'


class VentilationEnums(object):
    class Action(object):
        SET_AUTO = 'set_auto'
        SET_MANUAL = 'set_manual'

    class CallbackAction(object):
        REGISTER = 'register'
        REPORT_STATUS = 'report_status'


class UserEnums(object):
    class AuthenticationErrors(object):
        INVALID_CREDENTIALS = 'invalid_credentials'
        TERMS_NOT_ACCEPTED = 'terms_not_accepted'

    class DeleteErrors(object):
        LAST_ACCOUNT = 'Cannot delete last user account'


class ThermostatMode(object):
    COOLING = 'cooling'  # type: Literal['cooling']
    HEATING = 'heating'  # type: Literal['heating']


class ThermostatState(object):
    ON = 'on'  # type: Literal['on']
    OFF = 'off'  # type: Literal['off']


class IndicateType(object):
    OUTPUT = 0
    INPUT = 1
    SENSOR = 2


class SensorEnums(object):

    class PhysicalQuantities(object):
        TEMPERATURE = 'temperature'
        HUMIDITY = 'humidity'
        BRIGHTNESS = 'brightness'
        SOUND = 'sound'
        DUST = 'dust'
        COMFORT_INDEX = 'comfort_index'
        AQI = 'aqi'
        CO2 = 'co2'
        VOC = 'voc'
        ELECTRIC_POTENTIAL = 'electric_potential'
        ELECTRIC_CURRENT = 'electric_current'
        FREQUENCY = 'frequency'
        ENERGY = 'energy'
        POWER = 'power'

    ALL_PHYSICAL_QUANTITIES = [PhysicalQuantities.TEMPERATURE, PhysicalQuantities.HUMIDITY,
                               PhysicalQuantities.BRIGHTNESS, PhysicalQuantities.SOUND,
                               PhysicalQuantities.DUST, PhysicalQuantities.COMFORT_INDEX,
                               PhysicalQuantities.AQI, PhysicalQuantities.CO2, PhysicalQuantities.VOC,
                               PhysicalQuantities.ELECTRIC_POTENTIAL, PhysicalQuantities.ELECTRIC_CURRENT,
                               PhysicalQuantities.FREQUENCY, PhysicalQuantities.ELECTRIC_CURRENT,
                               PhysicalQuantities.ENERGY, PhysicalQuantities.POWER]

    class Units(object):
        NONE = 'none'
        CELCIUS = 'celcius'
        PERCENT = 'percent'
        DECIBEL = 'decibel'
        LUX = 'lux'
        MICRO_GRAM_PER_CUBIC_METER = 'micro_gram_per_cubic_meter'
        PARTS_PER_MILLION = 'parts_per_million'
        VOLT = 'volt'
        AMPERE = 'ampere'
        HERTZ = 'hertz'
        KILO_WATT_HOUR = 'kilo_watt_hour'
        JOULE = 'joule'
        WATT = 'watt'

    ALL_UNITS = [Units.NONE, Units.CELCIUS, Units.PERCENT, Units.DECIBEL, Units.LUX,
{'fraction_non_alphanumeric': 0.07936730123180291, 'fraction_numerical': 0.001539753639417693, 'mean_word_length': 2.575825825825826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7109550', 'n_tokens_mistral': 4497, 'n_tokens_neox': 4260, 'n_words': 1083}