mirror of
https://github.com/CrispyPin/crispypin.cc.git
synced 2025-02-22 12:44:00 +01:00
clean up python with black
This commit is contained in:
parent
cb5d7c726b
commit
644ce83d14
1 changed files with 5 additions and 4 deletions
|
@ -8,6 +8,7 @@ TARGET_DIR = "./docs/"
|
||||||
INCLUDE_MARKER = "<include "
|
INCLUDE_MARKER = "<include "
|
||||||
INCLUDE_MARKER_END = "/>"
|
INCLUDE_MARKER_END = "/>"
|
||||||
|
|
||||||
|
|
||||||
def process_dir(path: str = "") -> None:
|
def process_dir(path: str = "") -> None:
|
||||||
items = os.listdir(PAGE_DIR + path)
|
items = os.listdir(PAGE_DIR + path)
|
||||||
for name in items:
|
for name in items:
|
||||||
|
@ -17,12 +18,12 @@ def process_dir(path: str = "") -> None:
|
||||||
process_file(path + name)
|
process_file(path + name)
|
||||||
|
|
||||||
|
|
||||||
def process_file(filepath: str) -> str:
|
def process_file(filepath: str) -> None:
|
||||||
print("processing " + filepath)
|
print("processing " + filepath)
|
||||||
contents = read_file(PAGE_DIR + filepath)
|
contents = read_file(PAGE_DIR + filepath)
|
||||||
while INCLUDE_MARKER in contents:
|
while INCLUDE_MARKER in contents:
|
||||||
contents = apply_include(contents)
|
contents = apply_include(contents)
|
||||||
|
|
||||||
ensure_dir(TARGET_DIR + filepath)
|
ensure_dir(TARGET_DIR + filepath)
|
||||||
|
|
||||||
with open(TARGET_DIR + filepath, "w") as f:
|
with open(TARGET_DIR + filepath, "w") as f:
|
||||||
|
@ -61,7 +62,7 @@ def get_included_name(contents):
|
||||||
|
|
||||||
def get_marker_indices(contents: str) -> tuple:
|
def get_marker_indices(contents: str) -> tuple:
|
||||||
index_start = contents.find(INCLUDE_MARKER)
|
index_start = contents.find(INCLUDE_MARKER)
|
||||||
index_end = contents.find(INCLUDE_MARKER_END, index_start)
|
index_end = contents.find(INCLUDE_MARKER_END, index_start)
|
||||||
return (index_start, index_end)
|
return (index_start, index_end)
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ def read_file(filepath: str):
|
||||||
with open(filepath, "r") as f:
|
with open(filepath, "r") as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
return contents
|
return contents
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
process_dir()
|
process_dir()
|
||||||
|
|
Loading…
Add table
Reference in a new issue