Commit 448c06d1 authored by Laurent Bachelier's avatar Laurent Bachelier 🐧

pep8 blank lines fixes

flake8 --select W391,E302,E301,E304

autopep8 can't fix W391 even though it claims it can.
Fixed using a simple custom script.
parent be2c8bd7
......@@ -28,6 +28,7 @@ from weboob.core import Weboob, CallErrors
from weboob.capabilities.bank import CapBank
from weboob.exceptions import BrowserIncorrectPassword
class BoobankMuninPlugin(object):
def __init__(self):
if 'weboob_path' in os.environ:
......
......@@ -33,6 +33,7 @@ import os
# bpp: bits per pixel, could *only* be 24 or 32!
# return: an "array" of BYTES which, if write to file, is a size*size ico file
def genico(data, size=16, bpp=24):
from array import array
a = array('B')
......@@ -80,7 +81,6 @@ def genico(data, size=16, bpp=24):
return a
# x,y indicate the hotspot position
# simply set the type/hotspot(x&y) after generates the icon
def gencur(data, size=16, bpp=24, x=0, y=0):
......@@ -89,7 +89,6 @@ def gencur(data, size=16, bpp=24, x=0, y=0):
return a
#C:\Python27\Lib\site-packages\weboob-0.g-py2.7.egg\share\icons\hicolor\64x64\apps
if __name__ == "__main__":
......
......@@ -32,12 +32,15 @@ except ImportError:
DEFAULT_VERSION = "1.1.6"
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
def _python_cmd(*args):
args = (sys.executable,) + args
return subprocess.call(args) == 0
def _check_call_py24(cmd, *args, **kwargs):
res = subprocess.call(cmd, *args, **kwargs)
class CalledProcessError(Exception):
pass
if not res == 0:
......@@ -45,6 +48,7 @@ def _check_call_py24(cmd, *args, **kwargs):
raise CalledProcessError(msg)
vars(subprocess).setdefault('check_call', _check_call_py24)
def _install(tarball, install_args=()):
# extracting the tarball
tmpdir = tempfile.mkdtemp()
......@@ -151,6 +155,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
return _do_download(version, download_base, to_dir,
download_delay)
def download_file_powershell(url, target):
"""
Download the file at url to target using Powershell (which will validate
......@@ -164,6 +169,7 @@ def download_file_powershell(url, target):
]
subprocess.check_call(cmd)
def has_powershell():
if platform.system() != 'Windows':
return False
......@@ -180,10 +186,12 @@ def has_powershell():
download_file_powershell.viable = has_powershell
def download_file_curl(url, target):
cmd = ['curl', url, '--silent', '--output', target]
subprocess.check_call(cmd)
def has_curl():
cmd = ['curl', '--version']
devnull = open(os.path.devnull, 'wb')
......@@ -198,10 +206,12 @@ def has_curl():
download_file_curl.viable = has_curl
def download_file_wget(url, target):
cmd = ['wget', url, '--quiet', '--output-document', target]
subprocess.check_call(cmd)
def has_wget():
cmd = ['wget', '--version']
devnull = open(os.path.devnull, 'wb')
......@@ -216,6 +226,7 @@ def has_wget():
download_file_wget.viable = has_wget
def download_file_insecure(url, target):
"""
Use Python to download the file, even though it cannot authenticate the
......@@ -241,6 +252,7 @@ def download_file_insecure(url, target):
download_file_insecure.viable = lambda: True
def get_best_downloader():
downloaders = [
download_file_powershell,
......@@ -253,6 +265,7 @@ def get_best_downloader():
if dl.viable():
return dl
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15,
downloader_factory=get_best_downloader):
......@@ -338,6 +351,7 @@ def _build_install_args(options):
install_args.append('--user')
return install_args
def _parse_args():
"""
Parse the command line for options
......@@ -359,6 +373,7 @@ def _parse_args():
# positional arguments are ignored
return options
def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
options = _parse_args()
......
......@@ -24,6 +24,7 @@ from .browser import SevenFiftyGramsBrowser
import unicodedata
def strip_accents(s):
return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn')
......
......@@ -26,6 +26,7 @@ from weboob.deprecated.browser import Page
class ResultsPage(Page):
""" Page which contains results as a list of recipies
"""
def iter_recipes(self):
for div in self.parser.select(self.document.getroot(), 'div.recette_description > div.data'):
links = self.parser.select(div, 'div.info > p.title > a.fn')
......@@ -65,6 +66,7 @@ class ResultsPage(Page):
class RecipePage(Page):
""" Page which contains a recipe
"""
def get_recipe(self, id):
title = NotAvailable
preparation_time = NotAvailable
......
......@@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
import re
class AllocineTest(BackendTest):
MODULE = 'allocine'
......
......@@ -60,4 +60,3 @@ class AlloRestoModule(Module, CapBank):
def iter_coming(self, account):
return self.browser.get_coming(account)
......@@ -52,6 +52,7 @@ class AccountsPage(LoggedPage, HTMLPage):
class MyDate(Filter):
MONTHS = ['janv', u'févr', u'mars', u'avr', u'mai', u'juin', u'juil', u'août', u'sept', u'oct', u'nov', u'déc']
def filter(self, txt):
day, month, year = txt.split(' ')
day = int(day)
......
......@@ -30,6 +30,7 @@ class FourOFourPage(Page):
class ResultsPage(Page):
""" Page which contains results as a list of recipies
"""
def iter_recipes(self):
for div in self.parser.select(self.document.getroot(), 'div.recipe-info'):
thumbnail_url = NotAvailable
......@@ -59,6 +60,7 @@ class ResultsPage(Page):
class RecipePage(Page):
""" Page which contains a recipe
"""
def get_recipe(self, id):
title = NotAvailable
preparation_time = NotAvailable
......
......@@ -29,6 +29,7 @@ from weboob.capabilities.bill import Subscription, Detail, Bill
# Ugly array to avoid the use of french locale
FRENCH_MONTHS = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre']
class AmeliBasePage(Page):
def is_logged(self):
try:
......@@ -40,6 +41,7 @@ class AmeliBasePage(Page):
self.logger.debug('logged: %s' % (logged))
return logged
class LoginPage(AmeliBasePage):
def login(self, login, password):
self.browser.select_form('connexionCompteForm')
......@@ -47,9 +49,11 @@ class LoginPage(AmeliBasePage):
self.browser["connexioncompte_2codeConfidentiel"] = password.encode('utf8')
self.browser.submit()
class HomePage(AmeliBasePage):
pass
class AccountPage(AmeliBasePage):
def iter_subscription_list(self):
idents = self.document.xpath('//div[contains(@class, "blocfond")]')
......
......@@ -63,4 +63,3 @@ class AmericanExpressModule(Module, CapBank):
transactions = list(self.browser.get_history(account))
transactions.sort(key=lambda tr: tr.rdate, reverse=True)
return transactions
......@@ -56,6 +56,7 @@ class AccountsPage(Page):
yield a
class TransactionsPage(Page):
COL_ID = 0
COL_DATE = 1
......@@ -81,6 +82,7 @@ class TransactionsPage(Page):
return datetime.date(int(m.group(3)),
self.MONTHS.index(m.group(2).rstrip('.')) + 1,
int(m.group(1)))
def get_beginning_debit_date(self):
for option in self.document.xpath('//select[@id="viewPeriod"]/option'):
if 'selected' in option.attrib:
......
......@@ -39,4 +39,3 @@ class AudioAddictTest(BackendTest):
self.assertTrue(radio.current.what)
self.assertTrue(radio.streams[0].url)
self.assertTrue(radio.streams[0].title)
......@@ -127,6 +127,7 @@ class WebsiteBrowser(LoginBrowser):
return profile
class AuMBrowser(Browser):
DOMAIN = 'www.adopteunmec.com'
APIKEY = 'fb0123456789abcd'
......
......@@ -256,6 +256,7 @@ class TransactionsPage(BasePage):
yield t
class CBTransactionsPage(TransactionsPage):
COL_CB_CREDIT = 2
......
......@@ -87,6 +87,7 @@ class VirtKeyboard(MappedVirtKeyboard):
code += self.get_symbol_code(self.symbols[c])
return code
class LoginPage(HTMLPage):
def login(self, login, password):
vk = VirtKeyboard(self)
......@@ -98,6 +99,7 @@ class LoginPage(HTMLPage):
form['code'] = code
form.submit()
class IndexPage(LoggedPage, HTMLPage):
@method
class get_list(ListElement):
......@@ -152,6 +154,7 @@ class IndexPage(LoggedPage, HTMLPage):
def get_card_name(self):
return CleanText('//h1[1]')(self.doc)
class AccountsPage(LoggedPage, HTMLPage):
def get_balance(self):
balance = Decimal('0.0')
......
......@@ -82,6 +82,7 @@ class BanquePopulaire(Browser):
self.token = self.page.get_token()
ACCOUNT_URLS = ['mesComptes', 'mesComptesPRO', 'maSyntheseGratuite', 'accueilSynthese']
def go_on_accounts_list(self):
for taskInfoOID in self.ACCOUNT_URLS:
self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID=taskInfoOID, token=self.token))
......
......@@ -267,5 +267,6 @@ class HistoryPage(BEPage):
# Last page
return None
class UnknownPage(BEPage):
pass
......@@ -26,6 +26,7 @@ from .login import LoginPage, UpdateInfoPage
from .two_authentication import AuthenticationPage
class AccountPrelevement(AccountsList):
pass
......
......@@ -37,6 +37,7 @@ class UnavailablePage(Page):
def on_loaded(self):
raise BrowserUnavailable()
class Keyboard(VirtKeyboard):
symbols={'0':'daa52d75287bea58f505823ef6c8b96c',
'1':'f5da96c2592803a8cdc5a928a2e4a3b0',
......@@ -86,6 +87,7 @@ class Keyboard(VirtKeyboard):
x1, y1, x2, y2 = coords
return VirtKeyboard.get_symbol_coords(self, (x1+3, y1+3, x2-3, y2-3))
class LoginPage(Page):
def login(self, login, pwd):
vk = Keyboard(self)
......
......@@ -8,6 +8,7 @@ from .browser import BTDiggBrowser
__all__ = ['BTDiggModule']
class BTDiggModule(Module, CapTorrent):
NAME = 'btdigg'
MAINTAINER = u'Matthieu Rakotojaona'
......
......@@ -50,6 +50,7 @@ class TorrentsPage(Page):
torrent.date = date
yield torrent
class TorrentPage(Page):
def get_torrent(self, id):
trs = self.document.getroot().cssselect('table.torrent_info_tbl tr')
......
......@@ -39,6 +39,7 @@ class _LogoutPage(Page):
except BrokenPageError:
pass
class LoginPage(_LogoutPage):
def login(self, login):
self.browser.select_form(name='Main')
......@@ -83,6 +84,7 @@ class LoginPage(_LogoutPage):
class ErrorPage(_LogoutPage):
pass
class UnavailablePage(Page):
def on_loaded(self):
try:
......
......@@ -32,6 +32,7 @@ class IndexPage(Page):
self.browser['chronoNumbers'] = _id.encode('utf-8')
self.browser.submit()
class TrackPage(Page):
def get_info(self, id):
if len(self.document.xpath('//libelle[@nom="MSG_AUCUN_EVT"]')) > 0:
......
......@@ -47,10 +47,12 @@ class ChangePasswordPage(Page):
def on_loaded(self):
raise BrowserIncorrectPassword('Please change your password')
class VerifCodePage(Page):
def on_loaded(self):
raise BrowserIncorrectPassword('Unable to login: website asks a code from a card')
class InfoPage(Page):
pass
......@@ -303,6 +305,7 @@ class CardPage(OperationsPage):
tr.set_amount(tds[-1].text)
yield tr
class NoOperationsPage(OperationsPage):
def get_history(self):
return iter([])
......@@ -26,6 +26,7 @@ def update_status(p, status):
if p.status < status:
p.status = status
class TrackPage(Page):
def get_info(self, _id):
p = Parcel(_id)
......@@ -70,5 +71,6 @@ class TrackPage(Page):
pass
return p
class ErrorPage(Page):
pass
......@@ -20,6 +20,7 @@
class TokenExtractor(object):
""" Extracts texts token from an HTML document """
def __init__(self):
self.iterated_elements = []
......
......@@ -39,6 +39,7 @@ class HomePage(Page):
return None
class LoginPage(Page):
def login(self, password):
assert password.isdigit()
......@@ -60,12 +61,15 @@ class LoginPage(Page):
def get_result_url(self):
return self.parser.tocleanstring(self.document.getroot())
class UselessPage(Page):
pass
class LoginErrorPage(Page):
pass
class _AccountsPage(Page):
COL_LABEL = 0
COL_ID = 2
......@@ -223,12 +227,15 @@ class CardsPage(Page):
yield t
class AccountsPage(_AccountsPage):
pass
class SavingsPage(_AccountsPage):
COL_ID = 1
class TransactionsPage(Page):
def get_next_url(self):
links = self.document.xpath('//span[@class="pager"]/a[@class="liennavigationcorpspage"]')
......
......@@ -95,6 +95,7 @@ class Transaction(FrenchTransaction):
FrenchTransaction.TYPE_UNKNOWN),
]
class ITransactionsPage(Page):
def get_next_url(self):
# can be 'Suivant' or ' Suivant'
......@@ -108,6 +109,7 @@ class ITransactionsPage(Page):
def get_history(self):
raise NotImplementedError()
class TransactionsPage(ITransactionsPage):
TR_DATE = 0
TR_TEXT = 2
......@@ -135,6 +137,7 @@ class TransactionsPage(ITransactionsPage):
yield t
class ComingTransactionsPage(TransactionsPage):
TR_DATE = 2
TR_TEXT = 1
......@@ -142,6 +145,7 @@ class ComingTransactionsPage(TransactionsPage):
TR_CREDIT = -1
TABLE_NAME = 'operationAVenir'
class CardTransactionsPage(ITransactionsPage):
COM_TR_COMMENT = 0
COM_TR_DATE = 1
......
......@@ -53,13 +53,16 @@ class LoginErrorPage(HTMLPage):
class EmptyPage(LoggedPage, HTMLPage):
pass
class UserSpacePage(LoggedPage, HTMLPage):
pass
class ChangePasswordPage(LoggedPage, HTMLPage):
def on_load(self):
raise BrowserIncorrectPassword('Please change your password')
class VerifCodePage(LoggedPage, HTMLPage):
def on_load(self):
raise BrowserIncorrectPassword('Unable to login: website asks a code from a card')
......
......@@ -26,6 +26,7 @@ import unicodedata
__all__ = ['CuisineazModule']
def strip_accents(s):
return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn')
......
......@@ -26,6 +26,7 @@ from weboob.deprecated.browser import Page
class ResultsPage(Page):
""" Page which contains results as a list of recipies
"""
def iter_recipes(self):
for div in self.parser.select(self.document.getroot(), 'div.rechRecette'):
thumbnail_url = NotAvailable
......@@ -74,6 +75,7 @@ class ResultsPage(Page):
class RecipePage(Page):
""" Page which contains a recipe
"""
def get_recipe(self, id):
title = NotAvailable
preparation_time = NotAvailable
......
......@@ -154,6 +154,7 @@ class VideoPage(Page):
video.url = unicode(info[max_quality])
class KidsVideoPage(VideoPage):
CONTROLLER_PAGE = 'http://kids.dailymotion.com/controller/Page_Kids_KidsUserHome?%s'
......
......@@ -94,6 +94,7 @@ class OperationsPage(Page):
if next_button:
return next_button[0]
class LCRPage(OperationsPage):
def iter_history(self):
date = None
......
......@@ -27,6 +27,7 @@ from weboob.capabilities.bill import Subscription, Detail, Bill
base_url = "http://particuliers.edf.com/"
class EdfBasePage(Page):
def is_logged(self):
return (u'Me déconnecter' in self.document.xpath('//a/text()')) \
......@@ -45,16 +46,19 @@ class HomePage(EdfBasePage):
def on_loaded(self):
pass
class FirstRedirectionPage(EdfBasePage):
def on_loaded(self):
self.browser.select_form("form1")
self.browser.submit()
class SecondRedirectionPage(EdfBasePage):
def on_loaded(self):
self.browser.select_form("redirectForm")
self.browser.submit()
class OtherPage(EdfBasePage):
def on_loaded(self):
self.browser.open(base_url)
......@@ -122,6 +126,7 @@ class BillsPage(EdfBasePage):
def get_bill(self, bill):
self.location(bill._url)
class LastPaymentsPage(EdfBasePage):
def on_loaded(self):
......@@ -146,6 +151,7 @@ class LastPaymentsPage(EdfBasePage):
self.browser.location('/ASPFront/appmanager/ASPFront/front/portlet_echeancier_2?%s' % urllib.urlencode(params))
class LastPaymentsPage2(EdfBasePage):
def iter_payments(self, sub):
......
......@@ -79,6 +79,8 @@ class IndexPage(Page):
# the search page class uses a JSON parser,
# since it's what search.php returns when POSTed (from Ajax)
class SearchPage(Page):
def iter_videos(self):
if self.document is None or self.document['data'] is None:
......@@ -90,6 +92,7 @@ class SearchPage(Page):
continue
yield video
class VideoPage(Page):
def get_video(self, video=None):
# check for slides id variant
......
......@@ -199,6 +199,7 @@ class GithubBrowser(Browser):
# TODO use a cache for objects and/or pages?
# TODO use an api-key?
def parse_date(s):
if s.endswith('Z'):
s = s[:-1]
......
......@@ -32,6 +32,7 @@ STATUSES = {'open': Status('open', u'Open', Status.VALUE_NEW),
'closed': Status('closed', u'closed', Status.VALUE_RESOLVED)}
# TODO tentatively parse github "labels"?
class GithubModule(Module, CapBugTracker):
NAME = 'github'
DESCRIPTION = u'GitHub issues tracking'
......
......@@ -89,5 +89,6 @@ class AccountHistory(Page):
def get_IBAN(self):
return self.document.xpath('//a[@class="lien_perso_libelle"]')[0].attrib['id'][10:26]
class AccountComing(AccountHistory):
pass
......@@ -43,6 +43,7 @@ class Transaction(FrenchTransaction):
(re.compile(r'^REMISE (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
]
class AccountsPage(LoggedPage, HTMLPage):
def get_frame(self):
try:
......@@ -129,6 +130,7 @@ class CBOperationPage(LoggedPage, HTMLPage):
obj_date = DateGuesser(CleanText(TableCell("date")), Env("date_guesser"))
obj_vdate = DateGuesser(CleanText(TableCell("date")), Env("date_guesser"))
class CPTOperationPage(LoggedPage, HTMLPage):
def get_history(self):
for script in self.doc.xpath('//script'):
......@@ -142,6 +144,7 @@ class CPTOperationPage(LoggedPage, HTMLPage):
op._coming = (re.match(r'\d+/\d+/\d+', m.group(2)) is None)
yield op
class LoginPage(HTMLPage):
def on_load(self):
for message in self.doc.getroot().cssselect('div.csPanelErrors'):
......
......@@ -29,6 +29,7 @@ import re
class ReleasePage(Page):
''' Page containing releases of a movie
'''
def get_movie_releases(self, country_filter):
result = unicode()
links = self.parser.select(self.document.getroot(), 'table#release_dates a')
......@@ -57,6 +58,7 @@ class ReleasePage(Page):
class BiographyPage(Page):
''' Page containing biography of a person
'''
def get_biography(self):
bio = unicode()
start = False
......@@ -74,6 +76,7 @@ class BiographyPage(Page):
class MovieCrewPage(Page):
''' Page listing all the persons related to a movie
'''
def iter_persons(self, role_filter=None):
if (role_filter is None or (role_filter is not None and role_filter == 'actor')):
tables = self.parser.select(self.document.getroot(), 'table.cast_list')
......@@ -130,6 +133,7 @@ class PersonPage(Page):
''' Page informing about a person
It is used to build a Person instance and to get the movie list related to a person
'''