parameters: (self, enumname, required)
docstring: Mark an enum as required or not.
  
          - enumname - name of enum
          - required - boolean (to tag features as required or not)
docstring_summary: Mark an enum as required or not.
docstring_tokens: Mark an enum as required or not .
function: def markEnumRequired(self, enumname, required):
          """Mark an enum as required or not.
  
          - enumname - name of enum
          - required - boolean (to tag features as required or not)"""
  
          self.gen.logMsg('diag', 'markEnumRequired: tagging enum:', enumname, '-> required =', required)
          enum = self.lookupElementInfo(enumname, self.enumdict)
          if enum is not None:
              # If the enum is part of a group, and is being removed, then
              # look it up in that <enums> tag and remove the Element there,
              # so that it is not visible to generators (which traverse the
              # <enums> tag elements rather than using the dictionaries).
              if not required:
                  groupName = enum.elem.get('extends')
                  if groupName is not None:
                      self.gen.logMsg('diag', f'markEnumRequired: Removing extending enum {enum.elem.get("name")}')
  
                      # Look up the Info with matching groupName
                      if groupName in self.groupdict:
                          gi = self.groupdict[groupName]
                          gienum = gi.elem.find("enum[@name='" + enumname + "']")
                          if gienum is not None:
                              # Remove copy of this enum from the group
                              gi.elem.remove(gienum)
                          else:
                              self.gen.logMsg('warn', 'markEnumRequired: Cannot remove enum',
                                              enumname, 'not found in group',
                                              groupName)
                      else:
                          self.gen.logMsg('warn', 'markEnumRequired: Cannot remove enum',
                                          enumname, 'from nonexistent group',
                                          groupName)
                  else:
                      # This enum is not an extending enum.
                      # The XML tree must be searched for all <enums> that
                      # might have it, so we know the parent to delete from.
  
                      enumName = enum.elem.get('name')
  
                      self.gen.logMsg('diag', f'markEnumRequired: Removing non-extending enum {enumName}')
  
                      count = 0
                      for enums in self.reg.findall('enums'):
                          for thisEnum in enums.findall('enum'):
                              if thisEnum.get('name') == enumName:
                                  # Actually remove it
                                  count = count + 1
                                  enums.remove(thisEnum)
  
                      if count == 0:
                          self.gen.logMsg('warn', f'markEnumRequired: {enumName}) not found in any <enums> tag')
  
              enum.required = required
              # Tag enum dependencies in 'alias' attribute as required
              depname = enum.elem.get('alias')
              if depname:
                  self.gen.logMsg('diag', 'markEnumRequired: Generating dependent enum',
                                  depname, 'for alias', enumname, 'required =', enum.required)
                  self.markEnumRequired(depname, required)
          else:
              self.gen.logMsg('warn', f'markEnumRequired: {enumname} IS NOT DEFINED')
function_tokens: def markEnumRequired ( self , enumname , required ) : self . gen . logMsg ( 'diag' , 'markEnumRequired: tagging enum:' , enumname , '-> required =' , required ) enum = self . lookupElementInfo ( enumname , self . enumdict ) if enum is not None : # If the enum is part of a group, and is being removed, then # look it up in that <enums> tag and remove the Element there, # so that it is not visible to generators (which traverse the # <enums> tag elements rather than using the dictionaries). if not required : groupName = enum . elem . get ( 'extends' ) if groupName is not None : self . gen . logMsg ( 'diag' , f'markEnumRequired: Removing extending enum {enum.elem.get("name")}' ) # Look up the Info with matching groupName if groupName in self . groupdict : gi = self . groupdict [ groupName ] gienum = gi . elem . find ( "enum[@name='" + enumname + "']" ) if gienum is not None : # Remove copy of this enum from the group gi . elem . remove ( gienum ) else : self . gen . logMsg ( 'warn' , 'markEnumRequired: Cannot remove enum' , enumname , 'not found in group' , groupName ) else : self . gen . logMsg ( 'warn' , 'markEnumRequired: Cannot remove enum' , enumname , 'from nonexistent group' , groupName ) else : # This enum is not an extending enum. # The XML tree must be searched for all <enums> that # might have it, so we know the parent to delete from. enumName = enum . elem . get ( 'name' ) self . gen . logMsg ( 'diag' , f'markEnumRequired: Removing non-extending enum {enumName}' ) count = 0 for enums in self . reg . findall ( 'enums' ) : for thisEnum in enums . findall ( 'enum' ) : if thisEnum . get ( 'name' ) == enumName : # Actually remove it count = count + 1 enums . remove ( thisEnum ) if count == 0 : self . gen . logMsg ( 'warn' , f'markEnumRequired: {enumName}) not found in any <enums> tag' ) enum . required = required # Tag enum dependencies in 'alias' attribute as required depname = enum . elem . get ( 'alias' ) if depname : self . gen . logMsg ( 'diag' , 'markEnumRequired: Generating dependent enum' , depname , 'for alias' , enumname , 'required =' , enum . required ) self . markEnumRequired ( depname , required ) else : self . gen . logMsg ( 'warn' , f'markEnumRequired: {enumname} IS NOT DEFINED' )