1
from itertools import chain
3
from bzrlib.errors import BinaryFile
4
from bzrlib.iterablefile import IterableFile
5
from bzrlib.osutils import file_iterator
7
"""Produce a file iterator that is guaranteed to be text, without seeking.
8
BinaryFile is raised if the file contains a NUL in the first 1024 bytes.
10
first_chunk = input.read(1024)
11
if '\x00' in first_chunk:
13
return IterableFile(chain((first_chunk,), file_iterator(input)))