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