From 3ea1d539fc2c25f16a53f25ef05fa7d02ef82765 Mon Sep 17 00:00:00 2001 From: SharonGoliath Date: Tue, 21 Jan 2020 14:25:20 -0800 Subject: [PATCH] S2646 - add meta_producer setter to AbstractCaomEntity (#121) --- caom2/caom2/common.py | 12 +++++++++++- caom2/caom2/diff.py | 3 --- caom2/caom2/obs_reader_writer.py | 7 ++++--- caom2/setup.cfg | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/caom2/caom2/common.py b/caom2/caom2/common.py index 339a1fbb..71f0881b 100644 --- a/caom2/caom2/common.py +++ b/caom2/caom2/common.py @@ -273,7 +273,8 @@ def acc_meta_checksum(self, value): False) self._acc_meta_checksum = value - def get_meta_producer(self): + @property + def meta_producer(self): """ Returns meta producer type: URI @@ -281,6 +282,15 @@ def get_meta_producer(self): """ return self._meta_producer + @meta_producer.setter + def meta_producer(self, value): + try: + urlparse(value) + except ValueError: + raise TypeError('Expected any IVOA URI for meta_producer, ' + 'received {}'.format(value)) + self._meta_producer = value + class VocabularyTerm(object): """ VocabularyTerm """ diff --git a/caom2/caom2/diff.py b/caom2/caom2/diff.py index 45f4234a..f5668fe5 100644 --- a/caom2/caom2/diff.py +++ b/caom2/caom2/diff.py @@ -300,9 +300,6 @@ def _get_sequence_differences(expected, actual, parent): for ex_index, e in enumerate(expected): label = '{}[\'{}\']'.format(parent, ex_index) if isinstance(e, Chunk): - if len(expected) > 1: - report.append('Sequence:: more Chunks than expected {}'.format( - len(expected))) temp_report = get_differences(e, actual[0]) if temp_report is not None: report.extend(temp_report) diff --git a/caom2/caom2/obs_reader_writer.py b/caom2/caom2/obs_reader_writer.py index 6247fc1d..b2524a28 100644 --- a/caom2/caom2/obs_reader_writer.py +++ b/caom2/caom2/obs_reader_writer.py @@ -183,8 +183,7 @@ def _set_entity_attributes(self, element, ns, caom2_entity): caom2_entity._acc_meta_checksum = common.ChecksumURI( element_acc_meta_checksum) if element_meta_producer: - caom2_entity._meta_producer = common.ChecksumURI( - element_meta_producer) + caom2_entity._meta_producer = element_meta_producer def _get_child_element(self, element_tag, parent, ns, required): for element in list(parent): @@ -1917,9 +1916,11 @@ def _add_entity_attributes(self, entity, element): if entity._acc_meta_checksum is not None: self._add_attribute( "accMetaChecksum", entity._acc_meta_checksum.uri, element) + + if self._output_version >= 24: if entity._meta_producer is not None: self._add_attribute( - "metaProducer", entity.get_meta_producer().uri, element) + "metaProducer", entity.meta_producer, element) def _add_algorithm_element(self, algorithm, parent): if algorithm is None: diff --git a/caom2/setup.cfg b/caom2/setup.cfg index 9b590e55..7d0fa23a 100644 --- a/caom2/setup.cfg +++ b/caom2/setup.cfg @@ -42,7 +42,7 @@ install_requires = lxml<=4.3.0;python_version=="3.4" lxml>=3.7.0;python_version>="3.5" # version should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386) -version = 2.4.0c +version = 2.4.0d [entry_points]