Mercurial > louis > ofxstatement-us-hsbc
comparison 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 |
comparison
equal
deleted
inserted
replaced
6:5692e2a61764 | 7:829eb62755b0 |
---|---|
1 # Copyright (c) 2016, Louis Opter <louis@opter.org> | |
2 # | |
3 # This file is part of ofxstatement-us-hsbc. | |
4 # | |
5 # ofxstatement-us-hsbc is free software: you can redistribute it and/or | |
6 # modify it under the terms of the GNU General Public License as | |
7 # published by the Free Software Foundation, either version 3 of the | |
8 # License, or (at your option) any later version. | |
9 # | |
10 # ofxstatement-us-hsbc is distributed in the hope that it will be | |
11 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty | |
12 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 # GNU General Public License for more details. | |
14 # | |
15 # You should have received a copy of the GNU General Public License | |
16 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | |
18 import enum | |
19 import os | |
20 | |
21 from typing import List | |
22 | |
23 | |
24 class CsvIndexes(enum.Enum): | |
25 | |
26 STATUS = 0 | |
27 DATE = 1 | |
28 ORIGINAL_DESCRIPTION = 2 | |
29 SPLIT_TYPE = 3 | |
30 CATEGORY = 4 | |
31 CURRENCY = 5 | |
32 AMOUNT = 6 | |
33 USER_DESCRIPTION = 7 | |
34 MEMO = 8 | |
35 CLASSIFICATION = 9 | |
36 SIMPLE_DESCRIPTION = 10 | |
37 | |
38 | |
39 class Record: | |
40 | |
41 status: str = None | |
42 date: str = None | |
43 original_description: str = None | |
44 split_type: str = None | |
45 category: str = None | |
46 currency: str = None | |
47 amount: str = None | |
48 user_description: str = None | |
49 memo: str = None | |
50 classification: str = None | |
51 account_name: str = None | |
52 simple_description: str = None | |
53 | |
54 def __init__(self, line: List[str]) -> None: | |
55 for index in CsvIndexes: | |
56 setattr(self, index.name.lower(), line[index.value].strip()) | |
57 | |
58 def __repr__(self) -> str: | |
59 linesep = "{} ".format(os.linesep) | |
60 return "<{}({}{}) object at 0x{:x}>".format( | |
61 self.__class__.__name__, | |
62 linesep, | |
63 ",{}".format(linesep).join( | |
64 "{}={}".format(attrname, getattr(self, attrname.lower())) | |
65 for attrname in map(lambda idx: idx.name.lower(), CsvIndexes) | |
66 ), | |
67 id(self), | |
68 ) |