1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-03-10 06:30:08 +01:00

[utils] Add repr to match_filter_func

This commit is contained in:
pukkandan 2024-02-25 05:01:47 +05:30
parent 2369a2f8f6
commit 1ebca02e79
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39

View File

@ -3242,6 +3242,8 @@ def match_str(filter_str, dct, incomplete=False):
def match_filter_func(filters, breaking_filters=None):
if not filters and not breaking_filters:
return None
repr_ = f'{match_filter_func.__module__}.{match_filter_func.__qualname__}({filters}, {breaking_filters})'
breaking_filters = match_filter_func(breaking_filters) or (lambda _, __: None)
filters = set(variadic(filters or []))
@ -3249,6 +3251,7 @@ def match_filter_func(filters, breaking_filters=None):
if interactive:
filters.remove('-')
@function_with_repr.set_repr(repr_)
def _match_func(info_dict, incomplete=False):
ret = breaking_filters(info_dict, incomplete)
if ret is not None:
@ -4980,6 +4983,10 @@ class function_with_repr:
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)
@classmethod
def set_repr(cls, repr_):
return functools.partial(cls, repr_=repr_)
def __repr__(self):
if self.__repr:
return self.__repr