diff options
Diffstat (limited to 'tutorius/translator.py')
-rw-r--r-- | tutorius/translator.py | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/tutorius/translator.py b/tutorius/translator.py index 9925346..4e3e88d 100644 --- a/tutorius/translator.py +++ b/tutorius/translator.py @@ -20,9 +20,9 @@ import copy logger = logging.getLogger("ResourceTranslator") -from sugar.tutorius.properties import * +from .properties import * # TODO : Uncomment this line upon integration with the Vault -##from sugar.tutorius.vault import * +from .vault import Vault class ResourceTranslator(object): """ @@ -38,7 +38,7 @@ class ResourceTranslator(object): replace it. """ - def __init__(self, probe_manager, tutorial_id, testing=False): + def __init__(self, probe_manager, tutorial_id): """ Creates a new ResourceTranslator for the given tutorial. This translator is tasked with replacing resource properties of the @@ -49,15 +49,11 @@ class ResourceTranslator(object): @param probe_manager The probe manager to decorate @param tutorial_id The ID of the current tutorial - - @param testing Triggers the usage of a fake vault for testing purposes """ self._probe_manager = probe_manager self._tutorial_id = tutorial_id - self._testing = testing - - def translate_resource(self, res_prop): + def translate_resource(self, res_value): """ Replace the TResourceProperty in the container by their runtime-defined file equivalent. Since the resources are stored @@ -66,18 +62,13 @@ class ResourceTranslator(object): to transform the resource identifier into the absolute path for the process to be able to use it properly. - @param res_prop The resource property to be translated + @param res_prop The resource property's value to be translated @return The TFileProperty corresponding to this resource, containing an absolute path to the resource """ # We need to replace the resource by a file representation - filepath = "" - # TODO : Refactor when the Vault will be available - if not self._testing: - filepath = Vault.get_resource_path(self._tutorial_id, \ - prop_object.value) - else: - filepath = "/tmp/tutorius/temp.txt" + filepath = Vault.get_resource_path(self._tutorial_id, res_value) + # Create the new file representation file_prop = TFileProperty(filepath) @@ -114,7 +105,7 @@ class ResourceTranslator(object): # Apply the translation file_prop = self.translate_resource(prop_value) # Set the property with the new value - setattr(prop_container, propname, file_prop) + prop_container.replace_property(propname, file_prop) # If the property is an addon, then its value IS a # container too - we need to translate it @@ -139,7 +130,7 @@ class ResourceTranslator(object): prop_value.append(container) # Change the list contained in the addonlist property, since # we got a copy of the list when requesting it - setattr(prop_container, propname, prop_value) + prop_container.replace_property(propname, prop_value) ### ProbeManager interface for decorator ### |