Mercurial > traipse_dev
view upmana/manifest.py @ 121:496dbf12a6cb alpha
Traipse Alpha 'OpenRPG' {091030-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 (Cleaning up for Beta):
Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images!
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.
Fix to remote admin commands
Minor fix to texted based server, works in /System/ folder
Some Core changes to gametree to correctly disply Pretty Print, thanks David!
Fix to Splitter Nodes not being created.
Added images to Plugin Control panel for Autostart feature
Fix to massive amounts of images loading; from Core
fix to gsclient so with_statement imports
Added 'boot' command to remote admin
Prep work in Pass tool for remote admin rankings and different passwords, ei,
Server, Admin, Moderator, etc.
Remote Admin Commands more organized, more prep work.
Added Confirmation window for sent nodes.
Minor changes to allow for portability to an OpenSUSE linux OS (hopefully without
breaking)
{091028}
Made changes to gametree to start working with Element Tree, mostly from Core
Minor changes to Map to start working with Element Tree, from Core
Preliminary changes to map efficiency, from FlexiRPG
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Changes to main.py to start working with Element Tree
{091029}
Changes made to server to start working with Element Tree.
Changes made to Meta Server Lib. Prepping test work for a multi meta network
page.
Minor bug fixed with mini to gametree
Zoom Mouse plugin added.
{091030}
Getting ready for Beta. Server needs debugging so Alpha remains bugged.
Plugin UI code cleaned. Auto start works with a graphic, pop-up asks to enable or
disable plugin.
Update Manager now has a partially working Status Bar. Status Bar captures
terminal text, so Merc out put is visible. Manifest.xml file, will be renamed, is
now much cleaner.
Debug Console has a clear button and a Report Bug button. Prep work for a Term2Win
class in Debug Console.
Known: Current Alpha fails in Windows.
author | sirebral |
---|---|
date | Fri, 30 Oct 2009 22:21:40 -0500 |
parents | c54768cffbd4 |
children | 36919b8a3ef9 |
line wrap: on
line source
from __future__ import with_statement from orpg.dirpath import dir_struct from upmana.validate import validate from orpg.tools.orpg_log import logger from os import sep, getcwd from types import * from xml.etree.ElementTree import ElementTree, Element, parse, fromstring from xml.etree.ElementPath import find class ManifestChanges(object): etree = ElementTree() filename = dir_struct['home'] + 'upmana' + sep + 'updatemana.xml' def __new__(cls, *args, **kwargs): it = cls.__dict__.get("__it__") if it is not None: return it cls.__it__ = it = object.__new__(cls) it._init() return it def _init(self): validate.config_file('updatemana.xml', "default_manifest.xml") self.LoadDoc() def PluginChildren(self, plugname): plugin = self.etree.find(plugname) children = plugin.getchildren() nodes = [] for child in children: nodes.append(child.tag) return nodes def GetString(self, plugname, strname, defaultval="", verbose=False): strname = self.safe(strname) plugin = self.etree.find(plugname) if plugin is None or plugin.find(strname) is None: msg = ["plugindb: no value has been stored for", strname, "in", plugname, "so the default has been returned"] return defaultval return self.normal(plugin.find(strname).text) def DelString(self, plugname, strname): strname = self.safe(strname) plugin = self.etree.find(plugname) plugin.remove(plugin.find(strname)) self.SaveDoc() def SetString(self, plugname, strname, val): val = self.safe(val) strname = self.safe(strname) plugin = self.etree.find(plugname) if plugin is None: plugin = Element(plugname) self.etree.getroot().append(plugin) str_el = plugin.find(strname) if str_el is None: str_el = Element(strname) str_el.set('type', 'str') plugin.append(str_el) str_el.text = val self.SaveDoc() def FetchList(self, parent): retlist = [] for litem in parent.findall('lobject'): if litem.get('type') == 'int': retlist.append(int(litem.text)) if litem.get('type') == 'bool': retlist.append(litem.text == 'True') elif litem.get('type') == 'float': retlist.append(float(litem.text)) elif litem.get('type') == 'list': retlist.append(self.FetchList(litem)) elif litem.get('type') == 'dict': retlist.append(self.FetchDict(litem)) else: retlist.append(str(self.normal(litem.text))) return retlist def GetList(self, plugname, listname, defaultval=list(), verbose=False): listname = self.safe(listname) plugin = self.etree.find(plugname) if plugin is None or plugin.find(listname) is None: msg = ["plugindb: no value has been stored for", listname, "in", plugname, "so the default has been returned"] return defaultval retlist = self.FetchList(plugin.find(listname)) return retlist def BuildList(self, val): list_el = Element('list') for item in val: i = Element('lobject') if isinstance(item, bool): i.set('type', 'bool') i.text = str(item) elif isinstance(item, int):#it's an int i.set('type', 'int') i.text = str(item) elif isinstance(item, float):#it's a float i.set('type', 'float') i.text = str(item) elif isinstance(item, (list, tuple)):#it's a list i.set('type', 'list') i.append(self.BuildList(item)) elif isinstance(item, dict):#it's a dictionary i.set('type', 'dict') i.append(self.BuildDict(item)) else: i.set('type', 'str') i.text = self.safe(item) list_el.append(i) return list_el def SetList(self, plugname, listname, val): listname = self.safe(listname) plugin = self.etree.find(plugname) if plugin is None: plugin = Element(plugname) self.etree.getroot().append(plugin) list_el = plugin.find(listname) if list_el is None: list_el = Element(listname) list_el.set('type', 'list') plugin.append(list_el) else: list_el.remove(list_el.find('list')) list_el.append(self.BuildList(val)) self.SaveDoc() def BuildDict(self, val): dict_el = Element('dict') for key, item in val.items(): i = Element('dobject') if isinstance(item, bool): i.set('type', 'bool') i.set('name', self.safe(key)) i.text = str(item) elif isinstance(item, int):#it's an int i.set('type', 'int') i.set('name', self.safe(key)) i.text = str(item) elif isinstance(item, float):#it's a float i.set('type', 'float') i.set('name', self.safe(key)) i.text = str(item) elif isinstance(item, (list, tuple)):#it's a list i.set('type', 'list') i.set('name', self.safe(key)) i.append(self.BuildList(item)) elif isinstance(item, dict):#it's a dictionary i.set('type', 'dict') i.set('name', self.safe(key)) i.append(self.BuildDict(item)) else: i.set('type', 'str') i.set('name', self.safe(key)) i.text = self.safe(item) dict_el.append(i) return dict_el def SetDict(self, plugname, dictname, val): dictname = self.safe(dictname) plugin = self.etree.find(plugname) if plugin is None: plugin = Element(plugname) self.etree.getroot().append(plugin) dict_el = plugin.find(dictname) if dict_el is None: dict_el = Element(dictname) dict_el.set('type', 'dict') plugin.append(dict_el) else: dict_el.remove(list_el.find('dict')) dict_el.append(self.BuildDict(val)) self.SaveDoc() def FetchDict(self, parent): retdict = {} for ditem in parent.findall('dobject'): key = self.normal(ditem.get('name')) if ditem.get('type') == 'int': value = int(ditem.text) elif ditem.get('type') == 'bool': value = ditem.text == 'True' elif ditem.get('type') == 'float': value = float(ditem.text) elif ditem.get('type') == 'list': value = self.FetchList(ditem) elif ditem.get('type') == 'dict': value = self.FetchDict(ditem) else: value = str(self.normal(ditem[0])) retdict[key] = value return retdict def GetDict(self, plugname, dictname, defaultval=dict(), verbose=False): dictname = self.safe(dictname) plugin = self.etree.find(plugname) if plugin is None or plugin.find(dictname) is None: msg = ["plugindb: no value has been stored for", dictname, "in", plugname, "so the default has been returned"] return defaultval retdict = self.FetchDict(plugin.find(dictname)) return retdict def safe(self, string): return string.replace("<", "$$lt$$").replace(">", "$$gt$$")\ .replace("&","$$amp$$").replace('"',"$$quote$$") def normal(self, string): return string.replace("$$lt$$", "<").replace("$$gt$$", ">")\ .replace("$$amp$$","&").replace("$$quote$$",'"') def SaveDoc(self): with open(self.filename, "w") as f: self.etree.write(f) def LoadDoc(self): with open(self.filename) as f: self.etree.parse(f) manifest = ManifestChanges()