7
|
1 """
|
67
|
2 source project
|
|
3 contains:
|
|
4 - modules
|
|
5 - primitives like functions, types and variables
|
|
6 - other modules
|
7
|
7 """
|
|
8
|
67
|
9 import json
|
15
|
10
|
7
|
11 class Project:
|
67
|
12 def __init__(self, filename=None):
|
7
|
13 self.name = ""
|
67
|
14 self.modules = []
|
|
15 self.elements = []
|
7
|
16 self.settings = {}
|
68
|
17 if filename:
|
|
18 self.load(filename)
|
|
19
|
|
20 def load(self, filename):
|
|
21 """ Load the project from file """
|
15
|
22 self.filename = filename
|
|
23
|
68
|
24 with open(self.filename, 'r') as f:
|
|
25 d = json.load(f)
|
|
26 self.elements = d['elements']
|
|
27
|
67
|
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)
|
7
|
34
|