def tree_to_stream(entries, write):
 ord_zero = ord('0')
 bit_mask = 7
 for (binsha, mode, name) in entries:
  mode_str = ''
  for i in xrange(6):
   mode_str = (bchr((((mode >> (i * 3)) & bit_mask) + ord_zero)) + mode_str)
  if (byte_ord(mode_str[0]) == ord_zero):
   mode_str = mode_str[1:]
  if isinstance(name, text_type):
   name = name.encode(defenc)
  write(''.join((mode_str, ' ', name, '\x00', binsha)))

def tree_to_stream ( entries , write ) : ord_zero = ord ( '0' ) bit_mask = 7 for ( binsha , mode , name ) in entries : mode_str = '' for i in xrange ( 6 ) : mode_str = ( bchr ( ( ( ( mode >> ( i * 3 ) ) & bit_mask ) + ord_zero ) ) + mode_str ) if ( byte_ord ( mode_str [ 0 ] ) == ord_zero ) : mode_str = mode_str [ 1 : ] if isinstance ( name , text_type ) : name = name . encode ( defenc ) write ( '' . join ( ( mode_str , ' ' , name , '\x00' , binsha ) ) )
write the give list of entries into a stream using its write method .