Exemplo n.º 1
0
def load_initial_data_from(file_name):
    if not os.path.exists(file_name):
        file_name = os.path.join(os.path.dirname(__file__), 'data/{}'.format(file_name))
    with open(file_name) as file_obj:
        if file_name.endswith(".json"):
            return Munch.fromDict(load(file_obj))
        elif file_name.endswith(".yaml"):
            return fromYAML(file_obj)
def load_data_from(file_name, mode=None):
    if not os.path.exists(file_name):
        file_name = os.path.join(os.path.dirname(__file__), 'data', file_name)
    with open(file_name) as file_obj:
        if file_name.endswith(".json"):
            file_data = Munch.fromDict(load(file_obj))
        elif file_name.endswith(".yaml"):
            file_data = fromYAML(file_obj)
    if mode == "brokers":
        default = file_data.pop('Default')
        brokers = {}
        for k, v in file_data.iteritems():
            brokers[k] = merge_dicts(default, v)
        return brokers
    else:
        return file_data
Exemplo n.º 3
0
def load_data_from(file_name, mode=None):
    if not os.path.exists(file_name):
        file_name = os.path.join(os.path.dirname(__file__), 'data', file_name)
    with open(file_name) as file_obj:
        if file_name.endswith(".json"):
            file_data = Munch.fromDict(load(file_obj))
        elif file_name.endswith(".yaml"):
            file_data = fromYAML(file_obj)
    if mode == "brokers":
        default = file_data.pop('Default')
        brokers = {}
        for k, v in file_data.iteritems():
            brokers[k] = merge_dicts(default, v)
        return brokers
    else:
        return file_data