comparison orpg/tools/InterParse.py @ 36:d02e9197c066 ornery-orc

Traipse 'OpenRPG' {101220-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 Sun, 19 Dec 2010 22:44:36 -0600
parents fc48380f0c9f
children
comparison
equal deleted inserted replaced
35:ee890f424e16 36:d02e9197c066
42 if not tab: tab = component.get('chat') 42 if not tab: tab = component.get('chat')
43 s = self.Normalize(s, tab) 43 s = self.Normalize(s, tab)
44 tab.set_colors() 44 tab.set_colors()
45 tab.Post(s, send, myself) 45 tab.Post(s, send, myself)
46 46
47 def ParseLogic(self, s, node): 47 def ParseLogic(self, s, node=None):
48 'Nodes now parse through ParsLogic. Easily add new parse rules right here!!' 48 'Nodes now parse through ParsLogic. Easily add new parse rules right here!!'
49 s = self.NameSpaceE(s) 49 if not node: s = self.NameSpaceE(s)
50 s = self.NameSpaceI(s, node) 50 s = self.NameSpaceI(s, node)
51 s = self.NodeMap(s, node) 51 #s = self.NodeMap(s, node)
52 s = self.NodeParent(s, node.get('map')) 52 #s = self.NodeParent(s, node)
53 return s 53 return s
54 54
55 def Normalize(self, s, tab): 55 def Normalize(self, s, tab=False):
56 if not tab: tab = component.get('chat')
56 for plugin_fname in tab.activeplugins.keys(): 57 for plugin_fname in tab.activeplugins.keys():
57 plugin = tab.activeplugins[plugin_fname] 58 plugin = tab.activeplugins[plugin_fname]
58 try: s = plugin.pre_parse(s) 59 try: s = plugin.pre_parse(s)
59 except Exception, e: 60 except Exception, e:
60 if str(e) != "'module' object has no attribute 'post_msg'": 61 if str(e) != "'module' object has no attribute 'post_msg'":
156 """If you found this you found my first easter egg. I was tired of people telling me multiple 157 """If you found this you found my first easter egg. I was tired of people telling me multiple
157 references syntax for the game tree is confusing, so I dropped this in there without telling 158 references syntax for the game tree is confusing, so I dropped this in there without telling
158 anyone. Using !" :: "! will allow you to use an internal namespace from within another internal 159 anyone. Using !" :: "! will allow you to use an internal namespace from within another internal
159 namespace -- TaS, Prof. Ebral""" 160 namespace -- TaS, Prof. Ebral"""
160 reg2 = re.compile("(!=(.*?)=!)") 161 reg2 = re.compile("(!=(.*?)=!)")
161 matches = reg1.findall(s) + reg2.findall(s) 162 """Adding the Parent and Child references to Namespace Internal. Namespace 2.0 is powerful enough it
162 tree_map = node.get('map') 163 should be able to handle them with no problem. For future reference, if you are paying attention, Namespace
164 will include two methods for Internal and External. !@ :: @! and !& :: &! for External and !" :: "! and != :: =!
165 for Internal. See above Easter Egg for reasoning."""
166 reg3 = re.compile("(!!(.*?)!!)")
167 reg4 = re.compile("(!#(.*?)#!)")
168 matches = reg1.findall(s) + reg2.findall(s) + reg3.findall(s) + reg4.findall(s)
169 try: tree_map = node.get('map')
170 except: return node
163 for i in xrange(0,len(matches)): 171 for i in xrange(0,len(matches)):
164 ## Build the new tree_map 172 ## Build the new tree_map
165 new_map = tree_map.split('::') 173 new_map = tree_map.split('::')
174 if new_map == ['']: new_map = [node.get('name')]
166 find = matches[i][1].split('::') 175 find = matches[i][1].split('::')
167 ## Backwards Reference the Parent Children 176 ## Backwards Reference the Parent Children
168 node = self.get_node(new_map) 177 node = self.get_node(new_map)
169 newstr = self.LocationCheck(node, tree_map, new_map, find) 178 newstr = self.LocationCheck(node, tree_map, new_map, find)
170 s = s.replace(matches[i][0], newstr, 1) 179 s = s.replace(matches[i][0], newstr, 1)
171 s = self.ParseLogic(s, node) 180 s = s.replace(u'\xa0', ' ')
172 return s 181 s = self.NameSpaceI(s, node)
182 return s
183
184 def NameSpaceXE(self, s):
185 reg = re.compile("(!&(.*?)&!)")
186 matches = reg.findall(s)
187 nodeable = ['rpg_grid_handler', 'container_handler',
188 'group_handler', 'tabber_handler',
189 'splitter_handler', 'form_handler', 'textctrl_handler']
190
191 for i in xrange(0,len(matches)):
192 find = matches[i][1].split('::')
193 node = component.get('tree').xml_root
194 for x in xrange(0, len(find)):
195 namespace = node.getiterator('nodehandler')
196 for node in namespace:
197 if find[x] == node.get('name'):
198 if node.get('class') not in nodeable: continue
199 try:
200 if self.FutureCheck(node, find[x+1]): break
201 else: continue
202 except:
203 if x == len(find)-1:
204 return node
205 break
206 else: break
207 return None
173 208
174 def NameSpaceE(self, s): 209 def NameSpaceE(self, s):
175 reg = re.compile("(!&(.*?)&!)") 210 reg = re.compile("(!&(.*?)&!)")
176 matches = reg.findall(s) 211 matches = reg.findall(s)
177 newstr = False 212 newstr = False
202 else: newstr = 'Invalid Reference!' 237 else: newstr = 'Invalid Reference!'
203 break 238 break
204 else: break 239 else: break
205 if not newstr: newstr = 'Invalid Reference!' 240 if not newstr: newstr = 'Invalid Reference!'
206 s = s.replace(matches[i][0], newstr, 1) 241 s = s.replace(matches[i][0], newstr, 1)
242 s = s.replace(u'\xa0', ' ') #Required for XSLT sheets
207 s = self.ParseLogic(s, node) 243 s = self.ParseLogic(s, node)
208 return s 244 return s
209 245
210 def NameSpaceGrid(self, s, node): 246 def NameSpaceGrid(self, s, node):
211 cell = tuple(s.strip('(').strip(')').split(',')) 247 cell = tuple(s.strip('(').strip(')').split(','))
222 cur_loc = 0 258 cur_loc = 0
223 reg = re.compile("(!!(.*?)!!)") 259 reg = re.compile("(!!(.*?)!!)")
224 matches = reg.findall(s) 260 matches = reg.findall(s)
225 for i in xrange(0,len(matches)): 261 for i in xrange(0,len(matches)):
226 tree_map = node.get('map') 262 tree_map = node.get('map')
227 tree_map = tree_map + '::' + matches[i][1] 263 tree_map = str(tree_map + '::' + matches[i][1])
228 newstr = '!@'+ tree_map +'@!' 264 if tree_map[:2] == '::': tree_map = tree_map[2:]
265 newstr = '!@'+ str(tree_map) +'@!'
229 s = s.replace(matches[i][0], newstr, 1) 266 s = s.replace(matches[i][0], newstr, 1)
230 s = self.Node(s) 267 s = self.Node(s)
231 s = self.NodeParent(s, tree_map) 268 s = self.NodeParent(s, node)
232 return s 269 return s
233 270
234 def NodeParent(self, s, tree_map): 271 def NodeParent(self, s, node):
235 """Parses player input for embedded nodes rolls""" 272 """Parses player input for embedded nodes rolls"""
273 if node == 'Invalid Reference!': return node
274 tree_map = node.get('map')
236 cur_loc = 0 275 cur_loc = 0
237 reg = re.compile("(!#(.*?)#!)") 276 reg = re.compile("(!#(.*?)#!)")
238 matches = reg.findall(s) 277 matches = reg.findall(s)
239 for i in xrange(0,len(matches)): 278 for i in xrange(0,len(matches)):
240 ## Build the new tree_map 279 ## Build the new tree_map