MoobotFactoids: Use Supybot's shlex instead of the standard library's.

Supybot's uses a separator whitelist instead of a 'valid chars' blacklist,
which is better when handling non-ascii charsets.
This commit is contained in:
Valentin Lorentz 2012-08-04 14:00:23 +02:00
parent 602f1c7ecb
commit b17228d683

View File

@ -29,7 +29,6 @@
import os import os
import time import time
import shlex
import string import string
from cStringIO import StringIO from cStringIO import StringIO
@ -37,6 +36,7 @@ from cStringIO import StringIO
import supybot.conf as conf import supybot.conf as conf
import supybot.ircdb as ircdb import supybot.ircdb as ircdb
import supybot.utils as utils import supybot.utils as utils
import supybot.shlex as shlex
from supybot.commands import * from supybot.commands import *
import supybot.plugins as plugins import supybot.plugins as plugins
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
@ -44,9 +44,8 @@ import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('MoobotFactoids') _ = PluginInternationalization('MoobotFactoids')
allchars = string.maketrans('', '')
class OptionList(object): class OptionList(object):
validChars = allchars.translate(allchars, '|()') separators = '|()'
def _insideParens(self, lexer): def _insideParens(self, lexer):
ret = [] ret = []
while True: while True:
@ -73,7 +72,7 @@ class OptionList(object):
lexer.commenters = '' lexer.commenters = ''
lexer.quotes = '' lexer.quotes = ''
lexer.whitespace = '' lexer.whitespace = ''
lexer.wordchars = self.validChars lexer.separators += self.separators
ret = [] ret = []
while True: while True:
token = lexer.get_token() token = lexer.get_token()