language/environment: update kernel_invariants in setattr_argument and setattr_device

pull/605/head
Sebastien Bourdeauducq 2016-05-03 16:27:24 +08:00
parent 5efa5f5265
commit 136dc7039e
3 changed files with 16 additions and 6 deletions

View File

@ -40,6 +40,12 @@ unreleased [2.x]
has been replaced. Pass the parent as first argument instead.
1.0rc4 (unreleased)
-------------------
* setattr_argument and setattr_device add their key to kernel_invariants.
1.0rc3
------

View File

@ -216,8 +216,12 @@ class HasEnvironment:
def setattr_argument(self, key, processor=None, group=None):
"""Sets an argument as attribute. The names of the argument and of the
attribute are the same."""
attribute are the same.
The key is added to the instance's kernel invariants."""
setattr(self, key, self.get_argument(key, processor, group))
kernel_invariants = getattr(self, "kernel_invariants", set())
self.kernel_invariants = kernel_invariants | {key}
def get_device_db(self):
"""Returns the full contents of the device database."""
@ -229,8 +233,12 @@ class HasEnvironment:
def setattr_device(self, key):
"""Sets a device driver as attribute. The names of the device driver
and of the attribute are the same."""
and of the attribute are the same.
The key is added to the instance's kernel invariants."""
setattr(self, key, self.get_device(key))
kernel_invariants = getattr(self, "kernel_invariants", set())
self.kernel_invariants = kernel_invariants | {key}
def set_dataset(self, key, value,
broadcast=False, persist=False, save=True):

View File

@ -83,8 +83,6 @@ class ClockGeneratorLoopback(EnvExperiment):
class PulseRate(EnvExperiment):
kernel_invariants = {"core", "ttl_out"}
def build(self):
self.setattr_device("core")
self.setattr_device("ttl_out")
@ -107,8 +105,6 @@ class PulseRate(EnvExperiment):
class PulseRateDDS(EnvExperiment):
kernel_invariants = {"core", "core_dds", "dds0", "dds1"}
def build(self):
self.setattr_device("core")
self.setattr_device("core_dds")