def EnumTextToValue(fdesc, enum_text):
  """Looks up the value of enum_text, given the field descriptor it came from.

  Args:
    fdesc: the descriptor of the field the enum_text belongs to.
    enum_text: the text of an enum.
  Returns:
    integer representing the enum_text
  """
  # descriptor.py
  return fdesc.enum_type.values_by_name[enum_text].number