def load_table(table_loc, table_type):
"""
Loads a table of type ``table_type`` from the YAML file ``table_loc``.
"""
with open(table_loc, 'r') as yf:
table_file = yaml.safe_load(yf)
assert table_file['db_version'] == DB_VERSION
table_list = table_file['data']
raw_table = (table_type(**params) for params in table_list)
table_by_id = {x.id: x for x in raw_table}
return table_by_id
评论列表
文章目录