mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-21 23:00:43 -08:00
Apply black to the 00_Utilities/markdown_todo.py
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -26,7 +26,7 @@ obj/
|
|||||||
out/
|
out/
|
||||||
|
|
||||||
*.py[co]
|
*.py[co]
|
||||||
|
.python-version
|
||||||
Pipfile
|
Pipfile
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
34
.pre-commit-config.yaml
Normal file
34
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# pre-commit run --all-files
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.1.0
|
||||||
|
hooks:
|
||||||
|
- id: check-ast
|
||||||
|
- id: check-byte-order-marker
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: check-docstring-first
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: check-json
|
||||||
|
- id: check-yaml
|
||||||
|
- id: debug-statements
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: mixed-line-ending
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-isort
|
||||||
|
rev: v5.10.1
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 22.1.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
|
rev: v2.31.0
|
||||||
|
hooks:
|
||||||
|
- id: pyupgrade
|
||||||
|
args: [--py37-plus]
|
||||||
|
- repo: https://github.com/asottile/blacken-docs
|
||||||
|
rev: v1.12.1
|
||||||
|
hooks:
|
||||||
|
- id: blacken-docs
|
||||||
|
additional_dependencies: [black==20.8b1]
|
||||||
@@ -1,26 +1,40 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
lang_pos = {
|
lang_pos = {
|
||||||
"csharp": 1, "java": 2, "javascript": 3,
|
"csharp": 1,
|
||||||
"pascal": 4, "perl": 5, "python": 6, "ruby": 7, "vbnet": 8
|
"java": 2,
|
||||||
|
"javascript": 3,
|
||||||
|
"pascal": 4,
|
||||||
|
"perl": 5,
|
||||||
|
"python": 6,
|
||||||
|
"ruby": 7,
|
||||||
|
"vbnet": 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
write_string = "# TODO list \n game | csharp | java | javascript | pascal | perl | python | ruby | vbnet \n --- | --- | --- | --- | --- | --- | --- | --- | --- \n"
|
write_string = "# TODO list \n game | csharp | java | javascript | pascal | perl | python | ruby | vbnet \n --- | --- | --- | --- | --- | --- | --- | --- | --- \n"
|
||||||
# Set the directory you want to start from
|
# Set the directory you want to start from
|
||||||
rootDir = '..'
|
rootDir = ".."
|
||||||
|
|
||||||
strings_done = []
|
strings_done = []
|
||||||
|
|
||||||
checklist = ["game", "csharp", "java", "javascript",
|
checklist = [
|
||||||
"pascal", "perl", "python", "ruby", "vbnet"]
|
"game",
|
||||||
|
"csharp",
|
||||||
|
"java",
|
||||||
|
"javascript",
|
||||||
|
"pascal",
|
||||||
|
"perl",
|
||||||
|
"python",
|
||||||
|
"ruby",
|
||||||
|
"vbnet",
|
||||||
|
]
|
||||||
|
|
||||||
prev_game = ""
|
prev_game = ""
|
||||||
|
|
||||||
for dirName, subdirList, fileList in os.walk(rootDir):
|
for dirName, subdirList, fileList in os.walk(rootDir):
|
||||||
split_dir = dirName.split(os.path.sep)
|
split_dir = dirName.split(os.path.sep)
|
||||||
|
|
||||||
if len(split_dir) == 2 and not split_dir[1] in ['.git', '00_Utilities']:
|
if len(split_dir) == 2 and not split_dir[1] in [".git", "00_Utilities"]:
|
||||||
if prev_game == "":
|
if prev_game == "":
|
||||||
prev_game = split_dir[1]
|
prev_game = split_dir[1]
|
||||||
checklist[0] = split_dir[1]
|
checklist[0] = split_dir[1]
|
||||||
@@ -28,11 +42,20 @@ for dirName, subdirList, fileList in os.walk(rootDir):
|
|||||||
if prev_game != split_dir[1]:
|
if prev_game != split_dir[1]:
|
||||||
# it's a new dir
|
# it's a new dir
|
||||||
strings_done.append(checklist)
|
strings_done.append(checklist)
|
||||||
checklist = [split_dir[1], "csharp", "java", "javascript",
|
checklist = [
|
||||||
"pascal", "perl", "python", "ruby", "vbnet"]
|
split_dir[1],
|
||||||
|
"csharp",
|
||||||
|
"java",
|
||||||
|
"javascript",
|
||||||
|
"pascal",
|
||||||
|
"perl",
|
||||||
|
"python",
|
||||||
|
"ruby",
|
||||||
|
"vbnet",
|
||||||
|
]
|
||||||
prev_game = split_dir[1]
|
prev_game = split_dir[1]
|
||||||
|
|
||||||
elif len(split_dir) == 3 and split_dir[1] != '.git':
|
elif len(split_dir) == 3 and split_dir[1] != ".git":
|
||||||
if split_dir[2] in lang_pos.keys():
|
if split_dir[2] in lang_pos.keys():
|
||||||
if len(fileList) > 1 or len(subdirList) > 0:
|
if len(fileList) > 1 or len(subdirList) > 0:
|
||||||
# there is more files than the readme
|
# there is more files than the readme
|
||||||
@@ -41,10 +64,11 @@ for dirName, subdirList, fileList in os.walk(rootDir):
|
|||||||
checklist[lang_pos[split_dir[2]]] = "⬜️"
|
checklist[lang_pos[split_dir[2]]] = "⬜️"
|
||||||
|
|
||||||
|
|
||||||
sorted_strings = list(map(lambda l: " | ".join(l) + "\n",
|
sorted_strings = list(
|
||||||
sorted(strings_done, key=lambda x: x[0])))
|
map(lambda l: " | ".join(l) + "\n", sorted(strings_done, key=lambda x: x[0]))
|
||||||
write_string += ''.join(sorted_strings)
|
)
|
||||||
|
write_string += "".join(sorted_strings)
|
||||||
|
|
||||||
|
|
||||||
with open("README.md", "w", encoding='utf-8') as f:
|
with open("README.md", "w", encoding="utf-8") as f:
|
||||||
f.write(write_string)
|
f.write(write_string)
|
||||||
|
|||||||
Reference in New Issue
Block a user