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
135ea134
Commit
135ea134
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
DOC: added some missing docstrings
parent
3477d908
No related branches found
No related tags found
2 merge requests
!33
MAINT: change arguments of create_user
,
!16
F retrieve substructure
Pipeline
#9730
passed with warnings
3 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/common/datatype.py
+46
-2
46 additions, 2 deletions
src/caosdb/common/datatype.py
with
46 additions
and
2 deletions
src/caosdb/common/datatype.py
+
46
−
2
View file @
135ea134
...
@@ -60,10 +60,21 @@ def is_list_datatype(datatype):
...
@@ -60,10 +60,21 @@ def is_list_datatype(datatype):
def
is_reference
(
datatype
):
def
is_reference
(
datatype
):
"""
r
eturns whether the value is a reference
"""
R
eturns whether the value is a reference
FILE and REFERENCE properties are examples, but also datatypes that are
FILE and REFERENCE properties are examples, but also datatypes that are
RecordTypes
RecordTypes.
Parameters
----------
datatype : str
The datatype to check.
Returns
-------
bool
True if the datatype is a not base datatype or a list of a base datatype.
Otherwise False is returned.
"""
"""
if
datatype
in
[
DOUBLE
,
BOOLEAN
,
INTEGER
,
TEXT
,
DATETIME
]:
if
datatype
in
[
DOUBLE
,
BOOLEAN
,
INTEGER
,
TEXT
,
DATETIME
]:
...
@@ -73,6 +84,39 @@ def is_reference(datatype):
...
@@ -73,6 +84,39 @@ def is_reference(datatype):
else
:
else
:
return
True
return
True
def
get_referenced_recordtype
(
datatype
):
"""
Return the record type of the referenced datatype.
Raises
------
ValueError
In cases where datatype is not a reference, the list does not have
a referenced record type or the datatype is a FILE.
Parameters
----------
datatype : str
The datatype to check.
Returns
-------
str
String containing the name of the referenced datatype.
"""
if
not
is_reference
(
datatype
):
raise
ValueError
(
"
datatype must be a reference
"
)
if
is_list_datatype
(
datatype
):
datatype
=
get_list_datatype
(
datatype
)
if
datatype
is
None
:
raise
ValueError
(
"
list does not have a list datatype
"
)
if
datatype
==
FILE
:
raise
ValueError
(
"
FILE references are not considered references with a record type
"
)
return
datatype
def
get_id_of_datatype
(
datatype
):
def
get_id_of_datatype
(
datatype
):
"""
returns the id of a Record Type
"""
returns the id of a Record Type
...
...
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