Пример #1
0
    def run(self):
        # Start processing every monster!
        for monster_id in self.all_monster_cache_data:

            # if int(monster_id) < 11000:
            #     continue

            # Initialize the BuildMonster class, used for all monsters
            builder = build_monster.BuildMonster(
                monster_id=monster_id,
                all_monster_cache_data=self.all_monster_cache_data,
                all_db_monsters=self.all_db_monsters,
                all_wikitext_raw=self.all_wikitext_raw,
                all_wikitext_processed=self.all_wikitext_processed,
                monsters_drops=self.monsters_drops,
                schema_data=self.schema_data,
                known_monsters=self.known_monsters,
                verbose=self.verbose)

            status = builder.preprocessing()
            if status:
                builder.populate_monster()
                known_monster = builder.check_duplicate_monster()
                self.known_monsters.append(known_monster)
                builder.populate_monster_drops()
                if self.compare:
                    builder.compare_new_vs_old_monster()
                if self.export:
                    builder.export_monster_to_json()
                if self.validate:
                    builder.validate_monster()

        # Done processing, rejoice!
        print("Built.")
        exit(0)
Пример #2
0
def main(export: bool = False):
    # Load the current database contents
    monsters_complete_file_path = Path(config.DOCS_PATH / "monsters-complete.json")
    with open(monsters_complete_file_path) as f:
        all_db_monsters = json.load(f)

    # Load the current item database contents
    all_db_items = items_api.load()

    # Load the item wikitext file
    wiki_text_file_path = Path(config.DATA_WIKI_PATH / "page-text-monsters.json")
    with open(wiki_text_file_path) as f:
        all_wikitext_raw = json.load(f)

    # Temp loading of monster ID -> wikitext
    processed_wikitextfile_path = Path(config.DATA_WIKI_PATH / "processed-wikitext-monsters.json")
    with open(processed_wikitextfile_path) as f:
        all_wikitext_processed = json.load(f)

    # Load the raw OSRS cache monster data
    # This is the final data load, and used as baseline data for database population
    all_monster_cache_data_path = Path(config.DATA_MONSTERS_PATH / "monsters-cache-data.json")
    with open(all_monster_cache_data_path) as f:
        all_monster_cache_data = json.load(f)

    # Initialize a list of known monsters
    known_monsters = list()

    # Start processing every monster!
    for monster_id in all_monster_cache_data:
        # Toggle to start, stop at a specific monster ID
        # if int(monster_id) < 8030:
        #     continue

        # Initialize the BuildMonster class, used for all monster
        builder = build_monster.BuildMonster(monster_id=monster_id,
                                             all_monster_cache_data=all_monster_cache_data,
                                             all_wikitext_processed=all_wikitext_processed,
                                             all_wikitext_raw=all_wikitext_raw,
                                             all_db_monsters=all_db_monsters,
                                             all_db_items=all_db_items,
                                             known_monsters=known_monsters,
                                             export=export)

        status = builder.preprocessing()
        if status:
            builder.populate_monster()
            known_monster = builder.check_duplicate_monster()
            known_monsters.append(known_monster)
            builder.parse_monster_drops()
            builder.generate_monster_object()
            builder.compare_new_vs_old_monster()
            builder.export_monster_to_json()
            builder.validate_monster()

    # Done processing, rejoice!
    print("Done.")