Replace bad characters and remove trailing dots from parts.
(cls, arcname, pathsep)
| 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 |