Remove tuple method parameters

They can be found through autopep8 (W690) or python-modernize.
Variables manually renamed.

This is because Python 3 does not support tuple unpacking:
http://legacy.python.org/dev/peps/pep-3113/
This commit is contained in:
Laurent Bachelier 2014-10-10 22:20:05 +02:00
commit e783f2c821
10 changed files with 22 additions and 13 deletions

View file

@ -66,8 +66,9 @@ class VirtKeyboard(MappedVirtKeyboard):
return True
def get_symbol_coords(self, (x1, y1, x2, y2)):
def get_symbol_coords(self, coords):
# strip borders
x1, y1, x2, y2 = coords
return MappedVirtKeyboard.get_symbol_coords(self, (x1+10, y1+10, x2-10, y2-10))
def get_symbol_code(self, md5sum_list):

View file

@ -56,7 +56,7 @@ class BanquePopulaireModule(Module, CapBank):
'www.ibps.rivesparis.banquepopulaire.fr': u'Rives de Paris',
'www.ibps.sud.banquepopulaire.fr': u'Sud',
'www.ibps.valdefrance.banquepopulaire.fr': u'Val de France',
}.iteritems(), key=lambda (k, v): (v, k))])
}.iteritems(), key=lambda k_v: (k_v[1], k_v[0]))])
CONFIG = BackendConfig(Value('website', label=u'Région', choices=website_choices),
ValueBackendPassword('login', label='Identifiant', masked=False),
ValueBackendPassword('password', label='Mot de passee'))

View file

@ -80,8 +80,9 @@ class BNPVirtKeyboard(MappedVirtKeyboard):
MappedVirtKeyboard.__init__(self, imgdata, basepage.document, img, self.color)
self.check_symbols(self.symbols, basepage.browser.responses_dirname)
def get_symbol_coords(self, (x1, y1, x2, y2)):
def get_symbol_coords(self, coords):
# strip borders
x1, y1, x2, y2 = coords
return MappedVirtKeyboard.get_symbol_coords(self, (x1+6, y1+1, x2-6, y2-4))
def get_symbol_code(self, md5sum):
@ -96,8 +97,9 @@ class BNPVirtKeyboard(MappedVirtKeyboard):
code += self.get_symbol_code(self.symbols[c])
return code
def checksum(self, (x1, y1, x2, y2)):
def checksum(self, coords):
"""Copy of parent checksum(), but cropping (removes empty lines)"""
x1, y1, x2, y2 = coords
s = ''
for y in range(y1, min(y2 + 1, self.height)):
for x in range(x1, min(x2 + 1, self.width)):

View file

@ -41,7 +41,8 @@ class VirtKeyboard(MappedVirtKeyboard):
color=(0,0,0)
def check_color(self, (r, g, b)):
def check_color(self, color):
r, g, b = color
return r > 240 and g > 240 and b > 240
def __init__(self, page):
@ -61,7 +62,8 @@ class VirtKeyboard(MappedVirtKeyboard):
code += self.get_symbol_code(self.symbols[c])
return code
def checksum(self, (x1, y1, x2, y2)):
def checksum(self, coords):
x1, y1, x2, y2 = coords
s = ''
for y in range(y1, min(y2 + 1, self.height)):
for x in range(x1, min(x2 + 1, self.width)):

View file

@ -81,8 +81,9 @@ class Keyboard(VirtKeyboard):
code += self.get_symbol_code(self.symbols[c])
return code
def get_symbol_coords(self, (x1, y1, x2, y2)):
def get_symbol_coords(self, coords):
# strip borders
x1, y1, x2, y2 = coords
return VirtKeyboard.get_symbol_coords(self, (x1+3, y1+3, x2-3, y2-3))
class LoginPage(Page):

View file

@ -43,7 +43,7 @@ class CreditDuNordModule(Module, CapBank):
'www.banque-kolb.fr': u'Banque Kolb',
'www.banque-rhone-alpes.fr': u'Banque Rhône-Alpes',
'www.tarneaud.fr': u'Tarneaud',
}.iteritems(), key=lambda (k, v): (v, k))])
}.iteritems(), key=lambda k_v: (k_v[1], k_v[0]))])
CONFIG = BackendConfig(Value('website', label='Banque', choices=website_choices, default='www.credit-du-nord.fr'),
ValueBackendPassword('login', label='Identifiant', masked=False),
ValueBackendPassword('password', label='Code confidentiel'))

View file

@ -39,7 +39,7 @@ class GanAssurancesModule(Module, CapBank):
website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({
'espaceclient.groupama.fr': u'Groupama Banque',
'espaceclient.ganassurances.fr': u'Gan Assurances',
}.iteritems(), key=lambda (k, v): (v, k))])
}.iteritems(), key=lambda k_v: (k_v[1], k_v[0]))])
CONFIG = BackendConfig(Value('website', label='Banque', choices=website_choices, default='espaceclient.ganassurances.fr'),
ValueBackendPassword('login', label=u'Numéro client', masked=False),
ValueBackendPassword('password', label=u"Code d'accès"))

View file

@ -44,7 +44,8 @@ class Captcha(object):
self.tiles = [[Tile(y * self.nbc + x) for y in xrange(4)] for x in xrange(4)]
def __getitem__(self, (x, y)):
def __getitem__(self, coords):
x, y = coords
return self.inmat[x % self.nx, y % self.ny]
def all_coords(self):

View file

@ -231,7 +231,7 @@ class StatementParser(object):
# Infer amount type by its indentation in the layout.
amount_total = clean_amount('0')
for (_, _, _, _, indent, _), amount in amounts:
within = lambda (xmin, xmax): xmin <= indent <= xmax
within = lambda xmin_xmax: xmin_xmax[0] <= indent <= xmin_xmax[1]
if within(range_skip):
continue
elif within(range_plus):

View file

@ -98,7 +98,8 @@ class VirtKeyboard(object):
def check_color(self, pixel):
return pixel == self.color
def get_symbol_coords(self, (x1, y1, x2, y2)):
def get_symbol_coords(self, coords):
(x1, y1, x2, y2) = coords
if self.margin:
top, right, bottom, left = self.margin
x1, y1, x2, y2 = x1 + left, y1 + top, x2 - right, y2 - bottom
@ -133,7 +134,8 @@ class VirtKeyboard(object):
newX2 = x
return (newX1, newY1, newX2, newY2)
def checksum(self, (x1, y1, x2, y2)):
def checksum(self, coords):
(x1, y1, x2, y2) = coords
s = ''
for y in range(y1, min(y2 + 1, self.height)):
for x in range(x1, min(x2 + 1, self.width)):