MoinLight

Annotated moinformat/input/standalone.py

176:47af441b48bf
2018-11-26 Paul Boddie Support linking to stylesheets based on the collection of available files.
paul@104 1
#!/usr/bin/env python
paul@104 2
paul@104 3
"""
paul@104 4
Stand-alone input context.
paul@104 5
paul@104 6
Copyright (C) 2018 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@104 43
input = StandaloneInput
paul@104 44
paul@104 45
# vim: tabstop=4 expandtab shiftwidth=4