From 7896214c42db91bbf62853b5c7359c9e83064cf1 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Tue, 17 May 2022 22:08:12 +0530 Subject: [PATCH] Bugfix for 591bb9d3553a4d7b453777c1e28e0948741e3b50 Closes #3769 --- yt_dlp/YoutubeDL.py | 4 ++-- yt_dlp/downloader/common.py | 2 +- yt_dlp/utils.py | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index d1094a01b..31624f181 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -555,7 +555,7 @@ class YoutubeDL: ) self._allow_colors = Namespace(**{ type_: not self.params.get('no_color') and supports_terminal_sequences(stream) - for type_, stream in self._out_files.items_ if type_ != 'console' + for type_, stream in self._out_files if type_ != 'console' }) if sys.version_info < (3, 6): @@ -3611,7 +3611,7 @@ class YoutubeDL: sys.getfilesystemencoding(), self.get_encoding(), ', '.join( - f'{key} {get_encoding(stream)}' for key, stream in self._out_files.items_ + f'{key} {get_encoding(stream)}' for key, stream in self._out_files if stream is not None and key != 'console') ) diff --git a/yt_dlp/downloader/common.py b/yt_dlp/downloader/common.py index fad4e6664..465b5ef99 100644 --- a/yt_dlp/downloader/common.py +++ b/yt_dlp/downloader/common.py @@ -301,7 +301,7 @@ class FileDownloader: ) def _report_progress_status(self, s, default_template): - for name, style in self.ProgressStyles.items_: + for name, style in self.ProgressStyles: name = f'_{name}_str' if name not in s: continue diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 1249c0100..48a94415d 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -5324,9 +5324,6 @@ class classproperty: class Namespace: """Immutable namespace""" - @property - def items_(self): - return self._dict.items() def __init__(self, **kwargs): self._dict = kwargs @@ -5334,8 +5331,14 @@ class Namespace: def __getattr__(self, attr): return self._dict[attr] + def __contains__(self, item): + return item in self._dict.values() + + def __iter__(self): + return iter(self._dict.items()) + def __repr__(self): - return f'{type(self).__name__}({", ".join(f"{k}={v}" for k, v in self.items_)})' + return f'{type(self).__name__}({", ".join(f"{k}={v}" for k, v in self)})' # Deprecated