awesome-fastapi-projects/fastapi_projects/files.py
Marcelo Trylesinski 445ca2647a add
2021-05-09 03:05:11 +02:00

14 lines
454 B
Python

import os
from tempfile import TemporaryDirectory
from typing import Generator, TextIO
def get_python_files(dir: TemporaryDirectory) -> Generator[TextIO, None, None]:
for dirpath, _, filenames in os.walk(dir.name):
for filename in filenames:
if filename.endswith(".py"):
try:
yield open(os.sep.join([dirpath, filename]), "r")
except FileNotFoundError:
...