From 01912538aa2e0a4e2db9f68b92ca57e847886f17 Mon Sep 17 00:00:00 2001 From: Maximilian Paulsen Date: Wed, 28 Feb 2024 16:39:35 +0100 Subject: [PATCH] Use i2c AD python scripts --- py_scripts/make_cpp_files.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/py_scripts/make_cpp_files.py b/py_scripts/make_cpp_files.py index 389c629..405468d 100644 --- a/py_scripts/make_cpp_files.py +++ b/py_scripts/make_cpp_files.py @@ -1,5 +1,16 @@ import os +import shutil + +ARDUINO_FILE_EXTENSION = ".ino" +TARGET_FILE_EXTENSION = ".cpp" +EXAMPLE_FOLDER = "examples" # Create a .cpp file for all the .ino files in the examples dir (CAUTION: will overwrite existing) print("PRE_SCRIPT: Copying .ino file contents to .cpp files.") -os.system(f'find examples -type f -name "*.ino" -exec bash -c \'for file; do cp "$file" "$(dirname "$file")/$(basename "$file" .ino).cpp"; done\' _ {{}} +') +for e in os.listdir(EXAMPLE_FOLDER): + if os.path.isdir(f"{EXAMPLE_FOLDER}/{e}") and os.path.isfile(f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}"): + arduino_file =f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}" + cpp_file = f"{EXAMPLE_FOLDER}/{e}/{e}{TARGET_FILE_EXTENSION}" + shutil.copyfile(arduino_file, cpp_file) + print(f'\tcopied {arduino_file} to {cpp_file}') +print("\t>> Done.")