Home | History | Annotate | Download | only in Lib

Lines Matching refs:ENCODING

73            "ENCODING", "USTAR_FORMAT", "GNU_FORMAT", "PAX_FORMAT",
152 ENCODING = "utf-8"
154 ENCODING = sys.getfilesystemencoding()
160 def stn(s, length, encoding, errors):
163 s = s.encode(encoding, errors)
166 def nts(s, encoding, errors):
172 return s.decode(encoding, errors)
201 # particular encoding, the following digits-1 bytes are a big-endian
268 encoding = getattr(sys.stdout, 'encoding', None)
269 if encoding is not None:
270 s = s.encode(encoding, 'backslashreplace').decode(encoding)
803 def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"):
809 return self.create_ustar_header(info, encoding, errors)
811 return self.create_gnu_header(info, encoding, errors)
813 return self.create_pax_header(info, encoding)
817 def create_ustar_header(self, info, encoding, errors):
822 if len(info["linkname"].encode(encoding, errors)) > LENGTH_LINK:
825 if len(info["name"].encode(encoding, errors)) > LENGTH_NAME:
826 info["prefix"], info["name"] = self._posix_split_name(info["name"], encoding, errors)
828 return self._create_header(info, USTAR_FORMAT, encoding, errors)
830 def create_gnu_header(self, info, encoding, errors):
836 if len(info["linkname"].encode(encoding, errors)) > LENGTH_LINK:
837 buf += self._create_gnu_long_header(info["linkname"], GNUTYPE_LONGLINK, encoding, errors)
839 if len(info["name"].encode(encoding, errors)) > LENGTH_NAME:
840 buf += self._create_gnu_long_header(info["name"], GNUTYPE_LONGNAME, encoding, errors)
842 return buf + self._create_header(info, GNU_FORMAT, encoding, errors)
844 def create_pax_header(self, info, encoding):
853 # be represented in ASCII encoding.
887 buf = self._create_pax_generic_header(pax_headers, XHDTYPE, encoding)
899 def _posix_split_name(self, name, encoding, errors):
907 if len(prefix.encode(encoding, errors)) <= LENGTH_PREFIX and \
908 len(name.encode(encoding, errors)) <= LENGTH_NAME:
916 def _create_header(info, format, encoding, errors):
921 stn(info.get("name", ""), 100, encoding, errors),
929 stn(info.get("linkname", ""), 100, encoding, errors),
931 stn(info.get("uname", ""), 32, encoding, errors),
932 stn(info.get("gname", ""), 32, encoding, errors),
935 stn(info.get("prefix", ""), 155, encoding, errors)
954 def _create_gnu_long_header(cls, name, type, encoding, errors):
958 name = name.encode(encoding, errors) + NUL
967 return cls._create_header(info, USTAR_FORMAT, encoding, errors) + \
971 def _create_pax_generic_header(cls, pax_headers, type, encoding):
995 # Needless to say, that the encoding must match the string.
996 value = value.encode(encoding, "surrogateescape")
1022 def frombuf(cls, buf, encoding, errors):
1037 obj.name = nts(buf[0:100], encoding, errors)
1045 obj.linkname = nts(buf[157:257], encoding, errors)
1046 obj.uname = nts(buf[265:297], encoding, errors)
1047 obj.gname = nts(buf[297:329], encoding, errors)
1050 prefix = nts(buf[345:500], encoding, errors)
1090 obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
1131 self._apply_pax_info(tarfile.pax_headers, tarfile.encoding, tarfile.errors)
1151 next.name = nts(buf, tarfile.encoding, tarfile.errors)
1153 next.linkname = nts(buf, tarfile.encoding, tarfile.errors)
1201 # the encoding of the path, linkpath, uname and gname fields. Normally,
1214 encoding = tarfile.encoding
1216 encoding = "utf-8"
1233 # Normally, we could just use "utf-8" as the encoding and "strict"
1238 # We first try the strict standard encoding, and if that fails we
1239 # fall back on the user's encoding and error handler.
1243 value = self._decode_pax_field(value, encoding, tarfile.encoding,
1273 next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors)
1320 def _apply_pax_info(self, pax_headers, encoding, errors):
1343 def _decode_pax_field(self, value, encoding, fallback_encoding, fallback_errors):
1347 return value.decode(encoding, "strict")
1400 encoding = ENCODING # Encoding for 8-bit character strings.
1409 tarinfo=None, dereference=None, ignore_zeros=None, encoding=None,
1452 if encoding is not None:
1453 self.encoding = encoding
1971 buf = tarinfo.tobuf(self.format, self.encoding, self.errors)