diff ide/project.py @ 15:de004f808e56

Fixup in multidocument area stuff
author windel
date Tue, 15 Nov 2011 07:35:00 +0100
parents edd70006d3e4
children
line wrap: on
line diff
--- a/ide/project.py	Sun Nov 13 23:24:10 2011 +0100
+++ b/ide/project.py	Tue Nov 15 07:35:00 2011 +0100
@@ -21,12 +21,23 @@
       if name == 'Files':
          self.inFiles = False
 
+class ProjectFile:
+   def __init__(self, filename):
+      self.filename = filename
+
 class Project:
-   def __init__(self):
+   def __init__(self, filename, isnew=False):
       self.name = ""
       self.files = []
       self.settings = {}
-      self.filename = ""
+      self.filename = filename
+
+      if not isnew:
+         """ Load the project from the XML file """
+         parser = make_parser()
+         handler = ProjectContentHandler(self)
+         parser.setContentHandler(handler)
+         parser.parse(filename)
 
    def save(self, filename):
       """ Save the project in XML format """
@@ -50,14 +61,10 @@
       with open(filename, 'w') as f:
          f.write(xml)
 
-   def load(self, filename):
-      """ Load the project from the XML file """
-      if not os.path.exists(filename):
-         return
-      self.filename = filename
-      print(self.filename)
-      parser = make_parser()
-      handler = ProjectContentHandler(self)
-      parser.setContentHandler(handler)
-      parser.parse(filename)
+   def loadProjectFile(self, filename):
+      basedir = os.path.dirname(self.filename)
+      filename = os.path.join(basedir, filename)
+      with open(filename, 'r') as f:
+         src = f.read()
+      return src