Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
cc243cc8
Commit
cc243cc8
authored
May 21, 2011
by
Tarek Ziade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure the crawler can browse file-based indexes under win32
parent
76ad4f0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
Lib/packaging/pypi/simple.py
Lib/packaging/pypi/simple.py
+14
-4
Lib/packaging/tests/test_pypi_simple.py
Lib/packaging/tests/test_pypi_simple.py
+11
-3
No files found.
Lib/packaging/pypi/simple.py
View file @
cc243cc8
...
...
@@ -123,8 +123,14 @@ class Crawler(BaseClient):
self.follow_externals = follow_externals
# mirroring attributes.
if not index_url.endswith("
/
"):
index_url += "
/
"
parsed = urllib.parse.urlparse(index_url)
self.scheme = parsed[0]
if self.scheme == 'file':
ender = os.path.sep
else:
ender = '/'
if not index_url.endswith(ender):
index_url += ender
# if no mirrors are defined, use the method described in PEP 381.
if mirrors is None:
mirrors = get_mirrors(mirrors_url)
...
...
@@ -376,7 +382,11 @@ class Crawler(BaseClient):
:param name: the name of the project to find the page
"""
# Browse and index the content of the given PyPI page.
url = self.index_url + name + "
/
"
if self.scheme == 'file':
ender = os.path.sep
else:
ender = '/'
url = self.index_url + name + ender
self._process_url(url, name)
@socket_timeout()
...
...
@@ -395,7 +405,7 @@ class Crawler(BaseClient):
# add index.html automatically for filesystem paths
if scheme == 'file':
if url.endswith(
'/'
):
if url.endswith(
os.path.sep
):
url += "
index
.
html
"
# add authorization headers if auth is provided
...
...
Lib/packaging/tests/test_pypi_simple.py
View file @
cc243cc8
"""Tests for the packaging.pypi.simple module."""
import
re
import
os
import
sys
import
http.client
...
...
@@ -277,8 +277,16 @@ class SimpleCrawlerTestCase(TempdirManager,
def
test_browse_local_files
(
self
):
# Test that we can browse local files"""
index_path
=
os
.
sep
.
join
([
"file://"
+
PYPI_DEFAULT_STATIC_PATH
,
"test_found_links"
,
"simple"
])
index_url
=
"file://"
+
PYPI_DEFAULT_STATIC_PATH
if
sys
.
platform
==
'win32'
:
# under windows the correct syntax is:
# file:///C|\the\path\here
# instead of
# file://C:\the\path\here
fix
=
re
.
compile
(
r'^(file://)([A-Za-z])(:)'
)
index_url
=
fix
.
sub
(
'
\
\
1/
\
\
2|'
,
index_url
)
index_path
=
os
.
sep
.
join
([
index_url
,
"test_found_links"
,
"simple"
])
crawler
=
Crawler
(
index_path
)
dists
=
crawler
.
get_releases
(
"foobar"
)
self
.
assertEqual
(
4
,
len
(
dists
))
...
...
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