From 3151dbbd98cf90215b36951ea33a0ae4df4054b7 Mon Sep 17 00:00:00 2001 From: NoDRM Date: Thu, 29 Dec 2022 19:58:29 +0100 Subject: [PATCH] Try fixing a Python2 bug in the Obok plugin (#235) --- Obok_plugin/obok/obok.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Obok_plugin/obok/obok.py b/Obok_plugin/obok/obok.py index 4de7644..dc0a30d 100644 --- a/Obok_plugin/obok/obok.py +++ b/Obok_plugin/obok/obok.py @@ -312,11 +312,17 @@ class KoboLibrary(object): if sys.getwindowsversion().major > 5: if 'LOCALAPPDATA' in os.environ.keys(): # Python 2.x does not return unicode env. Use Python 3.x - self.kobodir = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%") + if sys.version_info[0] == 2: + self.kobodir = winreg.ExpandEnvironmentStrings(u"%LOCALAPPDATA%") + else: + self.kobodir = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%") if (self.kobodir == u""): if 'USERPROFILE' in os.environ.keys(): # Python 2.x does not return unicode env. Use Python 3.x - self.kobodir = os.path.join(winreg.ExpandEnvironmentStrings("%USERPROFILE%"), "Local Settings", "Application Data") + 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(self.kobodir, "Kobo", "Kobo Desktop Edition") elif sys.platform.startswith('darwin'): self.kobodir = os.path.join(os.environ['HOME'], "Library", "Application Support", "Kobo", "Kobo Desktop Edition")