Pi66

Home | Repos | About | Blog | Gaza

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

About | Files | Commits | Refs | License


refactor:simplify file operations

Author: pixel
Date: 2026-07-22 09:37
commit: a36060f1

Stat

M src/fileops.py 21 +7 -14

Diff

diff --git a/src/fileops.py b/src/fileops.py
index 0cad009..d426346 100644
--- a/src/fileops.py
+++ b/src/fileops.py
@@ -4,17 +4,15 @@ from .modules import Tree
 def is_dotfile(file_path):
     return any(part.startswith(".") for part in path.normpath(file_path).split(sep))

-def write_file(file_path: str, file_content: str) -> None: +def write_file(file_path, file_content): with open(file_path, "w") as f: f.write(file_content)

-def read_file(file_path:str) -> str: - """Read and return file contents""" - with open(file_path, "r") as f : +def read_file(file_path): + with open(file_path, "r") as f: return f.read()

...
Show all
diff --git a/src/fileops.py b/src/fileops.py
index 0cad009..d426346 100644
--- a/src/fileops.py
+++ b/src/fileops.py
@@ -4,17 +4,15 @@ from .modules import Tree
 def is_dotfile(file_path):
     return any(part.startswith(".") for part in path.normpath(file_path).split(sep))

-def write_file(file_path: str, file_content: str) -> None: +def write_file(file_path, file_content): with open(file_path, "w") as f: f.write(file_content)

-def read_file(file_path:str) -> str: - """Read and return file contents""" - with open(file_path, "r") as f : +def read_file(file_path): + with open(file_path, "r") as f: return f.read()

-def resolve_tree_paths(project_dir: str, tree: Tree) -> Tree: - """Return a new Tree with all paths joined onto project_dir.""" +def resolve_tree_paths(project_dir, tree): return Tree( markdown=path.join(project_dir, tree.markdown), static=path.join(project_dir, tree.static), @@ -24,11 +22,6 @@ def resolve_tree_paths(project_dir: str, tree: Tree) -> Tree: plugins=path.join(project_dir, tree.plugins), )

-def create_tree_dirs (tree:Tree) -> None: - """ Creates parent dirs before start writing """ - makedirs(tree.markdown , exist_ok=True) - makedirs(tree.static , exist_ok=True) - makedirs(tree.templates, exist_ok=True) - makedirs(tree.draft_dest , exist_ok=True) - makedirs(tree.release_dest , exist_ok=True) - makedirs(tree.plugins , exist_ok=True) +def create_tree_dirs(tree): + for d in [tree.markdown, tree.static, tree.templates, tree.draft_dest, tree.release_dest, tree.plugins]: + makedirs(d, exist_ok=True)

// Created by Pi66

// Copyright ©Pi66 2026