scruffy/config.py
def load(self, reload=False):
        """
        Load the config and defaults from files.
        """
        if reload or not self._loaded:
            # load defaults
            if self._defaults_file and type(self._defaults_file) == str:
                self._defaults_file = File(self._defaults_file, parent=self._parent)
            defaults = {}
            if self._defaults_file:
                defaults = yaml.safe_load(self._defaults_file.read().replace('\t', '    '))

            # load data
            data = {}
            if self.exists:
                data = yaml.safe_load(self.read().replace('\t', '    '))

            # initialise with the loaded data
            self._defaults = defaults
            self._data = copy.deepcopy(self._defaults)
            self.update(data=data)

            # if specified, apply environment variables
            if self._apply_env:
                self.update(ConfigEnv(self._env_prefix))

            self._loaded = True

        return self
def load(self, reload=False):
        """
        Load the config and defaults from files.
        """
        if reload or not self._loaded:
            # load defaults
            if self._defaults_file and type(self._defaults_file) == str:
                self._defaults_file = File(self._defaults_file, parent=self._parent)
            defaults = {}
            if self._defaults_file:
                defaults = yaml.safe_load(self._defaults_file.read().replace('\t', '    '))

            # load data
            data = {}
            if self.exists:
                data = yaml.safe_load(self.read().replace('\t', '    '))

            # initialise with the loaded data
            self._defaults = defaults
            self._data = copy.deepcopy(self._defaults)
            self.update(data=data)

            # if specified, apply environment variables
            if self._apply_env:
                self.update(ConfigEnv(self._env_prefix))

            self._loaded = True

        return self
def load ( self , reload = False ) : if reload or not self . _loaded : # load defaults if self . _defaults_file and type ( self . _defaults_file ) == str : self . _defaults_file = File ( self . _defaults_file , parent = self . _parent ) defaults = { } if self . _defaults_file : defaults = yaml . safe_load ( self . _defaults_file . read ( ) . replace ( '\t' , '    ' ) ) # load data data = { } if self . exists : data = yaml . safe_load ( self . read ( ) . replace ( '\t' , '    ' ) ) # initialise with the loaded data self . _defaults = defaults self . _data = copy . deepcopy ( self . _defaults ) self . update ( data = data ) # if specified, apply environment variables if self . _apply_env : self . update ( ConfigEnv ( self . _env_prefix ) ) self . _loaded = True return self
Load the config and defaults from files.
Load the config and defaults from files .