Add more data

Also renamed some of the files and had to change some code to account
for the new names.
This commit is contained in:
Nate Bowman
2026-10-14 19:01:48 -04:00
parent 10b02e3540
commit 6e1b876a14
8 changed files with 36091 additions and 11 deletions

View File

@@ -51,9 +51,11 @@ Process:
The data used for this project was downloaded from: The data used for this project was downloaded from:
``` ```
https://github.com/SiegeEngineers/halfon/blob/master/data/units_buildings_techs.de.json * https://github.com/SiegeEngineers/halfon/blob/master/data/units_buildings_techs.de.json
* https://github.com/SiegeEngineers/aoe2techtree/blob/master/data/data.json
* https://github.com/SiegeEngineers/aoe2techtree/blob/master/data/locales/en/strings.json
``` ```
The SiegeEngineers team on Github has a lot of cool stuff. The SiegeEngineers team on Github has a lot of cool stuff.
You should check them out. You should check them out.
The particular project I took this from is called HALFON. The particular projects I took this from are called HALFON and aoe2techtree.

34954
data/data.json Normal file

File diff suppressed because it is too large Load Diff

1105
data/strings.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -13,16 +13,16 @@ namelist = 'research.txt'
# key into json file specifying which data you want # key into json file specifying which data you want
# uncomment either 'units_buildings' or 'techs' # uncomment either 'units_buildings' or 'techs'
#data_json_key = 'units_buildings' #name_json_key = 'units_buildings'
data_json_key = 'techs' name_json_key = 'techs'
# --- create list of notes --- # --- create list of notes ---
# read in data # read in data
data = read_data_to_dict(data_json_key) data = read_name_data_to_dict(name_json_key)
# create maps between names and numbers based on namelist # create maps between names and numbers based on namelist
names, _ = create_maps(namelist, data_json_key) names, _ = create_maps(namelist, name_json_key)
# create cards based on data and maps # create cards based on data and maps
notes = [] notes = []

View File

@@ -1,5 +1,4 @@
from flashcards.decks import create_deck_from_back_function from flashcards.decks import create_deck_from_back_function
from flashcards.maps import create_maps, read_data_to_dict

View File

@@ -12,5 +12,7 @@ root_path = Path(c['storage']['root'])
config = SimpleNamespace() config = SimpleNamespace()
config.data_file = root_path / c['storage']['data'] / c['data_file'] config.data_file = root_path / c['storage']['data'] / c['data_file']
config.name_data_file = root_path / c['storage']['data'] / c['name_data_file']
config.string_data_file = root_path / c['storage']['data'] / c['string_data_file']
config.namelists_dir = root_path / c['storage']['namelists'] config.namelists_dir = root_path / c['storage']['namelists']
config.decks_dir = root_path / c['storage']['decks'] config.decks_dir = root_path / c['storage']['decks']

View File

@@ -21,7 +21,7 @@ def _fill_maps(big, key, whitelist):
def create_maps(namelist_fname, key): def create_maps(namelist_fname, key):
# Read in the full data dictionary # Read in the full data dictionary
with open(config.data_file, 'r') as f: with open(config.name_data_file, 'r') as f:
big = json.load(f) big = json.load(f)
# Use whitelist to filter data and map only as needed # Use whitelist to filter data and map only as needed
@@ -33,8 +33,26 @@ def create_maps(namelist_fname, key):
return names, nums return names, nums
def read_data_to_dict(key): def read_string_data_to_dict(keys):
with open(config.data_file, 'r') as f: return _read_file_to_dict(config.string_data_file, keys)
def read_name_data_to_dict(keys):
return _read_file_to_dict(config.name_data_file, keys)
def read_data_to_dict(keys):
return _read_file_to_dict(config.data_file, keys)
def _read_file_to_dict(fname, keys):
if not type(keys) is tuple:
keys = (keys,)
with open(fname, 'r') as f:
all_data = json.load(f) all_data = json.load(f)
return all_data[key] for key in keys:
all_data = all_data[key]
return all_data