forked from doocs/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,663 changed files
with
6,117 additions
and
9,051 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
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 |
---|---|---|
|
@@ -170,7 +170,6 @@ public: | |
} | ||
} | ||
}; | ||
|
||
``` | ||
|
||
### **Go** | ||
|
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,10 +1,44 @@ | ||
import os.path | ||
import re | ||
|
||
path = os.getcwd() | ||
for root, dirs, files in os.walk(path): | ||
for name in files: | ||
if name.endswith('.cpp') or name.endswith('.c'): | ||
local_path = root + '/' + name | ||
command = f'clang-format -i --style=file "{local_path}"' | ||
print(command) | ||
os.system(command) | ||
|
||
|
||
def format_cpp_file(): | ||
for root, __import__, files in os.walk(path): | ||
for name in files: | ||
if name.endswith('.cpp') or name.endswith('.c'): | ||
local_path = root + '/' + name | ||
command = f'clang-format -i --style=file "{local_path}"' | ||
print(command) | ||
os.system(command) | ||
|
||
|
||
def format_readme_cpp_code_block(): | ||
for root, _, files in os.walk(path): | ||
for name in files: | ||
if name.endswith('.md'): | ||
p1 = root + '/' + name | ||
with open(p1, 'r', encoding='utf-8') as f: | ||
content = f.read() | ||
x = content | ||
res = re.search('```cpp(.*?)```', content, re.S) | ||
if not res: | ||
continue | ||
print(p1) | ||
res = res.group(1) | ||
p2 = root + "/tmp.cpp" | ||
with open(p2, 'w', encoding='utf-8') as f: | ||
f.write(res) | ||
command = f'clang-format -i --style=file "{p2}"' | ||
os.system(command) | ||
with open(p2, 'r', encoding='utf-8') as f: | ||
content = f.read() | ||
content = x.replace(res, content) | ||
with open(p1, 'w', encoding='utf-8') as f: | ||
f.write(content) | ||
os.remove(p2) | ||
|
||
|
||
if __name__ == '__main__': | ||
format_readme_cpp_code_block() |
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
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
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
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
Oops, something went wrong.