From 4601aa97941dd25d094d350d8de21d955a4cbe32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 9 Sep 2024 20:28:18 +0200 Subject: [PATCH] [util] add 'NullContext' an even more minimal 'contextlib.nullcontext' that also works on older Python versions --- gallery_dl/util.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gallery_dl/util.py b/gallery_dl/util.py index df2ec5ab..967479da 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -516,6 +516,15 @@ class LazyPrompt(): return getpass.getpass() +class NullContext(): + + def __enter__(self): + return None + + def __exit__(self, exc_type, exc_value, traceback): + pass + + class CustomNone(): """None-style type that supports more operations than regular None""" __slots__ = ()