From 3535249ba1496391cd7e02252f9d5d372a4baffe Mon Sep 17 00:00:00 2001
From: Nikos Kouremenos <kourem@gmail.com>
Date: Wed, 11 Oct 2006 22:31:51 +0000
Subject: [PATCH] py25 comes with pysqlite module in the stdlib

---
 src/common/check_paths.py |  9 ++++++++-
 src/common/optparser.py   | 29 ++++++++++++++++++++++-------
 src/history_manager.py    |  8 ++++++--
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/src/common/check_paths.py b/src/common/check_paths.py
index a504c054dc..1008e8c4f5 100644
--- a/src/common/check_paths.py
+++ b/src/common/check_paths.py
@@ -20,7 +20,14 @@ import stat
 from common import gajim
 import logger
 
-from pysqlite2 import dbapi2 as sqlite # DO NOT MOVE ABOVE OF import gajim
+# DO NOT MOVE ABOVE OF import gajim
+try:
+	import sqlite3 as sqlite # python 2.5
+except ImportError:
+	try:
+		from pysqlite2 import dbapi2 as sqlite
+	except ImportError:
+		raise exceptions.PysqliteNotAvailable
 
 def create_log_db():
 	print _('creating logs database')
diff --git a/src/common/optparser.py b/src/common/optparser.py
index 570e68f731..170cc24a07 100644
--- a/src/common/optparser.py
+++ b/src/common/optparser.py
@@ -207,9 +207,12 @@ class OptionsParser:
 		'''create table unread_messages if there is no such table'''
 		import exceptions
 		try:
-			from pysqlite2 import dbapi2 as sqlite
+			import sqlite3 as sqlite # python 2.5
 		except ImportError:
-			raise exceptions.PysqliteNotAvailable
+			try:
+				from pysqlite2 import dbapi2 as sqlite
+			except ImportError:
+				raise exceptions.PysqliteNotAvailable
 		import logger
 
 		con = sqlite.connect(logger.LOG_DB_PATH) 
@@ -283,9 +286,12 @@ class OptionsParser:
 		'''create table transports_cache if there is no such table'''
 		import exceptions
 		try:
-			from pysqlite2 import dbapi2 as sqlite
+			import sqlite3 as sqlite # python 2.5
 		except ImportError:
-			raise exceptions.PysqliteNotAvailable
+			try:
+				from pysqlite2 import dbapi2 as sqlite
+			except ImportError:
+				raise exceptions.PysqliteNotAvailable
 		import logger
 
 		con = sqlite.connect(logger.LOG_DB_PATH) 
@@ -309,9 +315,12 @@ class OptionsParser:
 		'''apply indeces to the logs database'''
 		import exceptions
 		try:
-			from pysqlite2 import dbapi2 as sqlite
+			import sqlite3 as sqlite # python 2.5
 		except ImportError:
-			raise exceptions.PysqliteNotAvailable
+			try:
+				from pysqlite2 import dbapi2 as sqlite
+			except ImportError:
+				raise exceptions.PysqliteNotAvailable
 		import logger
 		print _('migrating logs database to indeces')
 		con = sqlite.connect(logger.LOG_DB_PATH) 
@@ -333,7 +342,13 @@ class OptionsParser:
 
 	def update_config_to_01015(self):
 		'''clean show values in logs database'''
-		from pysqlite2 import dbapi2 as sqlite
+		try:
+			import sqlite3 as sqlite # python 2.5
+		except ImportError:
+			try:
+				from pysqlite2 import dbapi2 as sqlite
+			except ImportError:
+				raise exceptions.PysqliteNotAvailable
 		import logger
 		con = sqlite.connect(logger.LOG_DB_PATH)
 		cur = con.cursor()
diff --git a/src/history_manager.py b/src/history_manager.py
index 86810d3dbe..bde306c326 100755
--- a/src/history_manager.py
+++ b/src/history_manager.py
@@ -44,10 +44,14 @@ C_SUBJECT,
 C_NICKNAME
 ) = range(2, 6)
 
+
 try:
-	from pysqlite2 import dbapi2 as sqlite
+	import sqlite3 as sqlite # python 2.5
 except ImportError:
-	raise exceptions.PysqliteNotAvailable
+	try:
+		from pysqlite2 import dbapi2 as sqlite
+	except ImportError:
+		raise exceptions.PysqliteNotAvailable
 
 
 class HistoryManager:
-- 
GitLab