Ejemplo n.º 1
0
 def __init__(self, hConsole, stream, fileno, name):
     self._hConsole = hConsole
     self._stream = stream
     self._fileno = fileno
     self.closed = False
     self.softspace = False
     self.mode = 'w'
     self.encoding = 'utf-8'
     self.name = name
     if hasattr(stream, 'encoding') and canonical_encoding(stream.encoding) != 'utf-8':
         log.msg("%s: %r had encoding %r, but we're going to write UTF-8 to it" %
                 (name, stream, stream.encoding), level=log.CURIOUS)
     self.flush()
Ejemplo n.º 2
0
 def __init__(self, hConsole, stream, fileno, name):
     self._hConsole = hConsole
     self._stream = stream
     self._fileno = fileno
     self.closed = False
     self.softspace = False
     self.mode = 'w'
     self.encoding = 'utf-8'
     self.name = name
     if hasattr(stream, 'encoding') and canonical_encoding(stream.encoding) != 'utf-8':
         log.msg("%s: %r had encoding %r, but we're going to write UTF-8 to it" %
                 (name, stream, stream.encoding), level=log.CURIOUS)
     self.flush()
Ejemplo n.º 3
0
    def __init__(self, hConsole, stream, fileno, name, _complain):
        """
        :param hConsole: ``None`` or a handle on the console to which to write
            unicode.  Mutually exclusive with ``stream``.

        :param stream: ``None`` or a file-like object to which to write bytes.

        :param fileno: A result to hand back from method of the same name.

        :param name: A human-friendly identifier for this output object.

        :param _complain: A one-argument callable which accepts bytes to be
            written when there's a problem.  Care should be taken to not make
            this do a write on this object.
        """
        self._hConsole = hConsole
        self._stream = stream
        self._fileno = fileno
        self.closed = False
        self.softspace = False
        self.mode = 'w'
        self.encoding = 'utf-8'
        self.name = name

        self._complain = _complain

        from allmydata.util.encodingutil import canonical_encoding
        from allmydata.util import log
        if hasattr(
                stream,
                'encoding') and canonical_encoding(stream.encoding) != 'utf-8':
            log.msg(
                "%s: %r had encoding %r, but we're going to write UTF-8 to it"
                % (name, stream, stream.encoding),
                level=log.CURIOUS)
        self.flush()