コード例 #1
0
 def __init__(self, templates_path: Union[str, dict]):
     if isinstance(templates_path, str):
         self.cfg = ConfigFactory().parse_file(templates_path)
     else:
         self.cfg = ConfigFactory().from_dict(templates_path)
コード例 #2
0
from types import SimpleNamespace
from pyhocon import ConfigFactory
import os

try:
    config_file = os.environ["APP_CONFIG_PATH"]
    print("Using custom config file: " + config_file)
except KeyError:
    config_file = "config/application.conf"
    print("Using default config file: " + config_file)

config = ConfigFactory().parse_file(config_file)

influx = SimpleNamespace(host=config.get_string("influx.host"),
                         port=config.get_int("influx.port"),
                         user=config.get_string("influx.user"),
                         password=config.get_string("influx.password"),
                         database=config.get_string("influx.database"))

collector = SimpleNamespace(host=config.get_string("collector.host"),
                            port=config.get_int("collector.port"))
コード例 #3
0
def format_hocon(value):
    """"
    This convert a dict to hocon(STR) type.
    """
    config = ConfigFactory().from_dict(value)
    return HOCONConverter.convert(config, 'hocon')