MoinLight

Annotated moinformat/input/standalone.py

307:bc2834224ef7
2021-10-25 Paul Boddie Moved the region's add method to the general container abstraction since such functionality is useful for other nodes such as table cells provided by the table parser.
paul@104 1
#!/usr/bin/env python
paul@104 2
paul@104 3
"""
paul@104 4
Stand-alone input context.
paul@104 5
paul@223 6
Copyright (C) 2018, 2019 Paul Boddie <paul@boddie.org.uk>
paul@104 7
paul@104 8
This program is free software; you can redistribute it and/or modify it under
paul@104 9
the terms of the GNU General Public License as published by the Free Software
paul@104 10
Foundation; either version 3 of the License, or (at your option) any later
paul@104 11
version.
paul@104 12
paul@104 13
This program is distributed in the hope that it will be useful, but WITHOUT
paul@104 14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
paul@104 15
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
paul@104 16
details.
paul@104 17
paul@104 18
You should have received a copy of the GNU General Public License along with
paul@104 19
this program.  If not, see <http://www.gnu.org/licenses/>.
paul@104 20
"""
paul@104 21
paul@104 22
from moinformat.input.common import Input
paul@104 23
import codecs
paul@104 24
import sys
paul@104 25
paul@104 26
class StandaloneInput(Input):
paul@104 27
paul@104 28
    "A stand-alone output context."
paul@104 29
paul@104 30
    name = "standalone"
paul@104 31
paul@104 32
    def read(self, stream=None):
paul@104 33
paul@104 34
        """
paul@104 35
        Read from 'stream', or standard input if not specified, returning a
paul@104 36
        character string.
paul@104 37
        """
paul@104 38
paul@104 39
        stream = stream or sys.stdin
paul@104 40
        f = codecs.getreader(self.encoding)(stream)
paul@104 41
        return f.read()
paul@104 42
paul@223 43
    # Convenience methods.
paul@223 44
paul@223 45
    def get_attachment_filename(self, pagename, filename):
paul@223 46
paul@223 47
        """
paul@223 48
        Prevent independent output by returning a filename of None corresponding
paul@223 49
        to the given 'pagename' and any specified 'filename'.
paul@223 50
        """
paul@223 51
paul@223 52
        return None
paul@223 53
paul@104 54
input = StandaloneInput
paul@104 55
paul@104 56
# vim: tabstop=4 expandtab shiftwidth=4