diff --git a/account_banking/parsers/models.py b/account_banking/parsers/models.py index c94b7e443..c33add722 100644 --- a/account_banking/parsers/models.py +++ b/account_banking/parsers/models.py @@ -397,7 +397,7 @@ class parser(object): param being a company account is not enforced here either. """ def normalize(account_no): - return re.sub('\s', '', account_no) + return re.sub(r'\s', '', account_no) account = normalize(account) cr.execute( diff --git a/account_banking_fi_patu/parser.py b/account_banking_fi_patu/parser.py index 5d5d0bd3b..7df2ca0b6 100644 --- a/account_banking_fi_patu/parser.py +++ b/account_banking_fi_patu/parser.py @@ -27,111 +27,111 @@ class PatuParser(object): recparse = dict() recparse["00"] = ( - "T(?P00)(?P\d{3})" - "(?P\d{3})(?P\d{14})" - "(?P\d{3})(?P\d{6})" - "(?P\d{6})" - "(?P\d{6})(?P\d{4})" - "(?P.{17})(?P\d{6})" - "(?P.{19})" - "(?P\d{6})(?P.{3})" - "(?P.{30})" - "(?P\d{18})(?P.{35})" - "(?P.{40})(?P.{40})" - "(?P.{30})(?P.{30})" + r"T(?P00)(?P\d{3})" + r"(?P\d{3})(?P\d{14})" + r"(?P\d{3})(?P\d{6})" + r"(?P\d{6})" + r"(?P\d{6})(?P\d{4})" + r"(?P.{17})(?P\d{6})" + r"(?P.{19})" + r"(?P\d{6})(?P.{3})" + r"(?P.{30})" + r"(?P\d{18})(?P.{35})" + r"(?P.{40})(?P.{40})" + r"(?P.{30})(?P.{30})" ) recparse["10"] = ( - "T(?P[18]0)(?P\d{3})" - "(?P\d{6})" - "(?P.{18})(?P\d{6})" - "(?P\d{6})" - "(?P\d{6})(?P\d)" - "(?P.{3})(?P.{35})" - "(?P.{19})(?P.)(?P.)" - "(?P.{35})(?P.)" - "(?P.{14})(?P.)" - "(?P.{20})" - "(?P.{8})(?P.)" + r"T(?P[18]0)(?P\d{3})" + r"(?P\d{6})" + r"(?P.{18})(?P\d{6})" + r"(?P\d{6})" + r"(?P\d{6})(?P\d)" + r"(?P.{3})(?P.{35})" + r"(?P.{19})(?P.)(?P.)" + r"(?P.{35})(?P.)" + r"(?P.{14})(?P.)" + r"(?P.{20})" + r"(?P.{8})(?P.)" ) recparse["11"] = ( - "T(?P[18]1)(?P\d{3})" - "(?P.{2})" - "(?:(?# Match specific info)" - "(?<=00)(?P.{35})+" - "|" - "(?<=01)(?P\d{8})" - "|" - "(?<=02)(?P.{10})\s(?P.{15})\s" - "(?P\d{6})" - "|" - "(?<=03)(?P.{19})\s(?P.{14})" - "|" - "(?<=04)(?P.{18})" - "|" - "(?<=05)(?P.{19})\s(?P.{3})\s" - "(?P.{11})(?P.{6})" - "|" - "(?<=06)(?P.{35})(?P.{35})" - "|" - "(?<=07)(?P.{35})" - "(?P.{35})?" - "(?P.{35})?" - "(?P.{35})?" - "(?P.{35})?" - "(?P.{35})?" - "(?P.{35})?" - "(?P.{35})?" - "(?P.{35})?" - "(?P.{35})?" - "(?P.{35})?" - "(?P.{35})?" - "|" - "(?<=08)(?P\d{3})\s(?P.{31})" - "|" - "(?<=09)(?P.{35})" - "|" - "(?<=11)(?P.{35})(?P.{35})" - "(?P.{35})(?P.{70})" - "(?P.{70})(?P.{35})" - "(?P.{70})" - ")" + r"T(?P[18]1)(?P\d{3})" + r"(?P.{2})" + r"(?:(?# Match specific info)" + r"(?<=00)(?P.{35})+" + r"|" + r"(?<=01)(?P\d{8})" + r"|" + r"(?<=02)(?P.{10})\s(?P.{15})\s" + r"(?P\d{6})" + r"|" + r"(?<=03)(?P.{19})\s(?P.{14})" + r"|" + r"(?<=04)(?P.{18})" + r"|" + r"(?<=05)(?P.{19})\s(?P.{3})\s" + r"(?P.{11})(?P.{6})" + r"|" + r"(?<=06)(?P.{35})(?P.{35})" + r"|" + r"(?<=07)(?P.{35})" + r"(?P.{35})?" + r"(?P.{35})?" + r"(?P.{35})?" + r"(?P.{35})?" + r"(?P.{35})?" + r"(?P.{35})?" + r"(?P.{35})?" + r"(?P.{35})?" + r"(?P.{35})?" + r"(?P.{35})?" + r"(?P.{35})?" + r"|" + r"(?<=08)(?P\d{3})\s(?P.{31})" + r"|" + r"(?<=09)(?P.{35})" + r"|" + r"(?<=11)(?P.{35})(?P.{35})" + r"(?P.{35})(?P.{70})" + r"(?P.{70})(?P.{35})" + r"(?P.{70})" + r")" ) recparse["40"] = ( - "T(?P40)(?P\d{3})" - "(?P\d{6})(?P.{19})" - "(?P.{19})" + r"T(?P40)(?P\d{3})" + r"(?P\d{6})(?P.{19})" + r"(?P.{19})" ) recparse["50"] = ( - "T(?P50)(?P\d{3})" - "(?P\d)(?P\d{6})" - "(?P\d{8})(?P.{19})" - "(?P\d{8})(?P.{19})" + r"T(?P50)(?P\d{3})" + r"(?P\d)(?P\d{6})" + r"(?P\d{8})(?P.{19})" + r"(?P\d{8})(?P.{19})" ) recparse["60"] = ( - "T(?P60)(?P\d{3})" - "(?P.{3})(?P01)" - "(?P\d{6})-" - "(?P\d{6})" - "(?P.)(?P.{19})" - "(?P.)(?P\d{7})" - "(?P.)(?P.{19})" - "(?P.)(?P\d{7})" - "(?P.)(?P\d{7})" - "(?P.)(?P.{19})" - "(?P.)(?P.{35})" - "(?P\d{7})" - "(?P.)(?P.{35})" - "(?P\d{7})" + r"T(?P60)(?P\d{3})" + r"(?P.{3})(?P01)" + r"(?P\d{6})-" + r"(?P\d{6})" + r"(?P.)(?P.{19})" + r"(?P.)(?P\d{7})" + r"(?P.)(?P.{19})" + r"(?P.)(?P\d{7})" + r"(?P.)(?P\d{7})" + r"(?P.)(?P.{19})" + r"(?P.)(?P.{35})" + r"(?P\d{7})" + r"(?P.)(?P.{35})" + r"(?P\d{7})" ) recparse["70"] = ( - "T(?P70)(?P\d{3})" - "(?P\d{3})" - "(?P.{80})" - "(?P.{80})?" - "(?P.{80})?" - "(?P.{80})?" - "(?P.{80})?" - "(?P.{80})?" + r"T(?P70)(?P\d{3})" + r"(?P\d{3})" + r"(?P.{80})" + r"(?P.{80})?" + r"(?P.{80})?" + r"(?P.{80})?" + r"(?P.{80})?" + r"(?P.{80})?" ) for record in recparse: recparse[record] = re.compile(recparse[record]) diff --git a/account_banking_nl_abnamro/abnamro.py b/account_banking_nl_abnamro/abnamro.py index 95aff2cf3..013487257 100644 --- a/account_banking_nl_abnamro/abnamro.py +++ b/account_banking_nl_abnamro/abnamro.py @@ -223,7 +223,7 @@ class transaction(models.mem_bank_transaction): transfer_type = 'GIRO' # field has markup 'GIRO ACCOUNT OWNER' # separated by clusters of space of varying size - account_match = re.match('\s*([0-9]+)\s(.*)$', field[5:]) + account_match = re.match(r'\s*([0-9]+)\s(.*)$', field[5:]) if account_match: remote_account = account_match.group(1).zfill(10) remote_owner = account_match.group(2).strip() or '' @@ -245,7 +245,7 @@ class transaction(models.mem_bank_transaction): # format elif field.startswith('MAANDBIJDRAGE ABNAMRO'): transfer_type = 'COSTS' - elif re.match("^\s([0-9]+\.){3}[0-9]+\s", field): + elif re.match(r"^\s([0-9]+\.){3}[0-9]+\s", field): transfer_type = 'BANK' remote_account = field[1:13].strip().replace('.', '').zfill(10) # column 14 to 31 is either empty or contains the remote owner @@ -325,8 +325,8 @@ class transaction(models.mem_bank_transaction): # but can be any numeric line really for field in fields[1:]: m = re.match( - "^\s*((BETALINGSKENM\.)|(ACCEPTGIRO))?\s*([0-9]+" - "([ /][0-9]+)*)\s*$", + r"^\s*((BETALINGSKENM\.)|(ACCEPTGIRO))?\s*([0-9]+" + r"([ /][0-9]+)*)\s*$", field) if m: self.reference = m.group(4) diff --git a/account_banking_nl_girotel/girotel.py b/account_banking_nl_girotel/girotel.py index 997530ed9..8cfe5deaa 100644 --- a/account_banking_nl_girotel/girotel.py +++ b/account_banking_nl_girotel/girotel.py @@ -117,7 +117,7 @@ class transaction_message(object): # payment batch done via clieop if (self.transfer_type == 'VZ' and (not self.remote_account or self.remote_account == '0') - and (not self.message or re.match('^\s*$', self.message)) + and (not self.message or re.match(r'^\s*$', self.message)) and self.remote_owner.startswith('TOTAAL ')): self.transfer_type = 'PB' self.message = self.remote_owner @@ -127,7 +127,7 @@ class transaction_message(object): and not self.remote_account\ and not self.remote_owner\ and re.match( - '^Verzamel Eurobetaling .* TOTAAL \d+ POSTEN\s*$', + r'^Verzamel Eurobetaling .* TOTAAL \d+ POSTEN\s*$', self.message): self.transfer_type = 'PB' else: diff --git a/account_banking_nl_ing/ing.py b/account_banking_nl_ing/ing.py index 9faf70bc6..8a749138c 100644 --- a/account_banking_nl_ing/ing.py +++ b/account_banking_nl_ing/ing.py @@ -116,7 +116,7 @@ class transaction(models.mem_bank_transaction): } # global expression for matching storno references - ref_expr = re.compile('REF[\*:]([0-9A-Z-z_-]+)') + ref_expr = re.compile(r'REF[\*:]([0-9A-Z-z_-]+)') # match references for Acceptgiro's through Internet banking kn_expr = re.compile('KN: ([^ ]+)') @@ -178,8 +178,8 @@ class transaction(models.mem_bank_transaction): before = self.message[:index] self.message = self.message[index:] expression = ( - "^\s*(KN:\s*(?P[^\s]+))?(\s*)" - "(?PNAVR:\s*[^\s]+)?(\s*)(?P.*?)$") + r"^\s*(KN:\s*(?P[^\s]+))?(\s*)" + r"(?PNAVR:\s*[^\s]+)?(\s*)(?P.*?)$") msg_match = re.match(expression, self.message) after = msg_match.group('after') kn = msg_match.group('kn') @@ -196,7 +196,7 @@ class transaction(models.mem_bank_transaction): if parts: zip_city = parts.pop(0).strip() zip_match = re.match( - "^(?P[^ ]{6})\s+(?P.*?)$", zip_city) + r"^(?P[^ ]{6})\s+(?P.*?)$", zip_city) if zip_match: self.remote_owner_postalcode = zip_match.group('zipcode') self.remote_owner_city = zip_match.group('city') diff --git a/account_banking_nl_ing_mt940/account_banking_nl_ing_mt940.py b/account_banking_nl_ing_mt940/account_banking_nl_ing_mt940.py index 82cf6771e..32f560c77 100644 --- a/account_banking_nl_ing_mt940/account_banking_nl_ing_mt940.py +++ b/account_banking_nl_ing_mt940/account_banking_nl_ing_mt940.py @@ -39,8 +39,8 @@ class IngMT940Parser(MT940, parser): code = 'INT_MT940_STRUC' tag_61_regex = re.compile( - '^(?P\d{6})(?P[CD])(?P\d+,\d{2})N(?P.{3})' - '(?P\w{1,16})') + r'^(?P\d{6})(?P[CD])(?P\d+,\d{2})N(?P.{3})' + r'(?P\w{1,16})') def create_transaction(self, cr): return transaction() diff --git a/account_banking_nl_rabo_mt940/account_banking_nl_rabo_mt940.py b/account_banking_nl_rabo_mt940/account_banking_nl_rabo_mt940.py index 7c695ad4d..a3c703578 100644 --- a/account_banking_nl_rabo_mt940/account_banking_nl_rabo_mt940.py +++ b/account_banking_nl_rabo_mt940/account_banking_nl_rabo_mt940.py @@ -38,8 +38,8 @@ class RaboMT940Parser(MT940, parser): header_lines = 1 tag_61_regex = re.compile( - '^(?P\d{6})(?P[CD])(?P\d+,\d{2})N(?P.{3})' - '(?P\w{1,16})') + r'^(?P\d{6})(?P[CD])(?P\d+,\d{2})N(?P.{3})' + r'(?P\w{1,16})') def parse(self, cr, data): 'implements account_banking.parsers.models.parser.parse()' diff --git a/account_banking_nl_triodos/triodos.py b/account_banking_nl_triodos/triodos.py index 3b3ccadd1..9a2418f57 100644 --- a/account_banking_nl_triodos/triodos.py +++ b/account_banking_nl_triodos/triodos.py @@ -61,7 +61,7 @@ class transaction_message(object): self.__dict__.update(dict(zip(self.attrnames, values))) # for lack of a standardized locale function to parse amounts self.transferred_amount = float( - re.sub(',', '.', re.sub('\.', '', self.transferred_amount))) + re.sub(',', '.', re.sub(r'\.', '', self.transferred_amount))) if self.debcred == 'Debet': self.transferred_amount = -self.transferred_amount self.execution_date = str2date(self.date, '%d-%m-%Y') diff --git a/account_banking_uk_hsbc/hsbc_mt940.py b/account_banking_uk_hsbc/hsbc_mt940.py index 6b33d1660..4cc7a2939 100644 --- a/account_banking_uk_hsbc/hsbc_mt940.py +++ b/account_banking_uk_hsbc/hsbc_mt940.py @@ -178,10 +178,10 @@ class parser_hsbc_mt940(models.parser): result = [] parser = HSBCParser() # Split into statements - statements = [st for st in re.split('[\r\n]*(?=:20:)', data)] + statements = [st for st in re.split(r'[\r\n]*(?=:20:)', data)] # Split by records statement_list = [ - re.split('[\r\n ]*(?=:\d\d[\w]?:)', st) + re.split(r'[\r\n ]*(?=:\d\d[\w]?:)', st) for st in statements ] diff --git a/account_banking_uk_hsbc/mt940_parser.py b/account_banking_uk_hsbc/mt940_parser.py index 1a1d1730d..70943c432 100644 --- a/account_banking_uk_hsbc/mt940_parser.py +++ b/account_banking_uk_hsbc/mt940_parser.py @@ -31,7 +31,7 @@ class HSBCParser(object): def __init__(self): recparse = dict() - patterns = {'ebcdic': "\w/\?:\(\).,'+{} -"} + patterns = {'ebcdic': r"\w/\?:\(\).,'+{} -"} # MT940 header recparse["20"] = r":(?P20):(?P.{1,16})" @@ -60,18 +60,18 @@ class HSBCParser(object): # Further info recparse["86"] = (r":(?P86):" - "(?P.{1,80})?" - "(?:\n(?P.{1,80}))?" - "(?:\n(?P.{1,80}))?" - "(?:\n(?P.{1,80}))?" - "(?:\n(?P.{1,80}))?") + r"(?P.{1,80})?" + r"(?:\n(?P.{1,80}))?" + r"(?:\n(?P.{1,80}))?" + r"(?:\n(?P.{1,80}))?" + r"(?:\n(?P.{1,80}))?") # Forward available balance (64) / Closing balance (62F) # / Interim balance (62M) recparse["64"] = (r":(?P64|62[FM]):" - "(?P[CD])" - "(?P\d{6})(?P.{3})" - "(?P[\d,]{1,15})") + r"(?P[CD])" + r"(?P\d{6})(?P.{3})" + r"(?P[\d,]{1,15})") for record in recparse: recparse[record] = re.compile(recparse[record])