SupyML: remove all the proxify and proxifyIrc variables
parent
0ad6fb5bfd
commit
08f1d9f826
|
@ -95,41 +95,33 @@ class SupyMLParser:
|
||||||
self.warnings = []
|
self.warnings = []
|
||||||
self.data = self._parse(code)
|
self.data = self._parse(code)
|
||||||
|
|
||||||
def _run(self, code, proxify):
|
def _run(self, code):
|
||||||
"""Runs the command using Supybot engine"""
|
"""Runs the command using Supybot engine"""
|
||||||
tokens = callbacks.tokenize(str(code))
|
tokens = callbacks.tokenize(str(code))
|
||||||
if proxify:
|
fakeIrc = FakeIrc(self._irc)
|
||||||
fakeIrc = FakeIrc(self._irc)
|
# TODO : add nested level
|
||||||
# TODO : add nested level
|
|
||||||
else:
|
|
||||||
fakeIrc = self._irc
|
|
||||||
self._plugin.Proxy(fakeIrc, self._msg, tokens)
|
self._plugin.Proxy(fakeIrc, self._msg, tokens)
|
||||||
self.rawData = fakeIrc._rawData
|
self.rawData = fakeIrc._rawData
|
||||||
if proxify:
|
# TODO : don't wait if the plugin is not threaded
|
||||||
# TODO : don't wait if the plugin is not threaded
|
time.sleep(0.1)
|
||||||
time.sleep(0.1)
|
return fakeIrc._data
|
||||||
return fakeIrc._data
|
|
||||||
|
|
||||||
def _parse(self, code, variables={}, proxify=False):
|
def _parse(self, code, variables={}):
|
||||||
"""Returns a dom object from the code."""
|
"""Returns a dom object from the code."""
|
||||||
dom = minidom.parseString(code)
|
dom = minidom.parseString(code)
|
||||||
output = self._processDocument(dom, variables, proxify)
|
output = self._processDocument(dom, variables)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def _processDocument(self, dom, variables={}, proxify=False):
|
def _processDocument(self, dom, variables={}):
|
||||||
"""Handles the root node and call child nodes"""
|
"""Handles the root node and call child nodes"""
|
||||||
proxify = True
|
|
||||||
for childNode in dom.childNodes:
|
for childNode in dom.childNodes:
|
||||||
if isinstance(childNode, minidom.Element):
|
if isinstance(childNode, minidom.Element):
|
||||||
output = self._processNode(childNode, variables, proxify)
|
output = self._processNode(childNode, variables)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def _processNode(self, node, variables, proxifyIrc=True):
|
def _processNode(self, node, variables):
|
||||||
"""Returns the value of an internapreted node.
|
"""Returns the value of an internapreted node."""
|
||||||
|
|
||||||
Takes an optional attribute, passed to self._run() that mean if the
|
|
||||||
Irc object should be proxified. If it is not, the real Irc object is
|
|
||||||
used, datas are sent to IRC, and this function will return None."""
|
|
||||||
if isinstance(node, minidom.Text):
|
if isinstance(node, minidom.Text):
|
||||||
return node.data
|
return node.data
|
||||||
output = node.nodeName + ' '
|
output = node.nodeName + ' '
|
||||||
|
@ -146,10 +138,9 @@ class SupyMLParser:
|
||||||
output += self._processSet(childNode, variables)
|
output += self._processSet(childNode, variables)
|
||||||
else:
|
else:
|
||||||
output += self._processNode(childNode, variables) or ''
|
output += self._processNode(childNode, variables) or ''
|
||||||
value = self._run(output, proxifyIrc)
|
value = self._run(output)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
# Don't proxify variables
|
|
||||||
def _processSet(self, node, variables):
|
def _processSet(self, node, variables):
|
||||||
"""Handles the <set> tag"""
|
"""Handles the <set> tag"""
|
||||||
variableName = str(node.attributes['name'].value)
|
variableName = str(node.attributes['name'].value)
|
||||||
|
@ -187,7 +178,7 @@ class SupyMLParser:
|
||||||
if loopType == 'while':
|
if loopType == 'while':
|
||||||
try:
|
try:
|
||||||
while utils.str.toBool(self._parse(loopCond, variables,
|
while utils.str.toBool(self._parse(loopCond, variables,
|
||||||
True).split(': ')[-1]):
|
).split(': ')[-1]):
|
||||||
loopContent = '<echo>%s</echo>' % loopContent
|
loopContent = '<echo>%s</echo>' % loopContent
|
||||||
output += self._parse(loopContent) or ''
|
output += self._parse(loopContent) or ''
|
||||||
except AttributeError: # toBool() failed
|
except AttributeError: # toBool() failed
|
||||||
|
|
Loading…
Reference in New Issue