Re: [Freeipa-devel] [PATCH 26/26] Add backslash escape support for csv reader

2011-06-22 Thread Rob Crittenden

John Dennis wrote:

The csv reader is used to break comma separated lists into individual
items. However what if you want one of those items to have an embedded
comma? The answer is to escape it by preceding the comma with a
backslash. This patch adds support for escaping in the csv reader.



ack, pushed to master and ipa-2-0

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH 26/26] Add backslash escape support for csv reader

2011-06-15 Thread John Dennis
The csv reader is used to break comma separated lists into individual 
items. However what if you want one of those items to have an embedded 
comma? The answer is to escape it by preceding the comma with a 
backslash. This patch adds support for escaping in the csv reader.


--
John Dennis jden...@redhat.com

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
From e2e68df5a833417351cd89d1ac2cb7155334f795 Mon Sep 17 00:00:00 2001
From: John Dennis jden...@redhat.com
Date: Wed, 15 Jun 2011 13:06:14 -0400
Subject: [PATCH 26/26] Add backslash escape support for cvs reader
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

---
 ipalib/parameters.py|3 ++-
 ipaserver/install/ldapupdate.py |3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 1551df3..ee66084 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -1404,7 +1404,8 @@ class List(Param):
 def __unicode_csv_reader(self, unicode_csv_data, dialect=csv.excel, **kwargs):
 # csv.py doesn't do Unicode; encode temporarily as UTF-8:
 csv_reader = csv.reader(self.__utf_8_encoder(unicode_csv_data),
-dialect=dialect, delimiter=self.separator,
+dialect=dialect,
+delimiter=self.separator, escapechar='\\',
 skipinitialspace=self.skipspace,
 **kwargs)
 for row in csv_reader:
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index 9d36ddd..2d9c473 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -141,7 +141,8 @@ class LDAPUpdate:
 def __unicode_csv_reader(self, unicode_csv_data, quote_char=', dialect=csv.excel, **kwargs):
 # csv.py doesn't do Unicode; encode temporarily as UTF-8:
 csv_reader = csv.reader(self.__utf_8_encoder(unicode_csv_data),
-dialect=dialect, delimiter=',',
+dialect=dialect,
+delimiter=',', escapechar='\\',
 quotechar=quote_char,
 skipinitialspace=True,
 **kwargs)
-- 
1.7.4.4

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel