16 from codecs
import BOM_UTF8
18 from .robottypes
import is_string
25 self.
_file_file = open(path_or_file,
'rb')
28 self.
_file_file = path_or_file
32 if hasattr(self.
_file_file,
'mode')
and self.
_file_file.mode !=
'rb':
33 raise ValueError(
'Only files in binary mode accepted.')
40 self.
_file_file.close()
47 yield self.
_decode_decode(line, remove_bom=index == 0)
49 def _decode(self, content, remove_bom=True):
50 if remove_bom
and content.startswith(BOM_UTF8):
51 content = content[len(BOM_UTF8):]
52 return content.decode(
'UTF-8')
def __exit__(self, *exc_info)
def __init__(self, path_or_file)
def _decode(self, content, remove_bom=True)