예제 #1
0
파일: backend.py 프로젝트: koblas/blitzdb
    def load_config(self,config = None,overwrite_config = False):
        config_file = self._path+"/config.json"
        if os.path.exists(config_file):
            with open(config_file,"rb") as config_file:
                #configuration is always stored in JSON format
                self._config = JsonSerializer.deserialize(config_file.read())
        else:
            if config:
                self._config = config.copy()
            else:
                self._config = {}
        if overwrite_config and config:
            self._config.update(config)

        for key,value in self.default_config.items():
            if not key in self._config:
                self._config[key] = value
        
        self.save_config()
예제 #2
0
    def load_config(self, config=None, overwrite_config=False):
        config_file = os.path.join(self._path, "config.json")
        if os.path.exists(config_file):
            with open(config_file, 'rb') as config_file:
                # configuration is always stored in JSON format
                self._config = JsonSerializer.deserialize(config_file.read())
        else:
            if config:
                self._config = config.copy()
            else:
                self._config = {}
        if overwrite_config and config:
            self._config.update(config)

        for key, value in self.default_config.items():
            if key not in self._config:
                self._config[key] = value
        if 'version' not in self._config:
            self._config['version'] = blitzdb.__version__
        self.save_config()
예제 #3
0
 def save_config(self):
     config_file = self._path + "/config.json"
     with open(config_file, "wb") as config_file:
         config_file.write(JsonSerializer.serialize(self._config))
예제 #4
0
 def save_config(self):
     config_file = os.path.join(self._path, 'config.json')
     with open(config_file, 'wb') as config_file:
         config_file.write(JsonSerializer.serialize(self._config))