mirror of
https://github.com/Kludex/awesome-fastapi-projects.git
synced 2025-01-18 15:27:03 +00:00
14 lines
454 B
Python
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:
|
|
...
|