How to use the cryptostore.config.Config function in cryptostore

To help you get started, we’ve selected a few cryptostore 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 bmoscon / cryptostore / cryptostore / plugin / controller.py View on Github external
def __init__(self, config: str):
        super().__init__()
        self.plugins = []
        self.cfg = None
        if config:
            self.cfg = Config(config)
        else:
            if 'CRYPTOSTORE_CONFIG' in os.environ:
                file_name = os.environ['CRYPTOSTORE_CONFIG']
            else:
                file_name = os.path.join(os.getcwd(), 'config.yaml')

            if os.path.isfile(file_name):
                self.cfg = Config(file_name)
github bmoscon / cryptostore / cryptostore / plugin / controller.py View on Github external
def __init__(self, config: str):
        super().__init__()
        self.plugins = []
        self.cfg = None
        if config:
            self.cfg = Config(config)
        else:
            if 'CRYPTOSTORE_CONFIG' in os.environ:
                file_name = os.environ['CRYPTOSTORE_CONFIG']
            else:
                file_name = os.path.join(os.getcwd(), 'config.yaml')

            if os.path.isfile(file_name):
                self.cfg = Config(file_name)
github bmoscon / cryptostore / cryptostore / config.py View on Github external
__setattr__ = __setitem__


class Config:
    def __init__(self, file_name):
        with open(file_name) as fp:
            self.config = AttrDict(yaml.load(fp, Loader=yaml.FullLoader))

    def __getattr__(self, attr):
        return self.config[attr]

    def __contains__(self, item):
        return item in self.config


class DynamicConfig(Config):
    def __init__(self, file_name=None, reload_interval=10, callback=None):
        if file_name is None:
            if 'CRYPTOSTORE_CONFIG' in os.environ:
                file_name = os.environ['CRYPTOSTORE_CONFIG']
            else:
                file_name = os.path.join(os.getcwd(), 'config.yaml')
        if not os.path.isfile(file_name):
            raise FileNotFoundError(f"Config file {file_name} not found")

        self.config = {}
        self._load(file_name, reload_interval, callback)

    async def __loader(self, file, interval, callback):
        last_modified = 0
        while True:
            cur_mtime = os.stat(file).st_mtime
github bmoscon / cryptostore / cryptostore / plugin / backfill.py View on Github external
def __init__(self, config):
        super().__init__(config)
        self.config = Config(config)
        self.daemon = True
        self.threads = []