MECO™ API Reference
Public Member Functions | List of all members
mCore.enumAbs.Enum Class Reference

[ ABSTRACT CLASS ] - Abstract class for enum classes. More...

Inheritance diagram for mCore.enumAbs.Enum:
mApplication.parentApplicationLib.Application mApplication.parentApplicationLib.DeveloperApplication mCore.displayLib.ColorName mCore.displayLib.DarwinColor mCore.displayLib.LinuxColor mCore.displayLib.WindowsColor mCore.displayLib.WindowsLegacyColor mCore.platformLib.Name mDeveloper.enumLib.DeveloperModuleAttribute mMecoSettings.enumLib.AppFileAttribute mProcess.dataLib.DisplayMessage mProcess.dataLib.RunLevel mProcess.dataLib.RunMode mQtWidgets.iconLib.AnimatedIcon mQtWidgets.iconLib.ColorScheme mQtWidgets.iconLib.CommonIcon mQtWidgets.iconLib.DotIcon mQtWidgets.iconLib.EditMenuIcon mQtWidgets.iconLib.FeedbackIcon mQtWidgets.iconLib.FileExtensionIcon mQtWidgets.iconLib.FileMenuIcon mQtWidgets.iconLib.HelpMenuIcon mQtWidgets.iconLib.LanguageIcon mQtWidgets.iconLib.MediaIcon mQtWidgets.iconLib.PlatformIcon mQtWidgets.iconLib.SplitterIcon mQtWidgets.iconLib.TabMenuIcon

Public Member Functions

def listAttributes (cls, stringOnly=True, getValues=True, removeK=True, startAttrNamesLower=False)
 List static public attributes of the class. More...
 
def listAttributeElements (cls, attribute)
 List elements of a static public attribute. More...
 
def getAttributeNameFromValue (cls, value, removeK=True, defaultAttributeName=None, startLower=False)
 Get the name of the attribute for given value. More...
 
def getValueFromAttributeName (cls, attribute, removeK=False, defaultValue=None)
 Get value from attribute name. More...
 
def asDict (cls, removeK=True)
 Get all the attributes and their values in a dict instance. More...
 

Detailed Description

[ ABSTRACT CLASS ] - Abstract class for enum classes.

import sys
class Type(Enum):
kPublished = 'published'
kWIP = 'wip'
kProduct = 'product'
for a, v in zip(Type.listAttributes(False, False, False), Type.listAttributes(True, True, True, False)):
sys.stdout.write(a, '-', v)
#kProduct - product
#kPublished - published
#kWIP - wip
sys.stdout.write(Type.getAttributeNameFromValue('product', removeK=False))
#kProduct
sys.stdout.write(Type.getValueFromAttributeName('kProduct'))
#product
sys.stdout.write(Type.asDict())
#{'Product': 'product', 'WIP': 'wip', 'Published': 'published'}

Member Function Documentation

◆ listAttributes()

def mCore.enumAbs.Enum.listAttributes (   cls,
  stringOnly = True,
  getValues = True,
  removeK = True,
  startAttrNamesLower = False 
)

List static public attributes of the class.

Parameters
cls[ object | None | in ] - Class object.
stringOnly[ bool | True | in ] - List attributes only with string values.
getValues[ bool | True | in ] - Get values of the attributes instead of their names.
removeK[ bool | True | in ] - Remove k character from the attribute names if getValues is provided False.
startAttrNamesLower[ bool | False | in ] - Start attribute names with lower case.
Exceptions
N/A
Returns
list of str - Names or values of the attributes.

Reimplemented in mApplication.parentApplicationLib.Application.

◆ listAttributeElements()

def mCore.enumAbs.Enum.listAttributeElements (   cls,
  attribute 
)

List elements of a static public attribute.

Parameters
cls[ object | None | in ] - Class object.
attribute[ str | None | in ] - Name of the attribute.
Exceptions
N/A
Returns
list - Elements.
None - If given attribute doesn't exist.

◆ getAttributeNameFromValue()

def mCore.enumAbs.Enum.getAttributeNameFromValue (   cls,
  value,
  removeK = True,
  defaultAttributeName = None,
  startLower = False 
)

Get the name of the attribute for given value.

Parameters
cls[ object | None | in ] - Class object.
value[ None | None | in ] - Value.
removeK[ bool | True | in ] - Remove k character from the name of the attribute.
defaultAttributeName[ None | None | in ] - Default value to return if given value doesn't exist.
startLower[ bool | False | in ] - Start attribute names with lower case.
Exceptions
N/A
Returns
str - Attribute name.
variant - If given value doesn't exist based on provided value for defaultAttributeName argument.

◆ getValueFromAttributeName()

def mCore.enumAbs.Enum.getValueFromAttributeName (   cls,
  attribute,
  removeK = False,
  defaultValue = None 
)

Get value from attribute name.

Parameters
cls[ object | None | in ] - Class object.
attribute[ str | None | in ] - Name of the attribute.
removeK[ bool | False | in ] - Remove k character from the name of the attribute.
defaultValue[ None | None | in ] - Default value to return if requested value doesn't exist.
Exceptions
N/A
Returns
variant - Value.
variant - If given attribute doesn't exist based on provided value for defaultValue argument.

◆ asDict()

def mCore.enumAbs.Enum.asDict (   cls,
  removeK = True 
)

Get all the attributes and their values in a dict instance.

Parameters
cls[ object | None | in ] - Class object.
removeK[ bool | True | in ] - Remove k characters from the name of the attributes.
Exceptions
N/A
Returns
dict - Instance of dict object that contains attributes and their values.

The documentation for this class was generated from the following file: