diff options
Diffstat (limited to 'tutorius/translator.py')
-rw-r--r-- | tutorius/translator.py | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/tutorius/translator.py b/tutorius/translator.py index 13b3c61..4f29078 100644 --- a/tutorius/translator.py +++ b/tutorius/translator.py @@ -53,10 +53,6 @@ class ResourceTranslator(object): self._probe_manager = probe_manager self._tutorial_id = tutorial_id - self._translation_mapping = {} - self._action_installed_cbs = {} - self._install_error_cbs = {} - def translate_resource(self, res_value): """ Replace the TResourceProperty in the container by their @@ -154,8 +150,8 @@ class ResourceTranslator(object): def detach(self, activity_id): self._probe_manager.detach(activity_id) - def subscribe(self, event_name, event, notification_cb, event_subscribed_cb, error_cb): - return self._probe_manager.subscribe(event_name, event, notification_cb, event_subscribed_cb, error_cb) + def subscribe(self, event, notification_cb, event_subscribed_cb, error_cb): + return self._probe_manager.subscribe(event, notification_cb, event_subscribed_cb, error_cb) def unsubscribe(self, address): return self._probe_manager.unsubscribe(address) @@ -171,19 +167,14 @@ class ResourceTranslator(object): ########################################################################### - def action_installed(self, new_action, address): - # Update the internal mapping - self._translation_mapping[address] = new_action - + def action_installed(self, action_installed_cb, address): # Callback to the upper layers to inform them that the action # was installed - action_installed_cb = self._action_installed_cbs[new_action] action_installed_cb(address) - def action_install_error(self, new_action, exception): + def action_install_error(self, install_error_cb, old_action, exception): # Warn the upper layer that the installation failed - error_cb = self._install_error_cbs[new_action] - error_cb(old_action, exception) + install_error_cb(old_action, exception) # Decorated functions def install(self, action, action_installed_cb, error_cb): @@ -194,24 +185,16 @@ class ResourceTranslator(object): # Execute the replacement self.translate(new_action) - self._action_installed_cbs[new_action] = action_installed_cb - self._install_error_cbs[new_action] = error_cb - # Send the new action to the probe manager - self._probe_manager.install(new_action, save_args(self.action_installed, new_action), - save_args(self.action_install_error, new_action)) + self._probe_manager.install(new_action, save_args(self.action_installed, action_installed_cb), + save_args(self.action_install_error, error_cb, new_action)) def update(self, action_address, newaction): translated_new_action = copy_module.deepcopy(newaction) self.translate(translated_new_action) - self._translation_mapping[action_address] = translated_new_action - self._probe_manager.update(action_address, translated_new_action, block) def uninstall(self, action_address): - if self._translation_mapping.has_key(action_address): - del self._translation_mapping[action_address] - self._probe_manager.uninstall(action_address) |