def _AddClearFieldMethod(message_descriptor, cls):
 def ClearField(self, field_name):
  try:
   field = message_descriptor.fields_by_name[field_name]
  except KeyError:
   raise ValueError(('Protocol message has no "%s" field.' % field_name))
  if (field in self._fields):
   del self._fields[field]
  self._Modified()
 cls.ClearField = ClearField

def _AddClearFieldMethod ( message_descriptor , cls ) : def ClearField ( self , field_name ) : try : field = message_descriptor . fields_by_name [ field_name ] except KeyError : raise ValueError ( ( 'Protocol message has no "%s" field.' % field_name ) ) if ( field in self . _fields ) : del self . _fields [ field ] self . _Modified ( ) cls . ClearField = ClearField
helper for _addmessagemethods() .