Skip to content

Commit 2bf2f5e

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent 329c0f5 commit 2bf2f5e

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

doc/customizing.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.93.2.1 $
5+
:Version: $Revision: 1.93.2.2 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -468,6 +468,15 @@ for you are:
468468
It also provides the ``presetunread`` auditor which pre-sets the
469469
status to ``unread`` on new items if the status isn't explicitly
470470
defined.
471+
**messagesummary.py**
472+
Generates the ``summary`` property for new messages based on the message
473+
content.
474+
**userauditor.py**
475+
Verifies the content of some of the user fields (email addresses and
476+
roles lists).
477+
478+
If you don't want this default behaviour, you're completely free to change
479+
or remove these detectors.
471480

472481
See the detectors section in the `design document`__ for details of the
473482
interface for detectors.

roundup/rcsv.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
"""
2+
Supplies a Python-2.3 Object Craft csv module work-alike to the extent
3+
needed by Roundup using the Python 2.3 csv module.
4+
5+
"""
6+
7+
from roundup.i18n import _
8+
error = """Sorry, you need a module compatible with the csv module.
9+
Either upgrade your Python to 2.3 or later, or get and install
10+
the csv module from:
11+
http://www.object-craft.com.au/projects/csv/
12+
13+
These two csv modules are different but Roundup can use either.
14+
"""
15+
try:
16+
import csv
17+
try:
18+
reader = csv.reader
19+
writer = csv.writer
20+
excel = csv.excel
21+
error = ''
22+
except AttributeError:
23+
# fake it all up using the Object-Craft CSV module
24+
class excel:
25+
pass
26+
if hasattr(csv, 'parser'):
27+
error = ''
28+
def reader(fileobj, dialect=excel):
29+
# note real readers take an iterable but 2.1 doesn't
30+
# support iterable access to file objects.
31+
result = []
32+
p = csv.parser(field_sep=dialect.delimiter)
33+
34+
while 1:
35+
line = fileobj.readline()
36+
if not line: break
37+
38+
# parse lines until we get a complete entry
39+
while 1:
40+
fields = p.parse(line)
41+
if fields: break
42+
line = fileobj.readline()
43+
if not line:
44+
raise ValueError, "Unexpected EOF during CSV parse"
45+
result.append(fields)
46+
return result
47+
class writer:
48+
def __init__(self, fileobj, dialect=excel):
49+
self.fileobj = fileobj
50+
self.p = csv.parser(field_sep = dialect.delimiter)
51+
def writerow(self, fields):
52+
print >>self.fileobj, self.p.join(fields)
53+
def writerows(self, rows):
54+
for fields in rows:
55+
print >>self.fileobj, self.p.join(fields)
56+
57+
except ImportError:
58+
class excel:
59+
pass
60+
61+
class colon_separated(excel):
62+
delimiter = ':'
63+
class comma_separated(excel):
64+
delimiter = ','
65+
66+
67+
if __name__ == "__main__":
68+
f=open('testme.txt', 'r')
69+
r = reader(f, colon_separated)
70+
remember = []
71+
for record in r:
72+
print record
73+
remember.append(record)
74+
f.close()
75+
import sys
76+
w = writer(sys.stdout, colon_separated)
77+
w.writerows(remember)
78+

0 commit comments

Comments
 (0)