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

Method _sanitize_windows_name

Lib/zipfile/__init__.py:1870–1882  ·  view source on GitHub ↗

Replace bad characters and remove trailing dots from parts.

(cls, arcname, pathsep)

Source from the content-addressed store, hash-verified

1868
1869 @classmethod
1870 def _sanitize_windows_name(cls, arcname, pathsep):
1871 """Replace bad characters and remove trailing dots from parts."""
1872 table = cls._windows_illegal_name_trans_table
1873 if not table:
1874 illegal = ':<>|"?*'
1875 table = str.maketrans(illegal, '_' * len(illegal))
1876 cls._windows_illegal_name_trans_table = table
1877 arcname = arcname.translate(table)
1878 # remove trailing dots and spaces
1879 arcname = (x.rstrip(' .') for x in arcname.split(pathsep))
1880 # rejoin, removing empty parts.
1881 arcname = pathsep.join(x for x in arcname if x)
1882 return arcname
1883
1884 def _extract_member(self, member, targetpath, pwd):
1885 """Extract the ZipInfo object 'member' to a physical

Callers 1

_extract_memberMethod · 0.95

Calls 5

maketransMethod · 0.80
translateMethod · 0.45
rstripMethod · 0.45
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected