Skip to content

Commit

Permalink
feat: ignored_commands in config.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
clatapie committed Nov 25, 2024
1 parent e5ee2f6 commit 15fb796
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
17 changes: 17 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ specific_command_mapping:
"C***": c
"/INQUIRE": inquire

ignored_commands:
- "*VWR"
- "*MWR"
- "C***"
- "*CFO"
- "*CRE"
- "*END"
- "/EOF"
- "*ASK"
- "*IF"
- "*ELSE"
- "CMAT"
- "*REP"
- "*RETURN"
- "LSRE"


specific_classes:
2D to 3D Analysis: Analysis 2D to 3D
Parameters: Parameter definition
3 changes: 0 additions & 3 deletions src/pyconverter/xml2py/ast_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@
# Map XML command to pycommand function
NAME_MAP_GLOB = {}

# XML commands to skip
SKIP = {"*IF", "*ELSE", "C***", "*RETURN"}

NO_RESIZE_LIST = ["Variablelist"]


Expand Down
9 changes: 4 additions & 5 deletions src/pyconverter/xml2py/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
'``"``': "``",
}

# XML commands to skip
SKIP_XML = {"*IF", "*ELSE", "*RETURN", "*DEL"} # Equivalent to if, else, return, del


def convert(directory_path):
"""
Expand Down Expand Up @@ -407,6 +404,8 @@ def write_source(
new_package_name = get_config_data_value(config_path, "new_package_name")
logging.info(f"Creating package {new_package_name}...")
new_package_path = target_path / new_package_name

ignored_commands = set(get_config_data_value(config_path, "ignored_commands"))

if clean:
if new_package_path.is_dir():
Expand All @@ -420,7 +419,7 @@ def write_source(
if structured == False:
package_structure = None
for initial_command_name, command_obj in tqdm(command_map.items(), desc="Writing commands"):
if initial_command_name in SKIP_XML:
if initial_command_name in ignored_commands:
continue
python_name = name_map[initial_command_name]
path = library_path / f"{python_name}.py"
Expand All @@ -439,7 +438,7 @@ def write_source(
all_commands = []
specific_classes = get_config_data_value(config_path, "specific_classes")
for command in tqdm(command_map.values(), desc="Writing commands"):
if command.name in SKIP_XML or command.group is None:
if command.name in ignored_commands or command.group is None:
continue

module_name, initial_class_name, module_path = get_module_info(library_path, command)
Expand Down

0 comments on commit 15fb796

Please sign in to comment.