Files
distcloud/distributedcloud/run_black.py
Hugo Brito 70fd84b263 Apply black formatter to dcorch
This commit applies the Black format to the `dcorch`
files to ensure that it adheres to the Black code style guidelines.

Test Plan:
PASS: Success in stx-distcloud-tox-black

Story: 2011149
Task: 50445

Change-Id: I0f6298293e6a86237723b53164abe892fb54dab0
Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
2024-06-28 13:46:02 +00:00

43 lines
981 B
Python

# noqa: H102
import subprocess
import sys
# List of module directories to check
modules = [
"dccommon",
"dcdbsync",
"dcorch",
"dcmanager/api",
"dcmanager/audit",
"dcmanager/common",
"dcmanager/db",
"dcmanager/orchestrator",
"dcmanager/tests",
"dcmanager",
]
# List of modules that are already formatted with black
formatted_modules = [
"dccommon",
"dcdbsync",
"dcorch",
]
# Function to run black check
def run_black_check(module):
try:
subprocess.run(["black", "--check", "--quiet", f"./{module}"], check=True)
print(f"Black check passed for {module}")
except subprocess.CalledProcessError as e:
print(f"Black check failed for {module}")
# If the module is in formatted_modules, stx-distcloud-tox-black will fail
if module in formatted_modules:
sys.exit(e.returncode)
# Iterate over modules and run black check
for module in modules:
run_black_check(module)