Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
b91f936f
Commit
b91f936f
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
up
parent
94de0ce0
No related branches found
Branches containing commit
Tags
v0.13.2
Tags containing commit
No related merge requests found
Pipeline
#41093
failed
1 year ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/apiutils.py
+19
-0
19 additions, 0 deletions
src/caosdb/apiutils.py
with
19 additions
and
0 deletions
src/caosdb/apiutils.py
+
19
−
0
View file @
b91f936f
...
...
@@ -178,6 +178,16 @@ def getCommitIn(folder):
return
get_commit_in
(
folder
)
def
entity_and_id
(
this
,
that
):
"""
returns true iff exactly one of this and that is an Entity with an ID and the other is an
integer
"""
return
(
(
isinstance
(
this
,
Entity
)
and
this
.
id
is
not
None
and
isinstance
(
that
,
int
))
or
(
isinstance
(
this
,
int
)
and
isinstance
(
that
,
Entity
)
and
this
.
id
is
not
None
))
def
compare_entities
(
old_entity
:
Entity
,
new_entity
:
Entity
,
compare_referenced_records
:
bool
=
False
):
"""
Compare two entites.
...
...
@@ -279,6 +289,15 @@ def compare_entities(old_entity: Entity, new_entity: Entity, compare_referenced_
if
(
prop
.
value
!=
matching
[
0
].
value
):
# basic comparison of value objects says they are different
same_value
=
False
# one Entity with ID and one int?
if
(
sufficient_id
and
):
if
((
isinstance
(
matching
[
0
].
value
,
int
)
and
prop
.
value
.
id
==
matching
[
0
].
value
)
or
(
isinstance
(
prop
.
value
,
int
)
and
prop
.
value
==
matching
[
0
].
value
.
id
)):
same_value
=
True
if
compare_referenced_records
:
# scalar reference
if
isinstance
(
prop
.
value
,
Entity
)
and
isinstance
(
matching
[
0
].
value
,
Entity
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment