6 Class decorator to create a flag handler for a plugin. Adds the class variables FLAGDEFS and
7 ErrEnum. An instance variable flagHandler is added to the __init__ function to be created at
8 initialization. The arguments to this function are tuples which have the name of the failure
9 as the first element, and the documentation for the failure as the second element.
12 @addFlagHandler(("name_of_failure", "Doc for failure), ("name_of_second_faiure", "Doc of"
13 " second failure"), .....)
15 def classFactory(cls):
18 names = [entry[0]
for entry
in args]
19 if len(names) != len(set(names)):
20 raise ValueError(
"All flag names must be unique, given {}".format(names))
23 cls.ErrEnum = type(
'ErrEnum', (), {entry.name: i
for i, entry
in enumerate(cls.FLAGDEFS)})
24 oldInit = cls.__init__
26 def newInit(self, *args, **kwargs):
27 if 'schema' in kwargs:
28 schema = kwargs[
'schema']
35 self.flagHandler = FlagHandler.addFields(schema, name, self.FLAGDEFS)
36 oldInit(self, *args, **kwargs)
37 cls.__init__ = newInit
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...