Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
19006330
Unverified
Commit
19006330
authored
May 31, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error when listing distribution links for private repositories.
parent
2013f668
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
16 deletions
+84
-16
CHANGELOG.md
+1
-0
poetry/repositories/legacy_repository.py
+14
-16
tests/repositories/fixtures/legacy/absolute.html
+12
-0
tests/repositories/fixtures/legacy/relative.html
+12
-0
tests/repositories/test_legacy_repository.py
+45
-0
No files found.
CHANGELOG.md
View file @
19006330
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
-
Fixed Python requirements not properly set when resolving dependencies.
-
Fixed Python requirements not properly set when resolving dependencies.
-
Fixed terminal coloring being activated even if not supported.
-
Fixed terminal coloring being activated even if not supported.
-
Fixed wrong executable being picked up on Windows in
`poetry run`
.
-
Fixed wrong executable being picked up on Windows in
`poetry run`
.
-
Fixed error when listing distribution links for private repositories.
## [0.10.1] - 2018-05-28
## [0.10.1] - 2018-05-28
...
...
poetry/repositories/legacy_repository.py
View file @
19006330
...
@@ -48,6 +48,9 @@ class Page:
...
@@ -48,6 +48,9 @@ class Page:
VERSION_REGEX
=
re
.
compile
(
"(?i)([a-z0-9_
\
-.]+?)-(?=
\
d)([a-z0-9_.!+-]+)"
)
VERSION_REGEX
=
re
.
compile
(
"(?i)([a-z0-9_
\
-.]+?)-(?=
\
d)([a-z0-9_.!+-]+)"
)
def
__init__
(
self
,
url
,
content
,
headers
):
def
__init__
(
self
,
url
,
content
,
headers
):
if
not
url
.
endswith
(
"/"
):
url
+=
"/"
self
.
_url
=
url
self
.
_url
=
url
encoding
=
None
encoding
=
None
if
headers
and
"Content-Type"
in
headers
:
if
headers
and
"Content-Type"
in
headers
:
...
@@ -57,9 +60,13 @@ class Page:
...
@@ -57,9 +60,13 @@ class Page:
encoding
=
params
[
"charset"
]
encoding
=
params
[
"charset"
]
self
.
_content
=
content
self
.
_content
=
content
self
.
_parsed
=
html5lib
.
parse
(
content
,
transport_encoding
=
encoding
,
namespaceHTMLElements
=
False
if
encoding
is
None
:
)
self
.
_parsed
=
html5lib
.
parse
(
content
,
namespaceHTMLElements
=
False
)
else
:
self
.
_parsed
=
html5lib
.
parse
(
content
,
transport_encoding
=
encoding
,
namespaceHTMLElements
=
False
)
@property
@property
def
versions
(
self
):
# type: () -> Generator[Version]
def
versions
(
self
):
# type: () -> Generator[Version]
...
@@ -122,7 +129,7 @@ class Page:
...
@@ -122,7 +129,7 @@ class Page:
class
LegacyRepository
(
PyPiRepository
):
class
LegacyRepository
(
PyPiRepository
):
def
__init__
(
self
,
name
,
url
):
def
__init__
(
self
,
name
,
url
,
disable_cache
=
False
):
if
name
==
"pypi"
:
if
name
==
"pypi"
:
raise
ValueError
(
"The name [pypi] is reserved for repositories"
)
raise
ValueError
(
"The name [pypi] is reserved for repositories"
)
...
@@ -147,6 +154,8 @@ class LegacyRepository(PyPiRepository):
...
@@ -147,6 +154,8 @@ class LegacyRepository(PyPiRepository):
requests
.
session
(),
cache
=
FileCache
(
str
(
self
.
_cache_dir
/
"_http"
))
requests
.
session
(),
cache
=
FileCache
(
str
(
self
.
_cache_dir
/
"_http"
))
)
)
self
.
_disable_cache
=
disable_cache
@property
@property
def
name
(
self
):
def
name
(
self
):
return
self
.
_name
return
self
.
_name
...
@@ -196,7 +205,7 @@ class LegacyRepository(PyPiRepository):
...
@@ -196,7 +205,7 @@ class LegacyRepository(PyPiRepository):
We have to download a package to get the dependencies.
We have to download a package to get the dependencies.
We also need to download every file matching this release
We also need to download every file matching this release
to get the various hashes.
to get the various hashes.
Note that, this will be cached so the subsequent operations
Note that, this will be cached so the subsequent operations
should be much faster.
should be much faster.
"""
"""
...
@@ -252,17 +261,6 @@ class LegacyRepository(PyPiRepository):
...
@@ -252,17 +261,6 @@ class LegacyRepository(PyPiRepository):
return
package
return
package
def
get_release_info
(
self
,
name
,
version
):
# type: (str, str) -> dict
"""
Return the release information given a package name and a version.
The information is returned from the cache if it exists
or retrieved from the remote server.
"""
return
self
.
_cache
.
store
(
"releases"
)
.
remember_forever
(
"{}:{}"
.
format
(
name
,
version
),
lambda
:
self
.
_get_release_info
(
name
,
version
)
)
def
_get_release_info
(
self
,
name
,
version
):
# type: (str, str) -> dict
def
_get_release_info
(
self
,
name
,
version
):
# type: (str, str) -> dict
page
=
self
.
_get
(
"/{}"
.
format
(
canonicalize_name
(
name
)
.
replace
(
"."
,
"-"
)))
page
=
self
.
_get
(
"/{}"
.
format
(
canonicalize_name
(
name
)
.
replace
(
"."
,
"-"
)))
if
page
is
None
:
if
page
is
None
:
...
...
tests/repositories/fixtures/legacy/absolute.html
0 → 100644
View file @
19006330
<!DOCTYPE html>
<html>
<head>
<title>
Links for poetry
</title>
</head>
<body>
<h1>
Links for poetry
</h1>
<a
href=
"https://files.pythonhosted.org/packages/e9/df/0ab4afa9c5d9e6b690c5c27c9f50330b98a7ecfe1185ce2dc1b19188b064/poetry-0.1.0-py3-none-any.whl#sha256=1d85132efab8ead3c6f69202843da40a03823992091c29f8d65a31af68940163"
data-requires-python=
">=3.6.0"
>
poetry-0.1.0-py3-none-any.whl
</a><br/>
<a
href=
"https://files.pythonhosted.org/packages/d5/c5/4efe096ce56505435ccbe8aeefcd5c8c3bb0da211ef8fe58934d087daef2/poetry-0.1.0.tar.gz#sha256=db33179244321b0b86c6c3645225ff2062ed3495ca16d0d64b3a5df804a82273"
data-requires-python=
">=3.6.0"
>
poetry-0.1.0.tar.gz
</a><br/>
</body>
</html>
<!--SERIAL 3907384-->
tests/repositories/fixtures/legacy/relative.html
0 → 100644
View file @
19006330
<!DOCTYPE html>
<html>
<head>
<title>
Links for poetry
</title>
</head>
<body>
<h1>
Links for poetry
</h1>
<a
href=
"poetry-0.1.0-py3-none-any.whl#sha256=1d85132efab8ead3c6f69202843da40a03823992091c29f8d65a31af68940163"
data-requires-python=
">=3.6.0"
>
poetry-0.1.0-py3-none-any.whl
</a><br/>
<a
href=
"poetry-0.1.0.tar.gz#sha256=db33179244321b0b86c6c3645225ff2062ed3495ca16d0d64b3a5df804a82273"
data-requires-python=
">=3.6.0"
>
poetry-0.1.0.tar.gz
</a><br/>
</body>
</html>
<!--SERIAL 3907384-->
tests/repositories/test_legacy_repository.py
0 → 100644
View file @
19006330
import
pytest
from
poetry.repositories.legacy_repository
import
LegacyRepository
from
poetry.repositories.legacy_repository
import
Page
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
decode
class
MockRepository
(
LegacyRepository
):
FIXTURES
=
Path
(
__file__
)
.
parent
/
"fixtures"
/
"legacy"
def
__init__
(
self
):
super
(
MockRepository
,
self
)
.
__init__
(
"legacy"
,
url
=
"http://foo.bar"
,
disable_cache
=
True
)
def
_get
(
self
,
endpoint
):
parts
=
endpoint
.
split
(
"/"
)
name
=
parts
[
1
]
fixture
=
self
.
FIXTURES
/
(
name
+
".html"
)
with
fixture
.
open
()
as
f
:
return
Page
(
self
.
_url
+
endpoint
,
f
.
read
(),
{})
def
test_page_relative_links_path_are_correct
():
repo
=
MockRepository
()
page
=
repo
.
_get
(
"/relative"
)
for
link
in
page
.
links
:
assert
link
.
netloc
==
"foo.bar"
assert
link
.
path
.
startswith
(
"/relative/poetry"
)
def
test_page_absolute_links_path_are_correct
():
repo
=
MockRepository
()
page
=
repo
.
_get
(
"/absolute"
)
for
link
in
page
.
links
:
assert
link
.
netloc
==
"files.pythonhosted.org"
assert
link
.
path
.
startswith
(
"/packages/"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment