示例#1
0
 def load_settings(self, data_path=None):
     data_path = data_path or self.SETTINGS_PATH
     if os.path.isfile(data_path):
         f = open(data_path, "r")
         data = sporklib.byteify(json.loads(f.read(), "ascii"))
         try:
             self.load_custom_settings_path(sporklib.normalize_path(data["settingsPath"]))
             self.load_settings()
             return None #end loop here
         except (IOError,KeyError):
             pass
         try:
             self.RECORD_TEMPLATE = data["recordSchema"]
         except KeyError:
             pass
         try:
             self.CONTENT_DIRECTORY = sporklib.normalize_path(data["contentDirectory"])
         except KeyError:
             pass
         try:
             self.RECORDS_PATH = data["recordsPath"]
         except KeyError:
             pass
         try:
             self.AVAIL_ITEMS_PATH = data["availItemsPath"]
         except KeyError:
             pass
示例#2
0
 def _load_avail_items(self, data_path=None):
     data_path = data_path or self.DEFAULT_AVAIL_ITEMS_PATH
     avail_items = {}
     if os.path.isfile(data_path):
         with open(data_path) as f:
             self.AVAIL_ITEMS = sporklib.byteify(json.loads(f.read(), "ascii"))
     else:
         raise IOError("Did not find items data file at: %s" % data_file)
示例#3
0
 def load_records(self, data_path=None):
     data_path = data_path or self.DEFAULT_RECORDS_PATH
     if os.path.isfile(data_path):
         with open(data_path, "r") as f:
             data = sporklib.byteify(json.loads(f.read(), "ascii"))
         self.RECORDS = data
     else:
         raise IOError("Did not find records file at: %s" % data_path)