Lines Matching defs:errors

160 def stn(s, length, encoding, errors):
165 s = s.encode(encoding, errors)
168 def nts(s, encoding, errors):
174 return s.decode(encoding, errors)
275 """General exception for extract errors."""
287 """Base exception for header errors."""
976 def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"):
985 return self.create_ustar_header(info, encoding, errors)
987 return self.create_gnu_header(info, encoding, errors)
993 def create_ustar_header(self, info, encoding, errors):
998 if len(info["linkname"].encode(encoding, errors)) > LENGTH_LINK:
1001 if len(info["name"].encode(encoding, errors)) > LENGTH_NAME:
1002 info["prefix"], info["name"] = self._posix_split_name(info["name"], encoding, errors)
1004 return self._create_header(info, USTAR_FORMAT, encoding, errors)
1006 def create_gnu_header(self, info, encoding, errors):
1012 if len(info["linkname"].encode(encoding, errors)) > LENGTH_LINK:
1013 buf += self._create_gnu_long_header(info["linkname"], GNUTYPE_LONGLINK, encoding, errors)
1015 if len(info["name"].encode(encoding, errors)) > LENGTH_NAME:
1016 buf += self._create_gnu_long_header(info["name"], GNUTYPE_LONGNAME, encoding, errors)
1018 return buf + self._create_header(info, GNU_FORMAT, encoding, errors)
1084 def _posix_split_name(self, name, encoding, errors):
1092 if len(prefix.encode(encoding, errors)) <= LENGTH_PREFIX and \
1093 len(name.encode(encoding, errors)) <= LENGTH_NAME:
1101 def _create_header(info, format, encoding, errors):
1110 devmajor = stn("", 8, encoding, errors)
1111 devminor = stn("", 8, encoding, errors)
1120 stn(info.get("name", ""), 100, encoding, errors),
1128 stn(info.get("linkname", ""), 100, encoding, errors),
1130 stn(info.get("uname", ""), 32, encoding, errors),
1131 stn(info.get("gname", ""), 32, encoding, errors),
1134 stn(info.get("prefix", ""), 155, encoding, errors)
1153 def _create_gnu_long_header(cls, name, type, encoding, errors):
1157 name = name.encode(encoding, errors) + NUL
1166 return cls._create_header(info, USTAR_FORMAT, encoding, errors) + \
1221 def frombuf(cls, buf, encoding, errors):
1236 obj.name = nts(buf[0:100], encoding, errors)
1244 obj.linkname = nts(buf[157:257], encoding, errors)
1245 obj.uname = nts(buf[265:297], encoding, errors)
1246 obj.gname = nts(buf[297:329], encoding, errors)
1249 prefix = nts(buf[345:500], encoding, errors)
1289 obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
1330 self._apply_pax_info(tarfile.pax_headers, tarfile.encoding, tarfile.errors)
1355 next.name = nts(buf, tarfile.encoding, tarfile.errors)
1357 next.linkname = nts(buf, tarfile.encoding, tarfile.errors)
1470 tarfile.errors)
1473 tarfile.errors)
1476 tarfile.errors)
1501 next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors)
1557 def _apply_pax_info(self, pax_headers, encoding, errors):
1649 errorlevel = 1 # If 0, fatal errors only appear in debug
1650 # messages (if debug >= 0). If > 0, errors
1657 errors = None # Error handler for unicode conversion.
1667 errors="surrogateescape", pax_headers=None, debug=None,
1711 self.errors = errors
2224 buf = tarinfo.tobuf(self.format, self.encoding, self.errors)