Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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:
"""
.. 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"],