Skip to content

Instantly share code, notes, and snippets.

@nandyne
Created October 18, 2018 17:48
Show Gist options
  • Select an option

  • Save nandyne/5ff11254d8f28d4e06c09ea60235d7e8 to your computer and use it in GitHub Desktop.

Select an option

Save nandyne/5ff11254d8f28d4e06c09ea60235d7e8 to your computer and use it in GitHub Desktop.

Revisions

  1. nandyne created this gist Oct 18, 2018.
    21 changes: 21 additions & 0 deletions _config_loader.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    class _Config_Loader:
    """
    Loads the Config file given while instantiating
    """

    def __init__(self, config_path):
    from utility.exceptions import ImproperlyConfigured
    from pathlib import Path
    import yaml
    __config_path = Path(config_path).resolve()
    print('Loading Config from file %s' % __config_path)
    try:
    with open(__config_path, 'r') as yaml_config_file:
    self.config = yaml.safe_load(yaml_config_file)
    except (yaml.YAMLError, yaml.MarkedYAMLError) as e:
    raise ImproperlyConfigured(
    "Your settings file(s) contain invalid YAML syntax! Please fix and restart!\n" +
    repr(e))


    config = _Config_Loader('config.yaml').config