ATLAS Offline Software
Loading...
Searching...
No Matches
python.TransformConfig.Descriptor Class Reference
Inheritance diagram for python.TransformConfig.Descriptor:
Collaboration diagram for python.TransformConfig.Descriptor:

Public Types

typedef HLT::TypeInformation::for_each_type_c< typenameEDMLIST::map, my_functor, my_result<>, my_arg< HLT::TypeInformation::get_cont, CONTAINER > >::type result

Public Member Functions

 __init__ (self, doc, default, allowedValues=None)
 __get__ (self, instance, owner)
 __set__ (self, instance, value)
 name (self)
 default (self)
 doc (self)
 help (self)
 allowedValues (self)

Protected Member Functions

 _attributeName (self, instance)
 _checkType (self, variableName, value)
 _checkValue (self, variableName, value)
 _setValue (self, variableName, value)
 _checkAllowedValues (self, variableName, allowedValues)

Private Attributes

str __name = '\"%s\"' % doc
 __doc = doc
list __allowed = []
 __default = default

Detailed Description

Base class for all fixed types, implemented as descriptors. Each instance of a specific fixed type
(a derived class) can be set either to None (to indicate no value has been set), or to a type specified
by the derived class. The type is checked by the derived class by implementing the member function
_checkType()

Definition at line 9 of file TransformConfig.py.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

Constructor & Destructor Documentation

◆ __init__()

python.TransformConfig.Descriptor.__init__ ( self,
doc,
default,
allowedValues = None )

Definition at line 15 of file TransformConfig.py.

15 def __init__(self,doc,default,allowedValues=None):
16 self.__name = '\"%s\"' % doc # Temporary name overwritten by JobConfigMetaClass
17 self.__doc = doc
18 self.__allowed = []
19 if allowedValues is not None:
20 try:
21 allowedValues.__iter__
22 except AttributeError:
23 allowedValues = [ allowedValues ]
24 varName = "%s.allowedValues" % self.__name
25 self.__allowed = self._checkAllowedValues( varName, allowedValues )
26 # allow None as a value for all types
27 if default is not None:
28 # check type and value of default
29 varName = "%s default" % self.__name
30 default = self._checkType( varName, default )
31 default = self._checkValue( varName, default )
32 self.__default = default
33

Member Function Documentation

◆ __get__()

python.TransformConfig.Descriptor.__get__ ( self,
instance,
owner )

Definition at line 34 of file TransformConfig.py.

34 def __get__(self,instance,owner):
35 if instance is None:
36 return self
37 return instance._attributeDictionary().get(self._attributeName(instance),self.__default)
38
39
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ __set__()

python.TransformConfig.Descriptor.__set__ ( self,
instance,
value )

Definition at line 40 of file TransformConfig.py.

40 def __set__(self,instance,value):
41 varName = "%s.%s" % (instance.name(), self.__name) # for error/debug printout
42 # allow None as a value for all types
43 if value is not None:
44 # do value and/or type checking and possibly change type and/or value
45 value = self._checkType(varName,value)
46 value = self._checkValue(varName,value)
47 # Do possible additional actions
48 self._setValue(varName,value)
49 instance._attributeDictionary()[self._attributeName(instance)] = value # store the value
50
51

◆ _attributeName()

python.TransformConfig.Descriptor._attributeName ( self,
instance )
protected

Definition at line 52 of file TransformConfig.py.

52 def _attributeName(self,instance):
53 return '_%s__%s' % (instance.__class__.__name__,self.__name)
54
55

◆ _checkAllowedValues()

python.TransformConfig.Descriptor._checkAllowedValues ( self,
variableName,
allowedValues )
protected

Reimplemented in python.TransformConfig.UniqueList.

Definition at line 121 of file TransformConfig.py.

121 def _checkAllowedValues(self,variableName,allowedValues):
122 # Check all allowed values
123 for v in allowedValues:
124 self._checkType(variableName,v)
125 return allowedValues
126
127
128

◆ _checkType()

python.TransformConfig.Descriptor._checkType ( self,
variableName,
value )
protected
Private helper functin to check the type of <value>. May convert to another type.
This implementation does nothing, it just returns value.
This function can be overridden in derived class to do type checking.
It should return the value (possible with new type), or raise a TransformConfigError
exception in case of problems. 

Reimplemented in python.TransformConfig.ListOfStrings, and python.TransformConfig.UniqueList.

Definition at line 82 of file TransformConfig.py.

82 def _checkType(self,variableName,value):
83 """Private helper functin to check the type of <value>. May convert to another type.
84 This implementation does nothing, it just returns value.
85 This function can be overridden in derived class to do type checking.
86 It should return the value (possible with new type), or raise a TransformConfigError
87 exception in case of problems. """
88 return value
89
90

◆ _checkValue()

python.TransformConfig.Descriptor._checkValue ( self,
variableName,
value )
protected
Private helper function to check the value of <value>. This function is
called after calling _checkType. <value> can therefore be considered to be
of the correct type.
This implementation checks that the value is one of the allowed values (if defined).
This function can be overridden in derived class to do type & additional value checking.
It has to return the value (adapted if needed) if all is OK. It has to raise
a TransformConfigError exception in case of problems.
<variableName> is the name of the variable that is being set and is typically
only used for error messages.

Reimplemented in python.TransformConfig.Float, python.TransformConfig.Integer, python.TransformConfig.String, and python.TransformConfig.UniqueList.

Definition at line 91 of file TransformConfig.py.

91 def _checkValue(self,variableName,value):
92 """Private helper function to check the value of <value>. This function is
93 called after calling _checkType. <value> can therefore be considered to be
94 of the correct type.
95 This implementation checks that the value is one of the allowed values (if defined).
96 This function can be overridden in derived class to do type & additional value checking.
97 It has to return the value (adapted if needed) if all is OK. It has to raise
98 a TransformConfigError exception in case of problems.
99 <variableName> is the name of the variable that is being set and is typically
100 only used for error messages."""
101 if self.__allowed and value not in self.__allowed:
102 raise TransformConfigError( '%s value %r is not in %s' %
103 (variableName, value, self.__allowed) )
104
105 return value
106
107

◆ _setValue()

python.TransformConfig.Descriptor._setValue ( self,
variableName,
value )
protected
Private helper function which is called when the value of the object is set.
It is called after _checkType() and _checkValue(), so the value can be
assumed to be correct.
This function can be overridden in a derived class, typically to trigger additional action
when the value is set.
In case of error, raise a TransformConfigError exception, otherwise just return.
This implementation does nothing.
<variableName> is the name of the variable that is being set and is typically
only used for error messages.

Definition at line 108 of file TransformConfig.py.

108 def _setValue(self,variableName,value):
109 """Private helper function which is called when the value of the object is set.
110 It is called after _checkType() and _checkValue(), so the value can be
111 assumed to be correct.
112 This function can be overridden in a derived class, typically to trigger additional action
113 when the value is set.
114 In case of error, raise a TransformConfigError exception, otherwise just return.
115 This implementation does nothing.
116 <variableName> is the name of the variable that is being set and is typically
117 only used for error messages."""
118 pass
119
120

◆ allowedValues()

python.TransformConfig.Descriptor.allowedValues ( self)

Definition at line 78 of file TransformConfig.py.

78 def allowedValues(self):
79 return self.__allowed
80
81

◆ default()

python.TransformConfig.Descriptor.default ( self)

Definition at line 60 of file TransformConfig.py.

60 def default(self):
61 return self.__default
62
63

◆ doc()

python.TransformConfig.Descriptor.doc ( self)
The documentation string

Definition at line 64 of file TransformConfig.py.

64 def doc(self):
65 """The documentation string"""
66 return self.__doc
67
68

◆ help()

python.TransformConfig.Descriptor.help ( self)
The help string: type, documentation and possible values

Definition at line 69 of file TransformConfig.py.

69 def help(self):
70 """The help string: type, documentation and possible values"""
71 hlp = '(%s) %s' % (self.__class__.__name__, self.__doc)
72 if self.__allowed:
73 hlp += '. Possible values: %s' % self.__allowed
74
75 return hlp
76
77

◆ name()

python.TransformConfig.Descriptor.name ( self)

Definition at line 56 of file TransformConfig.py.

56 def name(self):
57 return self.__name
58
59

Member Data Documentation

◆ __allowed

python.TransformConfig.Descriptor.__allowed = []
private

Definition at line 18 of file TransformConfig.py.

◆ __default

python.TransformConfig.Descriptor.__default = default
private

Definition at line 32 of file TransformConfig.py.

◆ __doc

python.TransformConfig.Descriptor.__doc = doc
private

Definition at line 17 of file TransformConfig.py.

◆ __name

python.TransformConfig.Descriptor.__name = '\"%s\"' % doc
private

Definition at line 16 of file TransformConfig.py.


The documentation for this class was generated from the following file: