def long2raw(value, endian, size=None):
 assert (((not size) and (0 < value)) or (0 <= value))
 assert (endian in (LITTLE_ENDIAN, BIG_ENDIAN))
 text = []
 while ((value != 0) or (text == '')):
  byte = (value % 256)
  text.append(chr(byte))
  value >>= 8
 if size:
  need = max((size - len(text)), 0)
 else:
  need = 0
 if need:
  if (endian is BIG_ENDIAN):
   text = chain(repeat('\x00', need), reversed(text))
  else:
   text = chain(text, repeat('\x00', need))
 elif (endian is BIG_ENDIAN):
  text = reversed(text)
 return ''.join(text)

def long2raw ( value , endian , size = None ) : assert ( ( ( not size ) and ( 0 < value ) ) or ( 0 <= value ) ) assert ( endian in ( LITTLE_ENDIAN , BIG_ENDIAN ) ) text = [ ] while ( ( value != 0 ) or ( text == '' ) ) : byte = ( value % 256 ) text . append ( chr ( byte ) ) value >>= 8 if size : need = max ( ( size - len ( text ) ) , 0 ) else : need = 0 if need : if ( endian is BIG_ENDIAN ) : text = chain ( repeat ( '\x00' , need ) , reversed ( text ) ) else : text = chain ( text , repeat ( '\x00' , need ) ) elif ( endian is BIG_ENDIAN ) : text = reversed ( text ) return '' . join ( text )
convert a number to a raw string .