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
ec6e6fb1
Commit
ec6e6fb1
authored
Dec 31, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Normalize indentation and whitespace
parent
f7df5613
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
14 deletions
+22
-14
setuptools/archive_util.py
setuptools/archive_util.py
+22
-14
No files found.
setuptools/archive_util.py
View file @
ec6e6fb1
...
...
@@ -64,20 +64,23 @@ def unpack_directory(filename, extract_dir, progress_filter=default_filter):
Raises ``UnrecognizedFormat`` if `filename` is not a directory
"""
if
not
os
.
path
.
isdir
(
filename
):
raise
UnrecognizedFormat
(
"%s is not a directory"
%
(
filename
,)
)
raise
UnrecognizedFormat
(
"%s is not a directory"
%
filename
)
paths
=
{
filename
:(
''
,
extract_dir
)}
paths
=
{
filename
:
(
''
,
extract_dir
),
}
for
base
,
dirs
,
files
in
os
.
walk
(
filename
):
src
,
dst
=
paths
[
base
]
src
,
dst
=
paths
[
base
]
for
d
in
dirs
:
paths
[
os
.
path
.
join
(
base
,
d
)]
=
src
+
d
+
'/'
,
os
.
path
.
join
(
dst
,
d
)
paths
[
os
.
path
.
join
(
base
,
d
)]
=
src
+
d
+
'/'
,
os
.
path
.
join
(
dst
,
d
)
for
f
in
files
:
target
=
os
.
path
.
join
(
dst
,
f
)
target
=
progress_filter
(
src
+
f
,
target
)
target
=
os
.
path
.
join
(
dst
,
f
)
target
=
progress_filter
(
src
+
f
,
target
)
if
not
target
:
continue
# skip non-files
# skip non-files
continue
ensure_directory
(
target
)
f
=
os
.
path
.
join
(
base
,
f
)
f
=
os
.
path
.
join
(
base
,
f
)
shutil
.
copyfile
(
f
,
target
)
shutil
.
copystat
(
f
,
target
)
...
...
@@ -112,7 +115,7 @@ def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
# file
ensure_directory
(
target
)
data
=
z
.
read
(
info
.
filename
)
f
=
open
(
target
,
'wb'
)
f
=
open
(
target
,
'wb'
)
try
:
f
.
write
(
data
)
finally
:
...
...
@@ -137,18 +140,21 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
"%s is not a compressed or uncompressed tar file"
%
(
filename
,)
)
with
contextlib
.
closing
(
tarobj
):
tarobj
.
chown
=
lambda
*
args
:
None
# don't do any chowning!
# don't do any chowning!
tarobj
.
chown
=
lambda
*
args
:
None
for
member
in
tarobj
:
name
=
member
.
name
# don't extract absolute paths or ones with .. in them
if
not
name
.
startswith
(
'/'
)
and
'..'
not
in
name
.
split
(
'/'
):
prelim_dst
=
os
.
path
.
join
(
extract_dir
,
*
name
.
split
(
'/'
))
# resolve any links and to extract the link targets as normal files
# resolve any links and to extract the link targets as normal
# files
while
member
is
not
None
and
(
member
.
islnk
()
or
member
.
issym
()):
linkpath
=
member
.
linkname
if
member
.
issym
():
linkpath
=
posixpath
.
join
(
posixpath
.
dirname
(
member
.
name
),
linkpath
)
base
=
posixpath
.
dirname
(
member
.
name
)
linkpath
=
posixpath
.
join
(
base
,
linkpath
)
linkpath
=
posixpath
.
normpath
(
linkpath
)
member
=
tarobj
.
_getmember
(
linkpath
)
...
...
@@ -158,9 +164,11 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
if
final_dst
.
endswith
(
os
.
sep
):
final_dst
=
final_dst
[:
-
1
]
try
:
tarobj
.
_extract_member
(
member
,
final_dst
)
# XXX Ugh
# XXX Ugh
tarobj
.
_extract_member
(
member
,
final_dst
)
except
tarfile
.
ExtractError
:
pass
# chown/chmod/mkfifo/mknode/makedev failed
# chown/chmod/mkfifo/mknode/makedev failed
pass
return
True
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