Skip to content

Commit f5e33ae

Browse files
Merge pull request #601 from MartinThoma/python-formatter-black
Apply black to the 00_Utilities/markdown_todo.py
2 parents dd54866 + ef2e2f3 commit f5e33ae

File tree

3 files changed

+73
-15
lines changed

3 files changed

+73
-15
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ obj/
2626
out/
2727

2828
*.py[co]
29-
29+
.python-version
3030
Pipfile
3131

3232
.DS_Store

.pre-commit-config.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# pre-commit run --all-files
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.1.0
5+
hooks:
6+
- id: check-ast
7+
- id: check-byte-order-marker
8+
- id: check-case-conflict
9+
- id: check-docstring-first
10+
- id: check-executables-have-shebangs
11+
- id: check-json
12+
- id: check-yaml
13+
- id: debug-statements
14+
- id: end-of-file-fixer
15+
- id: trailing-whitespace
16+
- id: mixed-line-ending
17+
- repo: https://github.com/pre-commit/mirrors-isort
18+
rev: v5.10.1
19+
hooks:
20+
- id: isort
21+
- repo: https://github.com/psf/black
22+
rev: 22.1.0
23+
hooks:
24+
- id: black
25+
- repo: https://github.com/asottile/pyupgrade
26+
rev: v2.31.0
27+
hooks:
28+
- id: pyupgrade
29+
args: [--py37-plus]
30+
- repo: https://github.com/asottile/blacken-docs
31+
rev: v1.12.1
32+
hooks:
33+
- id: blacken-docs
34+
additional_dependencies: [black==20.8b1]

00_Utilities/markdown_todo.py

+38-14
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,61 @@
11
import os
22

3-
43
lang_pos = {
5-
"csharp": 1, "java": 2, "javascript": 3,
6-
"pascal": 4, "perl": 5, "python": 6, "ruby": 7, "vbnet": 8
4+
"csharp": 1,
5+
"java": 2,
6+
"javascript": 3,
7+
"pascal": 4,
8+
"perl": 5,
9+
"python": 6,
10+
"ruby": 7,
11+
"vbnet": 8,
712
}
813

914
write_string = "# TODO list \n game | csharp | java | javascript | pascal | perl | python | ruby | vbnet \n --- | --- | --- | --- | --- | --- | --- | --- | --- \n"
1015
# Set the directory you want to start from
11-
rootDir = '..'
16+
rootDir = ".."
1217

1318
strings_done = []
1419

15-
checklist = ["game", "csharp", "java", "javascript",
16-
"pascal", "perl", "python", "ruby", "vbnet"]
20+
checklist = [
21+
"game",
22+
"csharp",
23+
"java",
24+
"javascript",
25+
"pascal",
26+
"perl",
27+
"python",
28+
"ruby",
29+
"vbnet",
30+
]
1731

1832
prev_game = ""
1933

2034
for dirName, subdirList, fileList in os.walk(rootDir):
2135
split_dir = dirName.split(os.path.sep)
2236

23-
if len(split_dir) == 2 and not split_dir[1] in ['.git', '00_Utilities']:
37+
if len(split_dir) == 2 and not split_dir[1] in [".git", "00_Utilities"]:
2438
if prev_game == "":
2539
prev_game = split_dir[1]
2640
checklist[0] = split_dir[1]
2741

2842
if prev_game != split_dir[1]:
2943
# it's a new dir
3044
strings_done.append(checklist)
31-
checklist = [split_dir[1], "csharp", "java", "javascript",
32-
"pascal", "perl", "python", "ruby", "vbnet"]
45+
checklist = [
46+
split_dir[1],
47+
"csharp",
48+
"java",
49+
"javascript",
50+
"pascal",
51+
"perl",
52+
"python",
53+
"ruby",
54+
"vbnet",
55+
]
3356
prev_game = split_dir[1]
3457

35-
elif len(split_dir) == 3 and split_dir[1] != '.git':
58+
elif len(split_dir) == 3 and split_dir[1] != ".git":
3659
if split_dir[2] in lang_pos.keys():
3760
if len(fileList) > 1 or len(subdirList) > 0:
3861
# there is more files than the readme
@@ -41,10 +64,11 @@
4164
checklist[lang_pos[split_dir[2]]] = "⬜️"
4265

4366

44-
sorted_strings = list(map(lambda l: " | ".join(l) + "\n",
45-
sorted(strings_done, key=lambda x: x[0])))
46-
write_string += ''.join(sorted_strings)
67+
sorted_strings = list(
68+
map(lambda l: " | ".join(l) + "\n", sorted(strings_done, key=lambda x: x[0]))
69+
)
70+
write_string += "".join(sorted_strings)
4771

4872

49-
with open("README.md", "w", encoding='utf-8') as f:
73+
with open("README.md", "w", encoding="utf-8") as f:
5074
f.write(write_string)

0 commit comments

Comments
 (0)