How to use the anyconfig.load function in anyconfig

To help you get started, we’ve selected a few anyconfig examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AirtestProject / Airtest / benchmark / plot.py View on Github external
def load_file(self, file, print_info=True):
        if print_info:
            print("loading config from :", repr(file))
        try:
            config = anyconfig.load(file, ignore_missing=True)
            return config
        except ValueError:
            print("loading config failed...")
            return {}
github WenmuZhou / crnn.gluon / train.py View on Github external
parser.add_argument('--config_file', default='config/icdar2015.yaml', type=str)
    args = parser.parse_args()
    return args


if __name__ == '__main__':
    import sys
    import anyconfig
    project = 'crnn.gluon'  # 工作项目根目录
    sys.path.append(os.getcwd().split(project)[0] + project)

    from utils import parse_config

    args = init_args()
    assert os.path.exists(args.config_file)
    config = anyconfig.load(open(args.config_file, 'rb'))
    if 'base' in config:
        config = parse_config(config)
    main(config)
github quantumblacklabs / kedro / kedro / config / config.py View on Github external
common = ", ".join(sorted(conf.keys() & keys))
            if common:
                if len(common) > 100:
                    common = common[:100] + "..."
                dups.add("{}: {}".format(str(file2), common))

        if dups:
            msg = "Duplicate keys found in {0} and:\n- {1}".format(
                file1, "\n- ".join(dups)
            )
            raise ValueError(msg)

    for config_file in config_files:
        cfg = {
            k: v
            for k, v in anyconfig.load(config_file).items()
            if not k.startswith("_")
        }
        _check_dups(config_file, cfg)
        keys_by_filepath[config_file] = cfg.keys()
        config.update(cfg)
    return config
github davidmcclure / open-syllabus-project / osp / common / config.py View on Github external
def read(self):

        """
        Load the configuration files, set connections.
        """

        self.config = anyconfig.load(self.paths, ignore_missing=True)

        self.es     = self.get_es()
        self.redis  = self.get_redis()
        self.rq     = self.get_rq()
github rabbitstack / fibratus / fibratus / config.py View on Github external
def load(self, validate=True):
        schema_file = os.path.join(sys._MEIPASS, 'schema.yml') \
            if hasattr(sys, '_MEIPASS') else self._default_schema_path
        try:
            self._yaml = anyconfig.load(self.path, ignore_missing=False)
        except FileNotFoundError:
            panic('ERROR - %s configuration file does not exist' % self.path)
        if validate:
            validator = Core(source_file=self.path, schema_files=[schema_file])
            validator.validate(raise_exception=True)
github eclecticiq / OpenTAXII / opentaxii / cli / persistence.py View on Github external
def sync_data_configuration():
    parser = argparse.ArgumentParser(
        description="Create services/collections/accounts",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument(
        "config", help="YAML file with data configuration")
    parser.add_argument(
        "-f", "--force-delete", dest="force_deletion",
        action="store_true",
        help=("force deletion of collections and their content blocks "
              "if collection is not defined in configuration file"),
        required=False)
    args = parser.parse_args()
    config = anyconfig.load(args.config, forced_type="yaml")

    with app.app_context():
        # run as admin with full access
        context.account = local_admin
        sync_conf_dict_into_db(
            app.taxii_server,
            config,
            force_collection_deletion=args.force_deletion)
github quantumblacklabs / kedro-examples / kedro-tutorial / kedro_cli.py View on Github external
def _config_file_callback(ctx, param, value):
    """Config file callback, that replaces command line options with config file
    values. If command line options are passed, they override config file values.
    """
    ctx.default_map = ctx.default_map or {}
    section = ctx.info_name

    if value:
        config = anyconfig.load(value)[section]
        ctx.default_map.update(config)

    return value
github quantumblacklabs / kedro / kedro / template / {{ cookiecutter.repo_name }} / kedro_cli.py View on Github external
def _config_file_callback(ctx, param, value):
    """Config file callback, that replaces command line options with config file
    values. If command line options are passed, they override config file values.
    """
    ctx.default_map = ctx.default_map or {}
    section = ctx.info_name

    if value:
        config = anyconfig.load(value)[section]
        ctx.default_map.update(config)

    return value