mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-11 20:58:29 +03:00
Separate setup() and module_setup().
This commit is contained in:
@@ -14,7 +14,7 @@ class BaseModule(ABC):
|
||||
Base module class. All modules should inherit from this class.
|
||||
|
||||
The exact methods a class implements will depend on the type of module it is,
|
||||
however all modules have a .setup(config: dict) method to run any setup code
|
||||
however modules can have a .setup() method to run any setup code
|
||||
(e.g. logging in to a site, spinning up a browser etc.)
|
||||
|
||||
See BaseModule.MODULE_TYPES for the types of modules you can create, noting that
|
||||
@@ -60,7 +60,7 @@ class BaseModule(ABC):
|
||||
def storages(self) -> list:
|
||||
return self.config.get('storages', [])
|
||||
|
||||
def setup(self, config: dict):
|
||||
def config_setup(self, config: dict):
|
||||
|
||||
authentication = config.get('authentication', {})
|
||||
# extract out concatenated sites
|
||||
@@ -80,7 +80,7 @@ class BaseModule(ABC):
|
||||
for key, val in config.get(self.name, {}).items():
|
||||
setattr(self, key, val)
|
||||
|
||||
def module_setup(self):
|
||||
def setup(self):
|
||||
# For any additional setup required by modules, e.g. autehntication
|
||||
pass
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ def get_module_lazy(module_name: str, suppress_warnings: bool = False) -> LazyBa
|
||||
|
||||
This has all the information about the module, but does not load the module itself or its dependencies
|
||||
|
||||
To load an actual module, call .setup() on a laz module
|
||||
To load an actual module, call .setup() on a lazy module
|
||||
|
||||
"""
|
||||
if module_name in _LAZY_LOADED_MODULES:
|
||||
@@ -241,8 +241,8 @@ class LazyBaseModule:
|
||||
# merge the default config with the user config
|
||||
default_config = dict((k, v['default']) for k, v in self.configs.items() if v.get('default'))
|
||||
config[self.name] = default_config | config.get(self.name, {})
|
||||
instance.setup(config)
|
||||
instance.module_setup()
|
||||
instance.config_setup(config)
|
||||
instance.setup()
|
||||
return instance
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
Reference in New Issue
Block a user