Replace re.match
with re.fullmatch
See [Benjamin-Loison/cpython/issues/43](https://github.com/Benjamin-Loison/cpython/issues/43).
This commit is contained in:
parent
91fb433258
commit
4969025722
14
utils.py
14
utils.py
@ -54,12 +54,12 @@ def readPdfBankStatement(filePath):
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
if not started:
|
if not started:
|
||||||
# We are interested in the content after this line:)
|
# We are interested in the content after this line:)
|
||||||
soldeCrediteurAuRegexMatch = SOLDE_CREDITEUR_AU_REGEX.match(line)
|
soldeCrediteurAuRegexMatch = SOLDE_CREDITEUR_AU_REGEX.fullmatch(line)
|
||||||
if COLUMNS_HEADER.match(line) is not None:
|
if COLUMNS_HEADER.fullmatch(line) is not None:
|
||||||
getIndex = lambda line, type_: line.index(type_) + len(type_)
|
getIndex = lambda line, type_: line.index(type_) + len(type_)
|
||||||
debitIndex = getIndex(line, 'Débit')
|
debitIndex = getIndex(line, 'Débit')
|
||||||
creditIndex = getIndex(line, 'Crédit')
|
creditIndex = getIndex(line, 'Crédit')
|
||||||
if soldeCrediteurAuRegexMatch is not None or (COLUMNS_HEADER.match(line) is not None and not firstPage):
|
if soldeCrediteurAuRegexMatch is not None or (COLUMNS_HEADER.fullmatch(line) is not None and not firstPage):
|
||||||
if soldeCrediteurAuRegexMatch is not None:
|
if soldeCrediteurAuRegexMatch is not None:
|
||||||
initialDate = datetime.strptime(soldeCrediteurAuRegexMatch.group(1), '%d.%m.%Y')
|
initialDate = datetime.strptime(soldeCrediteurAuRegexMatch.group(1), '%d.%m.%Y')
|
||||||
initialAmount = toFloat(soldeCrediteurAuRegexMatch.group(2))
|
initialAmount = toFloat(soldeCrediteurAuRegexMatch.group(2))
|
||||||
@ -69,14 +69,14 @@ def readPdfBankStatement(filePath):
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
# We aren't interested in the content after this line:
|
# We aren't interested in the content after this line:
|
||||||
if line.startswith('BNP PARIBAS SA au capital de') or END_PAGE_AFTER_THE_FIRST_ONE_REGEX.match(line) is not None:
|
if line.startswith('BNP PARIBAS SA au capital de') or END_PAGE_AFTER_THE_FIRST_ONE_REGEX.fullmatch(line) is not None:
|
||||||
firstPage = False
|
firstPage = False
|
||||||
started = False
|
started = False
|
||||||
continue
|
continue
|
||||||
# We aren't interested in the content after this line
|
# We aren't interested in the content after this line
|
||||||
else:
|
else:
|
||||||
totalDesOperationsRegexMatch = TOTAL_DES_OPERATIONS_REGEX.match(line)
|
totalDesOperationsRegexMatch = TOTAL_DES_OPERATIONS_REGEX.fullmatch(line)
|
||||||
totalDesOperationsCreditOnlyRegexMatch = TOTAL_DES_OPERATIONS_CREDIT_ONLY_REGEX.match(line)
|
totalDesOperationsCreditOnlyRegexMatch = TOTAL_DES_OPERATIONS_CREDIT_ONLY_REGEX.fullmatch(line)
|
||||||
if totalDesOperationsRegexMatch is not None or totalDesOperationsCreditOnlyRegexMatch is not None:
|
if totalDesOperationsRegexMatch is not None or totalDesOperationsCreditOnlyRegexMatch is not None:
|
||||||
# Note that transfer between accounts will be noted in both debits and credits, as trying to cancel would make benefits show as negative debit which does not make sense.
|
# Note that transfer between accounts will be noted in both debits and credits, as trying to cancel would make benefits show as negative debit which does not make sense.
|
||||||
# Cannot just consider January as benefits only as `20240122.pdf` also contains an additional transfer between my accounts.
|
# Cannot just consider January as benefits only as `20240122.pdf` also contains an additional transfer between my accounts.
|
||||||
@ -88,7 +88,7 @@ def readPdfBankStatement(filePath):
|
|||||||
print(f'{totalMonthlyDebit=}')
|
print(f'{totalMonthlyDebit=}')
|
||||||
print(f'{totalMonthlyCredit=}')
|
print(f'{totalMonthlyCredit=}')
|
||||||
break
|
break
|
||||||
firstLineOfPaymentRegexMatch = FIRST_LINE_OF_PAYMENT_REGEX.match(line)
|
firstLineOfPaymentRegexMatch = FIRST_LINE_OF_PAYMENT_REGEX.fullmatch(line)
|
||||||
if firstLineOfPaymentRegexMatch is not None:
|
if firstLineOfPaymentRegexMatch is not None:
|
||||||
if date is not None:
|
if date is not None:
|
||||||
transactions += [{
|
transactions += [{
|
||||||
|
Loading…
Reference in New Issue
Block a user