mirror of
https://github.com/CrispyPin/crispypin.cc.git
synced 2025-02-20 19:54:01 +01:00
fix subfolders
This commit is contained in:
parent
e3bd8369db
commit
cc2aecc16e
1 changed files with 11 additions and 1 deletions
|
@ -11,21 +11,31 @@ INCLUDE_MARKER_END = ")"
|
|||
def process_dir(path: str = "") -> None:
|
||||
items = os.listdir(PAGE_DIR + path)
|
||||
for name in items:
|
||||
if os.path.isdir(path + name):
|
||||
if os.path.isdir(PAGE_DIR + path + name):
|
||||
process_dir(path + name + "/")
|
||||
else:
|
||||
process_file(path + name)
|
||||
|
||||
|
||||
def process_file(filepath: str) -> str:
|
||||
print("processing " + filepath)
|
||||
contents = read_file(PAGE_DIR + filepath)
|
||||
while INCLUDE_MARKER in contents:
|
||||
contents = apply_include(contents)
|
||||
|
||||
ensure_dir(TARGET_DIR + filepath)
|
||||
|
||||
with open(TARGET_DIR + filepath, "w") as f:
|
||||
f.write(contents)
|
||||
|
||||
|
||||
def ensure_dir(filepath: str):
|
||||
i = len(filepath) - filepath[::-1].find("/")
|
||||
dir = filepath[:i]
|
||||
if not os.path.exists(dir):
|
||||
os.mkdir(dir)
|
||||
|
||||
|
||||
def apply_include(contents: str) -> str:
|
||||
included_file = get_included_name(contents)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue