Esempio n. 1
0
 def comparison_report(self):
     if self.__comparison_report is None:
         if os.path.isfile(self.output_location):
             comparisons_in = FileIO(self.output_location, mode='rb')
             try:
                 comparison_failure_stream = simpleion.load(comparisons_in, single_value=False)
             finally:
                 comparisons_in.close()
             self.__comparison_report = IonPyList.from_value(IonType.LIST, comparison_failure_stream)
         else:
             self.__comparison_report = IonPyList.from_value(IonType.LIST, [])
     return self.__comparison_report
Esempio n. 2
0
 def errors(self):
     if self.__errors is None:
         if os.path.isfile(self.error_location):
             errors_in = FileIO(self.error_location, mode='rb')
             try:
                 errors_stream = simpleion.load(errors_in, single_value=False)
             finally:
                 errors_in.close()
             self.__errors = IonPyList.from_value(IonType.LIST, errors_stream)
         else:
             self.__errors = IonPyList.from_value(IonType.LIST, [])
     return self.__errors
Esempio n. 3
0
 def _to_ion_nature(obj):
     out = obj
     if not isinstance(out, _IonNature):
         ion_type = _ion_type(out)
         out = _FROM_ION_TYPE[ion_type].from_value(ion_type, out)
     if isinstance(out, dict):
         update = {}
         for field, value in six.iteritems(out):
             update[field] = _to_ion_nature(value)
         update = IonPyDict.from_value(out.ion_type, update, out.ion_annotations)
         out = update
     elif isinstance(out, list):
         update = []
         for value in out:
             update.append(_to_ion_nature(value))
         update = IonPyList.from_value(out.ion_type, update, out.ion_annotations)
         out = update
     return out
Esempio n. 4
0
 def _to_ion_nature(obj):
     out = obj
     if not isinstance(out, _IonNature):
         ion_type = _ion_type(out)
         out = _FROM_ION_TYPE[ion_type].from_value(ion_type, out)
     if isinstance(out, dict):
         update = {}
         for field, value in six.iteritems(out):
             update[field] = _to_ion_nature(value)
         update = IonPyDict.from_value(out.ion_type, update,
                                       out.ion_annotations)
         out = update
     elif isinstance(out, list):
         update = []
         for value in out:
             update.append(_to_ion_nature(value))
         update = IonPyList.from_value(out.ion_type, update,
                                       out.ion_annotations)
         out = update
     return out
Esempio n. 5
0
class _Expected(record('binary', 'text')):
    def __new__(cls, binary, text):
        return super(_Expected, cls).__new__(cls, (binary, ), (text, ))


def bytes_of(*args, **kwargs):
    return bytes(bytearray(*args, **kwargs))


_SIMPLE_CONTAINER_MAP = {
    IonType.LIST: (
        ([
            [],
        ], _Expected(b'\xB0', b'[]')),
        ([
            IonPyList.from_value(IonType.LIST, []),
        ], _Expected(b'\xB0', b'[]')),
        (
            [
                [0],
            ],
            _Expected(
                bytes_of([
                    0xB0 | 0x01,  # Int value 0 fits in 1 byte.
                    ION_ENCODED_INT_ZERO
                ]),
                b'[0]')),
        (
            [
                IonPyList.from_value(IonType.LIST, [0]),
            ],
Esempio n. 6
0
    def __new__(cls, binary, text):
        return super(_Expected, cls).__new__(cls, (binary,), (text,))


def bytes_of(*args, **kwargs):
    return bytes(bytearray(*args, **kwargs))


_SIMPLE_CONTAINER_MAP = {
    IonType.LIST: (
        (
            [[], ],
            _Expected(b'\xB0', b'[]')
        ),
        (
            [IonPyList.from_value(IonType.LIST, []), ],
            _Expected(b'\xB0', b'[]')
        ),
        (
            [[0], ],
            _Expected(
                bytes_of([
                    0xB0 | 0x01,  # Int value 0 fits in 1 byte.
                    ION_ENCODED_INT_ZERO
                ]),
                b'[0]'
            )
        ),
        (
            [IonPyList.from_value(IonType.LIST, [0]), ],
            _Expected(