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 82ce8590b1
10 changed files with 36098 additions and 16 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

@@ -1,5 +1,5 @@
from flashcards.decks import create_deck from flashcards.decks import create_deck
from flashcards.maps import create_maps, read_data_to_dict from flashcards.maps import create_maps, read_name_data_to_dict
@@ -9,20 +9,20 @@ deck_fname = 'research-costs'
# specify the namelist to be used to create the deck # specify the namelist to be used to create the deck
# give the relative path of the file from config.namelists_dir # give the relative path of the file from config.namelists_dir
namelist = 'research.txt' namelist = 'research-standard.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

@@ -1,4 +1,4 @@
from flashcards.maps import create_maps, read_data_to_dict from flashcards.maps import create_maps, read_name_data_to_dict
from flashcards.models import simple from flashcards.models import simple
from flashcards.random import random_anki_identifier from flashcards.random import random_anki_identifier
from flashcards.config import config from flashcards.config import config
@@ -52,7 +52,7 @@ def create_deck_from_functions(namelist,
deck_name, deck_name,
deck_fname): deck_fname):
# read in data # read in data
data = read_data_to_dict(data_json_key) data = read_name_data_to_dict(data_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, data_json_key)

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

View File

@@ -4,4 +4,6 @@ storage:
namelists: 'output/namelists' namelists: 'output/namelists'
maps: 'output/maps' maps: 'output/maps'
decks: 'output/decks-output' decks: 'output/decks-output'
data_file: 'units_buildings_techs.de.json' data_file: 'data.json'
name_data_file: 'name_data.json'
string_data_file: 'strings.json'