Skip to content

Commit

Permalink
S2646 - add meta_producer setter to AbstractCaomEntity (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
SharonGoliath authored and andamian committed Jan 21, 2020
1 parent 282fce3 commit 3ea1d53
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
12 changes: 11 additions & 1 deletion caom2/caom2/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,24 @@ 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
"""
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 """
Expand Down
3 changes: 0 additions & 3 deletions caom2/caom2/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions caom2/caom2/obs_reader_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion caom2/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 3ea1d53

Please sign in to comment.