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
465f41f2
Commit
465f41f2
authored
2 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
DOC: renamed COMAPRED to SPECIAL_ATTRIBUTES and added documentation
parent
394d2f5d
No related branches found
No related tags found
2 merge requests
!57
RELEASE 0.7.3
,
!45
F copy entity
Pipeline
#21648
passed
2 years 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
+8
-4
8 additions, 4 deletions
src/caosdb/apiutils.py
with
8 additions
and
4 deletions
src/caosdb/apiutils.py
+
8
−
4
View file @
465f41f2
...
...
@@ -565,8 +565,8 @@ def getCommitIn(folder):
return
t
.
readline
().
strip
()
COMPARED
=
[
"
name
"
,
"
role
"
,
"
datatype
"
,
"
description
"
,
"
id
"
,
"
path
"
,
"
checksum
"
,
"
size
"
]
SPECIAL_ATTRIBUTES
=
[
"
name
"
,
"
role
"
,
"
datatype
"
,
"
description
"
,
"
id
"
,
"
path
"
,
"
checksum
"
,
"
size
"
]
def
compare_entities
(
old_entity
:
Entity
,
new_entity
:
Entity
):
...
...
@@ -592,7 +592,7 @@ def compare_entities(old_entity: Entity, new_entity: Entity):
if
old_entity
is
new_entity
:
return
(
olddiff
,
newdiff
)
for
attr
in
COMPARED
:
for
attr
in
SPECIAL_ATTRIBUTES
:
try
:
oldattr
=
old_entity
.
__getattribute__
(
attr
)
old_entity_attr_exists
=
True
...
...
@@ -686,6 +686,10 @@ def copy_entity(entity: Entity):
Return a copy of entity.
If deep == True return a deep copy, recursively copying all sub entities.
Standard properties are copied using add_property.
Special attributes, as defined by the global variable SPECIAL_ATTRIBUTES and additionaly
the
"
value
"
are copied using setattr.
"""
print
(
entity
)
if
entity
.
role
==
"
File
"
:
...
...
@@ -704,7 +708,7 @@ def copy_entity(entity: Entity):
# Copy special attributes:
# TODO: this might rise an exception when copying
# special file attributes like checksum and size.
for
attribute
in
COMPARED
+
[
"
value
"
]:
for
attribute
in
SPECIAL_ATTRIBUTES
+
[
"
value
"
]:
val
=
getattr
(
entity
,
attribute
)
if
val
is
not
None
:
setattr
(
new
,
attribute
,
val
)
...
...
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