test
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 33 of file conddblib.py.

Constructor & Destructor Documentation

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

Definition at line 34 of file conddblib.py.

References cmsPerfStripChart.dict, and dir.

34 
35  def __init__(cls, name, bases, dct):
36  cls._members = sorted([member for member in dir(cls) if not member.startswith('_')])
37  cls._map = dict([(member, getattr(cls, member)) for member in cls._members])
38  cls._reversemap = dict([(value, key) for (key, value) in cls._map.items()])
39  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 53 of file conddblib.py.

53 
54  def __call__(cls, value):
55  '''Returns the key for this value.
56  '''
57 
58  return cls._reversemap[value]
59 
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 43 of file conddblib.py.

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

Definition at line 40 of file conddblib.py.

40 
41  def __len__(cls):
42  return len(cls._members)