|
11 | 11 | core.set_default_server_context(core.AvailableServerContexts.premium) |
12 | 12 | core.start_local_server(config=core.AvailableServerConfigs.LegacyGrpcServer) |
13 | 13 |
|
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": "", |
19 | 19 | # 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 | +} |
25 | 27 |
|
26 | 28 | local_dir = Path(__file__).parent |
27 | 29 | TARGET_PATH = local_dir.parent / "src" / "ansys" / "dpf" / "core" / "operators" |
28 | 30 | files = TARGET_PATH.glob("*") |
29 | 31 | 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): |
31 | 33 | 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() |
35 | 41 | else: |
36 | | - file_path.unlink() |
37 | | - except: |
38 | | - pass |
| 42 | + shutil.rmtree(file_path) |
| 43 | + else: |
| 44 | + file_path.unlink() |
39 | 45 |
|
40 | 46 | build.build_operators() |
0 commit comments