PEP8 style fixes and other small style fixes
I used autopep8 on some files and did carefully check the changes. I ignored E501,E302,E231,E225,E222,E221,E241,E203 in my search, and at least E501 on any autopep8 run. Other style fixes not related to PEP8: * Only use new-style classes. I don't think the usage of old-style classes was voluntary. Old-style classes are removed in Python 3. * Convert an if/else to a one-liner in mediawiki, change docstring style change to a comment something that wasn't really appropriate for a docstring. * Unneeded first if condition in meteofrance
This commit is contained in:
parent
1e000acf3a
commit
006e97a8be
99 changed files with 441 additions and 350 deletions
|
|
@ -24,7 +24,7 @@ import Image
|
||||||
|
|
||||||
class CaptchaError(Exception): pass
|
class CaptchaError(Exception): pass
|
||||||
|
|
||||||
class Tile:
|
class Tile(object):
|
||||||
hash = {
|
hash = {
|
||||||
'bc8d52d96058478a6def26226145d53b': 'A',
|
'bc8d52d96058478a6def26226145d53b': 'A',
|
||||||
'c62ecdfddb72b2feaed96cd9fe7c2802': 'A',
|
'c62ecdfddb72b2feaed96cd9fe7c2802': 'A',
|
||||||
|
|
@ -111,7 +111,7 @@ class Tile:
|
||||||
print 'hash: %s' % checksum
|
print 'hash: %s' % checksum
|
||||||
raise CaptchaError()
|
raise CaptchaError()
|
||||||
|
|
||||||
class Captcha:
|
class Captcha(object):
|
||||||
def __init__(self, f):
|
def __init__(self, f):
|
||||||
self.img = Image.open(f)
|
self.img = Image.open(f)
|
||||||
self.w, self.h = self.img.size
|
self.w, self.h = self.img.size
|
||||||
|
|
@ -152,7 +152,7 @@ class Captcha:
|
||||||
s += tile.letter
|
s += tile.letter
|
||||||
return s
|
return s
|
||||||
|
|
||||||
class Decoder:
|
class Decoder(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.hash = {}
|
self.hash = {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ from weboob.tools.ordereddict import OrderedDict
|
||||||
from weboob.capabilities.contact import Contact as _Contact, ProfileNode
|
from weboob.capabilities.contact import Contact as _Contact, ProfileNode
|
||||||
from weboob.tools.misc import html2text
|
from weboob.tools.misc import html2text
|
||||||
|
|
||||||
class FieldBase:
|
|
||||||
|
class FieldBase(object):
|
||||||
def __init__(self, key, key2=None):
|
def __init__(self, key, key2=None):
|
||||||
self.key = key
|
self.key = key
|
||||||
self.key2 = key2
|
self.key2 = key2
|
||||||
|
|
@ -34,18 +35,22 @@ class FieldBase:
|
||||||
def get_value(self, value, consts):
|
def get_value(self, value, consts):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
class FieldStr(FieldBase):
|
class FieldStr(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
return html2text(unicode(profile[self.key])).strip()
|
return html2text(unicode(profile[self.key])).strip()
|
||||||
|
|
||||||
|
|
||||||
class FieldBool(FieldBase):
|
class FieldBool(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
return bool(int(profile[self.key]))
|
return bool(int(profile[self.key]))
|
||||||
|
|
||||||
|
|
||||||
class FieldDist(FieldBase):
|
class FieldDist(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
return '%.2f km' % float(profile[self.key])
|
return '%.2f km' % float(profile[self.key])
|
||||||
|
|
||||||
|
|
||||||
class FieldIP(FieldBase):
|
class FieldIP(FieldBase):
|
||||||
def get_hostname(self, s):
|
def get_hostname(self, s):
|
||||||
try:
|
try:
|
||||||
|
|
@ -59,6 +64,7 @@ class FieldIP(FieldBase):
|
||||||
s += ' (first %s)' % self.get_hostname(profile[self.key2])
|
s += ' (first %s)' % self.get_hostname(profile[self.key2])
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
class FieldProfileURL(FieldBase):
|
class FieldProfileURL(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
id = int(profile[self.key])
|
id = int(profile[self.key])
|
||||||
|
|
@ -67,10 +73,12 @@ class FieldProfileURL(FieldBase):
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class FieldPopu(FieldBase):
|
class FieldPopu(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
return unicode(profile['popu'][self.key])
|
return unicode(profile['popu'][self.key])
|
||||||
|
|
||||||
|
|
||||||
class FieldPopuRatio(FieldBase):
|
class FieldPopuRatio(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
v1 = float(profile['popu'][self.key])
|
v1 = float(profile['popu'][self.key])
|
||||||
|
|
@ -80,15 +88,18 @@ class FieldPopuRatio(FieldBase):
|
||||||
else:
|
else:
|
||||||
return '%.2f' % (v1 / v2)
|
return '%.2f' % (v1 / v2)
|
||||||
|
|
||||||
|
|
||||||
class FieldOld(FieldBase):
|
class FieldOld(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
birthday = parse_dt(profile[self.key])
|
birthday = parse_dt(profile[self.key])
|
||||||
return int((datetime.now() - birthday).days / 365.25)
|
return int((datetime.now() - birthday).days / 365.25)
|
||||||
|
|
||||||
|
|
||||||
class FieldSplit(FieldBase):
|
class FieldSplit(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
return [html2text(s).strip() for s in profile[self.key].split(self.key2) if len(s.strip()) > 0]
|
return [html2text(s).strip() for s in profile[self.key].split(self.key2) if len(s.strip()) > 0]
|
||||||
|
|
||||||
|
|
||||||
class FieldBMI(FieldBase):
|
class FieldBMI(FieldBase):
|
||||||
def __init__(self, key, key2, fat=False):
|
def __init__(self, key, key2, fat=False):
|
||||||
FieldBase.__init__(self, key, key2)
|
FieldBase.__init__(self, key, key2)
|
||||||
|
|
@ -114,6 +125,7 @@ class FieldBMI(FieldBase):
|
||||||
else:
|
else:
|
||||||
return 'obese'
|
return 'obese'
|
||||||
|
|
||||||
|
|
||||||
class FieldFlags(FieldBase):
|
class FieldFlags(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
i = int(profile[self.key])
|
i = int(profile[self.key])
|
||||||
|
|
@ -123,6 +135,7 @@ class FieldFlags(FieldBase):
|
||||||
labels.append(html2text(d['label']).strip())
|
labels.append(html2text(d['label']).strip())
|
||||||
return labels
|
return labels
|
||||||
|
|
||||||
|
|
||||||
class FieldList(FieldBase):
|
class FieldList(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
i = int(profile[self.key])
|
i = int(profile[self.key])
|
||||||
|
|
@ -131,6 +144,7 @@ class FieldList(FieldBase):
|
||||||
return html2text(d['label']).strip()
|
return html2text(d['label']).strip()
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class Contact(_Contact):
|
class Contact(_Contact):
|
||||||
TABLE = OrderedDict((
|
TABLE = OrderedDict((
|
||||||
('_info', OrderedDict((
|
('_info', OrderedDict((
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ from weboob.tools.test import BackendTest
|
||||||
from weboob.tools.browser import BrowserUnavailable
|
from weboob.tools.browser import BrowserUnavailable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['AuMTest']
|
__all__ = ['AuMTest']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicRea
|
||||||
|
|
||||||
__all__ = ['BatotoBackend']
|
__all__ = ['BatotoBackend']
|
||||||
|
|
||||||
|
|
||||||
class BatotoBackend(GenericComicReaderBackend):
|
class BatotoBackend(GenericComicReaderBackend):
|
||||||
NAME = 'batoto'
|
NAME = 'batoto'
|
||||||
DESCRIPTION = 'Batoto manga reading website'
|
DESCRIPTION = 'Batoto manga reading website'
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,9 @@
|
||||||
|
|
||||||
from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderTest
|
from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderTest
|
||||||
|
|
||||||
|
|
||||||
class BatotoTest(GenericComicReaderTest):
|
class BatotoTest(GenericComicReaderTest):
|
||||||
BACKEND = 'batoto'
|
BACKEND = 'batoto'
|
||||||
|
|
||||||
def test_download(self):
|
def test_download(self):
|
||||||
return self._test_download('26287/yurumates_ch4_by_primitive-scans')
|
return self._test_download('26287/yurumates_ch4_by_primitive-scans')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,4 +70,3 @@ class BoursoramaBackend(BaseBackend, ICapBank):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
for coming in self.browser.get_coming_operations(account):
|
for coming in self.browser.get_coming_operations(account):
|
||||||
yield coming
|
yield coming
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@ from .account_history import AccountHistory
|
||||||
from .accounts_list import AccountsList
|
from .accounts_list import AccountsList
|
||||||
from .login import LoginPage
|
from .login import LoginPage
|
||||||
|
|
||||||
class AccountPrelevement(AccountsList): pass
|
class AccountPrelevement(AccountsList):
|
||||||
|
pass
|
||||||
|
|
||||||
__all__ = ['LoginPage',
|
__all__ = ['LoginPage',
|
||||||
'AccountsList',
|
'AccountsList',
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
from weboob.capabilities.bank import Account
|
from weboob.capabilities.bank import Account
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
|
|
||||||
class AccountsList(BasePage):
|
|
||||||
|
|
||||||
|
class AccountsList(BasePage):
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ __all__ = ['CanalplusVideo']
|
||||||
|
|
||||||
class CanalplusVideo(BaseVideo):
|
class CanalplusVideo(BaseVideo):
|
||||||
swf_player = False
|
swf_player = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def id2url(cls, _id):
|
def id2url(cls, _id):
|
||||||
return 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s' % _id
|
return 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s' % _id
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,10 @@ from lxml import etree
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['CmbBackend']
|
__all__ = ['CmbBackend']
|
||||||
|
|
||||||
|
|
||||||
class CmbBackend(BaseBackend, ICapBank):
|
class CmbBackend(BaseBackend, ICapBank):
|
||||||
NAME = 'cmb'
|
NAME = 'cmb'
|
||||||
MAINTAINER = 'Johann Broudin'
|
MAINTAINER = 'Johann Broudin'
|
||||||
|
|
@ -83,7 +85,6 @@ class CmbBackend(BaseBackend, ICapBank):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
cookie = None
|
cookie = None
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent':
|
'User-Agent':
|
||||||
|
|
@ -268,4 +269,3 @@ class CmbBackend(BaseBackend, ICapBank):
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
yield operation
|
yield operation
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ from weboob.capabilities.bank import Account
|
||||||
from .base import CragrBasePage
|
from .base import CragrBasePage
|
||||||
from weboob.capabilities.bank import Transaction
|
from weboob.capabilities.bank import Transaction
|
||||||
|
|
||||||
|
|
||||||
def clean_amount(amount):
|
def clean_amount(amount):
|
||||||
"""
|
"""
|
||||||
Removes weird characters and converts to a float
|
Removes weird characters and converts to a float
|
||||||
|
|
@ -34,6 +35,7 @@ def clean_amount(amount):
|
||||||
matches = re.findall('^(-?[0-9]+\.[0-9]{2}).*$', data)
|
matches = re.findall('^(-?[0-9]+\.[0-9]{2}).*$', data)
|
||||||
return float(matches[0]) if (matches) else 0.0
|
return float(matches[0]) if (matches) else 0.0
|
||||||
|
|
||||||
|
|
||||||
class AccountsList(CragrBasePage):
|
class AccountsList(CragrBasePage):
|
||||||
|
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ from .pages import LoginPage, LoginErrorPage, AccountsPage, UserSpacePage, Opera
|
||||||
|
|
||||||
__all__ = ['CreditMutuelBrowser']
|
__all__ = ['CreditMutuelBrowser']
|
||||||
|
|
||||||
|
|
||||||
# Browser
|
# Browser
|
||||||
class CreditMutuelBrowser(BaseBrowser):
|
class CreditMutuelBrowser(BaseBrowser):
|
||||||
PROTOCOL = 'https'
|
PROTOCOL = 'https'
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue