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
02c51e90
Commit
02c51e90
authored
6 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: rename variable to more meaningful version
parent
bd38843d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/apiutils.py
+24
-24
24 additions, 24 deletions
src/caosdb/apiutils.py
with
24 additions
and
24 deletions
src/caosdb/apiutils.py
+
24
−
24
View file @
02c51e90
...
...
@@ -484,18 +484,18 @@ def getCommitIn(folder):
COMPARED
=
[
"
name
"
,
"
role
"
,
"
datatype
"
,
"
description
"
,
"
importance
"
]
def
compare_entities
(
r1
,
r2
):
def
compare_entities
(
old_entity
,
new_entity
):
description
=
""
# if
r1 is r2
:
# if
old_entity is new_entity
:
# return description
for
attr
in
COMPARED
:
try
:
r1
.
__getattribute__
(
attr
)
old_entity
.
__getattribute__
(
attr
)
r1_attr_exists
=
True
except
BaseException
:
r1_attr_exists
=
False
try
:
r2
.
__getattribute__
(
attr
)
new_entity
.
__getattribute__
(
attr
)
r2_attr_exists
=
True
except
BaseException
:
r2_attr_exists
=
False
...
...
@@ -504,22 +504,22 @@ def compare_entities(r1, r2):
continue
if
not
r1_attr_exists
and
not
r2_attr_exists
:
continue
if
r1
.
__getattribute__
(
attr
)
!=
r2
.
__getattribute__
(
attr
):
if
old_entity
.
__getattribute__
(
attr
)
!=
new_entity
.
__getattribute__
(
attr
):
description
+=
attr
+
"
differs:
\n
"
description
+=
str
(
r1
.
__getattribute__
(
attr
))
+
"
\n
"
description
+=
str
(
r2
.
__getattribute__
(
attr
))
+
"
\n
"
description
+=
str
(
old_entity
.
__getattribute__
(
attr
))
+
"
\n
"
description
+=
str
(
new_entity
.
__getattribute__
(
attr
))
+
"
\n
"
# properties
if
(
len
(
r1
.
properties
)
>
0
)
^
(
len
(
r2
.
properties
)
>
0
):
if
(
len
(
old_entity
.
properties
)
>
0
)
^
(
len
(
new_entity
.
properties
)
>
0
):
description
+=
"
only one has properties
\n
"
else
:
for
prop
in
r1
.
properties
:
matching
=
[
p
for
p
in
r2
.
properties
if
p
.
name
==
prop
.
name
]
for
prop
in
old_entity
.
properties
:
matching
=
[
p
for
p
in
new_entity
.
properties
if
p
.
name
==
prop
.
name
]
if
len
(
matching
)
==
0
:
description
+=
"
r2
is missing the property
'"
+
prop
.
name
+
"'
\n
"
description
+=
"
new_entity
is missing the property
'"
+
prop
.
name
+
"'
\n
"
elif
len
(
matching
)
==
1
:
if
(
r1
.
get_importance
(
prop
.
name
)
!=
r2
.
get_importance
(
prop
.
name
)):
if
(
old_entity
.
get_importance
(
prop
.
name
)
!=
new_entity
.
get_importance
(
prop
.
name
)):
description
+=
"
importance of
'"
+
prop
.
name
+
"'
differs
\n
"
if
((
prop
.
datatype
is
not
None
and
matching
[
0
].
datatype
is
not
None
)
and
...
...
@@ -527,28 +527,28 @@ def compare_entities(r1, r2):
description
+=
"
datatype of
'"
+
prop
.
name
+
"'
differs
\n
"
else
:
raise
NotImplementedError
()
for
prop
in
r2
.
properties
:
if
len
([
0
for
p
in
r1
.
properties
if
p
.
name
==
prop
.
name
])
==
0
:
description
+=
"
r1
is missing the property
'"
+
prop
.
name
+
"'
\n
"
for
prop
in
new_entity
.
properties
:
if
len
([
0
for
p
in
old_entity
.
properties
if
p
.
name
==
prop
.
name
])
==
0
:
description
+=
"
old_entity
is missing the property
'"
+
prop
.
name
+
"'
\n
"
# parents
if
((
len
(
r1
.
parents
)
>
0
)
^
(
len
(
r2
.
parents
)
>
0
)):
if
((
len
(
old_entity
.
parents
)
>
0
)
^
(
len
(
new_entity
.
parents
)
>
0
)):
description
+=
"
only one has parents
\n
"
else
:
for
par
in
r1
.
parents
:
matching
=
[
p
for
p
in
r2
.
parents
if
p
.
name
==
par
.
name
]
for
par
in
old_entity
.
parents
:
matching
=
[
p
for
p
in
new_entity
.
parents
if
p
.
name
==
par
.
name
]
if
len
(
matching
)
==
0
:
description
+=
"
r2
is missing the parent
'"
+
par
.
name
+
"'
\n
"
description
+=
"
new_entity
is missing the parent
'"
+
par
.
name
+
"'
\n
"
elif
len
(
matching
)
==
1
:
description
+=
compare_entities
(
par
,
matching
[
0
])
else
:
raise
NotImplementedError
()
for
par
in
r2
.
parents
:
if
len
([
0
for
p
in
r1
.
parents
if
p
.
name
==
par
.
name
])
==
0
:
description
+=
"
r1
is missing the parent
'"
+
par
.
name
+
"'
\n
"
for
par
in
new_entity
.
parents
:
if
len
([
0
for
p
in
old_entity
.
parents
if
p
.
name
==
par
.
name
])
==
0
:
description
+=
"
old_entity
is missing the parent
'"
+
par
.
name
+
"'
\n
"
if
description
!=
""
:
description
=
"""
#######################
{}
#######################
\n
"""
.
format
(
r1
.
name
)
+
description
#######################
\n
"""
.
format
(
old_entity
.
name
)
+
description
return
description
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