예제 #1
0
 def test_implicit_little(self):
     """Test encoding using implicit VR little endian."""
     elem = DataElement(0x00100010, 'PN', 'CITIZEN^Snips')
     bytestring = encode_element(elem, True, True)
     assert bytestring == (b'\x10\x00\x10\x00\x0e\x00\x00\x00\x43'
                           b'\x49\x54\x49\x5a\x45\x4e\x5e\x53\x6e'
                           b'\x69\x70\x73\x20')
예제 #2
0
 def test_explicit_little(self):
     """Test encoding using explicit VR little endian."""
     elem = DataElement(0x00100010, 'PN', 'CITIZEN^Snips')
     bytestring = encode_element(elem, False, True)
     self.assertEqual(bytestring, b'\x10\x00\x10\x00\x50\x4e\x0e\x00\x43' \
                                  b'\x49\x54\x49\x5a\x45\x4e\x5e\x53\x6e' \
                                  b'\x69\x70\x73\x20')
예제 #3
0
 def test_explicit_big(self):
     """Test encoding using explicit VR big endian."""
     elem = DataElement(0x00100010, 'PN', 'CITIZEN^Snips')
     bytestring = encode_element(elem, False, False)
     assert bytestring == (b'\x00\x10\x00\x10\x50\x4e\x00\x0e\x43'
                           b'\x49\x54\x49\x5a\x45\x4e\x5e\x53\x6e'
                           b'\x69\x70\x73\x20')
예제 #4
0
    def _set_command_group_length(self):
        """Reset the Command Group Length element value.

        Once the self.command_set Dataset has been built and filled with values,
        this should be called to set the CommandGroupLength element value
        correctly.
        """
        # Remove CommandGroupLength to stop it messing up the length calculation
        del self.command_set.CommandGroupLength

        length = 0
        for elem in self.command_set:
            # The Command Set is always Implicit VR Little Endian
            length += len(encode_element(elem, True, True))

        self.command_set.CommandGroupLength = length