mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 08:41:42 -05:00
Allow legacy package indices to return absolute paths (#719)
This commit is contained in:
parent
420107e7e7
commit
283b30a5c4
2 changed files with 14 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@ artifacts
|
|||
poetry2nix-flamegraph.svg
|
||||
.direnv
|
||||
flake.lock
|
||||
|
||||
.idea/
|
||||
|
|
|
@ -80,14 +80,23 @@ if package_filename not in parser.sources:
|
|||
exit(1)
|
||||
|
||||
package_file = open(package_filename, "wb")
|
||||
# Sometimes the href is a relative path
|
||||
if urlparse(parser.sources[package_filename]).netloc == "":
|
||||
# Sometimes the href is a relative or absolute path within the index's domain.
|
||||
indicated_url = urlparse(parser.sources[package_filename])
|
||||
if indicated_url.netloc == "":
|
||||
parsed_url = urlparse(index_url)
|
||||
|
||||
if indicated_url.path.startswith("/"):
|
||||
# An absolute path within the index's domain.
|
||||
path = parser.sources[package_filename]
|
||||
else:
|
||||
# A relative path.
|
||||
path = parsed_url.path + "/" + parser.sources[package_filename]
|
||||
|
||||
package_url = urlunparse(
|
||||
(
|
||||
parsed_url.scheme,
|
||||
parsed_url.netloc,
|
||||
parsed_url.path + "/" + parser.sources[package_filename],
|
||||
path,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
|
Loading…
Add table
Reference in a new issue