comparison data/plugin/action/submitcsv.py @ 623:5f499a634857

FormSubmit: fix pep8, remove unused imports, ...
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 25 Mar 2013 17:20:34 +0100
parents 12465aa315be
children bdebdc59b057
comparison
equal deleted inserted replaced
622:12465aa315be 623:5f499a634857
1 # -*- coding: iso-8859-1 -*- 1 # -*- coding: iso-8859-1 -*-
2
3 """ 2 """
4 MoinMoin - submitcsv Action 3 MoinMoin - submitcsv Action
5 4
6 Store submited data into CSV file. CSV file is located 5 Store submited data into CSV file. CSV file is located
7 in standard MoinMoin attchment folder or defined in 6 in standard MoinMoin attchment folder or defined in
9 8
10 @copyright: 2008 by Peter Bodi <petrdll@centrum.sk> 9 @copyright: 2008 by Peter Bodi <petrdll@centrum.sk>
11 @license: GNU GPL, see COPYING for details. 10 @license: GNU GPL, see COPYING for details.
12 """ 11 """
13 12
14 import os, csv, sys, codecs, cStringIO 13 import os
14 import csv
15 import codecs
16 import cStringIO
15 17
16 from MoinMoin import config, wikiutil 18 from MoinMoin import config, wikiutil
17 from MoinMoin.Page import Page 19 from MoinMoin.Page import Page
18 from MoinMoin.action import AttachFile 20 from MoinMoin.action import AttachFile
19 21
20 from submitbase import SubmitBase 22 from submitbase import SubmitBase
21 23
24
22 def execute(pagename, request): 25 def execute(pagename, request):
23 submitcsv(pagename, request).render() 26 submitcsv(pagename, request).render()
27
24 28
25 class submitcsv(SubmitBase): 29 class submitcsv(SubmitBase):
26 30
27 def __init__(self, pagename, request): 31 def __init__(self, pagename, request):
28 SubmitBase.__init__(self, pagename, request) 32 SubmitBase.__init__(self, pagename, request)
74 # Decoded Input to writer.writerow 78 # Decoded Input to writer.writerow
75 writer = UnicodeWriter(fh, delimiter=self.delimiter, quoting=csv.QUOTE_MINIMAL) 79 writer = UnicodeWriter(fh, delimiter=self.delimiter, quoting=csv.QUOTE_MINIMAL)
76 writer.writerow(self.values) 80 writer.writerow(self.values)
77 81
78 fh.close() 82 fh.close()
79 83
84
80 class UnicodeWriter: 85 class UnicodeWriter:
81 """ 86 """
82 A CSV writer which will write rows to CSV file "f", 87 A CSV writer which will write rows to CSV file "f",
83 which is encoded in the given encoding. 88 which is encoded in the given encoding.
84 """ 89 """
103 self.queue.truncate(0) 108 self.queue.truncate(0)
104 109
105 def writerows(self, rows): 110 def writerows(self, rows):
106 for row in rows: 111 for row in rows:
107 self.writerow(row) 112 self.writerow(row)
108
109