def setUp(self): self.module = pvl.PVLModule( a="b", staygroup=pvl.PVLGroup(c="d"), obj=pvl.PVLGroup(d="e", f=pvl.PVLGroup(g="h")), ) self.string = """A = b\r
def setUp(self): self.cub = data_dir / 'pattern.cub' self.cubpvl = pvl.PVLModule(IsisCube=pvl.PVLObject(Core=pvl.PVLObject( StartByte=65537, Format='Tile', TileSamples=128, TileLines=128, Dimensions=pvl.PVLGroup(Samples=90, Lines=90, Bands=1), Pixels=pvl.PVLGroup( Type='Real', ByteOrder='Lsb', Base=0.0, Multiplier=1.0))), Label=pvl.PVLObject(Bytes=65536))
def test_equlity(): assert not pvl.PVLModule() assert not pvl.PVLGroup() assert not pvl.PVLObject() assert not not pvl.PVLModule(a=1) assert not not pvl.PVLGroup(a=1) assert not not pvl.PVLObject(a=1) assert pvl.PVLModule() == pvl.PVLModule() assert pvl.PVLModule() != pvl.PVLGroup() assert pvl.PVLModule() != pvl.PVLObject() assert pvl.PVLGroup() != pvl.PVLModule() assert pvl.PVLGroup() == pvl.PVLGroup() assert pvl.PVLGroup() != pvl.PVLObject() assert pvl.PVLObject() != pvl.PVLModule() assert pvl.PVLObject() != pvl.PVLGroup() assert pvl.PVLObject() == pvl.PVLObject() assert pvl.PVLModule() != pvl.PVLModule(a=1) assert pvl.PVLModule(a=1) == pvl.PVLModule(a=1) assert pvl.PVLModule(a=1) == pvl.PVLModule([('a', 1)]) assert pvl.PVLModule(a=1) == pvl.PVLModule({'a': 1}) assert pvl.PVLModule(a=1) != pvl.PVLModule(b=1) assert pvl.PVLModule(a=1) != pvl.PVLModule(a=2)
def setUp(self): self.cub = data_dir / "pattern.cub" self.cubpvl = pvl.PVLModule( IsisCube=pvl.PVLObject( Core=pvl.PVLObject( StartByte=65537, Format="Tile", TileSamples=128, TileLines=128, Dimensions=pvl.PVLGroup(Samples=90, Lines=90, Bands=1), Pixels=pvl.PVLGroup( Type="Real", ByteOrder="Lsb", Base=0.0, Multiplier=1.0 ), ) ), Label=pvl.PVLObject(Bytes=65536), )
def create_pvl_header(self, version, headerstartbyte, networkid, targetname, description, username, buffer_header_size, points_bytes, creation_date, modified_date): """ Create the PVL header object Parameters ---------- version : int The current ISIS version to write, defaults to 2 headerstartbyte : int The seek offset that the protocol buffer header starts at networkid : str The name of the network targetname : str The name of the target, e.g. Moon description : str A description for the network. username : str The name of the user / application that created the control network buffer_header_size : int Total size of the header in bytes points_bytes : int The total number of bytes all points require Returns ------- : object An ISIS compliant PVL header object """ encoder = pvl.encoder.IsisCubeLabelEncoder header_bytes = buffer_header_size points_start_byte = HEADERSTARTBYTE + buffer_header_size header = pvl.PVLModule([( 'ProtoBuffer', ({ 'Core': { 'HeaderStartByte': headerstartbyte, 'HeaderBytes': header_bytes, 'PointsStartByte': points_start_byte, 'PointsBytes': points_bytes }, 'ControlNetworkInfo': pvl.PVLGroup([('NetworkId', networkid), ('TargetName', targetname), ('UserName', username), ('Created', creation_date), ('LastModified', modified_date), ('Description', description), ('NumberOfPoints', self.npoints), ('NumberOfMeasures', self.nmeasures), ('Version', version)]) }), )]) return pvl.dumps(header, cls=encoder)
def test_loads(self): some_pvl = ''' a = b GROUP = c c = d END_GROUP e =false END''' decoded = pvl.PVLModule(a='b', c=pvl.PVLGroup(c='d'), e=False) self.assertEqual(decoded, pvl.loads(some_pvl)) self.assertEqual(pvl.PVLModule(a='b'), pvl.loads('a=b'))
def test_loads(self): some_pvl = """ a = b GROUP = c c = d END_GROUP e =false END""" decoded = pvl.PVLModule(a="b", c=pvl.PVLGroup(c="d"), e=False) self.assertEqual(decoded, pvl.loads(some_pvl)) self.assertEqual(pvl.PVLModule(a="b"), pvl.loads("a=b"))
def setUp(self): self.module = pvl.PVLModule(a='b', staygroup=pvl.PVLGroup(c='d'), obj=pvl.PVLGroup(d='e', f=pvl.PVLGroup(g='h'))) self.string = '''A = b\r
('monty', 'python')], [2]), ('broken2.lbl', [('foo', 'bar'), ('life', EV(2))], [2]), ('broken3.lbl', [('foo', EV(1)), ('life', 42)], [1]), ('broken4.lbl', [('foo', 'bar'), ('life', EV(2)), ('monty', EV(3))], [2, 3]), ('broken5.lbl', [('foo', EV(1)), ('life', EV(2)), ('monty', 'python')], [1, 2]), ('broken6.lbl', [('foo', EV(1)), ('life', EV(1)), ('monty', EV(1))], [1, 2, 3]), ('broken7.lbl', [ ('foo', 1), ('embedded_object', pvl.PVLObject([('foo', 'bar'), ('life', EV(1))])) ], [4]), ('broken8.lbl', [ ('foo', 1), ('embedded_group', pvl.PVLGroup([('foo', 'bar'), ('life', EV(1))])) ], [4]), ('broken9.lbl', [('foo', 42), ('bar', EV(1))], [2]), ('broken10.lbl', [('foo', Units(42, 'beards')), ('cool', EV(1))], [2]), ('broken11.lbl', [('foo', EV(1)), ('cool', [Units(1, 'beards')])], [1]), ('broken12.lbl', [('strs', ['a', 'b']), ('empty', EV(2)), ('multiline', ['a', 'b'])], [2]), ('broken13.lbl', [('same', 'line'), ('no', 'problem'), ('foo', EV(1)), ('bar', EV(2))], [1, 2]), ('broken14.lbl', [('foo', 'bar'), ('weird', EV(3)), ('baz', 'bang')], [3]), ('broken15.lbl', [('foo', 'bar'), ('weird', 'comment'), ('baz', EV(4))], [4]), ('broken16.lbl', [('foo', EV(2)), ('weird', 'comment'), ('baz', 'bang')], [2]), ]) def test_broken_labels(label, expected, expected_errors):
[ ("foo", 1), ( "embedded_object", pvl.PVLObject([("foo", "bar"), ("life", EV(1))]), ), ], [4], ), ( "broken8.lbl", [ ("foo", 1), ( "embedded_group", pvl.PVLGroup([("foo", "bar"), ("life", EV(1))]), ), ], [4], ), ("broken9.lbl", [("foo", 42), ("bar", EV(1))], [2]), ("broken10.lbl", [("foo", Units(42, "beards")), ("cool", EV(1))], [2]), ( "broken11.lbl", [("foo", EV(1)), ("cool", [Units(1, "beards")])], [1], ), ( "broken12.lbl", [ ("strs", ["a", "b"]),