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

Minor updates in CMDOWS functions.

Former-commit-id: 8d7142d6415d628a3c5645b4588284c424553899
parent b3dd8f02
No related branches found
No related tags found
No related merge requests found
......@@ -269,7 +269,7 @@ class CMDOWS(object):
# ----------------------------------------- #
# Add / change file functions #
# ----------------------------------------- #
def add_header(self, creator, description, timestamp=None, fileVersion="0.0"):
def add_header(self, creator, description, timestamp=None, fileVersion="0.0", cmdowsVersion="0.7"):
"""Method to add a header to a CMDOWS file."""
# Assert header element exists
......@@ -280,7 +280,7 @@ class CMDOWS(object):
el.add("description", description)
el.add("timestamp", str(datetime.now()) if timestamp is None else timestamp)
el.add("fileVersion", fileVersion)
el.add("cmdowsVersion", self.version())
el.add("cmdowsVersion", cmdowsVersion)
return
def add_contact(self, name, email, uid, company=None, department=None, function=None, address=None, telephone=None, country=None, roles=None):
......@@ -436,8 +436,9 @@ class CMDOWS(object):
performance_info_element.add('run_time', run_time, only_add_if_valued=True, camel_case_conversion=True)
parent_element.append(performance_info_element)
self.add_dc_verification(dc_uid, verification['method'], verification['verifier'], verification['result'],
verification['date'], verification['version'])
if verification:
self.add_dc_verification(dc_uid, verification['method'], verification['verifier'], verification['result'],
verification['date'], verification['version'])
return
def add_dc_verification(self, dc_uid, method, verifier, result, date, version):
......@@ -499,7 +500,22 @@ class CMDOWS(object):
def add_new_parameters_from_element(self, parameters_element):
"""Method to add the new parameters based on a parameters element."""
# TODO: Create this function...
# First ensure a parameters XPath
el = self.ensure_abs_xpath('/cmdows/parameters')
# Determine the list of existing parameters
existing_parameters = []
for child in el.iterchildren():
assert child.attrib['uID'], 'Attribute uID is missing for parameter element.'
existing_parameters.append(child.attrib['uID'])
# For each element in the parameters_element determine whether it's new, and then add it (or not)
for new_child in parameters_element.iterchildren():
assert new_child.attrib['uID'], 'Attribute uID is missing for new parameter element.'
new_child_uid = new_child.attrib['uID']
if new_child_uid not in existing_parameters:
el.append(new_child)
return
def add_actor(self, contact_uid, role):
......
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