diff --git a/kadmos/cmdows/cmdows.py b/kadmos/cmdows/cmdows.py index ca865af5d3e22bedf64961c12dcc9980fd8e97d5..758e41e6034ec2f24fcbd3a025d28819f5e52637 100644 --- a/kadmos/cmdows/cmdows.py +++ b/kadmos/cmdows/cmdows.py @@ -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):