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
0f7f8d71
Commit
0f7f8d71
authored
May 17, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ContextualZipFile and contextlib.closing for archiveutil
parent
14f168f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
setuptools/archive_util.py
setuptools/archive_util.py
+4
-8
No files found.
setuptools/archive_util.py
View file @
0f7f8d71
...
...
@@ -11,7 +11,8 @@ import tarfile
import
os
import
shutil
import
posixpath
from
pkg_resources
import
ensure_directory
import
contextlib
from
pkg_resources
import
ensure_directory
,
ContextualZipFile
from
distutils.errors
import
DistutilsError
class
UnrecognizedFormat
(
DistutilsError
):
...
...
@@ -92,8 +93,7 @@ def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
if
not
zipfile
.
is_zipfile
(
filename
):
raise
UnrecognizedFormat
(
"%s is not a zip file"
%
(
filename
,))
z
=
zipfile
.
ZipFile
(
filename
)
try
:
with
ContextualZipFile
(
filename
)
as
z
:
for
info
in
z
.
infolist
():
name
=
info
.
filename
...
...
@@ -121,8 +121,6 @@ def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
unix_attributes
=
info
.
external_attr
>>
16
if
unix_attributes
:
os
.
chmod
(
target
,
unix_attributes
)
finally
:
z
.
close
()
def
unpack_tarfile
(
filename
,
extract_dir
,
progress_filter
=
default_filter
):
...
...
@@ -138,7 +136,7 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
raise
UnrecognizedFormat
(
"%s is not a compressed or uncompressed tar file"
%
(
filename
,)
)
try
:
with
contextlib
.
closing
(
tarobj
)
:
tarobj
.
chown
=
lambda
*
args
:
None
# don't do any chowning!
for
member
in
tarobj
:
name
=
member
.
name
...
...
@@ -164,7 +162,5 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
except
tarfile
.
ExtractError
:
pass
# chown/chmod/mkfifo/mknode/makedev failed
return
True
finally
:
tarobj
.
close
()
extraction_drivers
=
unpack_directory
,
unpack_zipfile
,
unpack_tarfile
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