Remove Python2.4-specific code.

This commit is contained in:
Valentin Lorentz 2013-07-13 17:28:21 +02:00
parent 9bfec720f5
commit 38bab185a9
10 changed files with 10 additions and 49 deletions

View File

@ -46,19 +46,6 @@ except:
_ = lambda x:x _ = lambda x:x
internationalizeDocstring = lambda x:x internationalizeDocstring = lambda x:x
# builtin any is overwritten by callbacks... and python2.4 doesn't have it
def _any(iterable):
for element in iterable:
if element:
return True
return False
# for consistency with above, and for python2.4
def _all(iterable):
for element in iterable:
if not element:
return False
return True
class Conditional(callbacks.Plugin): class Conditional(callbacks.Plugin):
"""Add the help for "@plugin help Conditional" here """Add the help for "@plugin help Conditional" here
@ -98,7 +85,7 @@ class Conditional(callbacks.Plugin):
Returns true if all conditions supplied evaluate to true. Returns true if all conditions supplied evaluate to true.
""" """
if _all(conds): if __builtins__.all(conds):
irc.reply("true") irc.reply("true")
else: else:
irc.reply("false") irc.reply("false")
@ -110,7 +97,7 @@ class Conditional(callbacks.Plugin):
Returns true if any one of conditions supplied evaluates to true. Returns true if any one of conditions supplied evaluates to true.
""" """
if _any(conds): if __builtins__.any(conds):
irc.reply("true") irc.reply("true")
else: else:
irc.reply("false") irc.reply("false")

View File

@ -44,10 +44,7 @@ import supybot.httpserver as httpserver
from supybot.i18n import PluginInternationalization, internationalizeDocstring from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Factoids') _ = PluginInternationalization('Factoids')
try: import sqlite3
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3 # for python2.4
import re import re
from supybot.utils.seq import dameraulevenshtein from supybot.utils.seq import dameraulevenshtein

View File

@ -31,10 +31,7 @@
from supybot.test import * from supybot.test import *
import supybot.conf as conf import supybot.conf as conf
try: import sqlite3
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3 # for python2.4
class FactoidsTestCase(ChannelPluginTestCase): class FactoidsTestCase(ChannelPluginTestCase):
plugins = ('Factoids',) plugins = ('Factoids',)

View File

@ -41,10 +41,7 @@ import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Karma') _ = PluginInternationalization('Karma')
try: import sqlite3
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3 # for python2.4
class SqliteKarmaDB(object): class SqliteKarmaDB(object):
def __init__(self, filename): def __init__(self, filename):

View File

@ -29,10 +29,7 @@
from supybot.test import * from supybot.test import *
try: import sqlite3
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3 # for python2.4
class KarmaTestCase(ChannelPluginTestCase): class KarmaTestCase(ChannelPluginTestCase):
plugins = ('Karma',) plugins = ('Karma',)

View File

@ -58,10 +58,7 @@ except:
#'plugin. Download it at ' \ #'plugin. Download it at ' \
#'<http://code.google.com/p/pysqlite/>' #'<http://code.google.com/p/pysqlite/>'
try: import sqlite3
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3 # for python2.4
# these are needed cuz we are overriding getdb # these are needed cuz we are overriding getdb
import threading import threading

View File

@ -30,10 +30,7 @@
from supybot.test import * from supybot.test import *
try: import sqlite3
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3 # for python2.4
class MessageParserTestCase(ChannelPluginTestCase): class MessageParserTestCase(ChannelPluginTestCase):

View File

@ -98,10 +98,7 @@ class SqliteMoobotDB(object):
self.dbs.clear() self.dbs.clear()
def _getDb(self, channel): def _getDb(self, channel):
try: import sqlite3
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3 # for python2.4
if channel in self.dbs: if channel in self.dbs:
return self.dbs[channel] return self.dbs[channel]

View File

@ -43,10 +43,7 @@ import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('QuoteGrabs') _ = PluginInternationalization('QuoteGrabs')
try: import sqlite3
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3 # for python2.4
import traceback import traceback

View File

@ -843,8 +843,6 @@ class Databases(registry.SpaceSeparatedListOfStrings):
v.insert(0, 'sqlite') v.insert(0, 'sqlite')
if 'sqlite3' in sys.modules: if 'sqlite3' in sys.modules:
v.insert(0, 'sqlite3') v.insert(0, 'sqlite3')
if 'pysqlite2' in sys.modules: # for python 2.4
v.insert(0, 'sqlite3')
return v return v
def serialize(self): def serialize(self):