Mercurial > traipse_dev
annotate upmana/manifest.py @ 107:ded1e7a25f8d alpha
Traipse Alpha 'OpenRPG' {091007-01}
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:
{091006}
00:
Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images!
03:
Changes made to the map for increased portability. SnowDog has changes planned in Core,
though.
Added an initial push to the BCG. Not much to see, just shows off how it is re-writing
Main code.
{091007}
00:
New images added to Plugin Control Panel for Auto Start.
01:
Attempting to fix Deprecation warning from Main.
author | sirebral |
---|---|
date | Wed, 07 Oct 2009 19:12:53 -0500 |
parents | c54768cffbd4 |
children | 496dbf12a6cb dcf4fbe09b70 |
rev | line source |
---|---|
33
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
1 import xmltramp |
66 | 2 from orpg.dirpath import dir_struct |
59
5aff3ef1ae46
New dev branch for Ornery Orc. Adds CSS styling to chat messages. Updates
sirebral
parents:
47
diff
changeset
|
3 import upmana.validate |
47
52f6a38f8885
Update Manager 0.6.7 (Initial Release). Getting ready to implement it now.
sirebral
parents:
34
diff
changeset
|
4 from os import sep |
33
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
5 from types import * |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
6 |
34
8b630fc8a343
Updated the Update Manager to 0.3. Settings are being created with a clone
sirebral
parents:
33
diff
changeset
|
7 class ManifestChanges: |
33
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
8 def __init__(self, filename="updatemana.xml"): |
66 | 9 self.filename = dir_struct["home"] + 'upmana' + sep + filename |
10 upmana.validate.Validate(dir_struct["home"] + 'upmana' + sep).config_file(filename,"default_manifest.xml") | |
33
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
11 self.xml_dom = self.LoadDoc() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
12 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
13 def GetString(self, plugname, strname, defaultval, verbose=0): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
14 strname = self.safe(strname) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
15 for plugin in self.xml_dom: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
16 if plugname == plugin._name: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
17 for child in plugin._dir: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
18 if child._name == strname: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
19 #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
|
20 if verbose: print "successfully found the value" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
21 if len(child): return str( self.normal(child[0]) ) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
22 else: return "" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
23 else: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
24 if verbose: |
34
8b630fc8a343
Updated the Update Manager to 0.3. Settings are being created with a clone
sirebral
parents:
33
diff
changeset
|
25 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
|
26 return defaultval |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
27 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
28 def SetString(self, plugname, strname, val): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
29 #Set Node, <repo, name, description, value> |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
30 #Set Setting, <setting, value> |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
31 val = self.safe(val) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
32 strname = self.safe(strname) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
33 for plugin in self.xml_dom: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
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. |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
35 if plugname == plugin._name: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
36 plugin[strname] = val |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
37 plugin[strname]._attrs["type"] = "string" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
38 self.SaveDoc() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
39 return "found plugin" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
40 else: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
41 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
|
42 self.SaveDoc() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
43 return "added plugin" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
44 |
34
8b630fc8a343
Updated the Update Manager to 0.3. Settings are being created with a clone
sirebral
parents:
33
diff
changeset
|
45 |
33
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
46 def FetchList(self, parent): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
47 retlist = [] |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
48 if not len(parent): return [] |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
49 for litem in parent[0]._dir: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
50 if len(litem): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
51 if litem._attrs["type"] == "int": retlist += [int(litem[0])] |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
52 elif litem._attrs["type"] == "long": retlist += [long(litem[0])] |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
53 elif litem._attrs["type"] == "float": retlist += [float(litem[0])] |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
54 elif litem._attrs["type"] == "list": retlist += [self.FetchList(litem)] |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
55 elif litem._attrs["type"] == "dict": retlist += [self.FetchDict(litem)] |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
56 else: retlist += [str( self.normal(litem[0]) )] |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
57 else: retlist += [""] |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
58 return retlist |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
59 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
60 def GetList(self, plugname, listname, defaultval, verbose=0): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
61 listname = self.safe(listname) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
62 for plugin in self.xml_dom: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
63 if plugname == plugin._name: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
64 for child in plugin._dir: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
65 if child._name == listname and child._attrs["type"] == "list": |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
66 retlist = self.FetchList(child) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
67 if verbose: print "successfully found the value" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
68 return retlist |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
69 else: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
70 if verbose: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
71 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
|
72 return defaultval |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
73 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
74 def BuildList(self, val): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
75 listerine = "<list>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
76 for item in val: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
77 if isinstance(item, basestring):#it's a string |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
78 listerine += "<lobject type=\"str\">" + self.safe(item) + "</lobject>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
79 elif isinstance(item, IntType):#it's an int |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
80 listerine += "<lobject type=\"int\">" + str(item) + "</lobject>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
81 elif isinstance(item, FloatType):#it's a float |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
82 listerine += "<lobject type=\"float\">" + str(item) + "</lobject>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
83 elif isinstance(item, LongType):#it's a long |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
84 listerine += "<lobject type=\"long\">" + str(item) + "</lobject>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
85 elif isinstance(item, ListType):#it's a list |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
86 listerine += "<lobject type=\"list\">" + self.BuildList(item) + "</lobject>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
87 elif isinstance(item, DictType):#it's a dictionary |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
88 listerine += "<lobject type=\"dict\">" + self.BuildDict(item) + "</lobject>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
89 else: return "type unknown" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
90 listerine += "</list>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
91 return listerine |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
92 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
93 def SetList(self, plugname, listname, val): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
94 listname = self.safe(listname) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
95 list = xmltramp.parse(self.BuildList(val)) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
96 for plugin in self.xml_dom: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
97 if plugname == plugin._name: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
98 plugin[listname] = list |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
99 plugin[listname]._attrs["type"] = "list" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
100 self.SaveDoc() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
101 return "found plugin" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
102 else: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
103 self.xml_dom[plugname] = xmltramp.parse("<" + listname + "></" + listname + ">") |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
104 self.xml_dom[plugname][listname] = list |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
105 self.xml_dom[plugname][listname]._attrs["type"] = "list" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
106 self.SaveDoc() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
107 return "added plugin" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
108 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
109 def BuildDict(self, val): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
110 dictator = "<dict>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
111 for item in val.keys(): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
112 if isinstance(val[item], basestring): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
113 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
|
114 elif isinstance(val[item], IntType):#it's an int |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
115 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
|
116 elif isinstance(val[item], FloatType):#it's a float |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
117 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
|
118 elif isinstance(val[item], LongType):#it's a long |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
119 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
|
120 elif isinstance(val[item], DictType):#it's a dictionary |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
121 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
|
122 elif isinstance(val[item], ListType):#it's a list |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
123 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
|
124 else: return str(val[item]) + ": type unknown" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
125 dictator += "</dict>" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
126 return dictator |
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 SetDict(self, plugname, dictname, val, file="plugindb.xml"): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
129 dictname = self.safe(dictname) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
130 dict = xmltramp.parse(self.BuildDict(val)) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
131 for plugin in self.xml_dom: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
132 if plugname == plugin._name: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
133 plugin[dictname] = dict |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
134 plugin[dictname]._attrs["type"] = "dict" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
135 self.SaveDoc() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
136 return "found plugin" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
137 else: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
138 self.xml_dom[plugname] = xmltramp.parse("<" + dictname + "></" + dictname + ">") |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
139 self.xml_dom[plugname][dictname] = dict |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
140 self.xml_dom[plugname][dictname]._attrs["type"] = "dict" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
141 self.SaveDoc() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
142 return "added plugin" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
143 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
144 def FetchDict(self, parent): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
145 retdict = {} |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
146 if not len(parent): return {} |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
147 for ditem in parent[0]._dir: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
148 if len(ditem): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
149 ditem._attrs["name"] = self.normal(ditem._attrs["name"]) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
150 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 else: retdict[ditem._attrs["name"]] = "" |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
157 return retdict |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
158 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
159 def GetDict(self, plugname, dictname, defaultval, verbose=0): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
160 dictname = self.safe(dictname) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
161 for plugin in self.xml_dom: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
162 if plugname == plugin._name: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
163 for child in plugin._dir: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
164 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
|
165 else: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
166 if verbose: |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
167 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
|
168 return defaultval |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
169 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
170 def safe(self, string): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
171 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
|
172 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
173 def normal(self, string): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
174 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
|
175 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
176 def SaveDoc(self): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
177 f = open(self.filename, "w") |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
178 f.write(self.xml_dom.__repr__(1, 1)) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
179 f.close() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
180 |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
181 def LoadDoc(self): |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
182 xml_file = open(self.filename) |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
183 manifest = xml_file.read() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
184 xml_file.close() |
3687514e0218
I actally forgot the Update Manager's new package. Sorry.
sirebral
parents:
diff
changeset
|
185 return xmltramp.parse(manifest) |