mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-07-29 05:02:02 +08:00

Update style to some files with clang-format using Google style Add Script to parse all embedded js/css files and format them using prettier based on .prettierrc config file Update style to embedded js/css files with prettier
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
#!/usr/bin/python
|
|
|
|
import os
|
|
import subprocess
|
|
|
|
# Base directory of the script
|
|
script_path = os.path.abspath(__file__)
|
|
|
|
# Extract dir path
|
|
script_dir = os.path.dirname(script_path)
|
|
|
|
# Build path of sources dir : ../esp3d
|
|
base_dir = os.path.abspath(os.path.normpath(os.path.join(script_dir, '..', 'esp3d')))
|
|
|
|
# Parse all c, h , cpp files in all directories and sub directories
|
|
file_paths = []
|
|
for root, dirs, files in os.walk(base_dir):
|
|
for file in files:
|
|
if file.endswith(('.c', '.cpp', '.h', '.ino')):
|
|
file_path = os.path.join(root, file)
|
|
file_paths.append(os.path.abspath(os.path.normpath(file_path)))
|
|
|
|
# Now format all files one by one with clang-format
|
|
for file_path in file_paths:
|
|
tmpPath = '"' + file_path + '"'
|
|
print("Formating " + tmpPath, end="")
|
|
try:
|
|
command = ['clang-format', '-i', '--style=Google', file_path]
|
|
subprocess.run(command, check=False)
|
|
print("=> Ok")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f'=>Error : {e}')
|