Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import sqlite3
- #dictionary that tells where to get the hashes for each table
- hash_dict = {'DestinyActivityDefinition':'activityHash','DestinyActivityTypeDefinition':'activityTypeHash','DestinyClassDefinition': 'classHash','DestinyGenderDefinition':'genderHash','DestinyInventoryBucketDefinition':'bucketHash','DestinyInventoryItemDefinition': 'itemHash','DestinyProgressionDefinition': 'progressionHash','DestinyRaceDefinition': 'raceHash','DestinyTalentGridDefinition': 'gridHash','DestinyUnlockFlagDefinition': 'flagHash', 'DestinyHistoricalStatsDefinition': 'statId','DestinyDirectorBookDefinition': 'bookHash','DestinyStatDefinition': 'statHash','DestinySandboxPerkDefinition': 'perkHash','DestinyDestinationDefinition': 'destinationHash','DestinyPlaceDefinition':'placeHash','DestinyActivityBundleDefinition':'bundleHash','DestinyStatGroupDefinition': 'statGroupHash','DestinySpecialEventDefinition':'eventHash','DestinyFactionDefinition':'factionHash','DestinyVendorCategoryDefinition':'categoryHash','DestinyEnemyRaceDefinition':'raceHash','DestinyScriptedSkullDefinition':'skullHash','DestinyGrimoireCardDefinition': 'cardId'}
- def build_data():
- #connect to the manifest
- con = sqlite3.connect('Manifest.content')
- #create a cursor object
- cur = con.cursor()
- #get a list of all table
- cur.execute("SELECT name from sqlite_master where type = 'table'")
- #this actually returns a list of tuples,
- #where the first item in the tuple is the Table Name, the second is empty
- all_tables = cur.fetchall()
- all_data = {}
- #for every table name
- for table in all_tables:
- table_name = table[0]
- #if the location of the hashes is in our hash_dict
- if table_name in hash_dict.keys():
- #get a list of all the jsons from the table
- cur.execute('SELECT json from '+table_name)
- #again, tuples: the first item is our json
- items = cur.fetchall()
- #create a list of jsons
- item_jsons = [json.loads(item[0]) for item in items]
- #create a dictionary with the hashes as keys
- #and the jsons as values
- item_dict = {}
- hash = hash_dict[table_name]
- for item in item_jsons:
- item_dict[item[hash]] = item
- #add that dictionary to our all_data using the name of the table
- #as a key.
- all_data[table_name] = item_dict
- return all_data
- #call function
- all_data = build_data()
- #Gjallarhorn
- gally = all_data['DestinyInventoryItemDefinition'][1274330687]
- print gally['itemName']
- print gally['itemTypeName']
- print gally['itemDescription']
- OUTPUT:
- >> Gjallarhorn
- >> Rocket Launcher
- >> "If there is beauty in destruction, why not also in its delivery?" - Feizel Crux
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement