~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-12-23 00:59:10 UTC
  • mfrom: (4794.1.21 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091223005910-zatr8ajlw8ul6d6s
(robertc) Add testtools 0.9.2 as a hard dependency to run the test
        suite, improving debug output on selftest --parallel,
        reducing code size and adding support for assertThat. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2087
2087
    if use_cache:
2088
2088
        _cached_concurrency = concurrency
2089
2089
    return concurrency
 
2090
 
 
2091
 
 
2092
class UnicodeOrBytesToBytesWriter(codecs.StreamWriter):
 
2093
    """A stream writer that doesn't decode str arguments."""
 
2094
 
 
2095
    def __init__(self, encode, stream, errors='strict'):
 
2096
        codecs.StreamWriter.__init__(self, stream, errors)
 
2097
        self.encode = encode
 
2098
 
 
2099
    def write(self, object):
 
2100
        if type(object) is str:
 
2101
            self.stream.write(object)
 
2102
        else:
 
2103
            data, _ = self.encode(object, self.errors)
 
2104
            self.stream.write(data)