Changeset - b33c83af0a0f
[Not reviewed]
0 2 0
Brett Smith - 6 years ago 2018-06-20 19:59:56
brettcsmith@brettcsmith.org
importers: Catch and handle CSV parse errors in can_import.

import2ledger bailed on one of these exceptions when trying to import
a recent XLS file that had a null byte on a line.
2 files changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
import2ledger/importers/_csv.py
Show inline comments
...
 
@@ -63,8 +63,12 @@ class CSVImporterBase:
 

	
 
    @classmethod
 
    def can_import(cls, input_file):
 
        _, fields = cls._read_header(input_file)
 
        return cls._NEEDED_KEYS.issubset(fields or ())
 
        try:
 
            _, fields = cls._read_header(input_file)
 
        except csv.Error:
 
            return False
 
        else:
 
            return cls._NEEDED_KEYS.issubset(fields or ())
 

	
 
    def __init__(self, input_file):
 
        self.entry_seed, fields = self._read_header(input_file)
setup.py
Show inline comments
...
 
@@ -30,7 +30,7 @@ REQUIREMENTS['tests_require'] = [
 
setup(
 
    name='import2ledger',
 
    description="Import different sources of financial data to Ledger",
 
    version='0.3',
 
    version='0.4',
 
    author='Brett Smith',
 
    author_email='brettcsmith@brettcsmith.org',
 
    license='GNU AGPLv3+',
0 comments (0 inline, 0 general)