comparison python/project.py @ 97:5a965e9664f2

Movage
author windel
date Mon, 24 Dec 2012 13:32:54 +0100
parents python/libs/project.py@654c5ac4f2c5
children
comparison
equal deleted inserted replaced
96:a350055d6119 97:5a965e9664f2
1 """
2 source project
3 contains:
4 - modules
5 - primitives like functions, types and variables
6 - other modules
7 """
8
9 import json
10
11 class Project:
12 def __init__(self, filename=None):
13 self.name = ""
14 self.modules = []
15 self.elements = []
16 self.settings = {}
17 if filename:
18 self.load(filename)
19
20 def load(self, filename):
21 """ Load the project from file """
22 self.filename = filename
23
24 with open(self.filename, 'r') as f:
25 d = json.load(f)
26 self.elements = d['elements']
27
28 def save(self):
29 if self.filename:
30 d = {'elements': self.elements}
31 print(d)
32 with open(self.filename, 'w') as f:
33 json.dump(d, f)
34