Skip to content

Commit 8c8b21d

Browse files
committed
Allow packages through from which we can't get the metadata
Example: openpyxl/0.0rc0 (or openpyxl-1.1.0-py2.6.egg)
1 parent 851dd42 commit 8c8b21d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

simple_repository_browser/fetch_description.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,20 @@ async def _fetch_metadata_resource(
160160
tmp_file_path: str,
161161
) -> tuple[model.File, pkginfo.Distribution]:
162162
"""Fetch metadata resource and return updated file and package info."""
163-
if file.dist_info_metadata:
164-
resource_name = file.filename + ".metadata"
165-
else:
166-
raise ValueError(f"Metadata not available for {file}")
163+
if not file.dist_info_metadata:
164+
# No metadata available for this file type (e.g., .egg files)
165+
# Return a minimal distribution object with basic info
166+
class MinimalDistribution(pkginfo.Distribution):
167+
def __init__(self, name: str, filename: str):
168+
super().__init__() # Get all the default None values
169+
self.name = name
170+
ext = filename.split(".")[-1] if "." in filename else "unknown"
171+
self.summary = f"Legacy package format ({ext}) - metadata not available"
172+
173+
minimal_dist = MinimalDistribution(project_name, file.filename)
174+
return file, minimal_dist
175+
176+
resource_name = file.filename + ".metadata"
167177

168178
logging.debug(f"Downloading metadata for {file.filename} from {resource_name}")
169179

0 commit comments

Comments
 (0)