def parse_ref(container, refspec):
 refspec = to_bytes(refspec)
 possible_refs = [refspec, ('refs/' + refspec), ('refs/tags/' + refspec), ('refs/heads/' + refspec), ('refs/remotes/' + refspec), (('refs/remotes/' + refspec) + '/HEAD')]
 for ref in possible_refs:
  if (ref in container):
   return ref
 else:
  raise KeyError(refspec)

def parse_ref ( container , refspec ) : refspec = to_bytes ( refspec ) possible_refs = [ refspec , ( 'refs/' + refspec ) , ( 'refs/tags/' + refspec ) , ( 'refs/heads/' + refspec ) , ( 'refs/remotes/' + refspec ) , ( ( 'refs/remotes/' + refspec ) + '/HEAD' ) ] for ref in possible_refs : if ( ref in container ) : return ref else : raise KeyError ( refspec )
parse a string referring to a reference .