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
Branches
Branches containing commit
Tags
Tags containing commit
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):
...
@@ -484,18 +484,18 @@ def getCommitIn(folder):
COMPARED
=
[
"
name
"
,
"
role
"
,
"
datatype
"
,
"
description
"
,
"
importance
"
]
COMPARED
=
[
"
name
"
,
"
role
"
,
"
datatype
"
,
"
description
"
,
"
importance
"
]
def
compare_entities
(
r1
,
r2
):
def
compare_entities
(
old_entity
,
new_entity
):
description
=
""
description
=
""
# if
r1 is r2
:
# if
old_entity is new_entity
:
# return description
# return description
for
attr
in
COMPARED
:
for
attr
in
COMPARED
:
try
:
try
:
r1
.
__getattribute__
(
attr
)
old_entity
.
__getattribute__
(
attr
)
r1_attr_exists
=
True
r1_attr_exists
=
True
except
BaseException
:
except
BaseException
:
r1_attr_exists
=
False
r1_attr_exists
=
False
try
:
try
:
r2
.
__getattribute__
(
attr
)
new_entity
.
__getattribute__
(
attr
)
r2_attr_exists
=
True
r2_attr_exists
=
True
except
BaseException
:
except
BaseException
:
r2_attr_exists
=
False
r2_attr_exists
=
False
...
@@ -504,22 +504,22 @@ def compare_entities(r1, r2):
...
@@ -504,22 +504,22 @@ def compare_entities(r1, r2):
continue
continue
if
not
r1_attr_exists
and
not
r2_attr_exists
:
if
not
r1_attr_exists
and
not
r2_attr_exists
:
continue
continue
if
r1
.
__getattribute__
(
attr
)
!=
r2
.
__getattribute__
(
attr
):
if
old_entity
.
__getattribute__
(
attr
)
!=
new_entity
.
__getattribute__
(
attr
):
description
+=
attr
+
"
differs:
\n
"
description
+=
attr
+
"
differs:
\n
"
description
+=
str
(
r1
.
__getattribute__
(
attr
))
+
"
\n
"
description
+=
str
(
old_entity
.
__getattribute__
(
attr
))
+
"
\n
"
description
+=
str
(
r2
.
__getattribute__
(
attr
))
+
"
\n
"
description
+=
str
(
new_entity
.
__getattribute__
(
attr
))
+
"
\n
"
# properties
# 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
"
description
+=
"
only one has properties
\n
"
else
:
else
:
for
prop
in
r1
.
properties
:
for
prop
in
old_entity
.
properties
:
matching
=
[
p
for
p
in
r2
.
properties
if
p
.
name
==
prop
.
name
]
matching
=
[
p
for
p
in
new_entity
.
properties
if
p
.
name
==
prop
.
name
]
if
len
(
matching
)
==
0
:
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
:
elif
len
(
matching
)
==
1
:
if
(
r1
.
get_importance
(
prop
.
name
)
!=
if
(
old_entity
.
get_importance
(
prop
.
name
)
!=
r2
.
get_importance
(
prop
.
name
)):
new_entity
.
get_importance
(
prop
.
name
)):
description
+=
"
importance of
'"
+
prop
.
name
+
"'
differs
\n
"
description
+=
"
importance of
'"
+
prop
.
name
+
"'
differs
\n
"
if
((
prop
.
datatype
is
not
None
and
if
((
prop
.
datatype
is
not
None
and
matching
[
0
].
datatype
is
not
None
)
and
matching
[
0
].
datatype
is
not
None
)
and
...
@@ -527,28 +527,28 @@ def compare_entities(r1, r2):
...
@@ -527,28 +527,28 @@ def compare_entities(r1, r2):
description
+=
"
datatype of
'"
+
prop
.
name
+
"'
differs
\n
"
description
+=
"
datatype of
'"
+
prop
.
name
+
"'
differs
\n
"
else
:
else
:
raise
NotImplementedError
()
raise
NotImplementedError
()
for
prop
in
r2
.
properties
:
for
prop
in
new_entity
.
properties
:
if
len
([
0
for
p
in
r1
.
properties
if
p
.
name
==
prop
.
name
])
==
0
:
if
len
([
0
for
p
in
old_entity
.
properties
if
p
.
name
==
prop
.
name
])
==
0
:
description
+=
"
r1
is missing the property
'"
+
prop
.
name
+
"'
\n
"
description
+=
"
old_entity
is missing the property
'"
+
prop
.
name
+
"'
\n
"
# parents
# 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
"
description
+=
"
only one has parents
\n
"
else
:
else
:
for
par
in
r1
.
parents
:
for
par
in
old_entity
.
parents
:
matching
=
[
p
for
p
in
r2
.
parents
if
p
.
name
==
par
.
name
]
matching
=
[
p
for
p
in
new_entity
.
parents
if
p
.
name
==
par
.
name
]
if
len
(
matching
)
==
0
:
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
:
elif
len
(
matching
)
==
1
:
description
+=
compare_entities
(
par
,
matching
[
0
])
description
+=
compare_entities
(
par
,
matching
[
0
])
else
:
else
:
raise
NotImplementedError
()
raise
NotImplementedError
()
for
par
in
r2
.
parents
:
for
par
in
new_entity
.
parents
:
if
len
([
0
for
p
in
r1
.
parents
if
p
.
name
==
par
.
name
])
==
0
:
if
len
([
0
for
p
in
old_entity
.
parents
if
p
.
name
==
par
.
name
])
==
0
:
description
+=
"
r1
is missing the parent
'"
+
par
.
name
+
"'
\n
"
description
+=
"
old_entity
is missing the parent
'"
+
par
.
name
+
"'
\n
"
if
description
!=
""
:
if
description
!=
""
:
description
=
"""
#######################
description
=
"""
#######################
{}
{}
#######################
\n
"""
.
format
(
r1
.
name
)
+
description
#######################
\n
"""
.
format
(
old_entity
.
name
)
+
description
return
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