blob: 1c815c3470699f8900f087571f373cf1be289b9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<?xml version="1.0"?>
<!--
###################################################
##Variable Config block:
## a variable that reads and writes to a config file
###################################################
-->
<block>
<name>Variable Config</name>
<key>variable_config</key>
<import>import ConfigParser</import>
<var_make>self._$(id)_config = ConfigParser.ConfigParser()
self._$(id)_config.read($config_file)
try: $(id) = self._$(id)_config.$(type.get)($section, $option)
except: $(id) = $value
self.$(id) = $(id)</var_make>
<make></make>
<callback>self.set_$(id)($value)</callback>
<callback>self._$(id)_config = ConfigParser.ConfigParser()
self._$(id)_config.read($config_file)
if not self._$(id)_config.has_section($section):
self._$(id)_config.add_section($section)
self._$(id)_config.set($section, $option, str($writeback))
self._$(id)_config.write(open($config_file, 'w'))</callback>
<param>
<name>Default Value</name>
<key>value</key>
<value>0</value>
<type>$type</type>
</param>
<param>
<name>Type</name>
<key>type</key>
<value>real</value>
<type>enum</type>
<option>
<name>Float</name>
<key>real</key>
<opt>get:getfloat</opt>
</option>
<option>
<name>Int</name>
<key>int</key>
<opt>get:getint</opt>
</option>
<option>
<name>Bool</name>
<key>bool</key>
<opt>get:getbool</opt>
</option>
<option>
<name>String</name>
<key>string</key>
<opt>get:get</opt>
</option>
</param>
<param>
<name>Config File</name>
<key>config_file</key>
<value>default</value>
<type>file_open</type>
</param>
<param>
<name>Section</name>
<key>section</key>
<value>main</value>
<type>string</type>
</param>
<param>
<name>Option</name>
<key>option</key>
<value>key</value>
<type>string</type>
</param>
<param>
<name>WriteBack</name>
<key>writeback</key>
<value>None</value>
<type>raw</type>
</param>
<doc>
This block represents a variable that can be read from a config file.
To save the value back into the config file: \
enter the name of another variable into the writeback param. \
When the other variable is changed at runtime, the config file will be re-written.
</doc>
</block>
|