Use ebcdic pattern of allowed characters for user message

This commit is contained in:
Dmitrijs Ledkovs
2011-11-09 16:15:12 +00:00
parent 60a4ae44ff
commit c99e9309ea

View File

@@ -31,6 +31,7 @@ class HSBCParser(object):
def __init__( self ): def __init__( self ):
recparse = dict() recparse = dict()
patterns = {'ebcdic': "\w/\?:\(\).,'+{} -"}
# MT940 header # MT940 header
recparse["20"] = ":(?P<recordid>20):(?P<transref>.{1,16})" recparse["20"] = ":(?P<recordid>20):(?P<transref>.{1,16})"
@@ -43,16 +44,18 @@ class HSBCParser(object):
+ "(?P<startingbalance>[\d,]{1,15})" + "(?P<startingbalance>[\d,]{1,15})"
# Transaction # Transaction
recparse["61"] = ":(?P<recordid>61):" \ recparse["61"] = """\
+ "(?P<valuedate>\d{6})(?P<bookingdate>\d{4})?" \ :(?P<recordid>61):\
+ "(?P<creditmarker>R?[CD])" \ (?P<valuedate>\d{6})(?P<bookingdate>\d{4})?\
+ "(?P<currency>[A-Z])?" \ (?P<creditmarker>R?[CD])\
+ "(?P<amount>[\d,]{1,15})" \ (?P<currency>[A-Z])?\
+ "(?P<bookingcode>[A-Z][A-Z0-9]{3})" \ (?P<amount>[\d,]{1,15})\
+ "(?P<custrefno>[A-Za-z0-9 _-]{1,16})" \ (?P<bookingcode>[A-Z][A-Z0-9]{3})\
+ "(?://)" \ (?P<custrefno>[%(ebcdic)s]{1,16})\
+ "(?P<bankref>[A-Za-z0-9 _]{1,16})?" \ (?://)\
+ "(?:\n(?P<furtherinfo>[A-Za-z0-9 _.]))?" (?P<bankref>[%(ebcdic)s]{1,16})?\
(?:\n(?P<furtherinfo>[%(ebcdic)s]))?\
""" % (patterns)
# Further info # Further info
recparse["86"] = ":(?P<recordid>86):" \ recparse["86"] = ":(?P<recordid>86):" \