Skip to content

Commit 0ea0345

Browse files
author
Hong-Thai Nguyen
authored
Merge pull request #9 from thaichat04/add-comment
Add comment in result parser
2 parents 6d6c220 + 099f4b0 commit 0ea0345

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

cfonb/parser/statement.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ def parse(self, file_obj):
4545
while True:
4646
index += 1
4747
if not row.get('label_%s'%index):
48-
row['label_%s'%index] = new_row.label
48+
row['label_%s'%index] = new_row.get('label')
4949
break
5050
else:
5151
row.update(new_row)
52+
comment = line.split(' ')[2].strip()
53+
if comment:
54+
row['comment'] = row.get('comment', '') + (BR_LINE if row.get('comment', '') else '') + comment
5255
elif line[0:2] == '07':
5356
statement.footer = Row(line)
5457
else:

cfonb/tests/test_statement.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ def test_parse_with_original_content(self):
5050
assert_true(result[0].lines[0].get('origin').endswith('0515589 29701EUR2E01711467640B1230620 LIBPRELEVEMENTS SEPA DOMICILIES '))
5151
assert_true(len(result[0].lines[0].get('origin').splitlines()) == 5)
5252

53+
def test_parse_with_comment_content(self):
54+
content = '''0115589 29701EUR2 01711467640 220620GAEC DE STANG KERBAIL 0000000352431O0000
55+
0415589 29701EUR2E01711467640B1230620 220620PRLV ORANGE 0 0000000000315}VOTRE ABONNEMENT
56+
0515589 29701EUR2E01711467640B1230620 NBEORANGE
57+
0515589 29701EUR2E01711467640B1230620 LCCVOTRE ABONNEMENT FIXE 02XXXXX896 (FACTURE: XXXXX8960E2) - P
58+
0515589 29701EUR2E01711467640B1230620 RCN298576896 985768960E235E
59+
0515589 29701EUR2E01711467640B1230620 LIBPRELEVEMENTS SEPA DOMICILIES
60+
0715589 29701EUR2 01711467640 230620 0000000352746O '''
61+
reader = StatementReader()
62+
result = reader.parse(StringIO(content))
63+
assert_equal(len(result[0].lines), 1)
64+
assert_true(result[0].lines[0].get('comment').startswith(
65+
'NBEORANGE'))
66+
assert_true(result[0].lines[0].get('comment').endswith(
67+
'LIBPRELEVEMENTS SEPA DOMICILIES'))
68+
assert_true(len(result[0].lines[0].get('comment').splitlines()) == 4)
69+
5370

5471
def suite():
5572
suite = unittest.TestSuite()

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup, find_packages
22

3-
version = '2.3'
3+
version = '2.4'
44

55
long_description = open('README.rst').read()
66

@@ -14,7 +14,7 @@
1414
author='Dhatim',
1515
author_email='[email protected]',
1616
url='https://github.com/dhatim/python-cfonb',
17-
download_url = 'https://github.com/dhatim/python-cfonb/archive/2.3.tar.gz',
17+
download_url = 'https://github.com/dhatim/python-cfonb/archive/2.4.tar.gz',
1818
license='LGPL',
1919
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
2020
include_package_data=True,

0 commit comments

Comments
 (0)