mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-25 20:29:23 +01:00
Remove fix_basestring.
This commit is contained in:
parent
2c380a4c3a
commit
f305ff3c02
@ -99,7 +99,7 @@ class FilterTest(ChannelPluginTestCase):
|
||||
self.assertResponse('rot13 [rot13 %s]' % s, s)
|
||||
|
||||
def testRot13HandlesNonAsciiStuff(self):
|
||||
self.assertNotError(u('rot13 é'))
|
||||
self.assertNotError('rot13 é')
|
||||
|
||||
def testHexlifyUnhexlify(self):
|
||||
for s in map(str, range(1000, 1010)):
|
||||
|
@ -127,7 +127,7 @@ class Google(callbacks.PluginRegexp):
|
||||
return data
|
||||
|
||||
def formatData(self, data, bold=True, max=0, onetoone=False):
|
||||
if isinstance(data, basestring):
|
||||
if isinstance(data, minisix.string_types):
|
||||
return data
|
||||
results = []
|
||||
if max:
|
||||
|
@ -32,6 +32,7 @@ import supybot.dbi as dbi
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.minisix as minisix
|
||||
import supybot.plugins as plugins
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.ircutils as ircutils
|
||||
@ -114,7 +115,7 @@ class URL(callbacks.Plugin):
|
||||
f = None
|
||||
nolimit = False
|
||||
for (option, arg) in optlist:
|
||||
if isinstance(arg, basestring):
|
||||
if isinstance(arg, minisix.string_types):
|
||||
arg = arg.lower()
|
||||
if option == 'nolimit':
|
||||
nolimit = True
|
||||
|
@ -26,7 +26,7 @@ def error(s):
|
||||
|
||||
def system(sh, errmsg=None, **kwargs):
|
||||
if errmsg is None:
|
||||
if isinstance(sh, basestring):
|
||||
if isinstance(sh, minisix.string_types):
|
||||
errmsg = repr(sh)
|
||||
else:
|
||||
errmsg = repr(' '.join(sh))
|
||||
|
2
setup.py
2
setup.py
@ -157,7 +157,7 @@ try:
|
||||
def log_debug(self, msg, *args):
|
||||
log.debug(msg, *args)
|
||||
|
||||
fixer_names = ['fix_basestring',
|
||||
fixer_names = [
|
||||
'fix_metaclass',
|
||||
'fix_numliterals',
|
||||
]
|
||||
|
@ -382,7 +382,7 @@ def formatCommand(command):
|
||||
return ' '.join(command)
|
||||
|
||||
def checkCommandCapability(msg, cb, commandName):
|
||||
assert isinstance(commandName, basestring), commandName
|
||||
assert isinstance(commandName, minisix.string_types), commandName
|
||||
plugin = cb.name().lower()
|
||||
pluginCommand = '%s.%s' % (plugin, commandName)
|
||||
def checkCapability(capability):
|
||||
@ -458,9 +458,9 @@ class RichReplyMethods(object):
|
||||
prefixer = ''
|
||||
if joiner is None:
|
||||
joiner = utils.str.commaAndify
|
||||
if isinstance(prefixer, basestring):
|
||||
if isinstance(prefixer, minisix.string_types):
|
||||
prefixer = prefixer.__add__
|
||||
if isinstance(joiner, basestring):
|
||||
if isinstance(joiner, minisix.string_types):
|
||||
joiner = joiner.join
|
||||
if oneToOne is None: # Can be True, False, or None
|
||||
if ircutils.isChannel(to):
|
||||
@ -495,7 +495,7 @@ class RichReplyMethods(object):
|
||||
def errorNoCapability(self, capability, s='', **kwargs):
|
||||
if 'Raise' not in kwargs:
|
||||
kwargs['Raise'] = True
|
||||
if isinstance(capability, basestring): # checkCommandCapability!
|
||||
if isinstance(capability, minisix.string_types): # checkCommandCapability!
|
||||
log.warning('Denying %s for lacking %q capability.',
|
||||
self.msg.prefix, capability)
|
||||
# noCapability means "don't send a specific capability error
|
||||
@ -669,7 +669,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
||||
def evalArgs(self):
|
||||
while self.counter < len(self.args):
|
||||
self.repliedTo = False
|
||||
if isinstance(self.args[self.counter], basestring):
|
||||
if isinstance(self.args[self.counter], minisix.string_types):
|
||||
# If it's a string, just go to the next arg. There is no
|
||||
# evaluation to be done for strings. If, at some point,
|
||||
# we decided to, say, convert every string using
|
||||
@ -692,7 +692,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
||||
return
|
||||
# Once all the list args are evaluated, we then evaluate our own
|
||||
# list of args, since we're assured that they're all strings now.
|
||||
assert all(lambda x: isinstance(x, basestring), self.args)
|
||||
assert all(lambda x: isinstance(x, minisix.string_types), self.args)
|
||||
self.finalEval()
|
||||
|
||||
def _callInvalidCommands(self):
|
||||
@ -873,7 +873,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
||||
# action=True implies noLengthCheck=True and prefixNick=False
|
||||
self.noLengthCheck=noLengthCheck or self.noLengthCheck or self.action
|
||||
target = self.private and self.to or self.msg.args[0]
|
||||
if not isinstance(s, basestring): # avoid trying to str() unicode
|
||||
if not isinstance(s, minisix.string_types): # avoid trying to str() unicode
|
||||
s = str(s) # Allow non-string esses.
|
||||
if self.finalEvaled:
|
||||
try:
|
||||
@ -1184,7 +1184,7 @@ class Commands(BasePlugin):
|
||||
|
||||
def isCommand(self, command):
|
||||
"""Convenience, backwards-compatibility, semi-deprecated."""
|
||||
if isinstance(command, basestring):
|
||||
if isinstance(command, minisix.string_types):
|
||||
return self.isCommandMethod(command)
|
||||
else:
|
||||
# Since we're doing a little type dispatching here, let's not be
|
||||
@ -1210,7 +1210,7 @@ class Commands(BasePlugin):
|
||||
def getCommandMethod(self, command):
|
||||
"""Gets the given command from this plugin."""
|
||||
#print '*** %s.getCommandMethod(%r)' % (self.name(), command)
|
||||
assert not isinstance(command, basestring)
|
||||
assert not isinstance(command, minisix.string_types)
|
||||
assert command == list(map(canonicalName, command))
|
||||
assert self.getCommand(command) == command
|
||||
for cb in self.cbs:
|
||||
|
@ -681,7 +681,7 @@ def getMatch(irc, msg, args, state, regexp, errmsg):
|
||||
|
||||
def getLiteral(irc, msg, args, state, literals, errmsg=None):
|
||||
# ??? Should we allow abbreviations?
|
||||
if isinstance(literals, basestring):
|
||||
if isinstance(literals, minisix.string_types):
|
||||
literals = (literals,)
|
||||
abbrevs = utils.abbrev(literals)
|
||||
if args[0] in abbrevs:
|
||||
@ -827,7 +827,7 @@ class context(object):
|
||||
self.converter = getConverter(spec[0])
|
||||
elif spec is None:
|
||||
self.converter = getConverter('anything')
|
||||
elif isinstance(spec, basestring):
|
||||
elif isinstance(spec, minisix.string_types):
|
||||
self.args = ()
|
||||
self.converter = getConverter(spec)
|
||||
else:
|
||||
|
@ -35,7 +35,7 @@ import os
|
||||
import csv
|
||||
import math
|
||||
|
||||
from . import cdb, utils
|
||||
from . import cdb, minisix, utils
|
||||
from .utils.iter import ilen
|
||||
|
||||
class Error(Exception):
|
||||
@ -329,7 +329,7 @@ class DB(object):
|
||||
self.Record = Record
|
||||
if Mapping is not None:
|
||||
self.Mapping = Mapping
|
||||
if isinstance(self.Mapping, basestring):
|
||||
if isinstance(self.Mapping, minisix.string_types):
|
||||
self.Mapping = Mappings[self.Mapping]
|
||||
self.map = self.Mapping(filename)
|
||||
|
||||
|
@ -36,7 +36,7 @@ import sys
|
||||
import time
|
||||
import socket
|
||||
|
||||
from .. import conf, ircmsgs, log as supylog, utils
|
||||
from .. import conf, ircmsgs, log as supylog, minisix, utils
|
||||
|
||||
_drivers = {}
|
||||
_deadDrivers = []
|
||||
@ -154,7 +154,7 @@ class Log(object):
|
||||
def reconnect(self, network, when=None):
|
||||
s = 'Reconnecting to %s' % network
|
||||
if when is not None:
|
||||
if not isinstance(when, basestring):
|
||||
if not isinstance(when, minisix.string_types):
|
||||
when = self.timestamp(when)
|
||||
s += ' at %s.' % when
|
||||
else:
|
||||
|
@ -33,7 +33,7 @@ import os
|
||||
import time
|
||||
import operator
|
||||
|
||||
from . import conf, ircutils, log, registry, unpreserve, utils, world
|
||||
from . import conf, ircutils, log, minisix, registry, unpreserve, utils, world
|
||||
|
||||
def isCapability(capability):
|
||||
return len(capability.split(None, 1)) == 1
|
||||
@ -303,7 +303,7 @@ class IrcUser(object):
|
||||
def addNick(self, network, nick):
|
||||
"""Adds a nick to the user's registered nicks on the network."""
|
||||
global users
|
||||
assert isinstance(network, basestring)
|
||||
assert isinstance(network, minisix.string_types)
|
||||
assert ircutils.isNick(nick), 'got %s' % nick
|
||||
if users.getUserFromNick(network, nick) is not None:
|
||||
raise KeyError
|
||||
@ -314,7 +314,7 @@ class IrcUser(object):
|
||||
|
||||
def removeNick(self, network, nick):
|
||||
"""Removes a nick from the user's registered nicks on the network."""
|
||||
assert isinstance(network, basestring)
|
||||
assert isinstance(network, minisix.string_types)
|
||||
if nick not in self.nicks[network]:
|
||||
raise KeyError
|
||||
self.nicks[network].remove(nick)
|
||||
|
@ -809,7 +809,7 @@ def names(channel=None, prefix='', msg=None):
|
||||
def mode(channel, args=(), prefix='', msg=None):
|
||||
if msg and not prefix:
|
||||
prefix = msg.prefix
|
||||
if isinstance(args, basestring):
|
||||
if isinstance(args, minisix.string_types):
|
||||
args = (args,)
|
||||
else:
|
||||
args = tuple(map(str, args))
|
||||
|
@ -115,8 +115,8 @@ def toLower(s, casemapping=None):
|
||||
def strEqual(nick1, nick2):
|
||||
"""s1, s2 => bool
|
||||
Returns True if nick1 == nick2 according to IRC case rules."""
|
||||
assert isinstance(nick1, basestring)
|
||||
assert isinstance(nick2, basestring)
|
||||
assert isinstance(nick1, minisix.string_types)
|
||||
assert isinstance(nick2, minisix.string_types)
|
||||
return toLower(nick1) == toLower(nick2)
|
||||
|
||||
nickEqual = strEqual
|
||||
@ -609,7 +609,7 @@ def safeArgument(s):
|
||||
"""If s is unsafe for IRC, returns a safe version."""
|
||||
if minisix.PY2 and isinstance(s, unicode):
|
||||
s = s.encode('utf-8')
|
||||
elif (minisix.PY2 and not isinstance(s, basestring)) or \
|
||||
elif (minisix.PY2 and not isinstance(s, minisix.string_types)) or \
|
||||
(minisix.PY3 and not isinstance(s, str)):
|
||||
debug('Got a non-string in safeArgument: %r', s)
|
||||
s = str(s)
|
||||
|
@ -37,7 +37,7 @@ import operator
|
||||
import textwrap
|
||||
import traceback
|
||||
|
||||
from . import ansi, conf, ircutils, registry, utils
|
||||
from . import ansi, conf, ircutils, minisix, registry, utils
|
||||
|
||||
deadlyExceptions = [KeyboardInterrupt, SystemExit]
|
||||
|
||||
@ -95,7 +95,7 @@ class StdoutStreamHandler(logging.StreamHandler):
|
||||
if record.levelname != 'ERROR' and conf.supybot.log.stdout.wrap():
|
||||
# We check for ERROR there because otherwise, tracebacks (which are
|
||||
# already wrapped by Python itself) wrap oddly.
|
||||
if not isinstance(record.levelname, basestring):
|
||||
if not isinstance(record.levelname, minisix.string_types):
|
||||
print(record)
|
||||
print(record.levelname)
|
||||
print(utils.stackTrace())
|
||||
|
@ -36,6 +36,7 @@ if sys.version_info[0] >= 3:
|
||||
PY3 = True
|
||||
intern = sys.intern
|
||||
integer_types = (int,)
|
||||
string_types = (str,)
|
||||
long = int
|
||||
|
||||
import io
|
||||
@ -51,6 +52,7 @@ else:
|
||||
else:
|
||||
intern = __builtins__.intern
|
||||
integer_types = (int, long)
|
||||
string_types = (basestring,)
|
||||
long = long
|
||||
|
||||
class io:
|
||||
|
@ -517,7 +517,7 @@ class String(Value):
|
||||
v = repr(v)
|
||||
try:
|
||||
v = utils.safeEval(v)
|
||||
if not isinstance(v, basestring):
|
||||
if not isinstance(v, minisix.string_types):
|
||||
raise ValueError
|
||||
self.setValue(v)
|
||||
except ValueError: # This catches utils.safeEval(s) errors too.
|
||||
|
@ -7,6 +7,8 @@
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
from . import minisix
|
||||
|
||||
__all__ = ["shlex"]
|
||||
|
||||
class shlex:
|
||||
@ -190,7 +192,7 @@ class shlex:
|
||||
if newfile[0] == '"':
|
||||
newfile = newfile[1:-1]
|
||||
# This implements cpp-like semantics for relative-path inclusion.
|
||||
if isinstance(self.infile, basestring) and not os.path.isabs(newfile):
|
||||
if isinstance(self.infile, minisix.string_types) and not os.path.isabs(newfile):
|
||||
newfile = os.path.join(os.path.dirname(self.infile), newfile)
|
||||
return (newfile, open(newfile, "r"))
|
||||
|
||||
|
@ -34,6 +34,8 @@ import random
|
||||
|
||||
from itertools import *
|
||||
|
||||
from .. import minisix
|
||||
|
||||
# For old plugins
|
||||
ifilter = filter
|
||||
def filterfalse(p, L):
|
||||
@ -102,7 +104,7 @@ def flatten(iterable, strings=False):
|
||||
"""Flattens a list of lists into a single list. See the test for examples.
|
||||
"""
|
||||
for elt in iterable:
|
||||
if not strings and isinstance(elt, basestring):
|
||||
if not strings and isinstance(elt, minisix.string_types):
|
||||
yield elt
|
||||
else:
|
||||
try:
|
||||
@ -115,7 +117,7 @@ def split(isSeparator, iterable, maxsplit=-1, yieldEmpty=False):
|
||||
"""split(isSeparator, iterable, maxsplit=-1, yieldEmpty=False)
|
||||
|
||||
Splits an iterator based on a predicate isSeparator."""
|
||||
if isinstance(isSeparator, basestring):
|
||||
if isinstance(isSeparator, minisix.string_types):
|
||||
f = lambda s: s == isSeparator
|
||||
else:
|
||||
f = isSeparator
|
||||
|
@ -539,7 +539,7 @@ def format(s, *args, **kwargs):
|
||||
if isinstance(t, tuple) and len(t) == 2:
|
||||
if not isinstance(t[0], list):
|
||||
raise ValueError('Invalid list for %%L in format: %s' % t)
|
||||
if not isinstance(t[1], basestring):
|
||||
if not isinstance(t[1], minisix.string_types):
|
||||
raise ValueError('Invalid string for %%L in format: %s' % t)
|
||||
return commaAndify(t[0], And=t[1])
|
||||
elif hasattr(t, '__iter__'):
|
||||
|
Loading…
Reference in New Issue
Block a user