示例#1
0
def get_presto_conf(conf_dir):
    if os.path.isdir(conf_dir):
        file_list = [name for name in os.listdir(conf_dir) if
                     name in PRESTO_FILES]
    else:
        _LOGGER.debug("No directory " + conf_dir)
        file_list = []

    conf = {}
    for filename in file_list:
        ext = os.path.splitext(filename)[1]
        file_path = os.path.join(conf_dir, filename)
        if ext == ".properties":
            conf[filename] = get_conf_from_properties_file(file_path)
        elif ext == ".config":
            conf[filename] = get_conf_from_config_file(file_path)
    return conf
示例#2
0
def get_presto_conf(conf_dir):
    if os.path.isdir(conf_dir):
        file_list = [
            name for name in os.listdir(conf_dir) if name in PRESTO_FILES
        ]
    else:
        _LOGGER.debug("No directory " + conf_dir)
        file_list = []

    conf = {}
    for filename in file_list:
        ext = os.path.splitext(filename)[1]
        file_path = os.path.join(conf_dir, filename)
        if ext == ".properties":
            conf[filename] = get_conf_from_properties_file(file_path)
        elif ext == ".config":
            conf[filename] = get_conf_from_config_file(file_path)
    return conf
示例#3
0
 def test_get_config(self):
     config_file = os.path.join(DIR, 'resources', 'valid.config')
     conf = config.get_conf_from_config_file(config_file)
     self.assertEqual(
         conf, ['prop1', 'prop2', 'prop3', '${ENVIRONMENT_VARIABLE}'])
示例#4
0
 def test_file_is_empty_config(self):
     emptyconf = []
     conf = config.get_conf_from_config_file(DIR + '/resources/empty.txt')
     self.assertEqual(conf, emptyconf)
示例#5
0
 def test_get_config(self):
     config_file = os.path.join(DIR, 'files', 'valid.config')
     conf = config.get_conf_from_config_file(config_file)
     self.assertEqual(conf, ['prop1', 'prop2', 'prop3'])
示例#6
0
 def test_file_is_empty_config(self):
     emptyconf = []
     conf = config.get_conf_from_config_file(DIR + '/files/empty.txt')
     self.assertEqual(conf, emptyconf)