Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
调整 fs_util
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Jul 18, 2023
1 parent d13850e commit 569e92c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions utils/fs_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

def delete_dir(path: str):
if os.path.exists(path):
if not os.path.isdir(path):
raise Exception(f"Path not a directory: '{path}'")
shutil.rmtree(path)


Expand All @@ -16,8 +18,10 @@ def make_dirs(path: str):
os.makedirs(path)


def walk_files(top: str) -> Iterator[tuple[str, str]]:
if os.path.isdir(top):
for parent, _, names in os.walk(top):
def walk_files(path: str) -> Iterator[tuple[str, str]]:
if os.path.exists(path):
if not os.path.isdir(path):
raise Exception(f"Path not a directory: '{path}'")
for parent, _, names in os.walk(path):
for name in names:
yield parent, name

0 comments on commit 569e92c

Please sign in to comment.