Skip to content
Snippets Groups Projects
Commit 96293ef2 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: doc string and rename of create_local_converters"

parent fb67f45e
No related branches found
No related tags found
1 merge request!53Release 0.1
Pipeline #28848 passed
......@@ -283,6 +283,10 @@ class Converter(object, metaclass=ABCMeta):
def converter_factory(definition: dict,
name: str,
converter_registry: dict):
"""creates a Converter instance of the appropriate class.
The `type` key in the `definition` defines the Converter class which is being used.
"""
if "type" not in definition:
raise RuntimeError(
......
......@@ -376,9 +376,13 @@ class Crawler(object):
converter_registry)
@staticmethod
def create_local_converters(crawler_definition: dict,
converter_registry: dict):
local_converters = []
def initialize_converters(crawler_definition: dict, converter_registry: dict):
"""
takes the cfood as dict (`crawler_definition`) and creates the converter objects that
are defined on the highest level. Child Converters will in turn be created during the
initialization of the Converters.
"""
converters = []
for key, value in crawler_definition.items():
# Definitions and Converters are reserved keywords
......@@ -390,10 +394,10 @@ class Crawler(object):
continue
elif key == "Converters":
continue
local_converters.append(Converter.converter_factory(
converters.append(Converter.converter_factory(
value, key, converter_registry))
return local_converters
return converters
def start_crawling(self, items: Union[List[StructureElement], StructureElement],
crawler_definition: dict,
......@@ -425,8 +429,7 @@ class Crawler(object):
items = [items]
self.run_id = uuid.uuid1()
local_converters = Crawler.create_local_converters(crawler_definition,
converter_registry)
local_converters = Crawler.initialize_converters(crawler_definition, converter_registry)
# This recursive crawling procedure generates the update list:
self.target_data: List[db.Record] = []
self._crawl(items,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment