Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
f9f94d71
Commit
f9f94d71
authored
May 17, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use context manager
--HG-- extra : amend_source : 5e98bee2918d9eeb073c8c896a849c5f68da6634
parent
032cd636
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
25 deletions
+22
-25
setuptools/package_index.py
setuptools/package_index.py
+22
-25
No files found.
setuptools/package_index.py
View file @
f9f94d71
...
@@ -632,7 +632,7 @@ class PackageIndex(Environment):
...
@@ -632,7 +632,7 @@ class PackageIndex(Environment):
shutil
.
copy2
(
filename
,
dst
)
shutil
.
copy2
(
filename
,
dst
)
filename
=
dst
filename
=
dst
file
=
open
(
os
.
path
.
join
(
tmpdir
,
'setup.py'
),
'w'
)
with
open
(
os
.
path
.
join
(
tmpdir
,
'setup.py'
),
'w'
)
as
file
:
file
.
write
(
file
.
write
(
"from setuptools import setup
\
n
"
"from setuptools import setup
\
n
"
"setup(name=%r, version=%r, py_modules=[%r])
\
n
"
"setup(name=%r, version=%r, py_modules=[%r])
\
n
"
...
@@ -641,7 +641,6 @@ class PackageIndex(Environment):
...
@@ -641,7 +641,6 @@ class PackageIndex(Environment):
os
.
path
.
splitext
(
basename
)[
0
]
os
.
path
.
splitext
(
basename
)[
0
]
)
)
)
)
file
.
close
()
return
filename
return
filename
elif
match
:
elif
match
:
...
@@ -660,7 +659,7 @@ class PackageIndex(Environment):
...
@@ -660,7 +659,7 @@ class PackageIndex(Environment):
def
_download_to
(
self
,
url
,
filename
):
def
_download_to
(
self
,
url
,
filename
):
self
.
info
(
"Downloading %s"
,
url
)
self
.
info
(
"Downloading %s"
,
url
)
# Download the file
# Download the file
fp
,
tfp
,
info
=
None
,
None
,
None
fp
,
info
=
None
,
None
try
:
try
:
checker
=
HashChecker
.
from_url
(
url
)
checker
=
HashChecker
.
from_url
(
url
)
fp
=
self
.
open_url
(
strip_fragment
(
url
))
fp
=
self
.
open_url
(
strip_fragment
(
url
))
...
@@ -677,7 +676,7 @@ class PackageIndex(Environment):
...
@@ -677,7 +676,7 @@ class PackageIndex(Environment):
sizes
=
get_all_headers
(
headers
,
'Content-Length'
)
sizes
=
get_all_headers
(
headers
,
'Content-Length'
)
size
=
max
(
map
(
int
,
sizes
))
size
=
max
(
map
(
int
,
sizes
))
self
.
reporthook
(
url
,
filename
,
blocknum
,
bs
,
size
)
self
.
reporthook
(
url
,
filename
,
blocknum
,
bs
,
size
)
tfp
=
open
(
filename
,
'wb'
)
with
open
(
filename
,
'wb'
)
as
tfp
:
while
True
:
while
True
:
block
=
fp
.
read
(
bs
)
block
=
fp
.
read
(
bs
)
if
block
:
if
block
:
...
@@ -691,7 +690,6 @@ class PackageIndex(Environment):
...
@@ -691,7 +690,6 @@ class PackageIndex(Environment):
return
headers
return
headers
finally
:
finally
:
if
fp
:
fp
.
close
()
if
fp
:
fp
.
close
()
if
tfp
:
tfp
.
close
()
def
reporthook
(
self
,
url
,
filename
,
blocknum
,
blksize
,
size
):
def
reporthook
(
self
,
url
,
filename
,
blocknum
,
blksize
,
size
):
pass
# no-op
pass
# no-op
...
@@ -1040,9 +1038,8 @@ def local_open(url):
...
@@ -1040,9 +1038,8 @@ def local_open(url):
files
=
[]
files
=
[]
for
f
in
os
.
listdir
(
filename
):
for
f
in
os
.
listdir
(
filename
):
if
f
==
'index.html'
:
if
f
==
'index.html'
:
fp
=
open
(
os
.
path
.
join
(
filename
,
f
),
'r'
)
with
open
(
os
.
path
.
join
(
filename
,
f
),
'r'
)
as
fp
:
body
=
fp
.
read
()
body
=
fp
.
read
()
fp
.
close
()
break
break
elif
os
.
path
.
isdir
(
os
.
path
.
join
(
filename
,
f
)):
elif
os
.
path
.
isdir
(
os
.
path
.
join
(
filename
,
f
)):
f
+=
'/'
f
+=
'/'
...
...
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