Try fixing a Python2 bug in the Obok plugin (#235)

This commit is contained in:
NoDRM 2022-12-29 19:58:29 +01:00
parent 08e7ac79ca
commit 3151dbbd98
1 changed files with 8 additions and 2 deletions

View File

@ -312,10 +312,16 @@ class KoboLibrary(object):
if sys.getwindowsversion().major > 5: if sys.getwindowsversion().major > 5:
if 'LOCALAPPDATA' in os.environ.keys(): if 'LOCALAPPDATA' in os.environ.keys():
# Python 2.x does not return unicode env. Use Python 3.x # Python 2.x does not return unicode env. Use Python 3.x
if sys.version_info[0] == 2:
self.kobodir = winreg.ExpandEnvironmentStrings(u"%LOCALAPPDATA%")
else:
self.kobodir = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%") self.kobodir = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%")
if (self.kobodir == u""): if (self.kobodir == u""):
if 'USERPROFILE' in os.environ.keys(): if 'USERPROFILE' in os.environ.keys():
# Python 2.x does not return unicode env. Use Python 3.x # Python 2.x does not return unicode env. Use Python 3.x
if sys.version_info[0] == 2:
self.kobodir = os.path.join(winreg.ExpandEnvironmentStrings(u"%USERPROFILE%"), "Local Settings", "Application Data")
else:
self.kobodir = os.path.join(winreg.ExpandEnvironmentStrings("%USERPROFILE%"), "Local Settings", "Application Data") self.kobodir = os.path.join(winreg.ExpandEnvironmentStrings("%USERPROFILE%"), "Local Settings", "Application Data")
self.kobodir = os.path.join(self.kobodir, "Kobo", "Kobo Desktop Edition") self.kobodir = os.path.join(self.kobodir, "Kobo", "Kobo Desktop Edition")
elif sys.platform.startswith('darwin'): elif sys.platform.startswith('darwin'):