(self, def_dict, api, wire_name, values, descriptions, parent)
Create an enum.

    Args:
      def_dict: (dict) The discovery dictionary for this element.
      api: (Api) The Api which owns this Property
      wire_name: (str) The identifier used in the wire protocol for this enum.
      values: ([str]) List of possible values. If not provided, use the 'enum'
          element from def_dict.
      descriptions: ([str]) List of value descriptions. If not provided, use
          the 'enumDescriptions' element from def_dict.
      parent: (Method) The object owning this enum.
Create an enum.
Create an enum .
def __init__(self, def_dict, api, wire_name, values, descriptions, parent):
    """Create an enum.

    Args:
      def_dict: (dict) The discovery dictionary for this element.
      api: (Api) The Api which owns this Property
      wire_name: (str) The identifier used in the wire protocol for this enum.
      values: ([str]) List of possible values. If not provided, use the 'enum'
          element from def_dict.
      descriptions: ([str]) List of value descriptions. If not provided, use
          the 'enumDescriptions' element from def_dict.
      parent: (Method) The object owning this enum.
    """
    super(Enum, self).__init__(def_dict, api, parent=parent)
    name = def_dict.get('id') or wire_name
    self.ValidateName(name)
    self.SetTemplateValue('wireName', name)
    self.SetTemplateValue('className',
                          api.ToClassName(name, self, element_type='enum'))
    if values is None:
      values = def_dict.get('enum')
    if descriptions is None:
      descriptions = def_dict.get('enumDescriptions') or []

    self._elements = []
    for i in range(len(values)):
      v = values[i]
      # Sometimes the description list is too short.
      d = descriptions[i] if (i < len(descriptions)) else None
      self._elements.append(
          template_objects.Constant(v, description=d, parent=self))
    self.SetTemplateValue(
        'elements', self._elements,
        meaning='The individual possible values of an Enum data type.')

    # TODO(user): Migrate users away from the enum pairs to 'elements' and
    # delete the rest of this method.
    def FixName(name):
      name = name[0].isdigit() and 'VALUE_' + name or name.lstrip('@')
      return name.upper().replace('-', '_')
    names = [FixName(s) for s in values]
    def FixDescription(desc):
      return self.ValidateAndSanitizeComment(self.StripHTML(desc))
    pairs = zip(names, values, map(FixDescription, descriptions))
    self.SetTemplateValue('pairs', pairs)
def __init__ ( self , def_dict , api , wire_name , values , descriptions , parent ) : super ( Enum , self ) . __init__ ( def_dict , api , parent = parent ) name = def_dict . get ( 'id' ) or wire_name self . ValidateName ( name ) self . SetTemplateValue ( 'wireName' , name ) self . SetTemplateValue ( 'className' , api . ToClassName ( name , self , element_type = 'enum' ) ) if values is None : values = def_dict . get ( 'enum' ) if descriptions is None : descriptions = def_dict . get ( 'enumDescriptions' ) or [ ] self . _elements = [ ] for i in range ( len ( values ) ) : v = values [ i ] # Sometimes the description list is too short. d = descriptions [ i ] if ( i < len ( descriptions ) ) else None self . _elements . append ( template_objects . Constant ( v , description = d , parent = self ) ) self . SetTemplateValue ( 'elements' , self . _elements , meaning = 'The individual possible values of an Enum data type.' ) # TODO(user): Migrate users away from the enum pairs to 'elements' and # delete the rest of this method. def FixName ( name ) : name = name [ 0 ] . isdigit ( ) and 'VALUE_' + name or name . lstrip ( '@' ) return name . upper ( ) . replace ( '-' , '_' ) names = [ FixName ( s ) for s in values ] def FixDescription ( desc ) : return self . ValidateAndSanitizeComment ( self . StripHTML ( desc ) ) pairs = zip ( names , values , map ( FixDescription , descriptions ) ) self . SetTemplateValue ( 'pairs' , pairs )