pymensago/keycard.py
def make_bytestring(self, signature_level : int) -> bytes:
		'''Creates a byte string from the fields in the keycard. Because this doesn't use join(), 
		it is not affected by Python's line ending handling, which is critical in ensuring that 
		signatures are not invalidated. The parameter, signature_level, specifies how many 
		signatures to include. Passing a negative number specifies all signatures.'''
		lines = list()
		if self.type:
			lines.append(b':'.join([b'Type', self.type.encode()]))

		for field in self.field_names:
			if field in self.fields and self.fields[field]:
				lines.append(b':'.join([field.encode(), self.fields[field].encode()]))
		
		if signature_level > len(self.signature_info) or signature_level < 0:
			signature_level = self.signature_info[-1]['level']
		
		sig_names = [x['name'] for x in self.signature_info]
		for i in range(signature_level):
			name = sig_names[i]
			if self.signature_info[i]['type'] == SIGINFO_HASH:
				if self.prev_hash:
					lines.append(b'Previous-Hash:%s' % self.prev_hash.encode())
				if self.hash:
					lines.append(b'Hash:%s' % self.hash.encode())
			elif name in self.signatures and self.signatures[name]:
				lines.append(b''.join([name.encode() + b'-Signature:',
								self.signatures[name].encode()]))

		lines.append(b'')
		return b'\r\n'.join(lines)
Creates a byte string from the fields in the keycard. Because this doesn't use join(), 
		it is not affected by Python's line ending handling, which is critical in ensuring that 
		signatures are not invalidated. The parameter, signature_level, specifies how many 
		signatures to include. Passing a negative number specifies all signatures.
Creates a byte string from the fields in the keycard. Because this doesn't use join(),
it is not affected by Python's line ending handling, which is critical in ensuring that
signatures are not invalidated. The parameter, signature_level, specifies how many
signatures to include. Passing a negative number specifies all signatures.
Creates a byte string from the fields in the keycard . Because this doesn ' t use join () it is not affected by Python ' s line ending handling which is critical in ensuring that signatures are not invalidated . The parameter signature_level specifies how many signatures to include . Passing a negative number specifies all signatures .
def make_bytestring(self, signature_level : int) -> bytes:
		lines = list()
		if self.type:
			lines.append(b':'.join([b'Type', self.type.encode()]))
		for field in self.field_names:
			if field in self.fields and self.fields[field]:
				lines.append(b':'.join([field.encode(), self.fields[field].encode()]))
		if signature_level > len(self.signature_info) or signature_level < 0:
			signature_level = self.signature_info[-1]['level']
		sig_names = [x['name'] for x in self.signature_info]
		for i in range(signature_level):
			name = sig_names[i]
			if self.signature_info[i]['type'] == SIGINFO_HASH:
				if self.prev_hash:
					lines.append(b'Previous-Hash:%s' % self.prev_hash.encode())
				if self.hash:
					lines.append(b'Hash:%s' % self.hash.encode())
			elif name in self.signatures and self.signatures[name]:
				lines.append(b''.join([name.encode() + b'-Signature:',
								self.signatures[name].encode()]))
		lines.append(b'')
		return b'\r\n'.join(lines)
def make_bytestring ( self , signature_level : int ) -> bytes : lines = list ( ) if self . type : lines . append ( b':' . join ( [ b'Type' , self . type . encode ( ) ] ) ) for field in self . field_names : if field in self . fields and self . fields [ field ] : lines . append ( b':' . join ( [ field . encode ( ) , self . fields [ field ] . encode ( ) ] ) ) if signature_level > len ( self . signature_info ) or signature_level < 0 : signature_level = self . signature_info [ - 1 ] [ 'level' ] sig_names = [ x [ 'name' ] for x in self . signature_info ] for i in range ( signature_level ) : name = sig_names [ i ] if self . signature_info [ i ] [ 'type' ] == SIGINFO_HASH : if self . prev_hash : lines . append ( b'Previous-Hash:%s' % self . prev_hash . encode ( ) ) if self . hash : lines . append ( b'Hash:%s' % self . hash . encode ( ) ) elif name in self . signatures and self . signatures [ name ] : lines . append ( b'' . join ( [ name . encode ( ) + b'-Signature:' , self . signatures [ name ] . encode ( ) ] ) ) lines . append ( b'' ) return b'\r\n' . join ( lines )
Creates a byte string from the fields in the keycard.
Creates a byte string from the fields in the keycard .
'''Creates a byte string from the fields in the keycard. Because this doesn't use join(), 
		it is not affected by Python's line ending handling, which is critical in ensuring that 
		signatures are not invalidated. The parameter, signature_level, specifies how many 
		signatures to include. Passing a negative number specifies all signatures.'''
self
signature_level
int