Example #1
0
    def test_20_find_by_type(self):
        ini_t = "ini"
        jsn_t = "json"
        yml_t = "yaml"
        unknown_t = "unknown_type"

        self.assertTrue(ini_t, T.BINI.IniConfigParser)
        self.assertTrue(jsn_t, T.BJSON.JsonConfigParser)
        self.assertTrue(yml_t, T.BYAML.YamlConfigParser)
        self.assertTrue(T.find_by_type(unknown_t) is None)
Example #2
0
    def test_20_find_by_type(self):
        ini_t = "ini"
        jsn_t = "json"
        yml_t = "yaml"
        unknown_t = "unknown_type"

        self.assertTrue(ini_t, T.BINI.IniConfigParser)
        self.assertTrue(jsn_t, T.BJSON.JsonConfigParser)
        self.assertTrue(yml_t, T.BYAML.YamlConfigParser)
        self.assertTrue(T.find_by_type(unknown_t) is None)
Example #3
0
def find_loader(config_path, forced_type=None):
    """
    :param config_path: Configuration file path
    :param forced_type: Forced configuration parser type
    :return: ConfigParser-inherited class object
    """
    if forced_type is not None:
        cparser = Backends.find_by_type(forced_type)
        if not cparser:
            logging.error("No parser found for given type: " + forced_type)
            return None
    else:
        cparser = Backends.find_by_file(config_path)
        if not cparser:
            logging.error("No parser found for given file: " + config_path)
            return None

    logging.debug("Using config parser of type: " + cparser.type())
    return cparser
Example #4
0
def find_loader(config_path, forced_type=None):
    """
    :param config_path: Configuration file path
    :param forced_type: Forced configuration parser type
    """
    if forced_type is not None:
        cparser = Backends.find_by_type(forced_type)
        if not cparser:
            logging.error(
                "No parser found for given type: " + forced_type
            )
            return None
    else:
        cparser = Backends.find_by_file(config_path)
        if not cparser:
            logging.error(
                "No parser found for given file: " + config_path
            )
            return None

    logging.debug("Using config parser: " + str(cparser))
    return cparser
 def instchk(cf, ctype):
     isinstance(T.find_by_type(ctype), cls)