mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-04-05 00:22:45 +00:00
56 lines
1.1 KiB
Python
56 lines
1.1 KiB
Python
"""Deprecated - New code should avoid these"""
|
|
import warnings
|
|
|
|
from ..compat.compat_utils import passthrough_module
|
|
|
|
# XXX: Implement this the same way as other DeprecationWarnings without circular import
|
|
passthrough_module(__name__, '.._legacy', callback=lambda attr: warnings.warn(
|
|
DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=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):
|
|
if not bs:
|
|
return []
|
|
if isinstance(bs[0], int): # Python 3
|
|
return list(bs)
|
|
else:
|
|
return [ord(c) for c in bs]
|
|
|
|
|
|
def intlist_to_bytes(xs):
|
|
if not xs:
|
|
return b''
|
|
return struct.pack('%dB' % len(xs), *xs)
|