diff python/project.py @ 97:5a965e9664f2

Movage
author windel
date Mon, 24 Dec 2012 13:32:54 +0100
parents python/libs/project.py@654c5ac4f2c5
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/project.py	Mon Dec 24 13:32:54 2012 +0100
@@ -0,0 +1,34 @@
+"""
+ 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)
+