Commit 7094931c authored by Laurent Bachelier's avatar Laurent Bachelier 🐧

Easy spacing fixes, trailing stuff

Remove useless trailing \
Remove trailing spaces
Add missing empty lines

autopep8 -ir -j2 --select=E301,E302,E502,W291,W293,W391 .

Diff quickly checked.
parent c21d1f79
......@@ -33,6 +33,7 @@ IRC_NICKNAME = 'boobot'
IRC_SERVER = 'irc.freenode.org'
STORAGE_FILE = 'boobot.storage'
class MyThread(Thread):
def __init__(self, bot):
Thread.__init__(self)
......@@ -50,9 +51,9 @@ class MyThread(Thread):
self.weboob.loop()
def find_keywords(self, text):
for word in ['weboob', 'videoob', 'havesex', 'havedate', 'monboob', 'boobmsg', \
'flatboob', 'boobill', 'pastoob', 'radioob', 'translaboob', 'traveloob', \
'boobathon', 'boobank', 'boobtracker', 'comparoob', 'wetboobs', \
for word in ['weboob', 'videoob', 'havesex', 'havedate', 'monboob', 'boobmsg',
'flatboob', 'boobill', 'pastoob', 'radioob', 'translaboob', 'traveloob',
'boobathon', 'boobank', 'boobtracker', 'comparoob', 'wetboobs',
'webcontentedit', 'weboorrents', 'capabilit', u'sàt', u'salut à toi']:
if word in text.lower():
return word
......@@ -80,6 +81,7 @@ class MyThread(Thread):
def stop(self):
self.weboob.want_stop()
class TestBot(SingleServerIRCBot):
def __init__(self, channel, nickname, server, port=6667):
SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname + "`")
......@@ -121,6 +123,7 @@ class TestBot(SingleServerIRCBot):
if h:
self.send_message(u'Housing: %s (%sm² / %s%s)' % (h.title, h.area, h.cost, h.currency))
def main():
logging.basicConfig(level=logging.DEBUG)
bot = TestBot(IRC_CHANNEL, IRC_NICKNAME, IRC_SERVER)
......
......@@ -39,14 +39,18 @@ if sys.stdout.encoding is None:
# end of hack
def removeNonAscii(s): return "".join(i for i in s if ord(i)<128)
rx = re.compile(u'[ \\/\\?\\:\\>\\<\\!\\\\\\*]+', re.UNICODE)
def removeSpecial(s):
return rx.sub(u' ', u'%s' % s)
DOWNLOAD_DIRECTORY=".files"
class Downloadboob:
def __init__(self, backend_name, download_directory, links_directory):
......
......@@ -100,7 +100,7 @@ class VideoobWeb(BaseApplication):
page_url=video.page_url,
url=video.url if video.url else '/download?id=%s' % video.id,
thumbnail_url=video.thumbnail.url,
) \
)
for video in backend.search_videos(pattern=q, nsfw=nsfw)]
if videos:
if merge:
......
......@@ -4,6 +4,7 @@ from __future__ import with_statement
import os
def genapi():
os.system('rm -rf api')
os.system('mkdir api')
......
......@@ -75,6 +75,7 @@ class IndexPage(BasePage):
yield video
class VideoPage(BasePage):
def get_video(self, video=None, lang='fr', quality='hd'):
if not video:
......
......@@ -87,7 +87,7 @@ class SubtitlesPage(BasePage):
traduced_title_words = traduced_title.split()
original_title_words = original_title.split()
# if the pattern is one word and in the title OR if the
# if the pattern is one word and in the title OR if the
# intersection between pattern and the title is at least 2 words
if (len(pattern_words) == 1 and pattern in traduced_title_words) or\
(len(pattern_words) == 1 and pattern in original_title_words) or\
......
......@@ -22,6 +22,7 @@ from weboob.tools.test import BackendTest
import urllib
from random import choice
class AttilasubTest(BackendTest):
BACKEND = 'attilasub'
......
......@@ -55,6 +55,7 @@ def parse_dt(s):
d = _parse_dt(s)
return local2utc(d)
class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapChat, ICapContact, ICapAccount):
NAME = 'aum'
MAINTAINER = u'Romain Bignon'
......@@ -503,6 +504,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
browser = None
REGISTER_REGEXP = re.compile('.*http://www.adopteunmec.com/register4.php\?([^\' ]*)\'')
def confirm_account(self, mail):
msg = email.message_from_string(mail)
......
......@@ -64,6 +64,7 @@ class AuMException(UserError):
Exception.__init__(self, self.ERRORS.get(code, code))
self.code = code
class AuMBrowser(BaseBrowser):
DOMAIN = 'www.adopteunmec.com'
APIKEY = 'fb0123456789abcd'
......
......@@ -26,8 +26,10 @@ try:
except ImportError:
raise ImportError('Please install python-imaging')
class CaptchaError(Exception): pass
class Tile(object):
hash = {
'bc8d52d96058478a6def26226145d53b': 'A',
......@@ -115,6 +117,7 @@ class Tile(object):
print 'hash: %s' % checksum
raise CaptchaError()
class Captcha(object):
def __init__(self, f):
self.img = Image.open(f)
......@@ -156,6 +159,7 @@ class Captcha(object):
s += tile.letter
return s
class Decoder(object):
def __init__(self):
self.hash = {}
......
......@@ -140,6 +140,7 @@ class FieldConst(FieldBase):
labels.append(consts[self.key][i])
return labels
class Contact(_Contact):
TABLE = OrderedDict((
('_info', OrderedDict((
......
......@@ -40,6 +40,7 @@ class UnavailablePage(BasePage):
def on_loaded(self):
raise BrowserUnavailable()
class VirtKeyboard(MappedVirtKeyboard):
symbols={'0':'f47e48cfdf3abc6716a6b0aadf8eebe3',
'1':'3495abaf658dc550e51c5c92ea56b60b',
......@@ -148,6 +149,7 @@ class AccountsPage(BasePage):
account._args = args
yield account
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile('^RET(RAIT) DAB (?P<dd>\d{2})/(?P<mm>\d{2}) (?P<text>.*)'),
FrenchTransaction.TYPE_WITHDRAWAL),
......
......@@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class AXABanqueTest(BackendTest):
BACKEND = 'axabanque'
......
......@@ -39,6 +39,7 @@ class UnavailablePage(BasePage):
else:
self.browser.location(a.attrib['href'])
class LoginPage(BasePage):
def login(self, login, passwd):
self.browser.select_form(name='Login')
......@@ -46,6 +47,7 @@ class LoginPage(BasePage):
self.browser['IDToken2'] = passwd.encode(self.browser.ENCODING)
self.browser.submit(nologin=True)
class IndexPage(BasePage):
def get_token(self):
url = self.document.getroot().xpath('//frame[@name="portalHeader"]')[0].attrib['src']
......@@ -53,6 +55,7 @@ class IndexPage(BasePage):
args = dict(parse_qsl(v.query))
return args['token']
class AccountsPage(BasePage):
ACCOUNT_TYPES = {u'Mes comptes d\'épargne': Account.TYPE_SAVINGS,
u'Mes comptes': Account.TYPE_CHECKING,
......@@ -101,6 +104,7 @@ class AccountsPage(BasePage):
return
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile('^RET DAB (?P<text>.*?) RETRAIT (DU|LE) (?P<dd>\d{2})(?P<mm>\d{2})(?P<yy>\d+).*'),
FrenchTransaction.TYPE_WITHDRAWAL),
......
......@@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class BanquePopulaireTest(BackendTest):
BACKEND = 'banquepopulaire'
......
......@@ -44,6 +44,7 @@ class LoginPage(BasePage):
else:
return True
class Login2Page(BasePage):
def login(self, secret):
label = self.document.xpath('//span[@class="PF_LABEL"]')[0].text.strip()
......@@ -55,9 +56,11 @@ class Login2Page(BasePage):
self.browser['word'] = letters
self.browser.submit(name='valider', nologin=True)
class IndexPage(BasePage):
pass
class AccountsPage(BasePage):
ACCOUNT_TYPES = {u'Epargne': Account.TYPE_SAVINGS,
u'Liquidités': Account.TYPE_CHECKING,
......@@ -170,11 +173,13 @@ class Transaction(FrenchTransaction):
FrenchTransaction.TYPE_UNKNOWN),
]
class HistoryBasePage(BasePage):
def get_history(self):
self.logger.warning('Do not support account of type %s' % type(self).__name__)
return iter([])
class TransactionsPage(HistoryBasePage):
def get_history(self):
for tr in self.document.xpath('//table[@id="operation"]/tbody/tr'):
......@@ -229,11 +234,14 @@ class CardPage(HistoryBasePage):
t.set_amount(amount)
yield t
class ValuationPage(HistoryBasePage):
pass
class LoanPage(HistoryBasePage):
pass
class MarketPage(HistoryBasePage):
pass
......@@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class BarclaysTest(BackendTest):
BACKEND = 'barclays'
......
......@@ -28,6 +28,7 @@ from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard,VirtKeyboardErr
__all__ = ['LoginPage', 'ConfirmPage', 'ChangePasswordPage']
class BNPVirtKeyboard(MappedVirtKeyboard):
symbols={'0':'9cc4789a2cb223e8f2d5e676e90264b5',
'1':'e10b58fc085f9683052d5a63c96fc912',
......@@ -100,10 +101,12 @@ class ConfirmPage(BasePage):
if m:
return m.group(1)
class InfoMessagePage(BasePage):
def on_loaded(self):
pass
class ChangePasswordPage(BasePage):
def change_password(self, current, new):
try:
......
......@@ -44,6 +44,7 @@ class Transaction(FrenchTransaction):
(re.compile('^(?P<category>REMISE CHEQUES)(?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
]
class AccountHistory(BasePage):
def iter_operations(self):
for tr in self.document.xpath('//table[@id="tableCompte"]//tr'):
......
......@@ -35,6 +35,7 @@ class Account(object):
self.send_checkbox = send_checkbox
self.receive_checkbox = receive_checkbox
class TransferPage(BasePage):
def on_loaded(self):
for td in self.document.xpath('//td[@class="hdvon1"]'):
......
......@@ -36,6 +36,7 @@ class ProAccountsList(BasePage):
COL_ID = 2
COL_BALANCE = 3
COL_COMING = 5
def get_list(self):
for tr in self.document.xpath('//tr[@class="comptes"]'):
cols = tr.findall('td')
......@@ -57,6 +58,7 @@ class ProAccountsList(BasePage):
yield account
class ProAccountHistory(BasePage):
COL_DATE = 0
COL_LABEL = 1
......
......@@ -23,6 +23,7 @@ from .account_history import AccountHistory
from .accounts_list import AccountsList
from .login import LoginPage, UpdateInfoPage
class AccountPrelevement(AccountsList):
pass
......
......@@ -29,6 +29,7 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
__all__ = ['AccountHistory']
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile(u'^CHQ\. (?P<text>.*)'), FrenchTransaction.TYPE_CHECK),
(re.compile('^(ACHAT|PAIEMENT) CARTE (?P<dd>\d{2})(?P<mm>\d{2})(?P<yy>\d{2}) (?P<text>.*)'),
......@@ -42,6 +43,7 @@ class Transaction(FrenchTransaction):
(re.compile('^REM CHQ (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
]
class AccountHistory(BasePage):
def on_loaded(self):
......
......@@ -75,6 +75,7 @@ class VirtKeyboard(MappedVirtKeyboard):
s += " "
return hashlib.md5(s).hexdigest()
class LoginPage(BasePage):
def on_loaded(self):
pass
......@@ -98,6 +99,7 @@ class LoginPage(BasePage):
self.browser.location(form.attrib['action'], urllib.urlencode(args), no_login=True)
class UpdateInfoPage(BasePage):
def on_loaded(self):
raise BrowserIncorrectPassword('Please update your user informations')
......@@ -21,6 +21,7 @@
from weboob.tools.test import BackendTest
class BoursoramaTest(BackendTest):
BACKEND = 'boursorama'
......
......@@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class BouyguesTest(BackendTest):
BACKEND = 'bouygues'
......
......@@ -47,6 +47,7 @@ class Transaction(FrenchTransaction):
(re.compile('^(?P<category>REMISE DE CHEQUE) (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
]
class AccountHistory(BasePage):
def get_next_link(self):
for a in self.document.xpath('//a[@class="btn_crt"]'):
......@@ -105,6 +106,7 @@ class AccountHistory(BasePage):
operations.append(op)
return operations
class CardsList(BasePage):
def get_cards(self):
cards = []
......
......@@ -30,6 +30,7 @@ def md5(f):
md5.update(f.read())
return md5.hexdigest()
class UnavailablePage(BasePage):
def on_loaded(self):
raise BrowserUnavailable()
......@@ -57,14 +58,17 @@ class LoginPage(BasePage):
self.browser['username'] = login
self.browser.submit()
class repositionnerCheminCourant(BasePage):
def on_loaded(self):
self.browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/securite/authentification/initialiser-identif.ea")
class Initident(BasePage):
def on_loaded(self):
self.browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/securite/authentification/verifierMotDePasse-identif.ea")
class CheckPassword(BasePage):
def on_loaded(self):
self.browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/comptesCommun/synthese_assurancesEtComptes/init-synthese.ea")
......
......@@ -37,6 +37,7 @@ class LoginPage(BasePage):
self.browser['pass'] = passwd.encode(self.browser.ENCODING)
self.browser.submit(nologin=True)
class LoginResultPage(BasePage):
def confirm(self):
self.browser.location('MainAuth?typeDemande=AC', no_login=True)
......@@ -52,9 +53,11 @@ class LoginResultPage(BasePage):
return error.text.strip()
class EmptyPage(BasePage):
pass
class BredBasePage(BasePage):
def js2args(self, s):
cur_arg = None
......@@ -70,6 +73,7 @@ class BredBasePage(BasePage):
return args
class AccountsPage(BredBasePage):
def get_list(self):
accounts = []
......@@ -123,6 +127,7 @@ class AccountsPage(BredBasePage):
return accounts
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile('^RETRAIT G.A.B. \d+ (?P<text>.*?)( CARTE .*)? LE (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{2}).*'),
FrenchTransaction.TYPE_WITHDRAWAL),
......
......@@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class BredTest(BackendTest):
BACKEND = 'bred'
......
......@@ -64,7 +64,6 @@ class TorrentsPage(BasePage):
torrent.description = NotLoaded
torrent.files = NotLoaded
yield torrent
class TorrentPage(BasePage):
......@@ -86,7 +85,7 @@ class TorrentPage(BasePage):
href_t = self.parser.select(div,'a.down',1).attrib.get('href','')
url = u'http://%s%s'%(self.browser.DOMAIN,href_t)
magnet = unicode(self.parser.select(div,'a.magnet',1).attrib.get('href',''))
divtabs = self.parser.select(div,'div#tabs',1)
files_div = self.parser.select(divtabs,'div.body > div.doubleblock > div.leftblock')
files = []
......
......@@ -22,6 +22,7 @@ from weboob.capabilities.base import NotLoaded
from random import choice
class BtmonTest(BackendTest):
BACKEND = 'btmon'
......
......@@ -54,6 +54,7 @@ class LoginPage(BasePage):
self.browser.form.action = m.group(1)
self.browser.submit(nologin=True)
class ErrorPage(BasePage):
def get_error(self):
try:
......@@ -61,6 +62,7 @@ class ErrorPage(BasePage):
except BrokenPageError:
return None
class UnavailablePage(BasePage):
def on_loaded(self):
try:
......@@ -68,6 +70,7 @@ class UnavailablePage(BasePage):
except BrokenPageError:
raise BrowserUnavailable()
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile('^CB (?P<text>.*?) FACT (?P<dd>\d{2})(?P<mm>\d{2})(?P<yy>\d{2})'),
FrenchTransaction.TYPE_CARD),
......@@ -87,6 +90,7 @@ class Transaction(FrenchTransaction):
(re.compile('^CB [\d\*]+ (?P<text>.*)'), FrenchTransaction.TYPE_CARD),
]
class IndexPage(BasePage):
ACCOUNT_TYPES = {u'Epargne liquide': Account.TYPE_SAVINGS,
u'Compte Courant': Account.TYPE_CHECKING,
......
......@@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CaisseEpargneTest(BackendTest):
BACKEND = 'caissedepargne'
......
......@@ -21,6 +21,7 @@
from weboob.tools.test import BackendTest
from weboob.capabilities.video import BaseVideo
class CanalPlusTest(BackendTest):
BACKEND = 'canalplus'
......
......@@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CanalTPTest(BackendTest):
BACKEND = 'canaltp'
......
......@@ -39,9 +39,11 @@ class LoginPage(BasePage):
except FormNotFoundError:
raise BrowserIncorrectPassword()
class HomePage(BasePage):
pass
class AccountsPage(BasePage):
def get_list(self):
div = self.document.xpath('//div[@id="descriptifdroite"]')[0]
......@@ -73,6 +75,7 @@ class AccountsPage(BasePage):
yield account
class TransactionsPage(BasePage):
COL_DATE = 0
COL_TEXT = 1
......
......@@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CarrefourBanqueTest(BackendTest):
BACKEND = 'carrefourbanque'
......
......@@ -28,6 +28,7 @@ from weboob.tools.ordereddict import OrderedDict
from weboob.capabilities.bank import Account
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
class LoginPage(BasePage):
def login(self, login, passwd):
self.browser.select_form(name='ident')
......@@ -35,25 +36,32 @@ class LoginPage(BasePage):
self.browser['_cm_pwd'] = passwd
self.browser.submit(nologin=True)
class LoginErrorPage(BasePage):
pass
class ChangePasswordPage(BasePage):
def on_loaded(self):
raise BrowserIncorrectPassword('Please change your password')
class InfoPage(BasePage):
pass
class EmptyPage(BasePage):
pass
class TransfertPage(BasePage):
pass
class UserSpacePage(BasePage):
pass
class AccountsPage(BasePage):
def get_list(self):
accounts = OrderedDict()
......@@ -102,6 +110,7 @@ class AccountsPage(BasePage):
return accounts.itervalues()
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile('^VIR(EMENT)? (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER),
(re.compile('^PRLV (?P<text>.*)'), FrenchTransaction.TYPE_ORDER),
......@@ -116,6 +125,7 @@ class Transaction(FrenchTransaction):
_is_coming = False
class OperationsPage(BasePage):
def get_history(self):