Skip to content

Commit

Permalink
chore: misc cleaning up tools.fs
Browse files Browse the repository at this point in the history
- Add missing entries to `__all__`
- Add missing `copytree` doc
- Remove incorrect `dir_exists` doc
  • Loading branch information
dangotbanned committed Jan 9, 2025
1 parent 2b962ea commit 0ed58e5
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tools/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@
from collections.abc import Callable


__all__ = ["REPO_ROOT", "mkdir", "rm"]
__all__ = [
"REPO_ROOT",
"copytree",
"dir_exists",
"file_exists",
"mkdir",
"modified_time",
"path_repr",
"rm",
"run_check",
"run_stream_stdout",
]

REPO_ROOT: Path = Path(__file__).parent.parent

Expand Down Expand Up @@ -44,6 +55,14 @@ def rm(*sources: str | Path, force: bool = True) -> None:


def copytree(src: str | Path, dst: str | Path, *, force: bool = True):
"""
Recursively copy a directory tree and return the destination directory.
Wraps `shutil.copytree`_.
.. _shutil.copytree:
https://docs.python.org/3/library/shutil.html#shutil.copytree
"""
return shutil.copytree(src, dst, dirs_exist_ok=force)


Expand All @@ -54,7 +73,6 @@ def file_exists(file: str | Path, /) -> bool:


def dir_exists(file: str | Path, /) -> bool:
"""Fail on files created using ``Path.touch()``."""
fp = Path(file)
return fp.exists() and fp.is_dir()

Expand Down

0 comments on commit 0ed58e5

Please sign in to comment.