|
3 | 3 | import os
|
4 | 4 | import sys
|
5 | 5 | import shutil
|
| 6 | +from glob import glob |
| 7 | +from pathlib import Path |
6 | 8 | if sys.version_info[0] < 3:
|
7 | 9 | raise RuntimeError('Requires python3')
|
8 | 10 |
|
@@ -389,24 +391,15 @@ def main(install=False,recompile=True):
|
389 | 391 |
|
390 | 392 | copy_ppp_header("%s/taint2/taint2.h" % PLUGINS_DIR)
|
391 | 393 |
|
| 394 | + # programatically copy anything that ends with _ppp.h |
| 395 | + for ppp_file in glob(f"{PLUGINS_DIR}/*/*_ppp.h", recursive=True): |
| 396 | + ppp = Path(ppp_file) |
| 397 | + copy_ppp_header(ppp_file) |
392 | 398 |
|
393 |
| - #programtically copy anything that ends with _ppp.h |
394 |
| - |
395 |
| - #for each subdirectory under PLUGINS_DIR |
396 |
| - plugin_dirs = [os.path.join(PLUGINS_DIR, f) for f in os.listdir(PLUGINS_DIR) if os.path.isdir(os.path.join(PLUGINS_DIR, f))] |
397 |
| - |
398 |
| - pattern = re.compile(r"_ppp\.h$") #matches strings ending with _ppp.h |
399 |
| - for plugin_dir in plugin_dirs: |
400 |
| - plugin_files = os.listdir(plugin_dir) |
401 |
| - |
402 |
| - for plugin_file in plugin_files: |
403 |
| - if pattern.search(plugin_file): |
404 |
| - copy_ppp_header(f"{plugin_dir}/{plugin_file}") |
405 |
| - |
406 |
| - #if the directory with the _ppp.h file also has a [plugin_name].h file, include it |
407 |
| - header_filepath = f"{plugin_dir}/{os.path.basename(plugin_dir) + '.h'}" |
408 |
| - if os.path.isfile(header_filepath): |
409 |
| - create_pypanda_header(header_filepath) |
| 399 | + plugin_dir = ppp.parent |
| 400 | + header_filepath = Path(plugin_dir, f"{plugin_dir.name}.h") |
| 401 | + if header_filepath.exists(): |
| 402 | + create_pypanda_header(str(header_filepath)) |
410 | 403 |
|
411 | 404 | with open(os.path.join(OUTPUT_DIR, "panda_datatypes.py"), "w") as pdty:
|
412 | 405 | pdty.write("""from __future__ import print_function
|
|
0 commit comments