Base class for all configurable instances.
Definition at line 145 of file _configurables.py.
◆ __init__()
def GaudiConfig2._configurables.Configurable.__init__ |
( |
|
self, |
|
|
|
name = None , |
|
|
** |
kwargs |
|
) |
| |
Definition at line 152 of file _configurables.py.
152 def __init__(self, name=None, **kwargs):
154 self._properties = {}
155 if "parent" in kwargs:
156 parent = kwargs.pop(
"parent")
157 if isinstance(parent, basestring
if sys.version_info[0] == 2
else str):
158 parent = self.instances[parent]
160 raise TypeError(
"name is needed when a parent is specified")
161 name =
"{}.{}".
format(parent.name, name)
164 elif not _GLOBAL_INSTANCES:
165 self.name = self.__cpp_type__
166 for key, value
in kwargs.items():
167 setattr(self, key, value)
◆ __getstate__()
def GaudiConfig2._configurables.Configurable.__getstate__ |
( |
|
self | ) |
|
Definition at line 220 of file _configurables.py.
220 def __getstate__(self):
221 state = {
"properties": self._properties}
223 state[
"name"] = self.name
224 except AttributeError:
◆ __opt_properties__()
def GaudiConfig2._configurables.Configurable.__opt_properties__ |
( |
|
self, |
|
|
|
explicit_defaults = False |
|
) |
| |
Definition at line 238 of file _configurables.py.
238 def __opt_properties__(self, explicit_defaults=False):
241 for p
in self._descriptors.values():
242 if explicit_defaults
or p.__is_set__(self,
type(self)):
243 out[
".".join([name, p.name])] =
opt_repr(
244 p.__opt_value__(self,
type(self))
◆ __opt_value__()
def GaudiConfig2._configurables.Configurable.__opt_value__ |
( |
|
self | ) |
|
Definition at line 233 of file _configurables.py.
233 def __opt_value__(self):
234 if self.__cpp_type__ == self.name:
235 return self.__cpp_type__
236 return "{}/{}".
format(self.__cpp_type__, self.name)
◆ __repr__()
def GaudiConfig2._configurables.Configurable.__repr__ |
( |
|
self | ) |
|
Definition at line 211 of file _configurables.py.
214 args.append(repr(self.name))
215 except AttributeError:
217 args.extend(
"{}={!r}".
format(*item)
for item
in self._properties.
items())
218 return "{}({})".
format(
type(self).__name__,
", ".join(args))
◆ __setstate__()
def GaudiConfig2._configurables.Configurable.__setstate__ |
( |
|
self, |
|
|
|
state |
|
) |
| |
Definition at line 228 of file _configurables.py.
228 def __setstate__(self, state):
230 self.name = state.get(
"name")
231 self._properties = state[
"properties"]
◆ getDefaultProperties()
def GaudiConfig2._configurables.Configurable.getDefaultProperties |
( |
|
cls | ) |
|
Definition at line 269 of file _configurables.py.
269 def getDefaultProperties(cls):
270 return {k: v.default
for k, v
in cls._descriptors.
items()}
◆ getDefaultProperty()
def GaudiConfig2._configurables.Configurable.getDefaultProperty |
( |
|
cls, |
|
|
|
name |
|
) |
| |
Definition at line 273 of file _configurables.py.
273 def getDefaultProperty(cls, name):
274 return cls._descriptors[name].default
◆ getFullJobOptName()
def GaudiConfig2._configurables.Configurable.getFullJobOptName |
( |
|
self | ) |
|
Definition at line 262 of file _configurables.py.
262 def getFullJobOptName(self):
263 return "{}/{}".
format(self.__cpp_type__, self.name)
◆ getGaudiType()
def GaudiConfig2._configurables.Configurable.getGaudiType |
( |
|
cls | ) |
|
Definition at line 252 of file _configurables.py.
252 def getGaudiType(cls):
253 return cls.__component_type__
◆ getInstance()
def GaudiConfig2._configurables.Configurable.getInstance |
( |
|
cls, |
|
|
|
name |
|
) |
| |
◆ getName()
def GaudiConfig2._configurables.Configurable.getName |
( |
|
self | ) |
|
◆ getType()
def GaudiConfig2._configurables.Configurable.getType |
( |
|
cls | ) |
|
◆ is_property_set()
def GaudiConfig2._configurables.Configurable.is_property_set |
( |
|
self, |
|
|
|
propname |
|
) |
| |
Definition at line 248 of file _configurables.py.
248 def is_property_set(self, propname):
249 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 276 of file _configurables.py.
276 def merge(self, other):
278 Merge the properties of the other instance into the current one.
280 The two instances have to be of the same type, have the same name
281 (or both unnamed) and the settings must be mergable (according to
288 "cannot merge instance of {} into an instance of {}".
format(
289 type(other).__name__,
type(self).__name__
292 if hasattr(self,
"name") != hasattr(other,
"name"):
293 raise ValueError(
"cannot merge a named configurable with an unnamed one")
294 if hasattr(self,
"name")
and (self.name != other.name):
296 "cannot merge configurables with different names ({} and {})".
format(
297 self.name, other.name
301 for name
in other._properties:
303 name
in self._properties
304 and self._properties[name] == other._properties[name]
311 self._descriptors[name].__merge__(
312 self,
type(self), getattr(other, name)
315 except ValueError
as err:
317 "conflicting settings for property {} of {}: {}".
format(
319 self.name
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 203 of file _configurables.py.
204 if _GLOBAL_INSTANCES:
206 del self.instances[self.name]
209 raise TypeError(
"name attribute cannot be deleted")
◆ name() [3/3]
def GaudiConfig2._configurables.Configurable.name |
( |
|
self, |
|
|
|
value |
|
) |
| |
Definition at line 182 of file _configurables.py.
182 def name(self, value):
183 if value == self._name:
186 not isinstance(value, basestring
if sys.version_info[0] == 2
else str)
190 "expected string, got {} instead".
format(
type(value).__name__)
192 if _GLOBAL_INSTANCES:
193 if value
in self.instances:
194 raise ValueError(
"name {!r} already used".
format(value))
195 if self._name
in self.instances:
196 del self.instances[self._name]
198 self.instances[value] = self
◆ toStringProperty()
def GaudiConfig2._configurables.Configurable.toStringProperty |
( |
|
self | ) |
|
Definition at line 265 of file _configurables.py.
265 def toStringProperty(self):
266 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: