def __init__(self, fileish, check_crc=True, data_processor=None): self._file = fileish_open(fileish, 'rb') self.check_crc = check_crc self._crc = None # Get total filesize self._file.seek(0, os.SEEK_END) self._filesize = self._file.tell() self._file.seek(0, os.SEEK_SET) # Start off by parsing the file header (sets initial attribute values) self._parse_file_header()
def __init__(self, fileish, check_crc=True, data_processor=None): self._file = fileish_open(fileish, 'rb') self.check_crc = check_crc self._crc = None self._processor = data_processor or FitFileDataProcessor() # Get total filesize self._file.seek(0, os.SEEK_END) self._filesize = self._file.tell() self._file.seek(0, os.SEEK_SET) self._messages = [] # Start off by parsing the file header (sets initial attribute values) self._parse_file_header()
def test_fopen(fileish): with fileish_open(fileish, 'wb') as f: f.write(b'\x12') f.seek(0, os.SEEK_SET)
def test_fopen(fileish): with fileish_open(fileish, 'rb') as f: self.assertIsNotNone(f.read(1)) f.seek(0, os.SEEK_SET)