Graphics/PackageItem.py

changeset 2034
8de0fc1f7fef
parent 2033
4b99609f6a87
child 2039
fa41ccd7f7bc
--- a/Graphics/PackageItem.py	Sun Sep 09 19:38:07 2012 +0200
+++ b/Graphics/PackageItem.py	Mon Sep 10 18:42:28 2012 +0200
@@ -11,6 +11,8 @@
 
 from .UMLItem import UMLItem
 
+import Utilities
+
 
 class PackageModel(object):
     """
@@ -203,10 +205,34 @@
         
         return ", " + ", ".join(entries)
     
-    def parseItemDataString(self, data):
+    def parseItemDataString(self, version, data):
         """
         Public method to parse the given persistence data.
         
+        @param version version of the data (string)
         @param data persisted data to be parsed (string)
+        @return flag indicating success (boolean)
         """
-        # TODO: implement this
+        parts = data.split(", ")
+        if len(parts) < 2:
+            return False
+        
+        name = ""
+        modules = []
+        
+        for part in parts:
+            key, value = part.split("=", 1)
+            if key == "no_modules":
+                self.external = Utilities.toBool(value.strip())
+            elif key == "name":
+                name = value.strip()
+            elif key == "modules":
+                modules = value.strip().split("||")
+            else:
+                return False
+        
+        self.model = PackageModel(name, modules)
+        self.__createTexts()
+        self.__calculateSize()
+        
+        return True

eric ide

mercurial