annotate upmana/manifest.py @ 18:97265586402b ornery-orc

Traipse 'OpenRPG' {090827-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: Update Manager is now in version 0.8. While not every button works, users can now browse the different revisions and their different changesets. The code has been refined some with feature from Core added to it. A Crash report is now created if the users software crashes. Update Manager has been moved to the Traipse Suite menu item, and a Debug Console as been added as well.
author sirebral
date Thu, 27 Aug 2009 01:04:43 -0500
parents 265b987cce4f
children ff154cf3350c
rev   line source
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
1 import xmltramp
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
2 from orpg.dirpath import dir_struct
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 14
diff changeset
3 import upmana.validate
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
4 from os import sep
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
5 from types import *
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
6
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
7 class ManifestChanges:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
8 def __init__(self, filename="updatemana.xml"):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
9 self.filename = dir_struct["home"] + 'upmana' + sep + filename
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
10 upmana.validate.Validate(dir_struct["home"] + 'upmana' + sep).config_file(filename,"default_manifest.xml")
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
11 self.xml_dom = self.LoadDoc()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
12
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
13 def GetString(self, plugname, strname, defaultval, verbose=0):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
14 strname = self.safe(strname)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
15 for plugin in self.xml_dom:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
16 if plugname == plugin._name:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
17 for child in plugin._dir:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
18 if child._name == strname:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
19 #str() on this to make sure it's ASCII, not unicode, since orpg can't handle unicode.
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
20 if verbose: print "successfully found the value"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
21 if len(child): return str( self.normal(child[0]) )
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
22 else: return ""
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
23 else:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
24 if verbose:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
25 print "manifest: no value has been stored for " + strname + " in " + plugname + " so the default has been returned"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
26 return defaultval
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
27
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
28 def SetString(self, plugname, strname, val):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
29 #Set Node, <repo, name, description, value>
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
30 #Set Setting, <setting, value>
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
31 val = self.safe(val)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
32 strname = self.safe(strname)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
33 for plugin in self.xml_dom:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
34 ##this isn't absolutely necessary, but it saves the trouble of sending a parsed object instead of a simple string.
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
35 if plugname == plugin._name:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
36 plugin[strname] = val
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
37 plugin[strname]._attrs["type"] = "string"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
38 self.SaveDoc()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
39 return "found plugin"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
40 else:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
41 self.xml_dom[plugname] = xmltramp.parse("<" + strname + " type=\"string\">" + val + "</" + strname + ">")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
42 self.SaveDoc()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
43 return "added plugin"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
44
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
45
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
46 def FetchList(self, parent):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
47 retlist = []
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
48 if not len(parent): return []
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
49 for litem in parent[0]._dir:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
50 if len(litem):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
51 if litem._attrs["type"] == "int": retlist += [int(litem[0])]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
52 elif litem._attrs["type"] == "long": retlist += [long(litem[0])]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
53 elif litem._attrs["type"] == "float": retlist += [float(litem[0])]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
54 elif litem._attrs["type"] == "list": retlist += [self.FetchList(litem)]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
55 elif litem._attrs["type"] == "dict": retlist += [self.FetchDict(litem)]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
56 else: retlist += [str( self.normal(litem[0]) )]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
57 else: retlist += [""]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
58 return retlist
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
59
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
60 def GetList(self, plugname, listname, defaultval, verbose=0):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
61 listname = self.safe(listname)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
62 for plugin in self.xml_dom:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
63 if plugname == plugin._name:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
64 for child in plugin._dir:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
65 if child._name == listname and child._attrs["type"] == "list":
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
66 retlist = self.FetchList(child)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
67 if verbose: print "successfully found the value"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
68 return retlist
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
69 else:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
70 if verbose:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
71 print "plugindb: no value has been stored for " + listname + " in " + plugname + " so the default has been returned"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
72 return defaultval
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
73
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
74 def BuildList(self, val):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
75 listerine = "<list>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
76 for item in val:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
77 if isinstance(item, basestring):#it's a string
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
78 listerine += "<lobject type=\"str\">" + self.safe(item) + "</lobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
79 elif isinstance(item, IntType):#it's an int
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
80 listerine += "<lobject type=\"int\">" + str(item) + "</lobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
81 elif isinstance(item, FloatType):#it's a float
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
82 listerine += "<lobject type=\"float\">" + str(item) + "</lobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
83 elif isinstance(item, LongType):#it's a long
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
84 listerine += "<lobject type=\"long\">" + str(item) + "</lobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
85 elif isinstance(item, ListType):#it's a list
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
86 listerine += "<lobject type=\"list\">" + self.BuildList(item) + "</lobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
87 elif isinstance(item, DictType):#it's a dictionary
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
88 listerine += "<lobject type=\"dict\">" + self.BuildDict(item) + "</lobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
89 else: return "type unknown"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
90 listerine += "</list>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
91 return listerine
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
92
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
93 def SetList(self, plugname, listname, val):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
94 listname = self.safe(listname)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
95 list = xmltramp.parse(self.BuildList(val))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
96 for plugin in self.xml_dom:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
97 if plugname == plugin._name:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
98 plugin[listname] = list
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
99 plugin[listname]._attrs["type"] = "list"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
100 self.SaveDoc()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
101 return "found plugin"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
102 else:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
103 self.xml_dom[plugname] = xmltramp.parse("<" + listname + "></" + listname + ">")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
104 self.xml_dom[plugname][listname] = list
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
105 self.xml_dom[plugname][listname]._attrs["type"] = "list"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
106 self.SaveDoc()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
107 return "added plugin"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
108
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
109 def BuildDict(self, val):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
110 dictator = "<dict>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
111 for item in val.keys():
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
112 if isinstance(val[item], basestring):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
113 dictator += "<dobject name=\"" + self.safe(item) + "\" type=\"str\">" + self.safe(val[item]) + "</dobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
114 elif isinstance(val[item], IntType):#it's an int
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
115 dictator += "<dobject name=\"" + self.safe(item) + "\" type=\"int\">" + str(val[item]) + "</dobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
116 elif isinstance(val[item], FloatType):#it's a float
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
117 dictator += "<dobject name=\"" + self.safe(item) + "\" type=\"float\">" + str(val[item]) + "</dobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
118 elif isinstance(val[item], LongType):#it's a long
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
119 dictator += "<dobject name=\"" + self.safe(item) + "\" type=\"long\">" + str(val[item]) + "</dobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
120 elif isinstance(val[item], DictType):#it's a dictionary
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
121 dictator += "<dobject name=\"" + self.safe(item) + "\" type=\"dict\">" + self.BuildDict(val[item]) + "</dobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
122 elif isinstance(val[item], ListType):#it's a list
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
123 dictator += "<dobject name=\"" + self.safe(item) + "\" type=\"list\">" + self.BuildList(val[item]) + "</dobject>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
124 else: return str(val[item]) + ": type unknown"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
125 dictator += "</dict>"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
126 return dictator
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
127
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
128 def SetDict(self, plugname, dictname, val, file="plugindb.xml"):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
129 dictname = self.safe(dictname)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
130 dict = xmltramp.parse(self.BuildDict(val))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
131 for plugin in self.xml_dom:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
132 if plugname == plugin._name:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
133 plugin[dictname] = dict
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
134 plugin[dictname]._attrs["type"] = "dict"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
135 self.SaveDoc()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
136 return "found plugin"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
137 else:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
138 self.xml_dom[plugname] = xmltramp.parse("<" + dictname + "></" + dictname + ">")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
139 self.xml_dom[plugname][dictname] = dict
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
140 self.xml_dom[plugname][dictname]._attrs["type"] = "dict"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
141 self.SaveDoc()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
142 return "added plugin"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
143
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
144 def FetchDict(self, parent):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
145 retdict = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
146 if not len(parent): return {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
147 for ditem in parent[0]._dir:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
148 if len(ditem):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
149 ditem._attrs["name"] = self.normal(ditem._attrs["name"])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
150 if ditem._attrs["type"] == "int": retdict[ditem._attrs["name"]] = int(ditem[0])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
151 elif ditem._attrs["type"] == "long": retdict[ditem._attrs["name"]] = long(ditem[0])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
152 elif ditem._attrs["type"] == "float": retdict[ditem._attrs["name"]] = float(ditem[0])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
153 elif ditem._attrs["type"] == "list": retdict[ditem._attrs["name"]] = self.FetchList(ditem)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
154 elif ditem._attrs["type"] == "dict": retdict[ditem._attrs["name"]] = self.FetchDict(ditem)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
155 else: retdict[ditem._attrs["name"]] = str( self.normal(ditem[0]) )
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
156 else: retdict[ditem._attrs["name"]] = ""
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
157 return retdict
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
158
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
159 def GetDict(self, plugname, dictname, defaultval, verbose=0):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
160 dictname = self.safe(dictname)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
161 for plugin in self.xml_dom:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
162 if plugname == plugin._name:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
163 for child in plugin._dir:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
164 if child._name == dictname and child._attrs["type"] == "dict": return self.FetchDict(child)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
165 else:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
166 if verbose:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
167 print "plugindb: no value has been stored for " + dictname + " in " + plugname + " so the default has been returned"
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
168 return defaultval
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
169
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
170 def safe(self, string):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
171 return string.replace("<", "$$lt$$").replace(">", "$$gt$$").replace("&","$$amp$$").replace('"',"$$quote$$")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
172
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
173 def normal(self, string):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
174 return string.replace("$$lt$$", "<").replace("$$gt$$", ">").replace("$$amp$$","&").replace("$$quote$$",'"')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
175
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
176 def SaveDoc(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
177 f = open(self.filename, "w")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
178 f.write(self.xml_dom.__repr__(1, 1))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
179 f.close()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
180
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
181 def LoadDoc(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
182 xml_file = open(self.filename)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
183 manifest = xml_file.read()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
184 xml_file.close()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
185 return xmltramp.parse(manifest)