MCPcopy Index your code
hub / github.com/python/cpython / _posix_split_name

Method _posix_split_name

Lib/tarfile.py:1140–1154  ·  view source on GitHub ↗

Split a name longer than 100 chars into a prefix and a name part.

(self, name, encoding, errors)

Source from the content-addressed store, hash-verified

1138 return cls._create_pax_generic_header(pax_headers, XGLTYPE, "utf-8")
1139
1140 def _posix_split_name(self, name, encoding, errors):
1141 """Split a name longer than 100 chars into a prefix
1142 and a name part.
1143 """
1144 components = name.split("/")
1145 for i in range(1, len(components)):
1146 prefix = "/".join(components[:i])
1147 name = "/".join(components[i:])
1148 if len(prefix.encode(encoding, errors)) <= LENGTH_PREFIX and \
1149 len(name.encode(encoding, errors)) <= LENGTH_NAME:
1150 break
1151 else:
1152 raise ValueError("name is too long")
1153
1154 return prefix, name
1155
1156 @staticmethod
1157 def _create_header(info, format, encoding, errors):

Callers 1

create_ustar_headerMethod · 0.95

Calls 3

splitMethod · 0.45
joinMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected