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.
This commit is contained in:
Laurent Bachelier 2014-10-10 23:04:08 +02:00
commit 448c06d125
142 changed files with 249 additions and 25 deletions

View file

@ -28,6 +28,7 @@ from weboob.core import Weboob, CallErrors
from weboob.capabilities.bank import CapBank from weboob.capabilities.bank import CapBank
from weboob.exceptions import BrowserIncorrectPassword from weboob.exceptions import BrowserIncorrectPassword
class BoobankMuninPlugin(object): class BoobankMuninPlugin(object):
def __init__(self): def __init__(self):
if 'weboob_path' in os.environ: if 'weboob_path' in os.environ:

View file

@ -33,6 +33,7 @@ import os
# bpp: bits per pixel, could *only* be 24 or 32! # 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 # return: an "array" of BYTES which, if write to file, is a size*size ico file
def genico(data, size=16, bpp=24): def genico(data, size=16, bpp=24):
from array import array from array import array
a = array('B') a = array('B')
@ -80,7 +81,6 @@ def genico(data, size=16, bpp=24):
return a return a
# x,y indicate the hotspot position # x,y indicate the hotspot position
# simply set the type/hotspot(x&y) after generates the icon # simply set the type/hotspot(x&y) after generates the icon
def gencur(data, size=16, bpp=24, x=0, y=0): 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 return a
#C:\Python27\Lib\site-packages\weboob-0.g-py2.7.egg\share\icons\hicolor\64x64\apps #C:\Python27\Lib\site-packages\weboob-0.g-py2.7.egg\share\icons\hicolor\64x64\apps
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -32,12 +32,15 @@ except ImportError:
DEFAULT_VERSION = "1.1.6" DEFAULT_VERSION = "1.1.6"
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/" DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
def _python_cmd(*args): def _python_cmd(*args):
args = (sys.executable,) + args args = (sys.executable,) + args
return subprocess.call(args) == 0 return subprocess.call(args) == 0
def _check_call_py24(cmd, *args, **kwargs): def _check_call_py24(cmd, *args, **kwargs):
res = subprocess.call(cmd, *args, **kwargs) res = subprocess.call(cmd, *args, **kwargs)
class CalledProcessError(Exception): class CalledProcessError(Exception):
pass pass
if not res == 0: if not res == 0:
@ -45,6 +48,7 @@ def _check_call_py24(cmd, *args, **kwargs):
raise CalledProcessError(msg) raise CalledProcessError(msg)
vars(subprocess).setdefault('check_call', _check_call_py24) vars(subprocess).setdefault('check_call', _check_call_py24)
def _install(tarball, install_args=()): def _install(tarball, install_args=()):
# extracting the tarball # extracting the tarball
tmpdir = tempfile.mkdtemp() 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, return _do_download(version, download_base, to_dir,
download_delay) download_delay)
def download_file_powershell(url, target): def download_file_powershell(url, target):
""" """
Download the file at url to target using Powershell (which will validate 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) subprocess.check_call(cmd)
def has_powershell(): def has_powershell():
if platform.system() != 'Windows': if platform.system() != 'Windows':
return False return False
@ -180,10 +186,12 @@ def has_powershell():
download_file_powershell.viable = has_powershell download_file_powershell.viable = has_powershell
def download_file_curl(url, target): def download_file_curl(url, target):
cmd = ['curl', url, '--silent', '--output', target] cmd = ['curl', url, '--silent', '--output', target]
subprocess.check_call(cmd) subprocess.check_call(cmd)
def has_curl(): def has_curl():
cmd = ['curl', '--version'] cmd = ['curl', '--version']
devnull = open(os.path.devnull, 'wb') devnull = open(os.path.devnull, 'wb')
@ -198,10 +206,12 @@ def has_curl():
download_file_curl.viable = has_curl download_file_curl.viable = has_curl
def download_file_wget(url, target): def download_file_wget(url, target):
cmd = ['wget', url, '--quiet', '--output-document', target] cmd = ['wget', url, '--quiet', '--output-document', target]
subprocess.check_call(cmd) subprocess.check_call(cmd)
def has_wget(): def has_wget():
cmd = ['wget', '--version'] cmd = ['wget', '--version']
devnull = open(os.path.devnull, 'wb') devnull = open(os.path.devnull, 'wb')
@ -216,6 +226,7 @@ def has_wget():
download_file_wget.viable = has_wget download_file_wget.viable = has_wget
def download_file_insecure(url, target): def download_file_insecure(url, target):
""" """
Use Python to download the file, even though it cannot authenticate the 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 download_file_insecure.viable = lambda: True
def get_best_downloader(): def get_best_downloader():
downloaders = [ downloaders = [
download_file_powershell, download_file_powershell,
@ -253,6 +265,7 @@ def get_best_downloader():
if dl.viable(): if dl.viable():
return dl return dl
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15, to_dir=os.curdir, delay=15,
downloader_factory=get_best_downloader): downloader_factory=get_best_downloader):
@ -338,6 +351,7 @@ def _build_install_args(options):
install_args.append('--user') install_args.append('--user')
return install_args return install_args
def _parse_args(): def _parse_args():
""" """
Parse the command line for options Parse the command line for options
@ -359,6 +373,7 @@ def _parse_args():
# positional arguments are ignored # positional arguments are ignored
return options return options
def main(version=DEFAULT_VERSION): def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall""" """Install or upgrade setuptools and EasyInstall"""
options = _parse_args() options = _parse_args()

View file

@ -24,6 +24,7 @@ from .browser import SevenFiftyGramsBrowser
import unicodedata import unicodedata
def strip_accents(s): def strip_accents(s):
return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn') return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn')

View file

@ -26,6 +26,7 @@ from weboob.deprecated.browser import Page
class ResultsPage(Page): class ResultsPage(Page):
""" Page which contains results as a list of recipies """ Page which contains results as a list of recipies
""" """
def iter_recipes(self): def iter_recipes(self):
for div in self.parser.select(self.document.getroot(), 'div.recette_description > div.data'): 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') links = self.parser.select(div, 'div.info > p.title > a.fn')
@ -65,6 +66,7 @@ class ResultsPage(Page):
class RecipePage(Page): class RecipePage(Page):
""" Page which contains a recipe """ Page which contains a recipe
""" """
def get_recipe(self, id): def get_recipe(self, id):
title = NotAvailable title = NotAvailable
preparation_time = NotAvailable preparation_time = NotAvailable

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest from weboob.tools.test import BackendTest
import re import re
class AllocineTest(BackendTest): class AllocineTest(BackendTest):
MODULE = 'allocine' MODULE = 'allocine'

View file

@ -60,4 +60,3 @@ class AlloRestoModule(Module, CapBank):
def iter_coming(self, account): def iter_coming(self, account):
return self.browser.get_coming(account) return self.browser.get_coming(account)

View file

@ -52,6 +52,7 @@ class AccountsPage(LoggedPage, HTMLPage):
class MyDate(Filter): 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'] 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): def filter(self, txt):
day, month, year = txt.split(' ') day, month, year = txt.split(' ')
day = int(day) day = int(day)

View file

@ -30,6 +30,7 @@ class FourOFourPage(Page):
class ResultsPage(Page): class ResultsPage(Page):
""" Page which contains results as a list of recipies """ Page which contains results as a list of recipies
""" """
def iter_recipes(self): def iter_recipes(self):
for div in self.parser.select(self.document.getroot(), 'div.recipe-info'): for div in self.parser.select(self.document.getroot(), 'div.recipe-info'):
thumbnail_url = NotAvailable thumbnail_url = NotAvailable
@ -59,6 +60,7 @@ class ResultsPage(Page):
class RecipePage(Page): class RecipePage(Page):
""" Page which contains a recipe """ Page which contains a recipe
""" """
def get_recipe(self, id): def get_recipe(self, id):
title = NotAvailable title = NotAvailable
preparation_time = NotAvailable preparation_time = NotAvailable

View file

@ -29,6 +29,7 @@ from weboob.capabilities.bill import Subscription, Detail, Bill
# Ugly array to avoid the use of french locale # 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'] 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): class AmeliBasePage(Page):
def is_logged(self): def is_logged(self):
try: try:
@ -40,6 +41,7 @@ class AmeliBasePage(Page):
self.logger.debug('logged: %s' % (logged)) self.logger.debug('logged: %s' % (logged))
return logged return logged
class LoginPage(AmeliBasePage): class LoginPage(AmeliBasePage):
def login(self, login, password): def login(self, login, password):
self.browser.select_form('connexionCompteForm') self.browser.select_form('connexionCompteForm')
@ -47,9 +49,11 @@ class LoginPage(AmeliBasePage):
self.browser["connexioncompte_2codeConfidentiel"] = password.encode('utf8') self.browser["connexioncompte_2codeConfidentiel"] = password.encode('utf8')
self.browser.submit() self.browser.submit()
class HomePage(AmeliBasePage): class HomePage(AmeliBasePage):
pass pass
class AccountPage(AmeliBasePage): class AccountPage(AmeliBasePage):
def iter_subscription_list(self): def iter_subscription_list(self):
idents = self.document.xpath('//div[contains(@class, "blocfond")]') idents = self.document.xpath('//div[contains(@class, "blocfond")]')

View file

@ -63,4 +63,3 @@ class AmericanExpressModule(Module, CapBank):
transactions = list(self.browser.get_history(account)) transactions = list(self.browser.get_history(account))
transactions.sort(key=lambda tr: tr.rdate, reverse=True) transactions.sort(key=lambda tr: tr.rdate, reverse=True)
return transactions return transactions

View file

@ -56,6 +56,7 @@ class AccountsPage(Page):
yield a yield a
class TransactionsPage(Page): class TransactionsPage(Page):
COL_ID = 0 COL_ID = 0
COL_DATE = 1 COL_DATE = 1
@ -81,6 +82,7 @@ class TransactionsPage(Page):
return datetime.date(int(m.group(3)), return datetime.date(int(m.group(3)),
self.MONTHS.index(m.group(2).rstrip('.')) + 1, self.MONTHS.index(m.group(2).rstrip('.')) + 1,
int(m.group(1))) int(m.group(1)))
def get_beginning_debit_date(self): def get_beginning_debit_date(self):
for option in self.document.xpath('//select[@id="viewPeriod"]/option'): for option in self.document.xpath('//select[@id="viewPeriod"]/option'):
if 'selected' in option.attrib: if 'selected' in option.attrib:

View file

@ -39,4 +39,3 @@ class AudioAddictTest(BackendTest):
self.assertTrue(radio.current.what) self.assertTrue(radio.current.what)
self.assertTrue(radio.streams[0].url) self.assertTrue(radio.streams[0].url)
self.assertTrue(radio.streams[0].title) self.assertTrue(radio.streams[0].title)

View file

@ -127,6 +127,7 @@ class WebsiteBrowser(LoginBrowser):
return profile return profile
class AuMBrowser(Browser): class AuMBrowser(Browser):
DOMAIN = 'www.adopteunmec.com' DOMAIN = 'www.adopteunmec.com'
APIKEY = 'fb0123456789abcd' APIKEY = 'fb0123456789abcd'

View file

@ -256,6 +256,7 @@ class TransactionsPage(BasePage):
yield t yield t
class CBTransactionsPage(TransactionsPage): class CBTransactionsPage(TransactionsPage):
COL_CB_CREDIT = 2 COL_CB_CREDIT = 2

View file

@ -87,6 +87,7 @@ class VirtKeyboard(MappedVirtKeyboard):
code += self.get_symbol_code(self.symbols[c]) code += self.get_symbol_code(self.symbols[c])
return code return code
class LoginPage(HTMLPage): class LoginPage(HTMLPage):
def login(self, login, password): def login(self, login, password):
vk = VirtKeyboard(self) vk = VirtKeyboard(self)
@ -98,6 +99,7 @@ class LoginPage(HTMLPage):
form['code'] = code form['code'] = code
form.submit() form.submit()
class IndexPage(LoggedPage, HTMLPage): class IndexPage(LoggedPage, HTMLPage):
@method @method
class get_list(ListElement): class get_list(ListElement):
@ -152,6 +154,7 @@ class IndexPage(LoggedPage, HTMLPage):
def get_card_name(self): def get_card_name(self):
return CleanText('//h1[1]')(self.doc) return CleanText('//h1[1]')(self.doc)
class AccountsPage(LoggedPage, HTMLPage): class AccountsPage(LoggedPage, HTMLPage):
def get_balance(self): def get_balance(self):
balance = Decimal('0.0') balance = Decimal('0.0')

View file

@ -82,6 +82,7 @@ class BanquePopulaire(Browser):
self.token = self.page.get_token() self.token = self.page.get_token()
ACCOUNT_URLS = ['mesComptes', 'mesComptesPRO', 'maSyntheseGratuite', 'accueilSynthese'] ACCOUNT_URLS = ['mesComptes', 'mesComptesPRO', 'maSyntheseGratuite', 'accueilSynthese']
def go_on_accounts_list(self): def go_on_accounts_list(self):
for taskInfoOID in self.ACCOUNT_URLS: for taskInfoOID in self.ACCOUNT_URLS:
self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID=taskInfoOID, token=self.token)) self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID=taskInfoOID, token=self.token))

View file

@ -267,5 +267,6 @@ class HistoryPage(BEPage):
# Last page # Last page
return None return None
class UnknownPage(BEPage): class UnknownPage(BEPage):
pass pass

View file

@ -26,6 +26,7 @@ from .login import LoginPage, UpdateInfoPage
from .two_authentication import AuthenticationPage from .two_authentication import AuthenticationPage
class AccountPrelevement(AccountsList): class AccountPrelevement(AccountsList):
pass pass

View file

@ -37,6 +37,7 @@ class UnavailablePage(Page):
def on_loaded(self): def on_loaded(self):
raise BrowserUnavailable() raise BrowserUnavailable()
class Keyboard(VirtKeyboard): class Keyboard(VirtKeyboard):
symbols={'0':'daa52d75287bea58f505823ef6c8b96c', symbols={'0':'daa52d75287bea58f505823ef6c8b96c',
'1':'f5da96c2592803a8cdc5a928a2e4a3b0', '1':'f5da96c2592803a8cdc5a928a2e4a3b0',
@ -86,6 +87,7 @@ class Keyboard(VirtKeyboard):
x1, y1, x2, y2 = coords x1, y1, x2, y2 = coords
return VirtKeyboard.get_symbol_coords(self, (x1+3, y1+3, x2-3, y2-3)) return VirtKeyboard.get_symbol_coords(self, (x1+3, y1+3, x2-3, y2-3))
class LoginPage(Page): class LoginPage(Page):
def login(self, login, pwd): def login(self, login, pwd):
vk = Keyboard(self) vk = Keyboard(self)

Some files were not shown because too many files have changed in this diff Show more