CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
conddblib.EnumMetaclass Class Reference
Inheritance diagram for conddblib.EnumMetaclass:

Public Member Functions

def __call__
 
def __getitem__
 
def __init__
 
def __len__
 

Detailed Description

Definition at line 28 of file conddblib.py.

Constructor & Destructor Documentation

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

Definition at line 29 of file conddblib.py.

References cmsPerfStripChart.dict, and dir.

29 
30  def __init__(cls, name, bases, dct):
31  cls._members = sorted([member for member in dir(cls) if not member.startswith('_')])
32  cls._map = dict([(member, getattr(cls, member)) for member in cls._members])
33  cls._reversemap = dict([(value, key) for (key, value) in cls._map.items()])
34  super(EnumMetaclass, cls).__init__(name, bases, dct)
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 48 of file conddblib.py.

48 
49  def __call__(cls, value):
50  '''Returns the key for this value.
51  '''
52 
53  return cls._reversemap[value]
54 
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 38 of file conddblib.py.

38 
39  def __getitem__(cls, key):
40  '''Returns the value for this key (if the key is an integer,
41  the value is the nth member from the sorted members list).
42  '''
43 
44  if isinstance(key, int):
45  # for tuple() and list()
46  key = cls._members[key]
47  return cls._map[key]
def conddblib.EnumMetaclass.__len__ (   cls)

Definition at line 35 of file conddblib.py.

35 
36  def __len__(cls):
37  return len(cls._members)