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')
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')
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 calc 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
def _set_command_group_length(self): """ Once the self.command_set Dataset has been built and filled with values, this should be called to set the CommandGroupLength element value correctly. """ length = 0 # Remove CommandGroupLength from dataset to prevent it from messing # with our length calculation. # We have to use the tag value due to a bug in pydicom 1.0.0 del self.command_set[0x00000000] for ii in list(self.command_set.values()): # encode_element(elem, is_implicit_VR, is_little_endian) length += len(encode_element(ii, True, True)) # Add the CommandGroupLength element back to the dataset with the # correct value self.command_set.CommandGroupLength = length