Base class for all configurable instances.
Definition at line 138 of file _configurables.py.
◆ __init__()
| def GaudiConfig2._configurables.Configurable.__init__ |
( |
|
self, |
|
|
|
name = None, |
|
|
** |
kwargs |
|
) |
| |
Definition at line 144 of file _configurables.py.
144 def __init__(self, name=None, **kwargs):
146 self._properties = {}
147 if 'parent' in kwargs:
148 parent = kwargs.pop(
'parent')
149 if isinstance(parent,
150 basestring
if sys.version_info[0] == 2
else str):
151 parent = self.instances[parent]
153 raise TypeError(
'name is needed when a parent is specified')
154 name =
'{}.{}'.
format(parent.name, name)
157 elif not _GLOBAL_INSTANCES:
158 self.name = self.__cpp_type__
159 for key, value
in kwargs.items():
160 setattr(self, key, value)
◆ __getstate__()
| def GaudiConfig2._configurables.Configurable.__getstate__ |
( |
|
self | ) |
|
Definition at line 210 of file _configurables.py.
210 def __getstate__(self):
211 state = {
'properties': self._properties}
213 state[
'name'] = self.name
214 except AttributeError:
◆ __opt_properties__()
| def GaudiConfig2._configurables.Configurable.__opt_properties__ |
( |
|
self, |
|
|
|
explicit_defaults = False |
|
) |
| |
Definition at line 228 of file _configurables.py.
228 def __opt_properties__(self, explicit_defaults=False):
231 for p
in self._descriptors.values():
232 if explicit_defaults
or p.__is_set__(self,
type(self)):
233 out[
'.'.join([name, p.name])] =
opt_repr(
234 p.__opt_value__(self,
type(self)))
◆ __opt_value__()
| def GaudiConfig2._configurables.Configurable.__opt_value__ |
( |
|
self | ) |
|
Definition at line 223 of file _configurables.py.
223 def __opt_value__(self):
224 if self.__cpp_type__ == self.name:
225 return self.__cpp_type__
226 return '{}/{}'.
format(self.__cpp_type__, self.name)
◆ __repr__()
| def GaudiConfig2._configurables.Configurable.__repr__ |
( |
|
self | ) |
|
Definition at line 200 of file _configurables.py.
203 args.append(repr(self.name))
204 except AttributeError:
207 '{}={!r}'.
format(*item)
for item
in self._properties.
items())
208 return '{}({})'.
format(
type(self).__name__,
', '.join(args))
◆ __setstate__()
| def GaudiConfig2._configurables.Configurable.__setstate__ |
( |
|
self, |
|
|
|
state |
|
) |
| |
Definition at line 218 of file _configurables.py.
218 def __setstate__(self, state):
220 self.name = state.get(
'name')
221 self._properties = state[
'properties']
◆ getFullJobOptName()
| def GaudiConfig2._configurables.Configurable.getFullJobOptName |
( |
|
self | ) |
|
Definition at line 246 of file _configurables.py.
246 def getFullJobOptName(self):
247 return "{}/{}".
format(self.__cpp_type__, self.name)
◆ getGaudiType()
| def GaudiConfig2._configurables.Configurable.getGaudiType |
( |
|
self | ) |
|
Definition at line 240 of file _configurables.py.
240 def getGaudiType(self):
241 return self.__component_type__
◆ getInstance()
| def GaudiConfig2._configurables.Configurable.getInstance |
( |
|
cls, |
|
|
|
name |
|
) |
| |
◆ getName()
| def GaudiConfig2._configurables.Configurable.getName |
( |
|
self | ) |
|
◆ is_property_set()
| def GaudiConfig2._configurables.Configurable.is_property_set |
( |
|
self, |
|
|
|
propname |
|
) |
| |
Definition at line 237 of file _configurables.py.
237 def is_property_set(self, propname):
238 return self._descriptors[propname].__is_set__(self,
type(self))
◆ merge()
| def GaudiConfig2._configurables.Configurable.merge |
( |
|
self, |
|
|
|
other |
|
) |
| |
Merge the properties of the other instance into the current one.
The two instances have to be of the same type, have the same name
(or both unnamed) and the settings must be mergable (according to
their semantics).
Definition at line 252 of file _configurables.py.
252 def merge(self, other):
254 Merge the properties of the other instance into the current one.
256 The two instances have to be of the same type, have the same name
257 (or both unnamed) and the settings must be mergable (according to
262 'cannot merge instance of {} into an instance of {}'.
format(
263 type(other).__name__,
264 type(self).__name__))
265 if hasattr(self,
'name') != hasattr(other,
'name'):
267 'cannot merge a named configurable with an unnamed one')
268 if hasattr(self,
'name')
and (self.name != other.name):
270 'cannot merge configurables with different names ({} and {})'.
271 format(self.name, other.name))
273 for name
in other._descriptors:
274 if not other.is_property_set(name):
278 self, name, self._descriptors[name].__merge__(
279 self,
type(self), getattr(other, name)))
280 except ValueError
as err:
282 'conflicting settings for property {} of {}: {}'.
format(
284 if hasattr(self,
'name')
else type(self).__name__,
◆ name() [1/3]
| def GaudiConfig2._configurables.Configurable.name |
( |
|
self | ) |
|
◆ name() [2/3]
| def GaudiConfig2._configurables.Configurable.name |
( |
|
self | ) |
|
Definition at line 192 of file _configurables.py.
193 if _GLOBAL_INSTANCES:
195 del self.instances[self.name]
198 raise TypeError(
'name attribute cannot be deleted')
◆ name() [3/3]
| def GaudiConfig2._configurables.Configurable.name |
( |
|
self, |
|
|
|
value |
|
) |
| |
Definition at line 174 of file _configurables.py.
174 def name(self, value):
175 if value == self._name:
177 if not isinstance(value, basestring
178 if sys.version_info[0] == 2
else str)
or not value:
179 raise TypeError(
'expected string, got {} instead'.
format(
180 type(value).__name__))
181 if _GLOBAL_INSTANCES:
182 if value
in self.instances:
183 raise ValueError(
'name {!r} already used'.
format(value))
184 if self._name
in self.instances:
185 del self.instances[self._name]
187 self.instances[value] = self
◆ toStringProperty()
| def GaudiConfig2._configurables.Configurable.toStringProperty |
( |
|
self | ) |
|
Definition at line 249 of file _configurables.py.
249 def toStringProperty(self):
250 return "{}/{}".
format(self.__cpp_type__, self.name)
◆ __cpp_type__
| GaudiConfig2._configurables.Configurable.__cpp_type__ |
|
private |
◆ _name
| GaudiConfig2._configurables.Configurable._name |
|
private |
◆ _properties
| GaudiConfig2._configurables.Configurable._properties |
|
private |
◆ instances
| dictionary GaudiConfig2._configurables.Configurable.instances = {} |
|
static |
◆ name
| GaudiConfig2._configurables.Configurable.name |
The documentation for this class was generated from the following file: