Skip to content

Commit 090e7ee

Browse files
committed
Update code_generation.py to handle kept operators
1 parent 8c9091c commit 090e7ee

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

.ci/code_generation.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,36 @@
1111
core.set_default_server_context(core.AvailableServerContexts.premium)
1212
core.start_local_server(config=core.AvailableServerConfigs.LegacyGrpcServer)
1313

14-
ignore_files = [
15-
"operator.mustache",
16-
"build.py",
17-
"specification.py",
18-
"translator.py",
14+
files_to_keep = {
15+
"operator.mustache": "",
16+
"build.py": "",
17+
"specification.py": "",
18+
"translator.py": "",
1919
# Deprecated operator scripting names
20-
"gasket_deformation.py",
21-
"gasket_deformation_X.py",
22-
"gasket_deformation_XY.py",
23-
"gasket_deformation_XZ.py",
24-
]
20+
"result": [
21+
"gasket_deformation.py",
22+
"gasket_deformation_X.py",
23+
"gasket_deformation_XY.py",
24+
"gasket_deformation_XZ.py",
25+
],
26+
}
2527

2628
local_dir = Path(__file__).parent
2729
TARGET_PATH = local_dir.parent / "src" / "ansys" / "dpf" / "core" / "operators"
2830
files = TARGET_PATH.glob("*")
2931
for file_path in files:
30-
if file_path.name in ignore_files:
32+
if file_path.is_file() and (file_path.name in files_to_keep):
3133
continue
32-
try:
33-
if file_path.is_dir():
34-
shutil.rmtree(file_path)
34+
if file_path.is_dir():
35+
shutil.rmtree(file_path / "__pycache__", ignore_errors=True)
36+
if file_path.name in files_to_keep:
37+
sub_files = file_path.glob("*")
38+
for sub_file in sub_files:
39+
if sub_file.name not in files_to_keep[file_path.name]:
40+
sub_file.unlink()
3541
else:
36-
file_path.unlink()
37-
except:
38-
pass
42+
shutil.rmtree(file_path)
43+
else:
44+
file_path.unlink()
3945

4046
build.build_operators()

0 commit comments

Comments
 (0)