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

MAINT: do first all the matches and then identifiables

parent 68167ebd
No related branches found
No related tags found
No related merge requests found
...@@ -78,6 +78,7 @@ class AbstractCFood(object): ...@@ -78,6 +78,7 @@ class AbstractCFood(object):
self.to_be_updated = db.Container() self.to_be_updated = db.Container()
self.identifiables = db.Container() self.identifiables = db.Container()
self.verbose = verbose self.verbose = verbose
self.attached_ones = []
@staticmethod @staticmethod
def get_re(): def get_re():
...@@ -127,8 +128,19 @@ class AbstractCFood(object): ...@@ -127,8 +128,19 @@ class AbstractCFood(object):
if len(self.to_be_updated) == 0: if len(self.to_be_updated) == 0:
return return
get_ids_for_entities_with_names(self.to_be_updated) get_ids_for_entities_with_names(self.to_be_updated)
print(self.to_be_updated)
self.to_be_updated.update() self.to_be_updated.update()
def attach(self, crawled_file):
self.attached_ones.append(crawled_file)
def looking_for(self, crawled_file):
"""
should set the instance variable Container with the identifiables
"""
return False
@staticmethod @staticmethod
# move to api? # move to api?
def set_parents(entity, names): def set_parents(entity, names):
...@@ -179,6 +191,9 @@ def assure_object_is_in_list(obj, containing_object, property_name, ...@@ -179,6 +191,9 @@ def assure_object_is_in_list(obj, containing_object, property_name,
containing_object.add_property(property_name, value=[], containing_object.add_property(property_name, value=[],
datatype=db.LIST(property_name)) datatype=db.LIST(property_name))
current_list = containing_object.get_property(property_name).value current_list = containing_object.get_property(property_name).value
if not isinstance(current_list, list):
current_list = [current_list]
contained = False contained = False
for el in current_list: for el in current_list:
......
...@@ -106,6 +106,11 @@ class Crawler(object): ...@@ -106,6 +106,11 @@ class Crawler(object):
if self.verbose and matches > 1: if self.verbose and matches > 1:
print("Attention: More than one matching cfood!") print("Attention: More than one matching cfood!")
for crawled_file in sorted(files, key=lambda x: x.path):
for cfood in cfoods:
if cfood.looking_for(crawled_file):
cfood.attach(crawled_file)
for cfood in cfoods: for cfood in cfoods:
try: try:
cfood.create_identifiables() cfood.create_identifiables()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment