From 21a9c4aae574236d36f1c0ace1908c9396c1ee8a Mon Sep 17 00:00:00 2001 From: Jean-Christophe Savard Date: Wed, 15 Apr 2009 19:26:32 +0000 Subject: Bundler.py updated --- diff --git a/src/sugar/tutorius/bundler.py b/src/sugar/tutorius/bundler.py index 3678e86..a98e130 100644 --- a/src/sugar/tutorius/bundler.py +++ b/src/sugar/tutorius/bundler.py @@ -115,42 +115,42 @@ class XMLSerializer(Serializer): Save fsm to disk, in the xml file specified by "xml_filename", in the "path" folder. If the specified file dont exist, it will be created. """ - - logging.debug("************ found .tml file : " + file_name) - key_line = linecache.getline(path + file_name, 1) - key_line = key_line.split("\n")[0] - fileKey = key_line.split("--KEY::")[1] - logging.debug("************ fileKey = " + fileKey) - if key == fileKey: - logging.debug("************ Key : " + key + \ - " = fileKey : " + fileKey) - tml = file(path + file_name, "r") - str = tml.read() - pick = str.split("--PICKLE::")[1] - - fsm = pickle.loads(pick) - tuto = {key:Tutorial(key,fsm)} - - return tuto + +## logging.debug("************ found .tml file : " + file_name) +## key_line = linecache.getline(path + file_name, 1) +## key_line = key_line.split("\n")[0] +## fileKey = key_line.split("--KEY::")[1] +## logging.debug("************ fileKey = " + fileKey) +## if key == fileKey: +## logging.debug("************ Key : " + key + \ +## " = fileKey : " + fileKey) +## tml = file(path + file_name, "r") +## str = tml.read() +## pick = str.split("--PICKLE::")[1] +## +## fsm = pickle.loads(pick) +## tuto = {key:Tutorial(key,fsm)} +## +## return tuto def load_fsm(self, guid): """ Load fsm from xml file who .ini file guid match argument guid. """ - - path = os.getenv("SUGAR_ACTIVITY_ROOT") + "/data/" - # Create /data/ folder if no exists - if not os.path.exists(path): - os.mkdir(path) - logging.debug("************* Creating data folder") - - # Save the dictionnary to .tml file - tutoSave = file(path + filename + ".tml", 'w') - str = "--KEY::" + key + "\n--NAME::" + name + "\n--PICKLE::" + \ - pickle.dumps(fsm,0) - tutoSave.write(str) - tutoSave.close() +## +## path = os.getenv("SUGAR_ACTIVITY_ROOT") + "/data/" +## # Create /data/ folder if no exists +## if not os.path.exists(path): +## os.mkdir(path) +## logging.debug("************* Creating data folder") +## +## # Save the dictionnary to .tml file +## tutoSave = file(path + filename + ".tml", 'w') +## str = "--KEY::" + key + "\n--NAME::" + name + "\n--PICKLE::" + \ +## pickle.dumps(fsm,0) +## tutoSave.write(str) +## tutoSave.close() class TutorialBundler: @@ -159,8 +159,6 @@ class TutorialBundler: editor. """ - TUT_STORE_ROOT = os.getenv("$SUGAR_PREFIX") + "/share/tutorius/Data" - TUT_BUNDLE_ROOT = os.getenv("$SUGAR_BUNDLE_PATH") + "/data/tutorius/Data" INI_ACTIVITY_SECTION = "RELATED_ACTIVITIES" INI_METADATA_SECTION = "GENERAL_METADATA" INI_GUID_PROPERTY = "GUID" @@ -185,20 +183,29 @@ class TutorialBundler: def __DelGuid(self): del self.__guid + def __SetPath(self, value): + self.__path = value + + def __GetPath(self): + return self.__path + + def __DelPath(self): + del self.__path + Guid = property(fget=__SetGuid, - fset=__GetGuid, - fdel=__DelGuid, - doc="The guid associated with the Tutoria_Bundler") - - guid = property(fget=get_guid(), - fset=set_guid()) + fset=__GetGuid, + fdel=__DelGuid, + doc="The guid associated with the Tutoria_Bundler") + + Path = property(fget=__SetPath, + fset=__GetPath, + fdel=__DelPath, + doc="The path associated with the Tutoria_Bundler") if generated_gui is not None: self.Guid = generated_guid else: self.Guid = uuid.uuid1() - - #TODO : GUID generation if no guid is given in entry to the constructor. @@ -210,13 +217,16 @@ class TutorialBundler: """ NotImplementedError - def return_ini_file_path(self): + def get_ini_file_path(self): """ Return the path of the .ini file associated with the guiven guid set in the Guid property of the Tutorial_Bundler. If the guid is present in more than one path, the TUT_STORE_ROOT is given priority. """ + TUT_STORE_ROOT = os.getenv("$SUGAR_PREFIX") + "/share/tutorius/Data" + TUT_BUNDLE_ROOT = os.getenv("$SUGAR_BUNDLE_PATH") + "/data/tutorius/Data" + config = SafeConfigParser() path = None @@ -266,7 +276,7 @@ class TutorialBundler: config = SafeConfigParser() if guid is not None: - path = return_ini_file_path() + path = get_ini_file_path() config.read(path) xml_filename = config.get(INI_METADATA_SECTION, INI_XML_FSM_PROPERTY) save_fsm(fsm, xml_filename, TUT_STORE_ROOT) -- cgit v0.9.1