2021-03-28 15:43:49 +02:00
|
|
|
#!/usr/bin/env python3
|
2021-05-26 19:11:46 +02:00
|
|
|
from generator_tools import *
|
2021-03-28 15:43:49 +02:00
|
|
|
|
2021-05-26 19:11:46 +02:00
|
|
|
# --------------------- GET CONFIGURATION FROM THE TREX.JSON ---------------- #
|
|
|
|
config_file = 'trex.json'
|
|
|
|
trex_config = read_json(config_file)
|
|
|
|
# --------------------------------------------------------------------------- #
|
2021-03-05 16:50:44 +01:00
|
|
|
|
2021-05-26 19:11:46 +02:00
|
|
|
# -------------------- GET ATTRIBUTES FROM THE CONFIGURATION ---------------- #
|
|
|
|
group_dict = get_group_dict(trex_config)
|
2021-05-31 16:39:21 +02:00
|
|
|
detailed_nums = get_detailed_num_dict(trex_config)
|
2021-06-04 15:36:18 +02:00
|
|
|
detailed_strs = get_detailed_str_dict(trex_config)
|
2021-05-31 16:39:21 +02:00
|
|
|
# helper dictionaries that contain names of groups, nums or dsets as keys
|
|
|
|
dsets = get_dset_dict(trex_config)
|
2022-09-27 19:56:09 +02:00
|
|
|
detailed_dsets_nostr, detailed_dsets_str, detailed_dsets_sparse, detailed_dsets_buf = split_dset_dict_detailed(dsets)
|
2021-05-31 16:39:21 +02:00
|
|
|
detailed_dsets = detailed_dsets_nostr.copy()
|
|
|
|
detailed_dsets.update(detailed_dsets_str)
|
2021-12-08 17:26:55 +01:00
|
|
|
# build a big dictionary with all pre-processed data
|
2021-12-09 16:15:17 +01:00
|
|
|
detailed_all = {
|
2022-09-27 19:56:09 +02:00
|
|
|
'datasets' : dict(detailed_dsets_nostr, **detailed_dsets_str, **detailed_dsets_sparse, **detailed_dsets_buf),
|
2021-12-09 16:15:17 +01:00
|
|
|
'groups' : group_dict,
|
|
|
|
'numbers' : detailed_nums,
|
|
|
|
'strings' : detailed_strs
|
|
|
|
}
|
2021-05-26 19:11:46 +02:00
|
|
|
# consistency check for dimensioning variables
|
2021-05-31 16:39:21 +02:00
|
|
|
check_dim_consistency(detailed_nums, dsets)
|
2021-05-26 19:11:46 +02:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
|
|
|
|
# -------------------- GET TEMPLATED FILES TO BE POPULATED ------------------ #
|
|
|
|
source = ['front', 'text', 'hdf5']
|
2021-11-30 16:30:36 +01:00
|
|
|
# build helper dictionaries with paths per source directory
|
2021-05-26 19:11:46 +02:00
|
|
|
template_paths = get_template_paths(source)
|
2021-11-30 16:30:36 +01:00
|
|
|
# build helper dictionaries with source files per source directory
|
2021-05-26 19:11:46 +02:00
|
|
|
source_files = get_source_files(template_paths)
|
|
|
|
# build helper dictionaries with templated files
|
|
|
|
files_todo = get_files_todo(source_files)
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
|
|
|
|
# ----------------------- POPULATE TEMPLATED FILES -------------------------- #
|
|
|
|
|
|
|
|
# populate files with iterative scheme, i.e. for unique functions
|
|
|
|
for fname in files_todo['auxiliary']:
|
2021-12-08 17:26:55 +01:00
|
|
|
iterative_populate_file(fname, template_paths, detailed_all)
|
2021-05-26 19:11:46 +02:00
|
|
|
|
|
|
|
# populate has/read/write_num functions with recursive scheme
|
2021-09-21 10:41:37 +02:00
|
|
|
for fname in files_todo['attr_num']:
|
2021-05-31 16:39:21 +02:00
|
|
|
recursive_populate_file(fname, template_paths, detailed_nums)
|
2021-05-26 19:11:46 +02:00
|
|
|
|
2021-06-04 15:36:18 +02:00
|
|
|
# populate has/read/write_str functions with recursive scheme
|
|
|
|
for fname in files_todo['attr_str']:
|
|
|
|
recursive_populate_file(fname, template_paths, detailed_strs)
|
|
|
|
|
2021-11-30 16:30:36 +01:00
|
|
|
# populate has/read/write_dset (numerical) functions with recursive scheme
|
2021-05-27 15:03:13 +02:00
|
|
|
for fname in files_todo['dset_data']:
|
2021-05-31 16:39:21 +02:00
|
|
|
recursive_populate_file(fname, template_paths, detailed_dsets_nostr)
|
|
|
|
|
2021-11-30 16:30:36 +01:00
|
|
|
# populate has/read/write_dset (strings) functions with recursive scheme
|
2021-05-31 16:39:21 +02:00
|
|
|
for fname in files_todo['dset_str']:
|
|
|
|
recursive_populate_file(fname, template_paths, detailed_dsets_str)
|
2021-05-26 19:11:46 +02:00
|
|
|
|
2021-11-30 16:30:36 +01:00
|
|
|
# populate has/read/write_dset (sparse) functions with recursive scheme
|
|
|
|
for fname in files_todo['dset_sparse']:
|
|
|
|
recursive_populate_file(fname, template_paths, detailed_dsets_sparse)
|
|
|
|
|
2022-09-27 19:56:09 +02:00
|
|
|
# populate has/read/write_buffered functions with recursive scheme
|
|
|
|
for fname in files_todo['buffered']:
|
|
|
|
recursive_populate_file(fname, template_paths, detailed_dsets_buf)
|
|
|
|
|
2022-01-24 10:10:45 +01:00
|
|
|
# populate group-related functions with mixed scheme
|
2021-05-26 19:11:46 +02:00
|
|
|
for fname in files_todo['group']:
|
2022-01-24 10:10:45 +01:00
|
|
|
# recursive scheme for delete_group functions
|
2022-07-04 11:22:31 +02:00
|
|
|
if 'delete' in fname or 'has' in fname:
|
2022-01-24 10:10:45 +01:00
|
|
|
recursive_populate_file(fname, template_paths, group_dict)
|
|
|
|
# mixed (iterative+recursive) scheme [text backend]
|
|
|
|
else:
|
|
|
|
special_populate_text_group(fname, template_paths, group_dict, detailed_dsets, detailed_nums, detailed_strs)
|
2021-05-26 19:11:46 +02:00
|
|
|
|
|
|
|
# --------------------------------------------------------------------------- #
|