Files
Shortumation/api/src/utils.py
T
2022-08-15 15:43:18 -04:00

21 lines
383 B
Python

from pathlib import Path
from typing import Iterator
def extract_files(p: Path) -> Iterator[Path]:
"""Extracts all files in folder and it's subfolders
Args:
p (Path):
Yields:
Iterator[Path]
"""
if not p.exists():
return
if p.is_dir():
for c in p.iterdir():
yield from extract_files(c)
else:
yield p