mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-10-04 22:28:14 -04:00
[update] Ability to set a maximum version for specific variants
This commit is contained in:
@@ -18,6 +18,7 @@ import html.parser
|
||||
import http.client
|
||||
import http.cookiejar
|
||||
import importlib.util
|
||||
import inspect
|
||||
import io
|
||||
import itertools
|
||||
import json
|
||||
@@ -1909,12 +1910,23 @@ class DateRange:
|
||||
|
||||
def platform_name():
|
||||
""" Returns the platform name as a str """
|
||||
res = platform.platform()
|
||||
if isinstance(res, bytes):
|
||||
res = res.decode(preferredencoding())
|
||||
write_string('DeprecationWarning: yt_dlp.utils.platform_name is deprecated, use platform.platform instead')
|
||||
return platform.platform()
|
||||
|
||||
assert isinstance(res, str)
|
||||
return res
|
||||
|
||||
@functools.cache
|
||||
def system_identifier():
|
||||
python_implementation = platform.python_implementation()
|
||||
if python_implementation == 'PyPy' and hasattr(sys, 'pypy_version_info'):
|
||||
python_implementation += ' version %d.%d.%d' % sys.pypy_version_info[:3]
|
||||
|
||||
return 'Python %s (%s %s) - %s %s' % (
|
||||
platform.python_version(),
|
||||
python_implementation,
|
||||
platform.architecture()[0],
|
||||
platform.platform(),
|
||||
format_field(join_nonempty(*platform.libc_ver(), delim=' '), None, '(%s)'),
|
||||
)
|
||||
|
||||
|
||||
@functools.cache
|
||||
@@ -5544,8 +5556,27 @@ def merge_headers(*dicts):
|
||||
return {k.title(): v for k, v in itertools.chain.from_iterable(map(dict.items, dicts))}
|
||||
|
||||
|
||||
def cached_method(f):
|
||||
"""Cache a method"""
|
||||
signature = inspect.signature(f)
|
||||
|
||||
@functools.wraps(f)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
bound_args = signature.bind(self, *args, **kwargs)
|
||||
bound_args.apply_defaults()
|
||||
key = tuple(bound_args.arguments.values())
|
||||
|
||||
if not hasattr(self, '__cached_method__cache'):
|
||||
self.__cached_method__cache = {}
|
||||
cache = self.__cached_method__cache.setdefault(f.__name__, {})
|
||||
if key not in cache:
|
||||
cache[key] = f(self, *args, **kwargs)
|
||||
return cache[key]
|
||||
return wrapper
|
||||
|
||||
|
||||
class classproperty:
|
||||
"""classmethod(property(func)) that works in py < 3.9"""
|
||||
"""property access for class methods"""
|
||||
|
||||
def __init__(self, func):
|
||||
functools.update_wrapper(self, func)
|
||||
|
Reference in New Issue
Block a user