changeset 1778:d85cb1ad9bc9 maint-0.6 0.6.1

merge from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Sun, 31 Aug 2003 03:44:27 +0000
parents 3d7bb1659d73
children ecfb6ccf20b0
files doc/customizing.txt roundup/rcsv.py
diffstat 2 files changed, 88 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/doc/customizing.txt	Fri Aug 29 12:45:54 2003 +0000
+++ b/doc/customizing.txt	Sun Aug 31 03:44:27 2003 +0000
@@ -2,7 +2,7 @@
 Customising Roundup
 ===================
 
-:Version: $Revision: 1.93.2.1 $
+:Version: $Revision: 1.93.2.2 $
 
 .. This document borrows from the ZopeBook section on ZPT. The original is at:
    http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -468,6 +468,15 @@
   It also provides the ``presetunread`` auditor which pre-sets the
   status to ``unread`` on new items if the status isn't explicitly
   defined.
+**messagesummary.py**
+  Generates the ``summary`` property for new messages based on the message
+  content.
+**userauditor.py**
+  Verifies the content of some of the user fields (email addresses and
+  roles lists).
+
+If you don't want this default behaviour, you're completely free to change
+or remove these detectors.
 
 See the detectors section in the `design document`__ for details of the
 interface for detectors.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/roundup/rcsv.py	Sun Aug 31 03:44:27 2003 +0000
@@ -0,0 +1,78 @@
+"""
+Supplies a Python-2.3 Object Craft csv module work-alike to the extent
+needed by Roundup using the Python 2.3 csv module.
+
+"""
+
+from roundup.i18n import _
+error = """Sorry, you need a module compatible with the csv module.
+Either upgrade your Python to 2.3 or later, or get and install
+the csv module from:
+http://www.object-craft.com.au/projects/csv/
+
+These two csv modules are different but Roundup can use either.
+"""
+try:
+    import csv
+    try:
+        reader = csv.reader
+        writer = csv.writer
+        excel = csv.excel
+        error = ''
+    except AttributeError:
+        # fake it all up using the Object-Craft CSV module
+        class excel:
+            pass
+        if hasattr(csv, 'parser'):
+            error = ''
+            def reader(fileobj, dialect=excel):
+                # note real readers take an iterable but 2.1 doesn't
+                # support iterable access to file objects.
+                result = []
+                p = csv.parser(field_sep=dialect.delimiter)
+
+                while 1:
+                    line = fileobj.readline()
+                    if not line: break
+ 
+                    # parse lines until we get a complete entry
+                    while 1:
+                        fields = p.parse(line)
+                        if fields: break
+                        line = fileobj.readline()
+                        if not line:
+                            raise ValueError, "Unexpected EOF during CSV parse"
+                    result.append(fields)
+                return result
+            class writer:
+                def __init__(self, fileobj, dialect=excel):
+                    self.fileobj = fileobj
+                    self.p = csv.parser(field_sep = dialect.delimiter)
+                def writerow(self, fields):
+                    print >>self.fileobj, self.p.join(fields)
+                def writerows(self, rows):
+                    for fields in rows:
+                        print >>self.fileobj, self.p.join(fields)
+
+except ImportError:
+    class excel:
+        pass
+       
+class colon_separated(excel):
+    delimiter = ':' 
+class comma_separated(excel):
+    delimiter = ',' 
+
+
+if __name__ == "__main__":
+    f=open('testme.txt', 'r')
+    r = reader(f, colon_separated)
+    remember = []
+    for record in r:
+        print record
+        remember.append(record)
+    f.close()
+    import sys
+    w = writer(sys.stdout, colon_separated)
+    w.writerows(remember)
+

Roundup Issue Tracker: http://roundup-tracker.org/