changeset 3314:55841be09a2f

csv reader: properly set quoting keyword
author Johannes Berg <johannes AT sipsolutions DOT net>
date Tue, 18 Mar 2008 22:24:37 +0100
parents 79b954f62d9c
children 5f9ed5b4596f
files MoinMoin/parser/text_csv.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/text_csv.py	Tue Mar 18 22:20:27 2008 +0100
+++ b/MoinMoin/parser/text_csv.py	Tue Mar 18 22:24:37 2008 +0100
@@ -28,7 +28,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-from csv import reader
+from csv import reader, QUOTE_NONE, QUOTE_MINIMAL
 
 from MoinMoin.util.dataset import TupleDataset, Column
 from MoinMoin.widget.browser import DataBrowserWidget
@@ -64,6 +64,7 @@
         linkcols = []
         delimiter = ';'
         quotechar = '\x00' # can't be entered
+        quoting = QUOTE_NONE
         name = None
         hdr = reader([kw.get('format_args', '').strip().encode('utf-8')], delimiter=" ")
         args = hdr.next()
@@ -87,6 +88,7 @@
             if key == 'quotechar':
                 if val == val.encode('utf-8'):
                     quotechar = val.encode('utf-8')
+                    quoting = QUOTE_MINIMAL
             elif key == 'show':
                 visible = val.split(',')
             elif key == 'hide':
@@ -107,7 +109,7 @@
         elif len(staticcols) < len(staticvals):
             staticvals = staticvals[:len(staticcols)]
 
-        r = reader(data, delimiter=delimiter, quotechar=quotechar)
+        r = reader(data, delimiter=delimiter, quotechar=quotechar, quoting=quoting)
         cols = map(lambda x: x.decode('utf-8'), r.next()) + staticcols
 
         self._show_header = True