print statement fixes

convert the print statement to a WARN level log line or to a call to the print
function, depending on the context.
This commit is contained in:
Alexandre Fayolle
2014-12-03 09:51:38 +01:00
parent 7b02b88c38
commit ca3d306f7d
5 changed files with 15 additions and 7 deletions

View File

@@ -41,6 +41,7 @@
# deviation to take the warning from SEPA seriously: this is the domain of the
# account owning banks. Don't use it, unless you are prepared to loose your
# money. It is for heuristic validation purposes only.
from __future__ import print_function
__all__ = ['IBAN', 'BBAN']

View File

@@ -23,7 +23,7 @@
Define a struct class which behaves like a dict, but allows using
object.attr alongside object['attr'].
'''
from __future__ import print_function
__all__ = ['struct']

View File

@@ -3,7 +3,9 @@
"""Parser for PATU format files"""
import re
import datetime
import logging
_logger = logging.getLogger(__name__)
def fixchars(line):
"""Fix the characters mangled in the input
@@ -150,7 +152,7 @@ class PatuParser(object):
if matchobj:
break
if not matchobj:
print(" **** failed to match line '%s'" % (line))
_logger.warning("failed to match line %r", line)
return
# Strip strings
matchdict = matchobj.groupdict()

View File

@@ -23,6 +23,8 @@
"""
Parser for MT940 format files
"""
from __future__ import print_function
import re
import datetime
import logging
@@ -219,12 +221,12 @@ def main(filename):
parser = MT940()
parser.parse(None, open(filename, 'r').read())
for statement in parser.statements:
print '''statement found for %(local_account)s at %(date)s
print('''statement found for %(local_account)s at %(date)s
with %(local_currency)s%(start_balance)s to %(end_balance)s
''' % statement.__dict__
''' % statement.__dict__)
for transaction in statement.transactions:
print '''
transaction on %(execution_date)s''' % transaction.__dict__
print('''
transaction on %(execution_date)s''' % transaction.__dict__)
if __name__ == '__main__':
import sys

View File

@@ -26,6 +26,9 @@ Based on fi_patu's parser
"""
import re
from datetime import datetime
import logging
_logger = logging.getLogger(__name__)
class HSBCParser(object):
@@ -86,7 +89,7 @@ class HSBCParser(object):
if matchobj:
break
if not matchobj:
print(" **** failed to match line '%s'" % (line))
_logger.warning("failed to match line %r", line)
return
# Strip strings
matchdict = matchobj.groupdict()