diff --git a/shadowmire.py b/shadowmire.py
index 1952f1c..6973fd2 100644
--- a/shadowmire.py
+++ b/shadowmire.py
@@ -163,6 +163,17 @@ def get_packages_from_index_html(contents: str) -> list[str]:
return ret
+def get_existing_hrefs(package_simple_path: Path) -> list[str]:
+ existing_hrefs = []
+ try:
+ with open(package_simple_path / "index.html") as f:
+ contents = f.read()
+ existing_hrefs = get_packages_from_index_html(contents)
+ except FileNotFoundError:
+ pass
+ return existing_hrefs
+
+
class CustomXMLRPCTransport(xmlrpc.client.Transport):
"""
Set user-agent for xmlrpc.client
@@ -208,7 +219,7 @@ class PyPI:
release_files.sort(key=lambda x: x["filename"])
return release_files
- def _file_url_to_local_url(self, url: str) -> str:
+ def file_url_to_local_url(self, url: str) -> str:
parsed = urlparse(url)
assert parsed.path.startswith("/packages")
prefix = "../.."
@@ -253,7 +264,7 @@ class PyPI:
simple_page_content += "\n".join(
[
' {}
'.format(
- self._file_url_to_local_url(r["url"]),
+ self.file_url_to_local_url(r["url"]),
self.digest_name,
r["digests"][self.digest_name],
gen_html_file_tags(r),
@@ -295,7 +306,7 @@ class PyPI:
"requires-python": r.get("requires_python", ""),
"size": r["size"],
"upload-time": r.get("upload_time_iso_8601", ""),
- "url": self._file_url_to_local_url(r["url"]),
+ "url": self.file_url_to_local_url(r["url"]),
"yanked": r.get("yanked", False),
}
)
@@ -438,6 +449,16 @@ class SyncBase:
f.write("