ofxstatement-lloyds 0.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ include README.rst
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.1
2
+ Name: ofxstatement-lloyds
3
+ Version: 0.9.0
4
+ Summary: Plugin for reading statements of Lloyds UK bank
5
+ Home-page: https://github.com/Metasaura/ofxstatement-lloyds
6
+ Author: Victoria Lebedeva
7
+ Author-email: victoria@lebedev.lt
8
+ License: MIT
9
+ Keywords: ofx,banking,statement,lloyds
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Natural Language :: English
13
+ Classifier: Topic :: Office/Business :: Financial :: Accounting
14
+ Classifier: Topic :: Utilities
15
+ Classifier: Environment :: Console
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Requires-Dist: ofxstatement
19
+
20
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
+ Plugin for reading statements of Lloyds UK bank
22
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23
+
24
+ This is a plugin for ofxstatement to convert CSV statements issued by Lloyds UK bank.
@@ -0,0 +1,5 @@
1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2
+ Plugin for reading statements of Lloyds UK bank
3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
+
5
+ This is a plugin for ofxstatement to convert CSV statements issued by Lloyds UK bank.
@@ -0,0 +1,7 @@
1
+ [mypy]
2
+ namespace_packages = True
3
+
4
+ [egg_info]
5
+ tag_build =
6
+ tag_date = 0
7
+
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/python3
2
+ """Setup
3
+ """
4
+ from setuptools import find_packages
5
+ from distutils.core import setup
6
+
7
+ version = "0.9.0"
8
+
9
+ with open("README.rst") as f:
10
+ long_description = f.read()
11
+
12
+ setup(
13
+ name="ofxstatement-lloyds",
14
+ version=version,
15
+ author="Victoria Lebedeva",
16
+ author_email="victoria@lebedev.lt",
17
+ url="https://github.com/Metasaura/ofxstatement-lloyds",
18
+ description=("Plugin for reading statements of Lloyds UK bank"),
19
+ long_description=long_description,
20
+ license="MIT",
21
+ keywords=["ofx", "banking", "statement", "lloyds"],
22
+ classifiers=[
23
+ "Development Status :: 4 - Beta",
24
+ "Programming Language :: Python :: 3",
25
+ "Natural Language :: English",
26
+ "Topic :: Office/Business :: Financial :: Accounting",
27
+ "Topic :: Utilities",
28
+ "Environment :: Console",
29
+ "Operating System :: OS Independent",
30
+ "License :: OSI Approved :: MIT License",
31
+ ],
32
+ packages=find_packages("src"),
33
+ package_dir={"": "src"},
34
+ entry_points={
35
+ "ofxstatement": ["lloyds = ofxstatement_lloyds.plugin:LloydsPlugin"]
36
+ },
37
+ install_requires=["ofxstatement"],
38
+ include_package_data=True,
39
+ zip_safe=True,
40
+ )
@@ -0,0 +1,48 @@
1
+ from typing import Iterable, Optional, TextIO
2
+
3
+ from ofxstatement.plugin import Plugin
4
+ from ofxstatement.parser import StatementParser
5
+ from ofxstatement.statement import Statement, StatementLine, generate_unique_transaction_id
6
+
7
+ from ofxstatement.parser import CsvStatementParser
8
+
9
+
10
+ class LloydsPlugin(Plugin):
11
+ """Lloyds plugin (for developers only)"""
12
+
13
+ def get_parser(self, filename: str) -> "LloydsParser":
14
+ f = open(filename, "r")
15
+ return LloydsParser(f)
16
+
17
+
18
+
19
+ class LloydsParser(CsvStatementParser):
20
+ mappings = {"date": 0, "memo": 4}
21
+ date_format = "%d/%m/%Y"
22
+
23
+ def __init__(self, fin: TextIO) -> None:
24
+ super().__init__(fin)
25
+ self.uids = set()
26
+
27
+ def parse_record(self, line: list[str]) -> Optional[StatementLine]:
28
+ sline = super().parse_record(line)
29
+ sline.id = generate_unique_transaction_id(sline, self.uids)
30
+ debit = line[5]
31
+ credit = line[6]
32
+ if debit == '':
33
+ debit = 0
34
+ else:
35
+ debit = self.parse_decimal(debit)
36
+ if credit == '':
37
+ credit = 0
38
+ else:
39
+ credit = self.parse_decimal(credit)
40
+ sline.amount = (-debit + credit)
41
+
42
+
43
+ return sline
44
+
45
+ def split_records(self) -> Iterable[list[str]]:
46
+ reader = super().split_records()
47
+ next(reader) #Skip first line
48
+ return reader
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.1
2
+ Name: ofxstatement-lloyds
3
+ Version: 0.9.0
4
+ Summary: Plugin for reading statements of Lloyds UK bank
5
+ Home-page: https://github.com/Metasaura/ofxstatement-lloyds
6
+ Author: Victoria Lebedeva
7
+ Author-email: victoria@lebedev.lt
8
+ License: MIT
9
+ Keywords: ofx,banking,statement,lloyds
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Natural Language :: English
13
+ Classifier: Topic :: Office/Business :: Financial :: Accounting
14
+ Classifier: Topic :: Utilities
15
+ Classifier: Environment :: Console
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Requires-Dist: ofxstatement
19
+
20
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
+ Plugin for reading statements of Lloyds UK bank
22
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23
+
24
+ This is a plugin for ofxstatement to convert CSV statements issued by Lloyds UK bank.
@@ -0,0 +1,14 @@
1
+ MANIFEST.in
2
+ README.rst
3
+ setup.cfg
4
+ setup.py
5
+ src/ofxstatement_lloyds/__init__.py
6
+ src/ofxstatement_lloyds/plugin.py
7
+ src/ofxstatement_lloyds.egg-info/PKG-INFO
8
+ src/ofxstatement_lloyds.egg-info/SOURCES.txt
9
+ src/ofxstatement_lloyds.egg-info/dependency_links.txt
10
+ src/ofxstatement_lloyds.egg-info/entry_points.txt
11
+ src/ofxstatement_lloyds.egg-info/requires.txt
12
+ src/ofxstatement_lloyds.egg-info/top_level.txt
13
+ src/ofxstatement_lloyds.egg-info/zip-safe
14
+ tests/test_sample.py
@@ -0,0 +1,2 @@
1
+ [ofxstatement]
2
+ lloyds = ofxstatement_lloyds.plugin:LloydsPlugin
@@ -0,0 +1 @@
1
+ ofxstatement_lloyds
@@ -0,0 +1,36 @@
1
+ import datetime
2
+ from decimal import Decimal
3
+ import os
4
+
5
+ from ofxstatement.ui import UI
6
+
7
+ from ofxstatement_lloyds.plugin import LloydsPlugin
8
+
9
+
10
+ def test_sample() -> None:
11
+ plugin = LloydsPlugin(UI(), {})
12
+ here = os.path.dirname(__file__)
13
+ sample_filename = os.path.join(here, "sample-statement.csv")
14
+
15
+ parser = plugin.get_parser(sample_filename)
16
+
17
+ statement = parser.parse()
18
+
19
+ assert statement is not None
20
+ assert len(statement.lines) == 6
21
+
22
+ assert statement.lines[0].amount == Decimal('-8.99')
23
+ assert statement.lines[3].amount == Decimal('2000')
24
+ assert statement.lines[5].date == datetime.datetime(2023, 12, 1)
25
+ assert statement.lines[2].memo == 'ADAGIO EUROS 202.40 VISAXR 1.16168 CD 1417 '
26
+
27
+
28
+ def sum2num(x, y):
29
+ return x+y
30
+
31
+ def test_iop():
32
+ h=2-5
33
+ h=h+5*19+8
34
+ assert h==100
35
+
36
+ assert sum2num(5, 9) == 14