Format Python scripts with black (NFC) (#4325)

This commit is contained in:
Tyler Veness
2022-07-01 06:41:44 -07:00
committed by GitHub
parent 2e09fa7325
commit 5eb44e22a9
9 changed files with 264 additions and 182 deletions

View File

@@ -4,7 +4,14 @@ import os
import shutil
import subprocess
from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, walk_cwd_and_copy_if, am_patches, walk_if, copy_to
from upstream_utils import (
setup_upstream_repo,
comment_out_invalid_includes,
walk_cwd_and_copy_if,
am_patches,
walk_if,
copy_to,
)
def crlf_to_lf(stackwalker_dir):
@@ -15,11 +22,11 @@ def crlf_to_lf(stackwalker_dir):
for fname in files:
filename = os.path.join(root, fname)
print(f"Converting CRLF -> LF for {filename}")
with open(filename, 'rb') as f:
with open(filename, "rb") as f:
content = f.read()
content = content.replace(b'\r\n', b'\n')
content = content.replace(b"\r\n", b"\n")
with open(filename, 'wb') as f:
with open(filename, "wb") as f:
f.write(content)
subprocess.check_call(["git", "add", "-A"])
@@ -30,7 +37,8 @@ def main():
root, repo = setup_upstream_repo(
"https://github.com/JochenKalmbach/StackWalker",
"42e7a6e056a9e7aca911a7e9e54e2e4f90bc2652",
shallow=False)
shallow=False,
)
wpiutil = os.path.join(root, "wpiutil")
# Run CRLF -> LF before trying any patches
@@ -38,19 +46,25 @@ def main():
# Apply patches to original git repo
patch_dir = os.path.join(root, "upstream_utils/stack_walker_patches")
am_patches(repo, [
os.path.join(patch_dir, "0001-Apply-PR-35.patch"),
os.path.join(patch_dir, "0002-Remove-_M_IX86-checks.patch"),
os.path.join(patch_dir, "0003-Add-advapi-pragma.patch"),
],
ignore_whitespce=True)
am_patches(
repo,
[
os.path.join(patch_dir, "0001-Apply-PR-35.patch"),
os.path.join(patch_dir, "0002-Remove-_M_IX86-checks.patch"),
os.path.join(patch_dir, "0003-Add-advapi-pragma.patch"),
],
ignore_whitespce=True,
)
shutil.copy(os.path.join("Main", "StackWalker", "StackWalker.h"),
os.path.join(wpiutil, "src/main/native/windows/StackWalker.h"))
shutil.copy(
os.path.join("Main", "StackWalker", "StackWalker.h"),
os.path.join(wpiutil, "src/main/native/windows/StackWalker.h"),
)
shutil.copy(
os.path.join("Main", "StackWalker", "StackWalker.cpp"),
os.path.join(wpiutil, "src/main/native/windows/StackWalker.cpp"))
os.path.join(wpiutil, "src/main/native/windows/StackWalker.cpp"),
)
if __name__ == "__main__":