Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PNG file icon. Find libraries one level deeper from wildcard #26

Merged
merged 5 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions create_requirement_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def asset_path(asset_name):
"txt": file_empty_icon,
"toml": file_icon,
"bmp": file_image_icon,
"png": file_image_icon,
"wav": file_music_icon,
"mp3": file_music_icon,
"mid": file_music_icon,
Expand Down
18 changes: 17 additions & 1 deletion get_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def get_files_for_project(project_name):


def get_libs_for_project(project_name):
# pylint: disable=too-many-nested-blocks
"""Get the set of libraries for a learn project"""
found_libs = set()
found_imports = []
Expand All @@ -173,12 +174,27 @@ def get_libs_for_project(project_name):
if file.endswith(".py"):

found_imports = findimports.find_imports(f"{project_dir}{file}")

for cur_import in found_imports:
cur_lib = cur_import.name.split(".")[0]
if cur_lib in bundle_data or cur_lib in community_bundle_data:
found_libs.add(cur_lib)

# findimports returns import name in the form of "foo.bar.*"
if cur_import.name.endswith(".*"):
filepath = os.path.join(
project_dir,
os.path.join(*cur_import.name[:-2].split(".")) + ".py",
)
if os.path.exists(filepath):
second_level_imports = findimports.find_imports(filepath)
for cur_second_level_import in second_level_imports:
cur_lib = cur_second_level_import.name.split(".")[0]
if (
cur_lib in bundle_data
or cur_lib in community_bundle_data
):
found_libs.add(cur_lib)

return found_libs


Expand Down