Mercurial > louis > ofxstatement-us-hsbc
diff src/ofxstatement/plugins/us_hsbc/record.py @ 7:829eb62755b0
First cut at an HSBC (USA) plugin
author | Louis Opter <kalessin@kalessin.fr> |
---|---|
date | Thu, 17 Nov 2016 16:25:12 -0800 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ofxstatement/plugins/us_hsbc/record.py Thu Nov 17 16:25:12 2016 -0800 @@ -0,0 +1,68 @@ +# Copyright (c) 2016, Louis Opter <louis@opter.org> +# +# This file is part of ofxstatement-us-hsbc. +# +# ofxstatement-us-hsbc is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# ofxstatement-us-hsbc is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import enum +import os + +from typing import List + + +class CsvIndexes(enum.Enum): + + STATUS = 0 + DATE = 1 + ORIGINAL_DESCRIPTION = 2 + SPLIT_TYPE = 3 + CATEGORY = 4 + CURRENCY = 5 + AMOUNT = 6 + USER_DESCRIPTION = 7 + MEMO = 8 + CLASSIFICATION = 9 + SIMPLE_DESCRIPTION = 10 + + +class Record: + + status: str = None + date: str = None + original_description: str = None + split_type: str = None + category: str = None + currency: str = None + amount: str = None + user_description: str = None + memo: str = None + classification: str = None + account_name: str = None + simple_description: str = None + + def __init__(self, line: List[str]) -> None: + for index in CsvIndexes: + setattr(self, index.name.lower(), line[index.value].strip()) + + def __repr__(self) -> str: + linesep = "{} ".format(os.linesep) + return "<{}({}{}) object at 0x{:x}>".format( + self.__class__.__name__, + linesep, + ",{}".format(linesep).join( + "{}={}".format(attrname, getattr(self, attrname.lower())) + for attrname in map(lambda idx: idx.name.lower(), CsvIndexes) + ), + id(self), + )