1
2
3
4 """
5 The tools to save/load/use the user's customisations.
6 """
7 import sys
8 import os
9 from ConfigParser import SafeConfigParser
10
11 import wx
12 import wx.py.dispatcher as dispatcher
13
14 MB_DEFAULT_OPTIONS="""
15 [Auto Completion]
16 Show_Auto_Completion = 1
17 Include_Magic_Attributes = 1
18 Include_Single_Underscores = 1
19 Include_Double_Underscores = 0
20
21 [Call Tips]
22 Show_Call_Tips = 1
23 Insert_Call_Tips = 1
24
25 [View]
26 Wrap_Lines = 1
27 Show_Line_Numbers = 1
28
29 [Development]
30 Verbosity_Level = INFO
31 """
32
34 """
35 Hold the configuration for the whole application and makes it
36 possible to save the default and prefered options of the users.
37
38 It is implemented as a singleton.
39 """
40
41 __instance = None
42
43 _filepath = ".config"
44
46 """
47 Save the default if the file does not exists, else just read it.
48 filepath should the the full path to the file (base + name)
49 """
50 if self.__instance is not None:
51 raise Exception("Instanciating a second singleton... arg !")
52
53 if not os.path.isfile(self._filepath):
54 config_file = open(self._filepath,'w')
55 config_file.write(MB_DEFAULT_OPTIONS)
56 config_file.close()
57
58 SafeConfigParser.__init__(self)
59 self.read(self._filepath)
60
62 """
63 Write the config in the file
64 """
65 config_file = open(self._filepath,'w')
66 self.write(config_file)
67 config_file.close()
68
69 @staticmethod
71 """
72 Set the config file's path.
73 To be called before any initialisation.
74 """
75 MathBenchConfig._filepath = filepath
76
77 @staticmethod
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106