in xar/xar_util.py [0:0]
def extract(self, zf, dst=None):
"""Extracts the zipfile into dst under the staging directory."""
dst = self._resolve_dst_dir(dst)
abs_dst = os.path.join(self._staging, dst)
timestamps = {}
for zi in zf.infolist():
filename = os.path.join(dst, zi.filename)
destination = self.absolute(filename)
mode = zi.external_attr >> 16
if stat.S_ISLNK(mode):
target = zf.read(zi).decode("utf-8")
self.symlink(target, filename)
else:
self._ensure_parent(filename)
zf.extract(zi, path=abs_dst)
os.chmod(destination, stat.S_IMODE(mode))
# Use the embedded timestamp for from the pyc file for the
# pyc and py file; otherwise, use the timezone-less
# timestamp from the zipfile (sigh).
if filename.endswith(".pyc"):
new_time = extract_pyc_timestamp(destination)
timestamps[destination] = new_time # pyc file
timestamps[destination[:-1]] = new_time # py file too
else:
new_time = tuple((list(zi.date_time) + [0, 0, -1]))
timestamps[destination] = time.mktime(new_time)
# Set our timestamps.
for path, timestamp in timestamps.items():
try:
os.utime(path, (timestamp, timestamp))
except OSError as e:
# Sometimes we had a pyc file but no py file; the utime
# would fail.
if not path.endswith(".py"):
raise e