diff --git a/gallery_dl/cache.py b/gallery_dl/cache.py index ea802dfb..70442f4f 100644 --- a/gallery_dl/cache.py +++ b/gallery_dl/cache.py @@ -189,8 +189,8 @@ def clear(): def _path(): - path = config.get(("cache",), "file", -1) - if path != -1: + path = config.get(("cache",), "file", util.SENTINEL) + if path is not util.SENTINEL: return util.expand_path(path) if util.WINDOWS: diff --git a/gallery_dl/config.py b/gallery_dl/config.py index 8a25901f..3221a9d5 100644 --- a/gallery_dl/config.py +++ b/gallery_dl/config.py @@ -139,7 +139,6 @@ def unset(path, key, *, conf=_config): class apply(): """Context Manager: apply a collection of key-value pairs""" - _sentinel = object() def __init__(self, kvlist): self.original = [] @@ -147,12 +146,12 @@ class apply(): def __enter__(self): for path, key, value in self.kvlist: - self.original.append((path, key, get(path, key, self._sentinel))) + self.original.append((path, key, get(path, key, util.SENTINEL))) set(path, key, value) def __exit__(self, etype, value, traceback): for path, key, value in self.original: - if value is self._sentinel: + if value is util.SENTINEL: unset(path, key) else: set(path, key, value) diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index 0a773f44..7a29e7af 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -481,7 +481,7 @@ class SharedConfigMixin(): """Enable sharing of config settings based on 'basecategory'""" basecategory = "" - def config(self, key, default=None, *, sentinel=object()): + def config(self, key, default=None, *, sentinel=util.SENTINEL): value = Extractor.config(self, key, sentinel) return value if value is not sentinel else config.interpolate( ("extractor", self.basecategory, self.subcategory), key, default) diff --git a/gallery_dl/extractor/mastodon.py b/gallery_dl/extractor/mastodon.py index 4f0e38d5..002c8f78 100644 --- a/gallery_dl/extractor/mastodon.py +++ b/gallery_dl/extractor/mastodon.py @@ -27,11 +27,9 @@ class MastodonExtractor(Extractor): Extractor.__init__(self, match) self.api = MastodonAPI(self) - def config(self, key, default=None, *, sentinel=object()): + def config(self, key, default=None, *, sentinel=util.SENTINEL): value = Extractor.config(self, key, sentinel) - if value is not sentinel: - return value - return config.interpolate( + return value if value is not sentinel else config.interpolate( ("extractor", "mastodon", self.instance, self.subcategory), key, default, ) diff --git a/gallery_dl/util.py b/gallery_dl/util.py index 931df9ee..076ee5cc 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -271,6 +271,7 @@ class UniversalNone(): NONE = UniversalNone() WINDOWS = (os.name == "nt") +SENTINEL = object() def build_predicate(predicates):