annotate upmana/manifest.py @ 239:56c1f2729413 beta

Traipse Beta 'OpenRPG' {100811-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Closing/Closed) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order New to Server GUI, can now clear log New Earthdawn Dieroller Updates: Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence. Update to Browser Server window. Display rooms with ' " & cleaner Update to Server. Handles ' " & cleaner. Update to Dieroller. Cleaner, more effecient expression system. Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created Fix to Single and Double quotes in Whiteboard text Fix to Background images not showing when using the Image Server Fix to Duplicate chat names appearing Fix to Server GUI's logging output Fix to FNB.COLORFUL_TABS bug Fix to Gametree for XSLT Sheets Fix to Gametree for locating gametree files
author sirebral
date Wed, 11 Aug 2010 13:52:30 -0500
parents e842a5f1b775
children
rev   line source
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
1 from __future__ import with_statement
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
2
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 59
diff changeset
3 from orpg.dirpath import dir_struct
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
4 from upmana.validate import validate
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
5 from orpg.tools.orpg_log import logger
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
6 from os import sep, getcwd
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
7 from types import *
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
8
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
9 from xml.etree.ElementTree import ElementTree, Element, parse, fromstring
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
10 from xml.etree.ElementPath import find
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
11
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
12 class ManifestChanges(object):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
13 etree = ElementTree()
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
14 filename = dir_struct['home'] + 'upmana' + sep + 'upmana.xml'
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
15
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
16 def __new__(cls, *args, **kwargs):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
17 it = cls.__dict__.get("__it__")
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
18 if it is not None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
19 return it
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
20 cls.__it__ = it = object.__new__(cls)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
21 it._init()
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
22 return it
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
23
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
24 def _init(self):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
25 validate.config_file('upmana.xml', "default_upmana.xml")
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
26 self.LoadDoc()
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
27
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
28 def PluginChildren(self, plugname):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
29 plugin = self.etree.find(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
30 children = plugin.getchildren()
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
31 nodes = []
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
32 for child in children:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
33 nodes.append(child.tag)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
34 return nodes
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
35
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
36 def GetString(self, plugname, strname, defaultval="", verbose=False):
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
37 strname = self.safe(strname)
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
38 plugin = self.etree.find(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
39 if plugin is None or plugin.find(strname) is None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
40 msg = ["plugindb: no value has been stored for", strname, "in",
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
41 plugname, "so the default has been returned"]
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
42 return defaultval
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
43 return self.normal(plugin.find(strname).text or '')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
44
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
45 def DelString(self, plugname, strname):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
46 strname = self.safe(strname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
47 plugin = self.etree.find(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
48 plugin.remove(plugin.find(strname))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
49 self.SaveDoc()
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
50
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
51 def SetString(self, plugname, strname, val):
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
52 val = self.safe(val)
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
53 strname = self.safe(strname)
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
54 plugin = self.etree.find(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
55 if plugin is None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
56 plugin = Element(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
57 self.etree.getroot().append(plugin)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
58 str_el = plugin.find(strname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
59 if str_el is None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
60 str_el = Element(strname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
61 str_el.set('type', 'str')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
62 plugin.append(str_el)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
63 str_el.text = val
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
64 self.SaveDoc()
34
8b630fc8a343 Updated the Update Manager to 0.3. Settings are being created with a clone
sirebral
parents: 33
diff changeset
65
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
66 def FetchList(self, parent):
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
67 retlist = []
140
e842a5f1b775 Traipse Beta 'OpenRPG' {091123-00}
sirebral
parents: 135
diff changeset
68 for litem in parent.find('list').findall('lobject'):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
69 if litem.get('type') == 'int': retlist.append(int(litem.text))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
70 if litem.get('type') == 'bool': retlist.append(litem.text == 'True')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
71 elif litem.get('type') == 'float': retlist.append(float(litem.text))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
72 elif litem.get('type') == 'list': retlist.append(self.FetchList(litem))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
73 elif litem.get('type') == 'dict': retlist.append(self.FetchDict(litem))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
74 else: retlist.append(str(self.normal(litem.text)))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
75 return retlist
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
76
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
77 def GetList(self, plugname, listname, defaultval=list(), verbose=False):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
78 listname = self.safe(listname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
79 plugin = self.etree.find(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
80 if plugin is None or plugin.find(listname) is None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
81 msg = ["plugindb: no value has been stored for", listname, "in",
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
82 plugname, "so the default has been returned"]
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
83 return defaultval
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
84 retlist = self.FetchList(plugin.find(listname))
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
85 return retlist
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
86
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
87 def BuildList(self, val):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
88 list_el = Element('list')
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
89 for item in val:
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
90 i = Element('lobject')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
91 if isinstance(item, bool):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
92 i.set('type', 'bool')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
93 i.text = str(item)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
94 elif isinstance(item, int):#it's an int
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
95 i.set('type', 'int')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
96 i.text = str(item)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
97 elif isinstance(item, float):#it's a float
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
98 i.set('type', 'float')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
99 i.text = str(item)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
100 elif isinstance(item, (list, tuple)):#it's a list
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
101 i.set('type', 'list')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
102 i.append(self.BuildList(item))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
103 elif isinstance(item, dict):#it's a dictionary
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
104 i.set('type', 'dict')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
105 i.append(self.BuildDict(item))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
106 else:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
107 i.set('type', 'str')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
108 i.text = self.safe(item)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
109 list_el.append(i)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
110 return list_el
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
111
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
112 def SetList(self, plugname, listname, val):
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
113 listname = self.safe(listname)
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
114 plugin = self.etree.find(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
115 if plugin is None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
116 plugin = Element(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
117 self.etree.getroot().append(plugin)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
118 list_el = plugin.find(listname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
119 if list_el is None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
120 list_el = Element(listname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
121 list_el.set('type', 'list')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
122 plugin.append(list_el)
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
123 else:
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
124 list_el.remove(list_el.find('list'))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
125 list_el.append(self.BuildList(val))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
126 self.SaveDoc()
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
127
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
128 def BuildDict(self, val):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
129 dict_el = Element('dict')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
130 for key, item in val.items():
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
131 i = Element('dobject')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
132 if isinstance(item, bool):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
133 i.set('type', 'bool')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
134 i.set('name', self.safe(key))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
135 i.text = str(item)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
136 elif isinstance(item, int):#it's an int
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
137 i.set('type', 'int')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
138 i.set('name', self.safe(key))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
139 i.text = str(item)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
140 elif isinstance(item, float):#it's a float
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
141 i.set('type', 'float')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
142 i.set('name', self.safe(key))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
143 i.text = str(item)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
144 elif isinstance(item, (list, tuple)):#it's a list
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
145 i.set('type', 'list')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
146 i.set('name', self.safe(key))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
147 i.append(self.BuildList(item))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
148 elif isinstance(item, dict):#it's a dictionary
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
149 i.set('type', 'dict')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
150 i.set('name', self.safe(key))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
151 i.append(self.BuildDict(item))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
152 else:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
153 i.set('type', 'str')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
154 i.set('name', self.safe(key))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
155 i.text = self.safe(item)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
156 dict_el.append(i)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
157 return dict_el
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
158
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
159 def SetDict(self, plugname, dictname, val):
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
160 dictname = self.safe(dictname)
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
161 plugin = self.etree.find(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
162 if plugin is None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
163 plugin = Element(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
164 self.etree.getroot().append(plugin)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
165 dict_el = plugin.find(dictname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
166 if dict_el is None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
167 dict_el = Element(dictname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
168 dict_el.set('type', 'dict')
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
169 plugin.append(dict_el)
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
170 else:
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
171 dict_el.remove(list_el.find('dict'))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
172 dict_el.append(self.BuildDict(val))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
173 self.SaveDoc()
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
174
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
175 def FetchDict(self, parent):
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
176 retdict = {}
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
177 for ditem in parent.findall('dobject'):
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
178 key = self.normal(ditem.get('name'))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
179 if ditem.get('type') == 'int': value = int(ditem.text)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
180 elif ditem.get('type') == 'bool': value = ditem.text == 'True'
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
181 elif ditem.get('type') == 'float': value = float(ditem.text)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
182 elif ditem.get('type') == 'list': value = self.FetchList(ditem)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
183 elif ditem.get('type') == 'dict': value = self.FetchDict(ditem)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
184 else: value = str(self.normal(ditem[0]))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
185 retdict[key] = value
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
186 return retdict
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
187
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
188 def GetDict(self, plugname, dictname, defaultval=dict(), verbose=False):
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
189 dictname = self.safe(dictname)
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
190 plugin = self.etree.find(plugname)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
191 if plugin is None or plugin.find(dictname) is None:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
192 msg = ["plugindb: no value has been stored for", dictname, "in",
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
193 plugname, "so the default has been returned"]
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
194 return defaultval
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
195 retdict = self.FetchDict(plugin.find(dictname))
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
196 return retdict
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
197
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
198 def safe(self, string):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
199 return string.replace("<", "$$lt$$").replace(">", "$$gt$$")\
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
200 .replace("&","$$amp$$").replace('"',"$$quote$$")
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
201
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
202 def normal(self, string):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
203 return string.replace("$$lt$$", "<").replace("$$gt$$", ">")\
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
204 .replace("$$amp$$","&").replace("$$quote$$",'"')
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
205
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
206 def SaveDoc(self):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
207 with open(self.filename, "w") as f:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
208 self.etree.write(f)
33
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
209
3687514e0218 I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff changeset
210 def LoadDoc(self):
135
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
211 with open(self.filename) as f:
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
212 self.etree.parse(f)
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
213
dcf4fbe09b70 Traipse Beta 'OpenRPG' {091010-00}
sirebral
parents: 66
diff changeset
214 manifest = ManifestChanges()