1.1 --- a/parsers/pgp_keys.py Wed Apr 02 23:57:59 2014 +0200
1.2 +++ b/parsers/pgp_keys.py Thu Apr 03 22:25:14 2014 +0200
1.3 @@ -2,7 +2,7 @@
1.4 """
1.5 MoinMoin - pgp_keys (MoinShare)
1.6
1.7 - @copyright: 2012, 2013 by Paul Boddie <paul@boddie.org.uk>
1.8 + @copyright: 2012, 2013, 2014 by Paul Boddie <paul@boddie.org.uk>
1.9 @license: GNU GPL (v2 or later), see COPYING.txt for details.
1.10 """
1.11
1.12 @@ -43,7 +43,7 @@
1.13 def format(self, fmt, write=None):
1.14
1.15 """
1.16 - Format a table using the given formatter 'fmt'. If the 'write' parameter
1.17 + Format a key using the given formatter 'fmt'. If the 'write' parameter
1.18 is specified, use it to write output; otherwise, write output using the
1.19 request.
1.20 """
1.21 @@ -55,7 +55,7 @@
1.22 def formatForOutputType(self, mimetype, write=None):
1.23
1.24 """
1.25 - Format a table for the given 'mimetype'. If the 'write' parameter is
1.26 + Format a key for the given 'mimetype'. If the 'write' parameter is
1.27 specified, use it to write output; otherwise, write output using the
1.28 request.
1.29 """
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/parsers/text_plain.py Thu Apr 03 22:25:14 2014 +0200
2.3 @@ -0,0 +1,78 @@
2.4 +# -*- coding: iso-8859-1 -*-
2.5 +"""
2.6 + MoinMoin - text_plain (MoinShare)
2.7 +
2.8 + @copyright: 2012, 2013, 2014 by Paul Boddie <paul@boddie.org.uk>
2.9 + @license: GNU GPL (v2 or later), see COPYING.txt for details.
2.10 +"""
2.11 +
2.12 +from MoinSupport import parseAttributes
2.13 +
2.14 +Dependencies = ["pages"]
2.15 +
2.16 +# Parser support.
2.17 +
2.18 +class Parser:
2.19 +
2.20 + "Display data in text/plain format."
2.21 +
2.22 + Dependencies = Dependencies
2.23 + extensions = [".txt"]
2.24 +
2.25 + # Input content types understood by this parser.
2.26 +
2.27 + input_mimetypes = ["text/plain"]
2.28 +
2.29 + # Output content types preferred by this parser.
2.30 +
2.31 + output_mimetypes = ["text/plain", "text/html"]
2.32 +
2.33 + def __init__(self, raw, request, **kw):
2.34 +
2.35 + """
2.36 + Initialise the parser with the given 'raw' data, 'request' and any
2.37 + keyword arguments that may have been supplied.
2.38 + """
2.39 +
2.40 + self.raw = raw
2.41 + self.request = request
2.42 + self.attrs = parseAttributes(kw.get("format_args", ""), False)
2.43 +
2.44 + def format(self, fmt, write=None):
2.45 +
2.46 + """
2.47 + Format plain text using the given formatter 'fmt'. If the 'write'
2.48 + parameter is specified, use it to write output; otherwise, write output
2.49 + using the request.
2.50 + """
2.51 +
2.52 + (write or self.request.write)(fmt.text(self.raw))
2.53 +
2.54 + # Extra API methods.
2.55 +
2.56 + def formatForOutputType(self, mimetype, write=None):
2.57 +
2.58 + """
2.59 + Format plain text for the given 'mimetype'. If the 'write' parameter is
2.60 + specified, use it to write output; otherwise, write output using the
2.61 + request.
2.62 + """
2.63 +
2.64 + request = self.request
2.65 + write = write or request.write
2.66 + fmt = request.html_formatter
2.67 + _ = request.getText
2.68 +
2.69 + if mimetype == "text/html":
2.70 + self.format(fmt, write)
2.71 + elif mimetype == "text/plain":
2.72 + write(self.raw)
2.73 +
2.74 + # Class methods.
2.75 +
2.76 + def getOutputTypes(self):
2.77 + return self.output_mimetypes
2.78 +
2.79 + getOutputTypes = classmethod(getOutputTypes)
2.80 +
2.81 +# vim: tabstop=4 expandtab shiftwidth=4