[d-feet] Quote and unquote list items to avoid splitting on comma litterals
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [d-feet] Quote and unquote list items to avoid splitting on comma litterals
- Date: Fri, 1 Oct 2010 20:45:25 +0000 (UTC)
commit f2060f5edb55905bc3f6e5b56e809243fd838ddf
Author: John (J5) Palmieri <johnp redhat com>
Date: Fri Oct 1 16:43:20 2010 -0400
Quote and unquote list items to avoid splitting on comma litterals
dfeet/settings.py | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/dfeet/settings.py b/dfeet/settings.py
index ef9e7b4..f4e0919 100644
--- a/dfeet/settings.py
+++ b/dfeet/settings.py
@@ -7,6 +7,9 @@
import ConfigParser
import os
+import re
+
+list_splitter = re.compile(',|"([^".]*)"')
class Settings:
"""
@@ -49,6 +52,14 @@ class Settings:
cls.instance = Settings()
return cls.instance
+ def decode_list(self, s):
+ result = []
+ split = list_splitter.split(s);
+ for item in split:
+ if item:
+ result.append(item)
+ return result
+
def read(self):
"""
Reads configuration settings from the config file and loads
@@ -61,7 +72,7 @@ class Settings:
for key, value in self.config.items("General"):
if key.endswith('list'):
- value = value.split(',')
+ value = self.decode_list(value)
self.general[key] = value
@@ -71,6 +82,8 @@ class Settings:
"""
for key in self.general:
if key.endswith('list'):
+ for i in range(0, len(self.general[key])):
+ self.general[key][i] = '"' + self.general[key][i] + '"'
self.general[key] = ','.join(self.general[key])
self.config.set("General", key, self.general[key])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]