diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index b2eb031291b93b713f7f961172d862106e6ce2ff..9e4e2a80da40599a51b674ad9a2001b8d9fa691b 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -99,7 +99,7 @@ in a quite complex fashion: - If one of the entities has additional parents or additional properties -> not identical - If the value of one of the properties differs -> not identical - If datatype, importance or unit are reported different for a property by compare_entities - return "not_identical" only if these attributes are set explicitely by record1. + return False only if these attributes are set explicitely by record1. Ignore the difference otherwise. - If description, name, id or path appear in list of differences -> not identical. - If file, checksum, size appear -> Only different, if explicitely set by record1. diff --git a/src/caoscrawler/sync_node.py b/src/caoscrawler/sync_node.py index d35b49c17aea4cba05ab46291ba65023007283ee..ad0feb98d38750ec46eaced1074bb0fa499acae5 100644 --- a/src/caoscrawler/sync_node.py +++ b/src/caoscrawler/sync_node.py @@ -26,7 +26,7 @@ from typing import TYPE_CHECKING, Any, Optional, Union import linkahead as db import yaml -from linkahead.common.models import Parent, _ParentList, _Properties +from linkahead.common.models import Parent, ParentList, PropertyList from warnings import warn from .exceptions import ImpossibleMergeError @@ -76,8 +76,8 @@ class SyncNode(db.Entity): self.role = entity.role self.path = entity.path self.file = entity.file - self.parents = _ParentList().extend(entity.parents) - self.properties = _Properties().extend(entity.properties) + self.parents = ParentList().extend(entity.parents) + self.properties = PropertyList().extend(entity.properties) self._check_for_multiproperties() # other members self.identifiable: Optional[Identifiable] = None @@ -254,25 +254,11 @@ class SyncNode(db.Entity): ids.add(p.id) -def parent_in_list(parent: Parent, plist: _ParentList) -> bool: +def parent_in_list(parent: Parent, plist: ParentList) -> bool: """helper function that checks whether a parent with the same name or ID is in the plist""" - missing = False - if parent.name is not None: - if parent.name not in plist._element_by_name: - missing = True - if parent.id is not None: - if str(parent.id) not in plist._element_by_id: - missing = True - return not missing + return plist.filter(parent) -def property_in_list(prop: db.Property, plist: _Properties) -> bool: +def property_in_list(prop: db.Property, plist: PropertyList) -> bool: """helper function that checks whether a property with the same name or ID is in the plist""" - missing = False - if prop.name is not None: - if prop.name not in plist._element_by_name: - missing = True - if prop.id is not None: - if str(prop.id) not in plist._element_by_id: - missing = True - return not missing + return plist.filter(prop)