-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5473 from Pinata-Consulting/python-black
python: ran black .
- Loading branch information
Showing
227 changed files
with
3,718 additions
and
2,586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Lint Python | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: psf/black@stable | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,78 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
|
||
|
||
def swap_prefix(file, old, new): | ||
with open(file, 'r') as f: | ||
with open(file, "r") as f: | ||
lines = f.read() | ||
lines = lines.replace(old, new) | ||
with open(file, 'wt') as f: | ||
with open(file, "wt") as f: | ||
f.write(lines) | ||
|
||
|
||
# modify ../include/ord/OpenROAD.hh | ||
swap_prefix('../include/ord/OpenRoad.hh', 'namespace dft {\nclass Dft;\n}', | ||
'namespace dft {\nclass Dft;\n}\n\nnamespace tool{\nclass Tool;\n}') | ||
swap_prefix( | ||
"../include/ord/OpenRoad.hh", | ||
"namespace dft {\nclass Dft;\n}", | ||
"namespace dft {\nclass Dft;\n}\n\nnamespace tool{\nclass Tool;\n}", | ||
) | ||
|
||
swap_prefix('../include/ord/OpenRoad.hh', 'dft::Dft* getDft() { return dft_; }', | ||
'dft::Dft* getDft() { return dft_; }\n tool::Tool* getTool() { return tool_; }') | ||
swap_prefix( | ||
"../include/ord/OpenRoad.hh", | ||
"dft::Dft* getDft() { return dft_; }", | ||
"dft::Dft* getDft() { return dft_; }\n tool::Tool* getTool() { return tool_; }", | ||
) | ||
|
||
swap_prefix('../include/ord/OpenRoad.hh', 'dft::Dft* dft_ = nullptr;', | ||
'dft::Dft* dft_ = nullptr;\n tool::Tool* tool_ = nullptr;') | ||
swap_prefix( | ||
"../include/ord/OpenRoad.hh", | ||
"dft::Dft* dft_ = nullptr;", | ||
"dft::Dft* dft_ = nullptr;\n tool::Tool* tool_ = nullptr;", | ||
) | ||
|
||
# modify ../src/CMakeLists.txt | ||
swap_prefix('../src/CMakeLists.txt', 'add_subdirectory(dft)', | ||
'add_subdirectory(dft)\nadd_subdirectory(tool)') | ||
swap_prefix( | ||
"../src/CMakeLists.txt", | ||
"add_subdirectory(dft)", | ||
"add_subdirectory(dft)\nadd_subdirectory(tool)", | ||
) | ||
|
||
swap_prefix('../src/CMakeLists.txt', 'pdn\n dft', 'pdn\n dft\n tool') | ||
swap_prefix("../src/CMakeLists.txt", "pdn\n dft", "pdn\n dft\n tool") | ||
|
||
# modify ../src/OpenROAD.cc | ||
swap_prefix('../src/OpenRoad.cc', '#include "utl/MakeLogger.h"', | ||
'#include "utl/MakeLogger.h"\n#include "tool/MakeTool.hh"') | ||
swap_prefix( | ||
"../src/OpenRoad.cc", | ||
'#include "utl/MakeLogger.h"', | ||
'#include "utl/MakeLogger.h"\n#include "tool/MakeTool.hh"', | ||
) | ||
|
||
swap_prefix('../src/OpenRoad.cc', 'dft_ = dft::makeDft();', | ||
'dft_ = dft::makeDft();\n tool_ = makeTool();') | ||
swap_prefix( | ||
"../src/OpenRoad.cc", | ||
"dft_ = dft::makeDft();", | ||
"dft_ = dft::makeDft();\n tool_ = makeTool();", | ||
) | ||
|
||
swap_prefix('../src/OpenRoad.cc', 'dft::deleteDft(dft_);', | ||
'dft::deleteDft(dft_);\n deleteTool(tool_);') | ||
swap_prefix( | ||
"../src/OpenRoad.cc", | ||
"dft::deleteDft(dft_);", | ||
"dft::deleteDft(dft_);\n deleteTool(tool_);", | ||
) | ||
|
||
swap_prefix('../src/OpenRoad.cc', 'dft::initDft(this);', | ||
'dft::initDft(this);\n initTool(this);') | ||
swap_prefix( | ||
"../src/OpenRoad.cc", | ||
"dft::initDft(this);", | ||
"dft::initDft(this);\n initTool(this);", | ||
) | ||
|
||
# create a patch file | ||
_ = os.popen('git add ../include/ord/OpenRoad.hh').read() | ||
_ = os.popen('git add ../src/CMakeLists.txt').read() | ||
_ = os.popen('git add ../src/OpenRoad.cc').read() | ||
_ = os.popen('git diff --cached > misc/AddTool.patch').read() | ||
_ = os.popen("git add ../include/ord/OpenRoad.hh").read() | ||
_ = os.popen("git add ../src/CMakeLists.txt").read() | ||
_ = os.popen("git add ../src/OpenRoad.cc").read() | ||
_ = os.popen("git diff --cached > misc/AddTool.patch").read() | ||
|
||
# restore all changes except patch | ||
_ = os.popen('git reset ../include/ord/OpenRoad.hh').read() | ||
_ = os.popen('git reset ../src/CMakeLists.txt').read() | ||
_ = os.popen('git reset ../src/OpenRoad.cc').read() | ||
_ = os.popen('git restore ../include/ord/OpenRoad.hh').read() | ||
_ = os.popen('git restore ../src/CMakeLists.txt').read() | ||
_ = os.popen('git restore ../src/OpenRoad.cc').read() | ||
|
||
_ = os.popen("git reset ../include/ord/OpenRoad.hh").read() | ||
_ = os.popen("git reset ../src/CMakeLists.txt").read() | ||
_ = os.popen("git reset ../src/OpenRoad.cc").read() | ||
_ = os.popen("git restore ../include/ord/OpenRoad.hh").read() | ||
_ = os.popen("git restore ../src/CMakeLists.txt").read() | ||
_ = os.popen("git restore ../src/OpenRoad.cc").read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
#!/usr/bin/env python3 | ||
|
||
|
||
def swap_prefix(file, old, new): | ||
with open(file, 'r') as f: | ||
with open(file, "r") as f: | ||
lines = f.read() | ||
lines = lines.replace(old, new) | ||
with open(file, 'wt') as f: | ||
with open(file, "wt") as f: | ||
f.write(lines) | ||
|
||
|
||
swap_prefix('../README.md', '(../', '(docs/') | ||
swap_prefix('../README.md', '```{mermaid}\n:align: center\n', '```mermaid') | ||
swap_prefix("../README.md", "(../", "(docs/") | ||
swap_prefix("../README.md", "```{mermaid}\n:align: center\n", "```mermaid") |
Oops, something went wrong.