view python/libs/project.py @ 67:99bf4f7d47f4

Changed project storage
author windel
date Fri, 12 Oct 2012 16:11:31 +0200
parents 32078200cdd6
children 654c5ac4f2c5
line wrap: on
line source

"""
 source project
 contains:
 - modules
   - primitives like functions, types and variables
   - other modules

"""

import json

class Project:
   def __init__(self, filename=None):
      self.name = ""
      self.modules = []
      self.elements = []
      self.settings = {}
      self.filename = filename

      if self.filename:
         """ Load the project from the XML file """
         with open(self.filename, 'r') as f:
            d = json.load(f)
         self.elements = d['elements']

   def save(self):
      if self.filename:
         d = {'elements': self.elements}
         print(d)
         with open(self.filename, 'w') as f:
            json.dump(d, f)