def index_data(self, asset): key = asset[0] path = asset[1] asset_type = "item" category = asset_category(key) asset_data = self.assets.read(key, path) if asset_data is None: return if type(asset_data) is list: logging.debug("Skipping mod patch file %s in %s" % (key, path)) return name = False item_name_keys = ["itemName", "name", "objectName"] for item_name in item_name_keys: try: name = asset_data[item_name] except KeyError: pass desc = "" if "shortdescription" in asset_data: desc = asset_data["shortdescription"] if not name: logging.warning("Skipping invalid item asset (no name set) %s in %s" % (key, path)) return else: if key.endswith(".techitem"): name = name + "-chip" return (key, path, asset_type, category, name, desc)
def index_data(self, asset): key = asset[0] path = asset[1] asset_type = "item" category = asset_category(key) asset_data = self.assets.read(key, path) if asset_data is None: return if type(asset_data) is list: logging.debug("Skipping mod patch file %s in %s" % (key, path)) return name = False item_name_keys = ["itemName", "name", "objectName"] for item_name in item_name_keys: try: name = asset_data[item_name] except KeyError: pass desc = "" if "shortdescription" in asset_data: desc = asset_data["shortdescription"] if not name: logging.warning( "Skipping invalid item asset (no name set) %s in %s" % (key, path)) return else: if key.endswith(".techitem"): name = name + "-chip" return (key, path, asset_type, category, name, desc)
def create_index(self, asset_files=False): logging.info("Creating new assets index...") if not asset_files: asset_files = self.find_assets() blueprints = Blueprints(self) items = Items(self) species = Species(self) monsters = Monsters(self) techs = Techs(self) frames = Frames(self) new_index_query = "insert into assets values (?, ?, ?, ?, ?, ?, ?, ?)" c = self.db.cursor() for asset in asset_files: yield (asset[0], asset[1], asset[2], asset[3]) tmp_data = None if asset_category(asset[0]) != '': if asset[0].endswith(".png"): tmp_data = (asset[0], asset[1], asset[2], asset[3], "image", "", "", "") elif blueprints.is_blueprint(asset[0]): tmp_data = blueprints.index_data(asset) elif species.is_species(asset[0]): tmp_data = species.index_data(asset) elif items.is_item(asset[0]): tmp_data = items.index_data(asset) elif monsters.is_monster(asset[0]): tmp_data = monsters.index_data(asset) elif techs.is_tech(asset[0]): tmp_data = techs.index_data(asset) elif frames.is_frames(asset[0]): tmp_data = frames.index_data(asset) elif asset[0] == "/humanoid.config": tmp_data = (asset[0], asset[1], asset[2], asset[3], "other", "", "", "") else: logging.warning( "Skipping invalid asset (no file extension) %s in %s" % (asset[0], asset[1])) if tmp_data is not None: c.execute(new_index_query, tmp_data) self.db.commit() logging.info("Finished creating index")
def create_index(self, asset_files=False): logging.info("Creating new assets index...") if not asset_files: asset_files = self.find_assets() blueprints = Blueprints(self) items = Items(self) species = Species(self) monsters = Monsters(self) techs = Techs(self) frames = Frames(self) new_index_query = "insert into assets values (?, ?, ?, ?, ?, ?)" c = self.db.cursor() for asset in asset_files: yield (asset[0], asset[1]) tmp_data = None if asset_category(asset[0]) != '': if asset[0].endswith(".png"): tmp_data = (asset[0], asset[1], "image", "", "", "") elif blueprints.is_blueprint(asset[0]): tmp_data = blueprints.index_data(asset) elif species.is_species(asset[0]): tmp_data = species.index_data(asset) elif items.is_item(asset[0]): tmp_data = items.index_data(asset) elif monsters.is_monster(asset[0]): tmp_data = monsters.index_data(asset) elif techs.is_tech(asset[0]): tmp_data = techs.index_data(asset) elif frames.is_frames(asset[0]): tmp_data = frames.index_data(asset) else: logging.warning("Skipping invalid asset (no file extension) %s in %s" % (asset[0], asset[1])) if tmp_data is not None: c.execute(new_index_query, tmp_data) self.db.commit() logging.info("Finished creating index")