view python/project.py @ 184:fe2b72381a83

Added testset for pyy
author Windel Bouwman
date Fri, 24 May 2013 16:13:23 +0200
parents 5a965e9664f2
children
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 = {}
      if filename:
         self.load(filename)

   def load(self, filename):
      """ Load the project from file """
      self.filename = filename

      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)