main: Open files with errors='replace'.

Stripe payment CSVs have apparently random encoding, and no way what to tell
what they're using beyond chardet.

The better way to fix this is following the existing to-do item, opening
files in binary mode and creating an importer base class to provide text
wrapping.  This would let each importer be as strict as possible.
This commit is contained in:
Brett Smith 2017-12-18 17:38:55 -05:00
parent 68a0a9625c
commit 9472be10f1

View file

@ -51,7 +51,7 @@ class FileImporter:
def import_path(self, in_path): def import_path(self, in_path):
if in_path is None: if in_path is None:
raise errors.UserInputFileError("only seekable files are supported", '<stdin>') raise errors.UserInputFileError("only seekable files are supported", '<stdin>')
with in_path.open() as in_file: with in_path.open(errors='replace') as in_file:
if not in_file.seekable(): if not in_file.seekable():
raise errors.UserInputFileError("only seekable files are supported", in_path) raise errors.UserInputFileError("only seekable files are supported", in_path)
return self.import_file(in_file) return self.import_file(in_file)