Add examples of deck scripts and namelists
This commit is contained in:
32
decks/building-times.py
Normal file
32
decks/building-times.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from flashcards.decks import create_deck
|
||||
from flashcards.maps import (create_name_to_lname_map,
|
||||
read_data_to_dict)
|
||||
|
||||
|
||||
|
||||
# your choice of deck name and filename
|
||||
deck_name = 'Building Times'
|
||||
deck_fname = 'building-times'
|
||||
|
||||
namelist = 'buildings.txt'
|
||||
|
||||
name_json_key = 'units_buildings'
|
||||
data_json_keys = ('data', 'Building',)
|
||||
|
||||
lnames = create_name_to_lname_map(namelist, name_json_key)
|
||||
data = read_data_to_dict(data_json_keys)
|
||||
|
||||
notes = []
|
||||
for v in data.values():
|
||||
name = v['internal_name']
|
||||
if name in lnames.keys():
|
||||
front = lnames[name]
|
||||
back = str(v['TrainTime'])
|
||||
notes.append((front, back))
|
||||
#print(front, back)
|
||||
else:
|
||||
print(f'missing: {name} --')
|
||||
print(v)
|
||||
print('\n\n')
|
||||
|
||||
deck = create_deck(notes, deck_name, deck_fname)
|
||||
Reference in New Issue
Block a user