1 # -*- coding: iso-8859-1 -*- 2 """ 3 MoinMoin - table (ImprovedTableParser) 4 5 @copyright: 2012 by Paul Boddie <paul@boddie.org.uk> 6 @license: GNU GPL (v2 or later), see COPYING.txt for details. 7 """ 8 9 from ImprovedTableParser import * 10 11 Dependencies = ["pages"] 12 13 # Parser support. 14 15 class Parser: 16 17 "Support a more flexible table syntax." 18 19 Dependencies = Dependencies 20 extensions = [] 21 22 # Output content types preferred by this parser. 23 24 output_mimetypes = ["text/html"] 25 26 def __init__(self, raw, request, **kw): 27 28 """ 29 Initialise the parser with the given 'raw' data, 'request' and any 30 keyword arguments that may have been supplied. 31 """ 32 33 self.raw = raw 34 self.request = request 35 self.attrs = parseAttributes(kw.get("format_args", ""), False) 36 37 def format(self, fmt, write=None): 38 39 """ 40 Format a table using the given formatter 'fmt'. If the 'write' parameter 41 is specified, use it to write output; otherwise, write output using the 42 request. 43 """ 44 45 formatTable(self.raw, self.request, fmt, self.attrs, write=write) 46 47 # Extra API methods. 48 49 def formatForOutputType(self, mimetype, write=None): 50 51 """ 52 Format a table for the given 'mimetype'. If the 'write' parameter is 53 specified, use it to write output; otherwise, write output using the 54 request. 55 """ 56 57 formatTableForOutputType(self.raw, self.request, mimetype, self.attrs, write=write) 58 59 # Class methods. 60 61 def getOutputTypes(self): 62 return self.output_mimetypes 63 64 getOutputTypes = classmethod(getOutputTypes) 65 66 # vim: tabstop=4 expandtab shiftwidth=4