def init_from_tarinfo(self, tarinfo): u"""Set data from tarinfo object (part of tarfile module)""" # Set the typepp type = tarinfo.type # pylint: disable=redefined-builtin if type == tarfile.REGTYPE or type == tarfile.AREGTYPE: self.type = u"reg" elif type == tarfile.LNKTYPE: raise PathException(u"Hard links not supported yet") elif type == tarfile.SYMTYPE: self.type = u"sym" self.symtext = tarinfo.linkname if isinstance(self.symtext, u"".__class__): self.symtext = util.fsencode(self.symtext) elif type == tarfile.CHRTYPE: self.type = u"chr" self.devnums = (tarinfo.devmajor, tarinfo.devminor) elif type == tarfile.BLKTYPE: self.type = u"blk" self.devnums = (tarinfo.devmajor, tarinfo.devminor) elif type == tarfile.DIRTYPE: self.type = u"dir" elif type == tarfile.FIFOTYPE: self.type = u"fifo" else: raise PathException(u"Unknown tarinfo type %s" % (type,)) self.mode = tarinfo.mode self.stat = StatResult() u""" If do_not_restore_owner is False, set user and group id use numeric id if name lookup fails OR --numeric-owner is set """ try: if config.numeric_owner: raise KeyError self.stat.st_uid = cached_ops.getpwnam(tarinfo.uname)[2] except KeyError: self.stat.st_uid = tarinfo.uid try: if config.numeric_owner: raise KeyError self.stat.st_gid = cached_ops.getgrnam(tarinfo.gname)[2] except KeyError: self.stat.st_gid = tarinfo.gid self.stat.st_mtime = int(tarinfo.mtime) if self.stat.st_mtime < 0: log.Warn(_(u"Warning: %s has negative mtime, treating as 0.") % (tarinfo.uc_name)) self.stat.st_mtime = 0 self.stat.st_size = tarinfo.size
def init_from_tarinfo(self, tarinfo): """Set data from tarinfo object (part of tarfile module)""" # Set the typepp type = tarinfo.type if type == tarfile.REGTYPE or type == tarfile.AREGTYPE: self.type = "reg" elif type == tarfile.LNKTYPE: raise PathException("Hard links not supported yet") elif type == tarfile.SYMTYPE: self.type = "sym" self.symtext = tarinfo.linkname elif type == tarfile.CHRTYPE: self.type = "chr" self.devnums = (tarinfo.devmajor, tarinfo.devminor) elif type == tarfile.BLKTYPE: self.type = "blk" self.devnums = (tarinfo.devmajor, tarinfo.devminor) elif type == tarfile.DIRTYPE: self.type = "dir" elif type == tarfile.FIFOTYPE: self.type = "fifo" else: raise PathException("Unknown tarinfo type %s" % (type, )) self.mode = tarinfo.mode self.stat = StatResult() """ Set user and group id use numeric id if name lookup fails OR --numeric-owner is set """ try: if globals.numeric_owner: raise KeyError self.stat.st_uid = cached_ops.getpwnam(tarinfo.uname)[2] except KeyError: self.stat.st_uid = tarinfo.uid try: if globals.numeric_owner: raise KeyError self.stat.st_gid = cached_ops.getgrnam(tarinfo.gname)[2] except KeyError: self.stat.st_gid = tarinfo.gid self.stat.st_mtime = int(tarinfo.mtime) if self.stat.st_mtime < 0: log.Warn( _("Warning: %s has negative mtime, treating as 0.") % (util.ufn(tarinfo.name))) self.stat.st_mtime = 0 self.stat.st_size = tarinfo.size
def init_from_tarinfo(self, tarinfo): """Set data from tarinfo object (part of tarfile module)""" # Set the typepp type = tarinfo.type if type == tarfile.REGTYPE or type == tarfile.AREGTYPE: self.type = "reg" elif type == tarfile.LNKTYPE: raise PathException("Hard links not supported yet") elif type == tarfile.SYMTYPE: self.type = "sym" self.symtext = tarinfo.linkname elif type == tarfile.CHRTYPE: self.type = "chr" self.devnums = (tarinfo.devmajor, tarinfo.devminor) elif type == tarfile.BLKTYPE: self.type = "blk" self.devnums = (tarinfo.devmajor, tarinfo.devminor) elif type == tarfile.DIRTYPE: self.type = "dir" elif type == tarfile.FIFOTYPE: self.type = "fifo" else: raise PathException("Unknown tarinfo type %s" % (type,)) self.mode = tarinfo.mode self.stat = StatResult() """ Set user and group id use numeric id if name lookup fails OR --numeric-owner is set """ try: if globals.numeric_owner: raise KeyError self.stat.st_uid = cached_ops.getpwnam(tarinfo.uname)[2] except KeyError: self.stat.st_uid = tarinfo.uid try: if globals.numeric_owner: raise KeyError self.stat.st_gid = cached_ops.getgrnam(tarinfo.gname)[2] except KeyError: self.stat.st_gid = tarinfo.gid self.stat.st_mtime = int(tarinfo.mtime) if self.stat.st_mtime < 0: log.Warn(_("Warning: %s has negative mtime, treating as 0.") % (util.ufn(tarinfo.name))) self.stat.st_mtime = 0 self.stat.st_size = tarinfo.size