Module renpy_distribute_tools.fixed_zipfile
This module contains a customized version of the ZipFile
object
to properly handle extraction of macOS apps so that permissions aren't
stripped.
Expand source code
"""
This module contains a customized version of the `ZipFile` object
to properly handle extraction of macOS apps so that permissions aren't
stripped.
"""
import os
from zipfile import ZipFile as PyZipFile, ZipInfo
from renpy_distribute_tools.util import deprecated
class ZipFile(PyZipFile):
"""The ZipFile class is a patched version of the ZipFile class in the `zipfile` module that
retains the attribute permissions for files.
"""
def extract(self, member, path=None, pwd=None):
if not isinstance(member, ZipInfo):
member = self.getinfo(member)
if path is None:
path = os.getcwd()
ret_val = self._extract_member(member, path, pwd)
attr = member.external_attr >> 16
if attr != 0:
os.chmod(ret_val, attr)
return ret_val
def extractall(self, path=None, members=None, pwd=None):
if members is None:
members = self.namelist()
if path is None:
path = os.getcwd()
else:
path = os.fspath(path)
for zipinfo in members:
self.extract(zipinfo, path, pwd)
@deprecated("MyZipFile has been renamed to ZipFile.")
class MyZipFile(ZipFile):
"""The MyZipFile class is a patched version of the ZipFile class in the `zipfile` module that
retains the attribute permissions for files.
"""
Classes
class MyZipFile (file, mode='r', compression=0, allowZip64=True, compresslevel=None, *, strict_timestamps=True)
-
The MyZipFile class is a patched version of the ZipFile class in the
zipfile
module that retains the attribute permissions for files.Open the ZIP file with mode read 'r', write 'w', exclusive create 'x', or append 'a'.
Expand source code
class MyZipFile(ZipFile): """The MyZipFile class is a patched version of the ZipFile class in the `zipfile` module that retains the attribute permissions for files. """
Ancestors
- ZipFile
- zipfile.ZipFile
Inherited members
class ZipFile (file, mode='r', compression=0, allowZip64=True, compresslevel=None, *, strict_timestamps=True)
-
The ZipFile class is a patched version of the ZipFile class in the
zipfile
module that retains the attribute permissions for files.Open the ZIP file with mode read 'r', write 'w', exclusive create 'x', or append 'a'.
Expand source code
class ZipFile(PyZipFile): """The ZipFile class is a patched version of the ZipFile class in the `zipfile` module that retains the attribute permissions for files. """ def extract(self, member, path=None, pwd=None): if not isinstance(member, ZipInfo): member = self.getinfo(member) if path is None: path = os.getcwd() ret_val = self._extract_member(member, path, pwd) attr = member.external_attr >> 16 if attr != 0: os.chmod(ret_val, attr) return ret_val def extractall(self, path=None, members=None, pwd=None): if members is None: members = self.namelist() if path is None: path = os.getcwd() else: path = os.fspath(path) for zipinfo in members: self.extract(zipinfo, path, pwd)
Ancestors
- zipfile.ZipFile
Subclasses
Methods
def extract(self, member, path=None, pwd=None)
-
Extract a member from the archive to the current working directory, using its full name. Its file information is extracted as accurately as possible.
member' may be a filename or a ZipInfo object. You can specify a different directory using
path'.Expand source code
def extract(self, member, path=None, pwd=None): if not isinstance(member, ZipInfo): member = self.getinfo(member) if path is None: path = os.getcwd() ret_val = self._extract_member(member, path, pwd) attr = member.external_attr >> 16 if attr != 0: os.chmod(ret_val, attr) return ret_val
def extractall(self, path=None, members=None, pwd=None)
-
Extract all members from the archive to the current working directory.
path' specifies a different directory to extract to.
members' is optional and must be a subset of the list returned by namelist().Expand source code
def extractall(self, path=None, members=None, pwd=None): if members is None: members = self.namelist() if path is None: path = os.getcwd() else: path = os.fspath(path) for zipinfo in members: self.extract(zipinfo, path, pwd)