Skip to content
Snippets Groups Projects

ENH: add is_reference to db.Property

Merged Henrik tom Wörden requested to merge f-is-reference into dev
Files
3
@@ -31,6 +31,7 @@ from __future__ import print_function, unicode_literals
import re
import sys
from builtins import str
from copy import deepcopy
from functools import cmp_to_key
from hashlib import sha512
from os import listdir
@@ -1504,6 +1505,42 @@ class Property(Entity):
return super(Property, self).to_xml(xml, add_properties)
def is_reference(self, server_retrieval=False):
"""Returns whether this Property is a reference
Parameters
----------
server_retrieval : bool, optional
If True and the datatype is not set, the Property is retrieved from the server, by default False
Returns
-------
bool, NoneType
Returns whether this Property is a reference or None if a server call is needed to
check correctly, but server_retrieval is set to False.
"""
if self.datatype is None:
if not self.is_valid():
# this is a workaround to prevent side effects
# since retrieve currently changes the object
if server_retrieval:
tmp_prop = deepcopy(self)
tmp_prop.retrieve()
return tmp_prop.is_reference()
else:
return None
else:
# a valid property without datatype has to be an RT
return True
else:
return is_reference(self.datatype)
class Message(object):
Loading