diff --git a/account_bank_statement_tax/__init__.py b/account_bank_statement_tax/__init__.py
index 16e8b082f..9186ee3ad 100644
--- a/account_bank_statement_tax/__init__.py
+++ b/account_bank_statement_tax/__init__.py
@@ -1 +1 @@
-import model
+from . import model
diff --git a/account_bank_statement_tax/model/__init__.py b/account_bank_statement_tax/model/__init__.py
index 0a522c87a..5d5fe647d 100644
--- a/account_bank_statement_tax/model/__init__.py
+++ b/account_bank_statement_tax/model/__init__.py
@@ -1,2 +1,2 @@
-import account_bank_statement_line
-import account_bank_statement
+from . import account_bank_statement_line
+from . import account_bank_statement
diff --git a/account_bank_statement_tax/model/account_bank_statement.py b/account_bank_statement_tax/model/account_bank_statement.py
index 8de910448..59e0d07f4 100644
--- a/account_bank_statement_tax/model/account_bank_statement.py
+++ b/account_bank_statement_tax/model/account_bank_statement.py
@@ -90,9 +90,6 @@ class AccountBankStatement(orm.Model):
defaults['account_id'])),
'credit': tax['amount'] < 0 and - tax['amount'] or 0.0,
'debit': tax['amount'] > 0 and tax['amount'] or 0.0,
- 'account_id': (
- tax.get('account_collected_id',
- defaults['account_id'])),
})
return move_lines, update_move_line
diff --git a/account_banking/__init__.py b/account_banking/__init__.py
index d7a19ee70..227d93962 100644
--- a/account_banking/__init__.py
+++ b/account_banking/__init__.py
@@ -25,12 +25,12 @@
#
##############################################################################
-import sepa
-import record
-import banking_import_transaction
-import account_banking
-import parsers
-import wizard
-import res_partner
-import res_bank
-import res_partner_bank
+from . import sepa
+from . import record
+from . import banking_import_transaction
+from . import account_banking
+from . import parsers
+from . import wizard
+from . import res_partner
+from . import res_bank
+from . import res_partner_bank
diff --git a/account_banking/parsers/convert.py b/account_banking/parsers/convert.py
index c3872b83d..680e7d511 100644
--- a/account_banking/parsers/convert.py
+++ b/account_banking/parsers/convert.py
@@ -23,11 +23,7 @@ import unicodedata
__all__ = ['str2date', 'date2str', 'date2date', 'to_swift']
-try:
- from datetime import datetime
- datetime.strptime
-except AttributeError:
- from mx import DateTime as datetime
+from datetime import datetime
def str2date(datestr, format='%d/%m/%y'):
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/record.py b/account_banking/record.py
index b0fb4d54a..d6ac25b0c 100644
--- a/account_banking/record.py
+++ b/account_banking/record.py
@@ -26,22 +26,12 @@ __all__ = [
__doc__ = '''Ease working with fixed length records in files'''
+import unicodedata
from datetime import datetime, date
-# Correct python2.4 issues
-try:
- datetime.strptime
- def strpdate(str, format):
- return datetime.strptime(str, format).date()
-except AttributeError:
- import time
-
- def strpdate(str, format):
- tm = time.strptime(str, format)
- return date(tm.tm_year, tm.tm_mon, tm.tm_mday)
-
-import unicodedata
+def strpdate(str, format):
+ return datetime.strptime(str, format).date()
class Field(object):
diff --git a/account_banking/sepa/__init__.py b/account_banking/sepa/__init__.py
index 0735d2123..a4fb060a4 100644
--- a/account_banking/sepa/__init__.py
+++ b/account_banking/sepa/__init__.py
@@ -18,6 +18,8 @@
# along with this program. If not, see .
#
##############################################################################
-import iban
+from . import iban
+
+
IBAN = iban.IBAN
BBAN = iban.BBAN
diff --git a/account_banking/sepa/iban.py b/account_banking/sepa/iban.py
index 20deb01c7..0d4e981c1 100644
--- a/account_banking/sepa/iban.py
+++ b/account_banking/sepa/iban.py
@@ -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']
diff --git a/account_banking/struct.py b/account_banking/struct.py
index b5e27e57d..8b511ee85 100644
--- a/account_banking/struct.py
+++ b/account_banking/struct.py
@@ -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']
diff --git a/account_banking/wizard/banking_transaction_wizard.py b/account_banking/wizard/banking_transaction_wizard.py
index 0ea119aa5..a46e491ee 100644
--- a/account_banking/wizard/banking_transaction_wizard.py
+++ b/account_banking/wizard/banking_transaction_wizard.py
@@ -21,17 +21,15 @@
#
##############################################################################
-from openerp.osv import orm, fields
-from openerp.tools.translate import _
-
"""
-
The banking transaction wizard is linked to a button in the statement line
tree view. It allows the user to undo the duplicate flag, select between
multiple matches or select a manual match.
-
"""
+from openerp.osv import orm, fields
+from openerp.tools.translate import _
+
class banking_transaction_wizard(orm.TransientModel):
_name = 'banking.transaction.wizard'
diff --git a/account_banking_camt/__init__.py b/account_banking_camt/__init__.py
index f8b1d5b3a..26130391c 100644
--- a/account_banking_camt/__init__.py
+++ b/account_banking_camt/__init__.py
@@ -1 +1 @@
-import camt
+from . import camt
diff --git a/account_banking_fi_patu/parser.py b/account_banking_fi_patu/parser.py
index 5d5d0bd3b..43420d46b 100644
--- a/account_banking_fi_patu/parser.py
+++ b/account_banking_fi_patu/parser.py
@@ -3,6 +3,9 @@
"""Parser for PATU format files"""
import re
import datetime
+import logging
+
+_logger = logging.getLogger(__name__)
def fixchars(line):
@@ -27,111 +30,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])
@@ -150,7 +153,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()
diff --git a/account_banking_mt940/mt940.py b/account_banking_mt940/mt940.py
index 010c4b07e..d1aa6e408 100644
--- a/account_banking_mt940/mt940.py
+++ b/account_banking_mt940/mt940.py
@@ -23,6 +23,8 @@
"""
Parser for MT940 format files
"""
+
+from __future__ import print_function
import re
import datetime
import logging
@@ -70,7 +72,6 @@ class MT940(object):
def __init__(self, *args, **kwargs):
super(MT940, self).__init__(*args, **kwargs)
- 'state variables'
self.current_statement = None
'type account_banking.parsers.models.mem_bank_statement'
self.current_transaction = None
@@ -198,7 +199,7 @@ class MT940(object):
transaction.execution_date = str2date(data[:6])
transaction.effective_date = str2date(data[:6])
transaction.value_date = str2date(data[:6])
- '...and the rest already is highly bank dependent'
+ # ...and the rest already is highly bank dependent
def handle_tag_86(self, cr, data):
'''details for previous transaction, here most differences between
@@ -219,12 +220,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
diff --git a/account_banking_nl_abnamro/__init__.py b/account_banking_nl_abnamro/__init__.py
index 151e7f003..cf5962720 100644
--- a/account_banking_nl_abnamro/__init__.py
+++ b/account_banking_nl_abnamro/__init__.py
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
-import abnamro
+from . import abnamro
diff --git a/account_banking_nl_abnamro/abnamro.py b/account_banking_nl_abnamro/abnamro.py
index 95aff2cf3..1e6bcfc10 100644
--- a/account_banking_nl_abnamro/abnamro.py
+++ b/account_banking_nl_abnamro/abnamro.py
@@ -60,7 +60,7 @@ class transaction_message(object):
_('Invalid transaction line: expected %d columns, found '
'%d') % (len(self.attrnames), len(values))
)
- ''' Strip all values except the blob '''
+ # Strip all values except the blob
for (key, val) in zip(self.attrnames, values):
self.__dict__[key] = key == 'blob' and val or val.strip()
# for lack of a standardized locale function to parse amounts
@@ -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/__init__.py b/account_banking_nl_ing/__init__.py
index e25cf133f..87a2f5b07 100644
--- a/account_banking_nl_ing/__init__.py
+++ b/account_banking_nl_ing/__init__.py
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
-import ing
+from . import ing
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