1
# Copyright 2012 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Enumeration helpers."""
6
from __future__ import (
18
def map_enum(enum_class):
19
"""Map out an enumeration class as a "NAME: value" dict."""
20
# Filter out anything that starts with '_', which covers private and
21
# special methods. We can make this smarter later if we start using
22
# a smarter enumeration base class etc. Or if we switch to a proper
23
# enum mechanism, this function will act as a marker for pieces of
24
# code that should be updated.
27
for key, value in vars(enum_class).items()
28
if not key.startswith('_')