/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/iterablefile.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
from __future__ import absolute_import
19
19
 
20
 
 
21
20
class IterableFileBase(object):
22
21
    """Create a file-like object from any iterable"""
23
22
 
52
51
                if len(result) >= length:
53
52
                    return length
54
53
            try:
55
 
                return result.index(sequence) + len(sequence)
 
54
                return result.index(sequence)+len(sequence)
56
55
            except ValueError:
57
56
                return None
58
57
        return self._read(test_contents)
86
85
            return None
87
86
        return self._read(no_stop)
88
87
 
 
88
 
89
89
    def push_back(self, contents):
90
90
        """
91
91
        >>> f = IterableFileBase(['Th\\nis ', 'is \\n', 'a ', 'te\\nst.'])
100
100
 
101
101
class IterableFile(object):
102
102
    """This class supplies all File methods that can be implemented cheaply."""
103
 
 
104
103
    def __init__(self, iterable):
105
104
        object.__init__(self)
106
105
        self._file_base = IterableFileBase(iterable)
140
139
        # If there was an error raised, prefer the original one
141
140
        try:
142
141
            self.close()
143
 
        except BaseException:
 
142
        except:
144
143
            if exc_type is None:
145
144
                raise
146
145
        return False