Skip to content
Snippets Groups Projects
Commit 42ee81af authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

Merge branch 'f-review-lists-and-compare' into 'dev'

FIX: prepare for usage of new parent/property lists

See merge request !196
parents e4de5c19 1f6364cb
Branches
Tags
2 merge requests!198REL: Release 0.10.0,!196FIX: prepare for usage of new parent/property lists
Pipeline #57362 passed
...@@ -99,7 +99,7 @@ in a quite complex fashion: ...@@ -99,7 +99,7 @@ in a quite complex fashion:
- If one of the entities has additional parents or additional properties -> not identical - 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 the value of one of the properties differs -> not identical
- If datatype, importance or unit are reported different for a property by compare_entities - 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. Ignore the difference otherwise.
- If description, name, id or path appear in list of differences -> not identical. - 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. - If file, checksum, size appear -> Only different, if explicitely set by record1.
......
...@@ -26,7 +26,7 @@ from typing import TYPE_CHECKING, Any, Optional, Union ...@@ -26,7 +26,7 @@ from typing import TYPE_CHECKING, Any, Optional, Union
import linkahead as db import linkahead as db
import yaml import yaml
from linkahead.common.models import Parent, _ParentList, _Properties from linkahead.common.models import Parent, ParentList, PropertyList
from warnings import warn from warnings import warn
from .exceptions import ImpossibleMergeError from .exceptions import ImpossibleMergeError
...@@ -76,8 +76,8 @@ class SyncNode(db.Entity): ...@@ -76,8 +76,8 @@ class SyncNode(db.Entity):
self.role = entity.role self.role = entity.role
self.path = entity.path self.path = entity.path
self.file = entity.file self.file = entity.file
self.parents = _ParentList().extend(entity.parents) self.parents = ParentList().extend(entity.parents)
self.properties = _Properties().extend(entity.properties) self.properties = PropertyList().extend(entity.properties)
self._check_for_multiproperties() self._check_for_multiproperties()
# other members # other members
self.identifiable: Optional[Identifiable] = None self.identifiable: Optional[Identifiable] = None
...@@ -254,25 +254,11 @@ class SyncNode(db.Entity): ...@@ -254,25 +254,11 @@ class SyncNode(db.Entity):
ids.add(p.id) 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""" """helper function that checks whether a parent with the same name or ID is in the plist"""
missing = False return plist.filter(parent)
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
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""" """helper function that checks whether a property with the same name or ID is in the plist"""
missing = False return plist.filter(prop)
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment