/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/textfile.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-22 01:30:48 UTC
  • mto: (6973.5.4 python3-c)
  • mto: This revision was merged to the branch mainline in revision 6984.
  • Revision ID: jelmer@jelmer.uk-20180522013048-r825wjanpr2yqige
port breezy.bzr.weave to Python3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Utilities for distinguishing binary files from text files"""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
from itertools import chain
20
22
 
21
 
from bzrlib.errors import BinaryFile
22
 
from bzrlib.iterablefile import IterableFile
23
 
from bzrlib.osutils import file_iterator
 
23
from .errors import BinaryFile
 
24
from .iterablefile import IterableFile
 
25
from .osutils import file_iterator
24
26
 
25
27
 
26
28
def text_file(input):
46
48
    """Check whether the supplied path is a text, not binary file.
47
49
    Raise BinaryFile if a NUL occurs in the first 1024 bytes.
48
50
    """
49
 
    f = open(path, 'rb')
50
 
    try:
 
51
    with open(path, 'rb') as f:
51
52
        text_file(f)
52
 
    finally:
53
 
        f.close()