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:
@@ -12,5 +12,7 @@ root_path = Path(c['storage']['root'])
|
||||
|
||||
config = SimpleNamespace()
|
||||
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.decks_dir = root_path / c['storage']['decks']
|
||||
|
||||
@@ -21,7 +21,7 @@ def _fill_maps(big, key, whitelist):
|
||||
|
||||
def create_maps(namelist_fname, key):
|
||||
# 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)
|
||||
|
||||
# Use whitelist to filter data and map only as needed
|
||||
@@ -33,8 +33,26 @@ def create_maps(namelist_fname, key):
|
||||
return names, nums
|
||||
|
||||
|
||||
def read_data_to_dict(key):
|
||||
with open(config.data_file, 'r') as f:
|
||||
def read_string_data_to_dict(keys):
|
||||
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)
|
||||
|
||||
return all_data[key]
|
||||
for key in keys:
|
||||
all_data = all_data[key]
|
||||
|
||||
return all_data
|
||||
|
||||
Reference in New Issue
Block a user