add 'config_instance' method

to allow for a more streamlined access to BaseExtractor instance options
This commit is contained in:
Mike Fährmann
2024-01-18 03:20:36 +01:00
parent 34a7afdbc1
commit 89066844f4
8 changed files with 26 additions and 49 deletions

View File

@@ -102,6 +102,9 @@ class Extractor():
def config_accumulate(self, key):
return config.accumulate(self._cfgpath, key)
def config_instance(self, key, default=None):
return default
def _config_shared(self, key, default=None):
return config.interpolate_common(
("extractor",), self._cfgpath, key, default)
@@ -735,9 +738,10 @@ class BaseExtractor(Extractor):
for index, group in enumerate(match.groups()):
if group is not None:
if index:
self.category, self.root = self.instances[index-1]
self.category, self.root, info = self.instances[index-1]
if not self.root:
self.root = text.root_from_url(match.group(0))
self.config_instance = info.get
else:
self.root = group
self.category = group.partition("://")[2]
@@ -757,7 +761,7 @@ class BaseExtractor(Extractor):
root = info["root"]
if root:
root = root.rstrip("/")
instance_list.append((category, root))
instance_list.append((category, root, info))
pattern = info.get("pattern")
if not pattern: