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