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

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

Inheritance diagram for mMeco.core.enumAbs.Enum:
mFileSystem.versionLib.Version mMeco.core.displayLib.ColorName mMeco.core.displayLib.DarwinColor mMeco.core.displayLib.LinuxColor mMeco.core.displayLib.WindowsColor mMeco.core.displayLib.WindowsLegacyColor mMeco.core.platformLib.Name mMeco.fileSystem.versionLib.Version mMeco.libs.enumLib.ColorName mMeco.libs.enumLib.EnvEntryContainerType mMeco.libs.enumLib.EnvEntryType mMeco.libs.enumLib.EnvPackageType mMeco.libs.enumLib.EnvType mMeco.libs.enumLib.ProjectFolderStructure mMeco.operators.appFileOpt.AppFileAttribute mMecoPackage.enumLib.PackageFile mMecoPackage.enumLib.PackageFolderName mMecoPackage.enumLib.PackageFolderStructure mMecoPackage.enumLib.PackageInfoModuleAttribute mMecoPackage.enumLib.PackagePythonFileSuffix

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 mMeco.core.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.

◆ listAttributeElements()

def mMeco.core.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 mMeco.core.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 mMeco.core.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 mMeco.core.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: