CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
conddblib.EnumMetaclass Class Reference
Inheritance diagram for conddblib.EnumMetaclass:

Public Member Functions

def __call__ (cls, value)
 
def __getitem__ (cls, key)
 
def __init__ (cls, name, bases, dct)
 
def __len__ (cls)
 

Private Attributes

 _map
 
 _members
 
 _reversemap
 

Detailed Description

Definition at line 47 of file conddblib.py.

Constructor & Destructor Documentation

def conddblib.EnumMetaclass.__init__ (   cls,
  name,
  bases,
  dct 
)

Definition at line 48 of file conddblib.py.

48  def __init__(cls, name, bases, dct):
49  cls._members = sorted([member for member in dir(cls) if not member.startswith('_')])
50  cls._map = dict([(member, getattr(cls, member)) for member in cls._members])
51  cls._reversemap = dict([(value, key) for (key, value) in cls._map.items()])
52  super(EnumMetaclass, cls).__init__(name, bases, dct)
53 
def __init__(cls, name, bases, dct)
Definition: conddblib.py:48
dbl *** dir
Definition: mlp_gen.cc:35

Member Function Documentation

def conddblib.EnumMetaclass.__call__ (   cls,
  value 
)
Returns the key for this value.

Definition at line 67 of file conddblib.py.

References conddblib.EnumMetaclass._reversemap.

67  def __call__(cls, value):
68  '''Returns the key for this value.
69  '''
70 
71  return cls._reversemap[value]
72 
73 
def __call__(cls, value)
Definition: conddblib.py:67
def conddblib.EnumMetaclass.__getitem__ (   cls,
  key 
)
Returns the value for this key (if the key is an integer,
the value is the nth member from the sorted members list).

Definition at line 57 of file conddblib.py.

References conddblib.EnumMetaclass._map, and conddblib.EnumMetaclass._members.

57  def __getitem__(cls, key):
58  '''Returns the value for this key (if the key is an integer,
59  the value is the nth member from the sorted members list).
60  '''
61 
62  if isinstance(key, int):
63  # for tuple() and list()
64  key = cls._members[key]
65  return cls._map[key]
66 
def __getitem__(cls, key)
Definition: conddblib.py:57
def conddblib.EnumMetaclass.__len__ (   cls)

Definition at line 54 of file conddblib.py.

References conddblib.EnumMetaclass._members.

54  def __len__(cls):
55  return len(cls._members)
56 

Member Data Documentation

conddblib.EnumMetaclass._map
private

Definition at line 50 of file conddblib.py.

Referenced by conddblib.EnumMetaclass.__getitem__().

conddblib.EnumMetaclass._members
private
conddblib.EnumMetaclass._reversemap
private

Definition at line 51 of file conddblib.py.

Referenced by conddblib.EnumMetaclass.__call__().