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
056d15af
Verified
Commit
056d15af
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
CLEANUP
parent
e49316b4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/common/models.py
+23
-40
23 additions, 40 deletions
src/caosdb/common/models.py
with
23 additions
and
40 deletions
src/caosdb/common/models.py
+
23
−
40
View file @
056d15af
...
@@ -609,59 +609,48 @@ class Entity(object):
...
@@ -609,59 +609,48 @@ class Entity(object):
Parameters
Parameters
----------
----------
properties : str or tuple of str
*
properties : str or tuple of str
A list of property names, e.g. `
"
height
"
,
"
width
"
` or a list of
A list of property names, e.g. `
"
height
"
,
"
width
"
` or a list of
tuples of properties, e.g. `(
"
window
"
,
"
height
"
), (
"
window
"
,
tuples of properties, e.g. `(
"
window
"
,
"
height
"
), (
"
window
"
,
"
width
"
)`.
"
width
"
)`.
Raises
------
TypeError :
If the properties parameter contains anything else than str or
tuple of str elements.
Returns
Returns
-------
-------
row : tuple
row : tuple
A row-like representation of the entit
ie
s properties.
A row-like representation of the entit
y
'
s properties.
"""
"""
selector
s
=
properties
propertie
s
=
properties
row
=
tuple
()
row
=
tuple
()
for
sel
in
selector
s
:
for
sel
ector
in
propertie
s
:
val
=
None
val
=
None
if
isinstance
(
sel
,
str
):
if
isinstance
(
selector
,
(
tuple
,
list
))
and
len
(
selector
)
>
0
:
if
hasattr
(
self
,
sel
.
lower
()):
val
=
getattr
(
self
,
sel
.
lower
())
else
:
prop
=
self
.
get_property
(
sel
)
if
prop
is
not
None
:
val
=
prop
.
value
elif
isinstance
(
sel
,
(
tuple
,
list
))
and
len
(
sel
)
>
0
:
val
=
None
val
=
None
ref
=
self
ref
=
self
# the while loop walks through the re
# the while loop walks through the re
while
len
(
sel
)
>
1
and
isinstance
(
ref
,
Entity
):
while
len
(
sel
ector
)
>
1
and
isinstance
(
ref
,
Entity
):
prop
=
ref
.
get_property
(
sel
[
0
])
prop
=
ref
.
get_property
(
sel
ector
[
0
])
if
prop
is
not
None
and
isinstance
(
prop
.
value
,
Entity
):
if
prop
is
not
None
and
isinstance
(
prop
.
value
,
Entity
):
ref
=
prop
.
value
ref
=
prop
.
value
else
:
else
:
# non-entity value -
# non-entity value -
ref
=
prop
ref
=
prop
sel
=
sel
[
1
:]
sel
ector
=
sel
ector
[
1
:]
if
len
(
sel
)
==
1
and
isinstance
(
ref
,
Entity
):
if
len
(
sel
ector
)
==
1
and
isinstance
(
ref
,
Entity
):
if
(
hasattr
(
sel
[
0
],
"
lower
"
)
if
(
hasattr
(
sel
ector
[
0
],
"
lower
"
)
and
hasattr
(
ref
,
sel
[
0
].
lower
())):
and
hasattr
(
ref
,
sel
ector
[
0
].
lower
())):
val
=
getattr
(
ref
,
sel
[
0
].
lower
())
val
=
getattr
(
ref
,
sel
ector
[
0
].
lower
())
else
:
else
:
prop
=
ref
.
get_property
(
sel
[
0
])
prop
=
ref
.
get_property
(
sel
ector
[
0
])
if
prop
is
not
None
:
if
prop
is
not
None
:
val
=
prop
.
value
val
=
prop
.
value
else
:
else
:
raise
TypeError
(
"
The elements of the parameter `properties`
"
if
hasattr
(
self
,
selector
.
lower
()):
"
must contain str or non-empty tuples of str.
"
val
=
getattr
(
self
,
selector
.
lower
())
"
Was {}.
"
.
format
(
sel
))
else
:
prop
=
self
.
get_property
(
selector
)
if
prop
is
not
None
:
val
=
prop
.
value
if
isinstance
(
val
,
Entity
):
if
isinstance
(
val
,
Entity
):
val
=
val
.
id
if
val
.
id
is
not
None
else
val
.
name
val
=
val
.
id
if
val
.
id
is
not
None
else
val
.
name
row
+=
(
val
,)
row
+=
(
val
,)
...
@@ -3202,16 +3191,10 @@ class Container(list):
...
@@ -3202,16 +3191,10 @@ class Container(list):
Parameters
Parameters
----------
----------
properties : list
*properties : str or tuple of str
A list of property names, e.g. `[
"
height
"
,
"
width
"
]` or a list of
A list of property names, e.g. `
"
height
"
,
"
width
"
` or a list of
tuples of properties, e.g. `[(
"
window
"
,
"
height
"
), (
"
window
"
,
tuples of properties, e.g. `(
"
window
"
,
"
height
"
), (
"
window
"
,
"
width
"
)]`.
"
width
"
)`.
Raises
------
TypeError :
If the properties parameter contains anything else than str or
tuple of str elements.
Returns
Returns
-------
-------
...
...
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