awesome-fastapi-projects/fastapi_projects/packages.py

12 lines
315 B
Python
Raw Normal View History

from typing import TextIO
def get_packages(file: TextIO):
2021-05-09 01:05:11 +00:00
try:
for line in file.readlines():
clean_line = line.strip()
if clean_line.startswith(("from ", "import ")):
yield clean_line.replace(".", " ").split()[1]
except UnicodeDecodeError:
yield ""