def parse_tree(text, strict=False):
 count = 0
 l = len(text)
 while (count < l):
  mode_end = text.index(' ', count)
  mode_text = text[count:mode_end]
  if (strict and mode_text.startswith('0')):
   raise ObjectFormatException(("Invalid mode '%s'" % mode_text))
  try:
   mode = int(mode_text, 8)
  except ValueError:
   raise ObjectFormatException(("Invalid mode '%s'" % mode_text))
  name_end = text.index('\x00', mode_end)
  name = text[(mode_end + 1):name_end]
  count = (name_end + 21)
  sha = text[(name_end + 1):count]
  if (len(sha) != 20):
   raise ObjectFormatException('Sha has invalid length')
  hexsha = sha_to_hex(sha)
  (yield (name, mode, hexsha))

def parse_tree ( text , strict = False ) : count = 0 l = len ( text ) while ( count < l ) : mode_end = text . index ( ' ' , count ) mode_text = text [ count : mode_end ] if ( strict and mode_text . startswith ( '0' ) ) : raise ObjectFormatException ( ( "Invalid mode '%s'" % mode_text ) ) try : mode = int ( mode_text , 8 ) except ValueError : raise ObjectFormatException ( ( "Invalid mode '%s'" % mode_text ) ) name_end = text . index ( '\x00' , mode_end ) name = text [ ( mode_end + 1 ) : name_end ] count = ( name_end + 21 ) sha = text [ ( name_end + 1 ) : count ] if ( len ( sha ) != 20 ) : raise ObjectFormatException ( 'Sha has invalid length' ) hexsha = sha_to_hex ( sha ) ( yield ( name , mode , hexsha ) )
parse a tree text .