[Moin-devel] CVS: MoinMoin/processor CSV.py,NONE,1.1 __init__.py,1.1,1.2

J?rgen Hermann jhermann at users.sourceforge.net
Sun Mar 17 05:47:04 EST 2002


Update of /cvsroot/moin/MoinMoin/processor
In directory usw-pr-cvs1:/tmp/cvs-serv24018/MoinMoin/processor

Modified Files:
	__init__.py 
Added Files:
	CSV.py 
Log Message:
Processor bang path must directly follow {{{, except for Colorize (have
to support 0.11 colored code displays); added first version of CSV 
processor


--- NEW FILE: CSV.py ---
"""
    MoinMoin - Processor for CSV data

    Copyright (c) 2002 by Jürgen Hermann <jh at web.de>
    All rights reserved, see COPYING for details.

    $Id: CSV.py,v 1.1 2002/03/17 13:46:17 jhermann Exp $
"""

import string, sys

def process(formatter, lines):
    # parse bangpath for arguments
    exclude = []
    for arg in string.split(lines[0])[1:]:
        if arg[0] == '-':
            try:
                idx = int(arg[1:])
            except ValueError:
                pass
            else:
                exclude.append(idx-1)

    # remove bang path, create output list
    del lines[0]
    output = []

    if lines[0]:
        # expect column headers in first line
        first = 1
    else:
        # empty first line, no bold headers
        first = 0
        del lines[0]

    output.append(formatter.table(1))
    for line in lines:
        output.append(formatter.table_row(1))
        cells = string.split(line, ';')
        for idx in range(len(cells)):
            if idx in exclude: continue
            output.append(formatter.table_cell(1))
            if first: output.append(formatter.strong(1))
            output.append(formatter.text(cells[idx]))
            if first: output.append(formatter.strong(0))
            output.append(formatter.table_cell(0))
        output.append(formatter.table_row(0))
        first = 0
    output.append(formatter.table(0))

    sys.stdout.write(string.join(output, ''))


Index: __init__.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/processor/__init__.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** __init__.py	16 Mar 2002 20:31:37 -0000	1.1
--- __init__.py	17 Mar 2002 13:46:17 -0000	1.2
***************
*** 10,16 ****
      since it is destroyed after processing.
  
!     Currently, when a processor is called, a preformatted
!     section is open. So you have to either close it immediately,
!     or after you emitted the output.
  
      $Id$
--- 10,15 ----
      since it is destroyed after processing.
  
!     The first line of the list is always the bang path, so
!     you can place arguments there and parse them.
  
      $Id$





More information about the Moin-devel mailing list