Factoids & Karma & MessageParser & MoobotFactoids & QuoteGrabs: Fix Pypy3 support (without breaking Python 2 support).

This commit is contained in:
Valentin Lorentz 2014-08-05 11:18:38 +02:00
parent 907ede8035
commit 35bfd76852
5 changed files with 24 additions and 9 deletions

View File

@ -29,6 +29,7 @@
###
import os
import sys
import time
import string
import urllib
@ -217,9 +218,11 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
def makeDb(self, filename):
if os.path.exists(filename):
db = sqlite3.connect(filename)
if sys.version_info[0] < 3:
db.text_factory = str
return db
db = sqlite3.connect(filename)
if sys.version_info[0] < 3:
db.text_factory = str
cursor = db.cursor()
cursor.execute("""CREATE TABLE keys (

View File

@ -29,6 +29,7 @@
###
import os
import sys
import csv
import supybot.conf as conf
@ -58,10 +59,13 @@ class SqliteKarmaDB(object):
return self.dbs[filename]
if os.path.exists(filename):
db = sqlite3.connect(filename, check_same_thread=False)
if sys.version_info[0] < 3:
db.text_factory = str
self.dbs[filename] = db
return db
db = sqlite3.connect(filename, check_same_thread=False)
if sys.version_info[0] < 3:
db.text_factory = str
self.dbs[filename] = db
cursor = db.cursor()
cursor.execute("""CREATE TABLE karma (

View File

@ -39,6 +39,7 @@ import supybot.ircdb as ircdb
import re
import os
import sys
import time
try:
@ -80,9 +81,11 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
"""Create the database and connect to it."""
if os.path.exists(filename):
db = sqlite3.connect(filename)
if sys.version_info[0] < 3:
db.text_factory = str
return db
db = sqlite3.connect(filename)
if sys.version_info[0] < 3:
db.text_factory = str
cursor = db.cursor()
cursor.execute("""CREATE TABLE triggers (

View File

@ -28,6 +28,7 @@
###
import os
import sys
import time
import string
@ -106,10 +107,12 @@ class SqliteMoobotDB(object):
if os.path.exists(filename):
db = sqlite3.connect(filename, check_same_thread=False)
if sys.version_info[0] < 3:
db.text_factory = str
self.dbs[channel] = db
return db
db = sqlite3.connect(filename, check_same_thread=False)
if sys.version_info[0] < 3:
db.text_factory = str
self.dbs[channel] = db
cursor = db.cursor()

View File

@ -82,11 +82,13 @@ class SqliteQuoteGrabsDB(object):
return self.dbs[filename]
if os.path.exists(filename):
db = sqlite3.connect(filename)
if sys.version_info[0] < 3:
db.text_factory = str
db.create_function('nickeq', 2, p)
self.dbs[filename] = db
return db
db = sqlite3.connect(filename)
if sys.version_info[0] < 3:
db.text_factory = str
db.create_function('nickeq', 2, p)
self.dbs[filename] = db