Skip to content
Snippets Groups Projects
Commit 135ea134 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

DOC: added some missing docstrings

parent 3477d908
No related branches found
No related tags found
2 merge requests!33MAINT: change arguments of create_user,!16F retrieve substructure
Pipeline #9730 passed with warnings
...@@ -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):
""" returns whether the value is a reference """Returns 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment