FetchingCoordinator -> fetcher_factory (better name)
This commit is contained in:
@@ -143,13 +143,13 @@ def batch_fetch(entities, *attr_paths):
|
||||
"""
|
||||
|
||||
if entities:
|
||||
fetcher = FetchingCoordinator()
|
||||
for attr_path in attr_paths:
|
||||
fetcher(entities, attr_path)
|
||||
for path in attr_paths:
|
||||
fetcher = fetcher_factory(entities, path)
|
||||
fetcher.fetch()
|
||||
fetcher.populate()
|
||||
|
||||
|
||||
class FetchingCoordinator(object):
|
||||
def __call__(self, entities, path):
|
||||
def fetcher_factory(entities, path):
|
||||
populate_backrefs = False
|
||||
if isinstance(path, with_backrefs):
|
||||
path = path.path
|
||||
@@ -162,11 +162,9 @@ class FetchingCoordinator(object):
|
||||
Path.parse(entities, path, populate_backrefs).fetcher
|
||||
)
|
||||
|
||||
fetcher = CompositeFetcher(*fetchers)
|
||||
return CompositeFetcher(*fetchers)
|
||||
else:
|
||||
fetcher = Path.parse(entities, path, populate_backrefs).fetcher
|
||||
fetcher.fetch()
|
||||
fetcher.populate()
|
||||
return Path.parse(entities, path, populate_backrefs).fetcher
|
||||
|
||||
|
||||
class CompositeFetcher(object):
|
||||
|
Reference in New Issue
Block a user