Skip to content
Snippets Groups Projects
Commit 8b75c824 authored by imcovangent's avatar imcovangent
Browse files

Added function to add valid range in CMDOWS file.

Former-commit-id: 45d113be421c78e90c472adced599b9225478250
parent 46345631
No related branches found
No related tags found
No related merge requests found
...@@ -388,7 +388,7 @@ class CMDOWS(object): ...@@ -388,7 +388,7 @@ class CMDOWS(object):
:param description: description of file content :param description: description of file content
:type description: str :type description: str
:param timestamp: (optional) date and time of creation :param timestamp: (optional) date and time of creation
:type timestamp: datetime :type timestamp: str
:param fileVersion: version of the file :param fileVersion: version of the file
:type fileVersion: str :type fileVersion: str
:param cmdowsVersion: version of the xsd schema :param cmdowsVersion: version of the xsd schema
...@@ -922,6 +922,34 @@ class CMDOWS(object): ...@@ -922,6 +922,34 @@ class CMDOWS(object):
self.add_subelement(el_pr[0], eltag) self.add_subelement(el_pr[0], eltag)
return self.root.xpath(local_xpath)[0] return self.root.xpath(local_xpath)[0]
def add_valid_ranges(self, elem_or_uid, minimum=None, maximum=None, list_range=None):
"""Method to add the list ranges element to an existing element.
:param elem_or_uid: element or the UID of an element
:type elem_or_uid: str or ExtendedElement
:param minimum: minimum value for valid range
:type minimum: float
:param maximum: maximum value for valid range
:type maximum: float
:param list_range: list of optional values
:type list_range: list
"""
if isinstance(elem_or_uid, str):
elem = self.get_element_of_uid(elem_or_uid)
else:
elem = elem_or_uid
vr_elem = elem.add('validRanges')
if minimum is not None or maximum is not None:
lr_elem = vr_elem.add('limitRange')
if minimum is not None:
lr_elem.add('minimum', float(minimum))
if maximum is not None:
lr_elem.add('maximum', float(maximum))
if list_range is not None:
list_range_elem = vr_elem.add('listRange')
for item in list_range:
list_range_elem.add('listRangeItem', str(item))
def append_element_to_xpath_element(self, xpath, element_tag, attrib=None): def append_element_to_xpath_element(self, xpath, element_tag, attrib=None):
"""Method to append a new element at an XPath location. """Method to append a new element at an XPath location.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment