improve config lookup when there are multiple possible locations
This specifically applies to all Mastodon extractors and all extractors with a 'basecategory', i.e. 'booru', 'foolslide', etc. Values inside those general config locations wouldn't be recognized when a value with the same was set on the 'extractor' level. For example 'extractor.mastodon.directory' should be used over 'extractor.directory' when both are set, but this was impossible with the previous implementation. (fixes #843)
This commit is contained in:
@@ -492,10 +492,13 @@ class SharedConfigMixin():
|
||||
"""Enable sharing of config settings based on 'basecategory'"""
|
||||
basecategory = ""
|
||||
|
||||
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)
|
||||
def config(self, key, default=None):
|
||||
return config.interpolate_common(
|
||||
("extractor",), (
|
||||
(self.category, self.subcategory),
|
||||
(self.basecategory, self.subcategory),
|
||||
), key, default,
|
||||
)
|
||||
|
||||
|
||||
def generate_extractors(extractor_data, symtable, classes):
|
||||
|
||||
@@ -27,11 +27,12 @@ class MastodonExtractor(Extractor):
|
||||
Extractor.__init__(self, match)
|
||||
self.api = MastodonAPI(self)
|
||||
|
||||
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", "mastodon", self.instance, self.subcategory),
|
||||
key, default,
|
||||
def config(self, key, default=None):
|
||||
return config.interpolate_common(
|
||||
("extractor",), (
|
||||
(self.category, self.subcategory),
|
||||
(self.basecategory, self.instance, self.subcategory),
|
||||
), key, default,
|
||||
)
|
||||
|
||||
def items(self):
|
||||
|
||||
Reference in New Issue
Block a user