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 # 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 # account owning banks. Don't use it, unless you are prepared to loose your
# money. It is for heuristic validation purposes only. # money. It is for heuristic validation purposes only.
from __future__ import print_function
__all__ = ['IBAN', 'BBAN'] __all__ = ['IBAN', 'BBAN']

View File

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

View File

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

View File

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

View File

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