def load_database(self, merge=False):
     logger.debug(
         "Loading database from {file}.".format(file=self._database_file))
     with open(self._database_file, "r") as file:
         json_data = file.read()
     # end with
     data = self._str_to_json(json_data)
     if not merge:
         logging.debug("Not merging.")
         self._attribute_to_key_map.clear()
         self.clear()
         DictObject.__init__(self, data)
     else:
         logging.debug("Merging data.")
         self.merge_dict(data)
Beispiel #2
0
 def load_database(self, merge=False):
     logging.debug("Loading database from {file}.".format(file=self._database_file))
     try:
         with open(self._database_file, "r") as file:
             json_data = file.read()
     except FileNotFoundError:
         logging.warning("File {file!r} was not found! Not loading anything!".format(file=self._database_file))
         return
     except Exception as e:
         logging.exception("Exception in loading file:")
         raise
     data = json.loads(json_data)
     if not merge:
         logging.debug("Not merging.")
         self._attribute_to_key_map.clear()
         self.clear()
         DictObject.__init__(self, data)
     else:
         logging.debug("Merging data.")
         self.merge_dict(data)
Beispiel #3
0
 def load_database(self, merge=False):
     logging.debug("Loading database from {file}.".format(file=self._database_file))
     try:
         with open(self._database_file, "r", encoding='utf8') as file:
             json_data = file.read()
     except FileNotFoundError:
         logging.warning("File {file!r} was not found! Not loading anything!".format(file=self._database_file))
         return
     except Exception as e:
         logging.exception("Exception in loading file:")
         raise
     data = json.loads(json_data)
     if not merge:
         logging.debug("Not merging.")
         self._attribute_to_key_map.clear()
         self.clear()
         DictObject.__init__(self, data)
     else:
         logging.debug("Merging data.")
         self.merge_dict(data)