How to use the aenum.OrderedEnum function in aenum

To help you get started, we’ve selected a few aenum examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github raymondEhlers / OVERWATCH / overwatch / base / config.py View on Github external
YAML parsing plugins are also specified here. This breaks the abstraction
a little bit, but it makes things much simpler, so it's worth the trade-off.

.. codeauthor:: Raymond Ehlers , Yale University
"""

import aenum
import ruamel.yaml as yaml
import os
import pkg_resources
from flask_bcrypt import generate_password_hash
import warnings
import logging
logger = logging.getLogger(__name__)

class configurationType(aenum.OrderedEnum):
    """ Specifies the module ordering for loading of configurations.

    It is also used to specify the maximum level for which a config should be loaded.
    For example, if ``webApp`` is specified, it should load all configurations, while
    for processing, everything but processing should be loaded.

    The numerical values of this enum basically specify the dependencies of the package.

    Note:
        The names of these values must match the names of their corresponding modules!
    """
    base = 0
    receiver = 1
    api = 2
    processing = 3
    webApp = 4
github rsrdesarrollo / sarna / sarna / model / enums / base_choice.py View on Github external
from aenum import OrderedEnum


class BaseChoice(OrderedEnum):
    @classmethod
    def choices(cls):
        return [(None, "---")] + [cls.choice(elem) for elem in cls]

    @classmethod
    def choice(cls, elem):
        if isinstance(elem, cls):
            desc = getattr(elem, 'desc', None)
            name = getattr(elem, 'code', elem.name.replace("_", " "))
            if desc:
                return elem, "{} - {}".format(name, desc)
            else:
                return elem, name
        elif elem:
            return cls[elem], cls[elem].name.replace("_", " ")
        else:
github raymondEhlers / OVERWATCH / overwatch / database / factoryMethod.py View on Github external
"""
.. code-author: Mateusz Piwowarczyk <>, AGH University of Science and Technology
"""
import aenum

from overwatch.base import config
from overwatch.database.mongoDatabaseFactory import MongoDatabaseFactory
from overwatch.database.zodbDatabaseFactory import ZodbDatabaseFactory

(databaseParameters, _) = config.readConfig(config.configurationType.database)


class databaseTypes(aenum.OrderedEnum):
    mongodb = 0
    zodb = 1


def getDatabaseFactory():
    """ Creates database factory object using parameters specified in config.yaml.
     Args:
         None

     Returns:
         Database factory object.
     """
    databaseType = databaseParameters["databaseType"]
    if databaseTypes[databaseType] == databaseTypes.mongodb:
        return MongoDatabaseFactory(
            databaseName=databaseParameters["databaseName"],

aenum

Advanced Enumerations (compatible with Python's stdlib Enum), NamedTuples, and NamedConstants

BSD-2-Clause
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis