def _GetFieldByName(message_descriptor, field_name):
 try:
  return message_descriptor.fields_by_name[field_name]
 except KeyError:
  raise ValueError(('Protocol message has no "%s" field.' % field_name))

def _GetFieldByName ( message_descriptor , field_name ) : try : return message_descriptor . fields_by_name [ field_name ] except KeyError : raise ValueError ( ( 'Protocol message has no "%s" field.' % field_name ) )
returns a field descriptor by field name .