From 57cc60e1bdfe01da7ff8a0fbd4f649e93b32054b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Wed, 14 Apr 2010 19:58:22 +0300 Subject: [PATCH 1/2] Config file unicode encoding fix --- openlp/core/lib/pluginconfig.py | 5 +++-- openlp/core/utils/registry.py | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/openlp/core/lib/pluginconfig.py b/openlp/core/lib/pluginconfig.py index 936a2f3a0..e27b86669 100644 --- a/openlp/core/lib/pluginconfig.py +++ b/openlp/core/lib/pluginconfig.py @@ -139,8 +139,9 @@ class PluginConfig(object): list = [] if list_count > 0: for counter in range(0, list_count): - item = unicode(self.get_config(u'%s %d' % (name, counter))) - list.append(item) + item = self.get_config(u'%s %d' % (name, counter)) + if item: + list.append(item) return list def set_list(self, name, list): diff --git a/openlp/core/utils/registry.py b/openlp/core/utils/registry.py index ba7c72a89..9842474ad 100644 --- a/openlp/core/utils/registry.py +++ b/openlp/core/utils/registry.py @@ -41,15 +41,17 @@ class Registry(object): """ Check if a value exists. """ - return self.config.has_option(section, key) + return self.config.has_option(section.encode('utf-8'), + key.encode('utf-8')) def get_value(self, section, key, default=None): """ Get a single value from the registry. """ try: - if self.config.get(section, key): - return self.config.get(section, key) + if self.config.get(section.encode('utf-8'), key.encode('utf-8')): + return self.config.get(section.encode('utf-8'), + key.encode('utf-8')).decode('utf-8') else: return default except: @@ -60,7 +62,8 @@ class Registry(object): Set a single value in the registry. """ try : - self.config.set(section, key, unicode(value)) + self.config.set(section.encode('utf-8'), key.encode('utf-8'), + unicode(value).encode('utf-8')) return self._save() except: return False @@ -70,7 +73,8 @@ class Registry(object): Delete a single value from the registry. """ try: - self.config.remove_option(section, key) + self.config.remove_option(section.encode('utf-8'), + key.encode('utf-8')) return self._save() except: return False @@ -79,14 +83,14 @@ class Registry(object): """ Check if a section exists. """ - return self.config.has_section(section) + return self.config.has_section(section.encode('utf-8')) def create_section(self, section): """ Create a new section in the registry. """ try: - self.config.add_section(section) + self.config.add_section(section.encode('utf-8')) return self._save() except: return False @@ -96,7 +100,7 @@ class Registry(object): Delete a section (including all values). """ try: - self.config.remove_section(section) + self.config.remove_section(section.encode('utf-8')) return self._save() except: return False From 235748a9e919c34eeed59e1de591b42e4f291f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Wed, 14 Apr 2010 20:12:30 +0300 Subject: [PATCH 2/2] indentation fix --- openlp/core/utils/registry.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/utils/registry.py b/openlp/core/utils/registry.py index 9842474ad..3d7137dfd 100644 --- a/openlp/core/utils/registry.py +++ b/openlp/core/utils/registry.py @@ -42,7 +42,7 @@ class Registry(object): Check if a value exists. """ return self.config.has_option(section.encode('utf-8'), - key.encode('utf-8')) + key.encode('utf-8')) def get_value(self, section, key, default=None): """ @@ -51,7 +51,7 @@ class Registry(object): try: if self.config.get(section.encode('utf-8'), key.encode('utf-8')): return self.config.get(section.encode('utf-8'), - key.encode('utf-8')).decode('utf-8') + key.encode('utf-8')).decode('utf-8') else: return default except: @@ -63,7 +63,7 @@ class Registry(object): """ try : self.config.set(section.encode('utf-8'), key.encode('utf-8'), - unicode(value).encode('utf-8')) + unicode(value).encode('utf-8')) return self._save() except: return False @@ -74,7 +74,7 @@ class Registry(object): """ try: self.config.remove_option(section.encode('utf-8'), - key.encode('utf-8')) + key.encode('utf-8')) return self._save() except: return False