Skip to content

Commit 1b8be76

Browse files
committed
Fix support for RUM/CPY entries
If not all characters are gonna be eaten by the parser, and they are blank, just ignore them...
1 parent f8a4363 commit 1b8be76

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

cfonb/parser/common.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def _post(self, res):
9393
def parse(self, line):
9494
if line[-1] == "\n":
9595
line = line[:-1]
96+
if len(line) > self.size and len(line.strip()) <= self.size:
97+
line = line[:self.size]
9698
if len(line) != self.size:
9799
raise ParsingError("Invalid line: >%s<. the len should be %s"
98100
"instead of %s" % (line, self.size, len(line)))
@@ -401,23 +403,20 @@ class ParserPDO(Parser):
401403
]
402404

403405

404-
405406
#specific to withdrawal
406-
# TODO FIXME it's look like there is something wrong in
407-
# confb norme indeed 35+4 != 70 and 35 != 70 :S outch!
408-
#class ParserRUM(Parser):
409-
# _code = 'RUM'
410-
# _regex = [
411-
# ('mandate_identification', G_ALL %35),
412-
# ('sequence_type', G_ALL %4),
413-
# ]
414-
#
415-
#class ParserCPY(Parser):
416-
# _code = 'CPY'
417-
# _regex = [
418-
# ('debtor_account', G_ALL %35),
419-
# ]
420-
#
407+
class ParserRUM(Parser):
408+
_code = 'RUM'
409+
_regex = [
410+
('mandate_identification', G_ALL, 35),
411+
('sequence_type', G_ALL, 4),
412+
]
413+
414+
class ParserCPY(Parser):
415+
_code = 'CPY'
416+
_regex = [
417+
('debtor_account', G_ALL, 35),
418+
]
419+
421420

422421
def parse_amount(amount_str, nb_of_dec):
423422
""" return a numerical amount from the cfonb amount string

0 commit comments

Comments
 (0)