Update Manager API: Util.enum module

Implementation of autodoc-aware Enum for Python

Classes

class UpdateManager.Util.enum.Enum(*names, **names_with_doc)

Simple autodoc-aware C-like enumeration.

All enumeration names must be upper case and may not contain spaces, see below for examples.

>>> ReturnCodes = Enum('SUCCESS', ERROR='A non-fatal error occured',
                       FATAL='A fatal error occured')
>>> ReturnCodes.SUCCESS
0

Note

When using values with docstring the values are ordered alphabetically by their name. This is caused by how the dict type works.

class UpdateManager.Util.enum.NegativeEnum(*names, **names_with_doc)

Simple autodoc-aware C-like negative enumeration.

The difference to Enum is that values are assigned starting at -1 downwards.

>>> NegativeCodes = Enum('UI_ERROR', negative=True,
                         BACKEND_ERROR='Backend error')
>>> NegativeCodes.UI_ERROR
-1

Table Of Contents

Previous topic

Update Manager API: Util module

Next topic

Update Manager API: Util.humanize module

This Page