aboutsummaryrefslogtreecommitdiff
path: root/addons/script.module.pysqlite
diff options
context:
space:
mode:
authorJim Carroll <thecarrolls@jiminger.com>2011-04-19 22:54:44 -0400
committerJim Carroll <thecarrolls@jiminger.com>2011-04-19 22:54:44 -0400
commit6f3e7ecd8841d9f7da74719c2c629e2dee4d891f (patch)
treebdacf881f6eba3595d843bc1db4dceb8703a6575 /addons/script.module.pysqlite
parent98a0ec1203eb48eac88fb76f2f1f8c9c0cd85b47 (diff)
Fixed the pysqlite bw compatibility stub to handle version numbers correctly. Plus fixed some other minor issues.
Diffstat (limited to 'addons/script.module.pysqlite')
-rw-r--r--addons/script.module.pysqlite/lib/pysqlite2/__init__.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/addons/script.module.pysqlite/lib/pysqlite2/__init__.py b/addons/script.module.pysqlite/lib/pysqlite2/__init__.py
index d3b3186485..94d26e6694 100644
--- a/addons/script.module.pysqlite/lib/pysqlite2/__init__.py
+++ b/addons/script.module.pysqlite/lib/pysqlite2/__init__.py
@@ -3,6 +3,14 @@
# this will only be allowed if the script is greater that version 1.0
import warnings
+import re
+
+# Credit gnud on stackoverflow:
+# see http://stackoverflow.com/questions/1714027/version-number-comparison/1714190#1714190
+def xbmcVerCmp(version1, version2):
+ def normalize(v):
+ return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
+ return cmp(normalize(version1), normalize(version2))
# Not sure why this might fail but ....
try:
@@ -10,11 +18,11 @@ try:
xbmcapiversion = __main__.__xbmcapiversion__
except:
xbmcapiversion = "1.0"
- warnings.warn("For some reason the module'" + std(__name__) + "' couldn't get access to '__main__'. This may prevent certain backward compatility modes from operating correctly.")
+ warnings.warn("For some reason the module '" + str(__name__) + "' couldn't get access to '__main__'. This may prevent certain backward compatility modes from operating correctly.")
# if the xbmcapiversion is either not set (because trying to get it failed or
# the script was invoked in an odd manner from xbmc) ...
-if (float(xbmcapiversion) <= 1.0):
+if (xbmcVerCmp(xbmcapiversion,"1.0") <= 0):
# then import sqlite3 in place of dbapi2
try:
import sqlite3 as dbapi2