annotate plugins/xxstdnamespace.py @ 39:ed322725b928 ornery-orc tip

Traipse 'OpenRPG' {110114-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 (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 New IronClaw roller, sheet, and image New ShapeShifter PC Sheet 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 Update to Hidden Die plugin, allows for non standard dice rolls Update to location.py, allows for more portable references when starting Traipse Update to the Features node 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 Server, removing wxPython dependencies where not needed 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 Fix to Send to Chat from Gametree Fix to Gametree, renaming and remapping operates correctly Fix to aliaslib, prevents error caused when SafeHTML is sent None
author sirebral
date Fri, 14 Jan 2011 05:24:52 -0600
parents d02e9197c066
children
rev   line source
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
1 import os, wx, re
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
2 import orpg.pluginhandler
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
3 from orpg.tools.InterParse import Parse
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
4 from orpg.orpgCore import component
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
5 from xml.etree.ElementTree import iselement
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
6
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
7 class Plugin(orpg.pluginhandler.PluginHandler):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
8 # Initialization subroutine.
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
9 #
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
10 # !self : instance of self
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
11 # !openrpg : instance of the the base openrpg control
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
12 def __init__(self, plugindb, parent):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
13 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
14
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
15 # The Following code should be edited to contain the proper information
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
16 self.name = 'Standard Namespace'
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
17 self.author = 'Prof. Ebral'
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
18 self.help = 'The Standard Namespace plugin allows for users of Traipse to use '
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
19 self.help += 'the Standard Namespace syntax of !@ :: @!\n\n'
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
20 self.help += 'This plugin modifies the External method, so context sensivity\n'
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
21 self.help += 'is not calculated when using the Standard syntax. References must '
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
22 self.help += 'have a unique name.'
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
23
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 34
diff changeset
24 self.parseMethods = {'Traipse': Parse.NameSpaceE, 'Standard': self.NameSpaceS}
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
25
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
26 def NameSpaceS(self, s): ## Re define NameSpace External
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 34
diff changeset
27 reg1 = re.compile("(!@(.*?)@!)") ## Inlcude 'Standard' method
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
28 reg2 = re.compile("(!&(.*?)&!)")
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
29 matches = reg1.findall(s) + reg2.findall(s)
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
30 newstr = False
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
31 nodeable = ['rpg_grid_handler', 'container_handler',
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
32 'group_handler', 'tabber_handler',
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
33 'splitter_handler', 'form_handler', 'textctrl_handler']
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
34 for i in xrange(0,len(matches)):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
35 find = matches[i][1].split('::')
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
36 node = component.get('tree').xml_root
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
37 if not iselement(node):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
38 s = s.replace(matches[i][0], 'Invalid Reference!', 1);
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 34
diff changeset
39 s = Parse.NameSpaceE(s)
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
40 return s
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
41 for x in xrange(0, len(find)):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
42 namespace = node.getiterator('nodehandler')
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
43 for node in namespace:
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
44 if find[x] == node.get('name'):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
45 if node.get('class') not in nodeable: continue
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
46 if node.get('class') == 'rpg_grid_handler':
36
d02e9197c066 Traipse 'OpenRPG' {101220-00}
sirebral
parents: 34
diff changeset
47 try: newstr = self.NameSpaceGrid(find[x+1], node); break
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
48 except: newstr = 'Invalid Grid Reference!'
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
49 try:
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
50 if Parse.FutureCheck(node, find[x+1]): break
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
51 else: continue
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
52 except:
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
53 if x == len(find)-1:
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
54 if node.find('text') != None: newstr = str(node.find('text').text)
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
55 else: newstr = 'Invalid Reference!'
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
56 break
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
57 else: break
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
58 if not newstr: newstr = 'Invalid Reference!'
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
59 s = s.replace(matches[i][0], newstr, 1)
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
60 s = Parse.ParseLogic(s, node)
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
61 return s
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
62
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
63 def plugin_menu(self):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
64 ## This is a standardized Menu item. It connects to plugin_toggle where you can set events.
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
65 self.menu = wx.Menu()
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
66 self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On')
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
67 self.topframe.Bind(wx.EVT_MENU, self.plugin_toggle, self.toggle)
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
68 self.toggle.Check(True)
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
69
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
70 def plugin_toggle(self, evt):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
71 if self.toggle.IsChecked() == True:
34
1fb663829ef6 Traipse 'OpenRPG' {100504-00}
sirebral
parents: 31
diff changeset
72 Parse.NameSpaceE = self.parseMethods['Standard']
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
73 self.plugindb.SetString('xxstdnamespace', 'Standard', 'True')
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
74 if self.toggle.IsChecked() == False:
34
1fb663829ef6 Traipse 'OpenRPG' {100504-00}
sirebral
parents: 31
diff changeset
75 Parse.NameSpaceE = self.parseMethods['Traipse']
31
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
76 self.plugindb.SetString('xxstdnamespace', 'Standard', 'False')
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
77 pass
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
78
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
79 def plugin_enabled(self):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
80 self.onoroff = self.plugindb.GetString('xxstdnamespace', 'Standard', '') or 'False'
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
81 self.toggle.Check(True) if self.onoroff == 'True' else self.toggle.Check(False)
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
82 Parse.NameSpaceE = self.parseMethods['Standard'] if self.onoroff == 'True' else self.parseMethods['Traipse']
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
83 pass
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
84
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
85 def plugin_disabled(self):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
86 Parse.NameSpaceE = self.parseMethods['Traipse']
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
87
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
88 def pre_parse(self, text):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
89 return text
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
90
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
91 def send_msg(self, text, send):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
92 return text, send
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
93
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
94 def plugin_incoming_msg(self, text, type, name, player):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
95 return text, type, name
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
96
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
97 def post_msg(self, text, myself):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
98 return text
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
99
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
100 def refresh_counter(self):
fc48380f0c9f Traipse Beta 'OpenRPG' {100503-00}
sirebral
parents:
diff changeset
101 pass