CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes
genericValidation.ValidationMetaClass Class Reference
Inheritance diagram for genericValidation.ValidationMetaClass:

Public Member Functions

def __new__ (cls, clsname, bases, dct)
 

Static Public Attributes

list dicts = ["defaults"]
 
list sets = ["mandatories", "optionals", "needpackages"]
 

Detailed Description

Definition at line 11 of file genericValidation.py.

Member Function Documentation

def genericValidation.ValidationMetaClass.__new__ (   cls,
  clsname,
  bases,
  dct 
)

Definition at line 14 of file genericValidation.py.

References genericValidation.ValidationMetaClass.dicts, genericValidation.ValidationMetaClass.sets, and update.

Referenced by SequenceTypes._ModuleSequenceType.copyAndExclude().

14  def __new__(cls, clsname, bases, dct):
15  for setname in cls.sets:
16  if setname not in dct: dct[setname] = set()
17  dct[setname] = set.union(dct[setname], *(getattr(base, setname) for base in bases if hasattr(base, setname)))
18 
19  for dictname in cls.dicts:
20  if dictname not in dct: dct[dictname] = {}
21  for base in bases:
22  if not hasattr(base, dictname): continue
23  newdict = getattr(base, dictname)
24  for key in set(newdict) & set(dct[dictname]):
25  if newdict[key] != dct[dictname][key]:
26  raise ValueError("Inconsistent values of defaults[{}]: {}, {}".format(key, newdict[key], dct[dictname][key]))
27  dct[dictname].update(newdict)
28 
29  for setname in cls.sets: #e.g. removemandatories, used in preexistingvalidation
30  #use with caution
31  if "remove"+setname not in dct: dct["remove"+setname] = set()
32  dct["remove"+setname] = set.union(dct["remove"+setname], *(getattr(base, "remove"+setname) for base in bases if hasattr(base, "remove"+setname)))
33 
34  dct[setname] -= dct["remove"+setname]
35 
36  return super(ValidationMetaClass, cls).__new__(cls, clsname, bases, dct)
37 
def __new__(cls, clsname, bases, dct)
#define update(a, b)

Member Data Documentation

list genericValidation.ValidationMetaClass.dicts = ["defaults"]
static

Definition at line 13 of file genericValidation.py.

Referenced by genericValidation.ValidationMetaClass.__new__().

list genericValidation.ValidationMetaClass.sets = ["mandatories", "optionals", "needpackages"]
static

Definition at line 12 of file genericValidation.py.

Referenced by genericValidation.ValidationMetaClass.__new__().