From ace817c96b1b231c27b5959dcfbd687ef9d46e5f Mon Sep 17 00:00:00 2001 From: Magus Date: Thu, 11 Jul 2024 15:40:41 +0700 Subject: [PATCH] Fix iesdp=>ielib import directory structure --- scripts/ie/common.py | 2 +- scripts/ie/offsets.py | 11 +++++++++++ scripts/iesdp_update.py | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/ie/common.py b/scripts/ie/common.py index b2cacfe..80bddab 100644 --- a/scripts/ie/common.py +++ b/scripts/ie/common.py @@ -124,7 +124,7 @@ def dump_definition(prefix, items, structures_dir): """ Dump dict of items (IESDP constants, usually offsets) to iesdp.tpp in the corresponding IElib dir - @arg prefix - file format from which items are source, e.g. "EFF_V2" + @arg prefix - file format from which items are sourced, e.g. "EFF_V2" @arg items - dict {name: value} @arg structures_dir - path to ielib/structures """ diff --git a/scripts/ie/offsets.py b/scripts/ie/offsets.py index 31704a4..27f321c 100644 --- a/scripts/ie/offsets.py +++ b/scripts/ie/offsets.py @@ -24,6 +24,17 @@ def get_offset_prefix(file_version, data_file_name): # eff_v2 / body.yml prefix = prefix.upper() return prefix +def get_format_version(file_version): + ''' + Get simplified file format version for usage in IELIB directory tree: + EFF_V2 => eff2 + ''' + base = re.sub("_v.*", "", file_version) + version = re.sub(".*_v", "", file_version) + version = version.replace(".", "") + if version == "1": + version = "" + return f"{base}{version}" def get_offset_id(item, prefix): """ diff --git a/scripts/iesdp_update.py b/scripts/iesdp_update.py index c3ced0f..4d85dfb 100755 --- a/scripts/iesdp_update.py +++ b/scripts/iesdp_update.py @@ -29,6 +29,7 @@ get_itemtypes, save_itemtypes_ielib, get_itemtypes_isense, + get_format_version, ) yaml = ruamel.yaml.YAML(typ="rt") @@ -310,7 +311,8 @@ def sanitise(self): definition_items = {**definition_items, **new_definition_items} pod.append_offsets(offsets, prefix) - dump_definition(prefix, definition_items, IELIB_STRUCTURES_DIR) + prefix_dir = get_format_version(ff) + dump_definition(prefix_dir, definition_items, IELIB_STRUCTURES_DIR) # feature block fpath = os.path.join(IESDP_FILE_FORMATS_DIR, "itm_v1", "feature_block.yml")