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