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
c671c5da
Commit
c671c5da
authored
May 17, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace get_zip_class with a specialized constructor.
parent
f78c3bea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
ez_setup.py
ez_setup.py
+17
-9
No files found.
ez_setup.py
View file @
c671c5da
...
...
@@ -69,17 +69,25 @@ def _build_egg(egg, archive_filename, to_dir):
raise
IOError
(
'Could not build the egg.'
)
def
get_zip_class
(
):
class
ContextualZipFile
(
zipfile
.
ZipFile
):
"""
Supplement ZipFile class to support context manager for Python 2.6
"""
class
ContextualZipFile
(
zipfile
.
ZipFile
):
def
__enter__
(
self
):
return
self
def
__exit__
(
self
,
type
,
value
,
traceback
):
self
.
close
()
zf_has_exit
=
hasattr
(
zipfile
.
ZipFile
,
'__exit__'
)
return
zipfile
.
ZipFile
if
zf_has_exit
else
ContextualZipFile
def
__enter__
(
self
):
return
self
def
__exit__
(
self
,
type
,
value
,
traceback
):
self
.
close
()
@
classmethod
def
compat
(
cls
,
*
args
,
**
kwargs
):
"""
Construct a ZipFile or ContextualZipFile as appropriate
"""
zf_has_exit
=
hasattr
(
zipfile
.
ZipFile
,
'__exit__'
)
class_
=
zipfile
.
ZipFile
if
zf_has_exit
else
cls
return
class_
(
*
args
,
**
kwargs
)
@
contextlib
.
contextmanager
...
...
@@ -90,7 +98,7 @@ def archive_context(filename):
old_wd
=
os
.
getcwd
()
try
:
os
.
chdir
(
tmpdir
)
with
get_zip_class
()
(
filename
)
as
archive
:
with
ContextualZipFile
.
compat
(
filename
)
as
archive
:
archive
.
extractall
()
# going in the directory
...
...
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