Skip to content

Commit

Permalink
Working fix for Python2/Python3 incompatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
wadetb committed Apr 2, 2015
1 parent 8812d60 commit 4ebbbf3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion csvplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
import re, sys, os
from math import *

# http://stackoverflow.com/questions/11301138/how-to-check-if-variable-is-string-with-python-2-and-3-compatibility
try:
isinstance("", basestring)
def isstr(s):
return isinstance(s, basestring)
except NameError:
def isstr(s):
return isinstance(s, str)

directory = os.path.dirname(os.path.realpath(__file__))
sys.path.append(directory)

Expand Down Expand Up @@ -65,7 +74,7 @@ def __init__(self):
self.valid = False

self.delimiter = self.settings.get('delimiter')
if not isinstance(self.delimiter, basestring) or len(self.delimiter) != 1:
if not isstr(self.delimiter) or len(self.delimiter) != 1:
print("'{0}' is not a valid delimiter, reverting to ','.".format(self.delimiter))
self.delimiter = ','

Expand Down

0 comments on commit 4ebbbf3

Please sign in to comment.