|
11 | 11 | core.set_default_server_context(core.AvailableServerContexts.premium) |
12 | 12 | core.start_local_server(config=core.AvailableServerConfigs.LegacyGrpcServer) |
13 | 13 |
|
| 14 | +files_to_keep = { |
| 15 | + "operator.mustache": "", |
| 16 | + "build.py": "", |
| 17 | + "specification.py": "", |
| 18 | + "translator.py": "", |
| 19 | + # Deprecated operator scripting names |
| 20 | + "result": [ |
| 21 | + "gasket_deformation.py", |
| 22 | + "gasket_deformation_X.py", |
| 23 | + "gasket_deformation_XY.py", |
| 24 | + "gasket_deformation_XZ.py", |
| 25 | + ], |
| 26 | +} |
| 27 | + |
14 | 28 | local_dir = Path(__file__).parent |
15 | 29 | TARGET_PATH = local_dir.parent / "src" / "ansys" / "dpf" / "core" / "operators" |
16 | 30 | files = TARGET_PATH.glob("*") |
17 | 31 | for file_path in files: |
18 | | - if file_path.stem == "specification": |
19 | | - continue |
20 | | - if file_path.stem == "translator": |
21 | | - continue |
22 | | - if file_path.name == "build.py": |
| 32 | + if file_path.is_file() and (file_path.name in files_to_keep): |
23 | 33 | continue |
24 | | - if file_path.name == "operator.mustache": |
25 | | - continue |
26 | | - try: |
27 | | - if file_path.is_dir(): |
28 | | - 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() |
29 | 41 | else: |
30 | | - file_path.unlink() |
31 | | - except: |
32 | | - pass |
| 42 | + shutil.rmtree(file_path) |
| 43 | + else: |
| 44 | + file_path.unlink() |
33 | 45 |
|
34 | 46 | build.build_operators() |
0 commit comments