forked from minhngoc25a/youtube-dl
[utils] Fix splitunc deprecation warning
This commit is contained in:
parent
65c1a750f5
commit
be531ef1ec
|
@ -312,17 +312,17 @@ def sanitize_path(s):
|
||||||
"""Sanitizes and normalizes path on Windows"""
|
"""Sanitizes and normalizes path on Windows"""
|
||||||
if sys.platform != 'win32':
|
if sys.platform != 'win32':
|
||||||
return s
|
return s
|
||||||
drive, _ = os.path.splitdrive(s)
|
drive_or_unc, _ = os.path.splitdrive(s)
|
||||||
unc, _ = os.path.splitunc(s)
|
if sys.version_info < (2, 7) and not drive_or_unc:
|
||||||
unc_or_drive = unc or drive
|
drive_or_unc, _ = os.path.splitunc(s)
|
||||||
norm_path = os.path.normpath(remove_start(s, unc_or_drive)).split(os.path.sep)
|
norm_path = os.path.normpath(remove_start(s, drive_or_unc)).split(os.path.sep)
|
||||||
if unc_or_drive:
|
if drive_or_unc:
|
||||||
norm_path.pop(0)
|
norm_path.pop(0)
|
||||||
sanitized_path = [
|
sanitized_path = [
|
||||||
path_part if path_part in ['.', '..'] else re.sub('(?:[/<>:"\\|\\\\?\\*]|\.$)', '#', path_part)
|
path_part if path_part in ['.', '..'] else re.sub('(?:[/<>:"\\|\\\\?\\*]|\.$)', '#', path_part)
|
||||||
for path_part in norm_path]
|
for path_part in norm_path]
|
||||||
if unc_or_drive:
|
if drive_or_unc:
|
||||||
sanitized_path.insert(0, unc_or_drive + os.path.sep)
|
sanitized_path.insert(0, drive_or_unc + os.path.sep)
|
||||||
return os.path.join(*sanitized_path)
|
return os.path.join(*sanitized_path)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue