From 6e51cbc6da31c356b5f434894a211327e0858916 Mon Sep 17 00:00:00 2001 From: sepro Date: Sun, 3 Nov 2024 10:22:43 +0100 Subject: [PATCH] Move entries from deprecated to legacy --- yt_dlp/compat/_deprecated.py | 14 +------------- yt_dlp/compat/_legacy.py | 7 +++++++ yt_dlp/utils/_deprecated.py | 28 ---------------------------- yt_dlp/utils/_legacy.py | 27 +++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 41 deletions(-) diff --git a/yt_dlp/compat/_deprecated.py b/yt_dlp/compat/_deprecated.py index db59f14388..1b764aaa79 100644 --- a/yt_dlp/compat/_deprecated.py +++ b/yt_dlp/compat/_deprecated.py @@ -8,22 +8,10 @@ passthrough_module(__name__, '.._legacy', callback=lambda attr: warnings.warn( DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=6)) del passthrough_module -import base64 import os -import urllib.error -import urllib.parse -compat_str = str -compat_b64decode = base64.b64decode - -compat_urlparse = urllib.parse -compat_parse_qs = urllib.parse.parse_qs -compat_urllib_parse_unquote = urllib.parse.unquote -compat_urllib_parse_urlencode = urllib.parse.urlencode -compat_urllib_parse_urlparse = urllib.parse.urlparse - -compat_os_name = os._name if os.name == 'java' else os.name +compat_os_name = os.name compat_realpath = os.path.realpath diff --git a/yt_dlp/compat/_legacy.py b/yt_dlp/compat/_legacy.py index 1e483f6e99..dae2c14592 100644 --- a/yt_dlp/compat/_legacy.py +++ b/yt_dlp/compat/_legacy.py @@ -104,5 +104,12 @@ compat_xml_parse_error = compat_xml_etree_ElementTree_ParseError = etree.ParseEr compat_xpath = lambda xpath: xpath compat_zip = zip workaround_optparse_bug9161 = lambda: None +compat_str = str +compat_b64decode = base64.b64decode +compat_urlparse = urllib.parse +compat_parse_qs = urllib.parse.parse_qs +compat_urllib_parse_unquote = urllib.parse.unquote +compat_urllib_parse_urlencode = urllib.parse.urlencode +compat_urllib_parse_urlparse = urllib.parse.urlparse legacy = [] diff --git a/yt_dlp/utils/_deprecated.py b/yt_dlp/utils/_deprecated.py index 15cc82d542..85649a534f 100644 --- a/yt_dlp/utils/_deprecated.py +++ b/yt_dlp/utils/_deprecated.py @@ -10,34 +10,6 @@ del passthrough_module import struct -from ._utils import preferredencoding - - -def encodeFilename(s, for_subprocess=False): - assert isinstance(s, str) - return s - - -def decodeFilename(b, for_subprocess=False): - return b - - -def decodeArgument(b): - return b - - -def decodeOption(optval): - if optval is None: - return optval - if isinstance(optval, bytes): - optval = optval.decode(preferredencoding()) - - assert isinstance(optval, str) - return optval - - -def error_to_compat_str(err): - return str(err) def bytes_to_intlist(bs): diff --git a/yt_dlp/utils/_legacy.py b/yt_dlp/utils/_legacy.py index 356e580226..d65b135d9d 100644 --- a/yt_dlp/utils/_legacy.py +++ b/yt_dlp/utils/_legacy.py @@ -313,3 +313,30 @@ def make_HTTPS_handler(params, **kwargs): def process_communicate_or_kill(p, *args, **kwargs): return Popen.communicate_or_kill(p, *args, **kwargs) + + +def encodeFilename(s, for_subprocess=False): + assert isinstance(s, str) + return s + + +def decodeFilename(b, for_subprocess=False): + return b + + +def decodeArgument(b): + return b + + +def decodeOption(optval): + if optval is None: + return optval + if isinstance(optval, bytes): + optval = optval.decode(preferredencoding()) + + assert isinstance(optval, str) + return optval + + +def error_to_compat_str(err): + return str(err)