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.
This commit is contained in:
Laurent Bachelier 2013-03-15 20:01:49 +01:00
commit 7094931c92
231 changed files with 474 additions and 67 deletions

View file

@ -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)

View file

@ -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):

View file

@ -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:

View file

@ -4,6 +4,7 @@ from __future__ import with_statement
import os
def genapi():
os.system('rm -rf api')
os.system('mkdir api')

View file

@ -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:

View file

@ -22,6 +22,7 @@ from weboob.tools.test import BackendTest
import urllib
from random import choice
class AttilasubTest(BackendTest):
BACKEND = 'attilasub'

View file

@ -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)

View file

@ -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'

View file

@ -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 = {}

View file

@ -140,6 +140,7 @@ class FieldConst(FieldBase):
labels.append(consts[self.key][i])
return labels
class Contact(_Contact):
TABLE = OrderedDict((
('_info', OrderedDict((

View file

@ -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),

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class AXABanqueTest(BackendTest):
BACKEND = 'axabanque'

View file

@ -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),

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class BanquePopulaireTest(BackendTest):
BACKEND = 'banquepopulaire'

View file

@ -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

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class BarclaysTest(BackendTest):
BACKEND = 'barclays'

View file

@ -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:

View file

@ -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'):

View file

@ -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"]'):

View file

@ -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

View file

@ -23,6 +23,7 @@ from .account_history import AccountHistory
from .accounts_list import AccountsList
from .login import LoginPage, UpdateInfoPage
class AccountPrelevement(AccountsList):
pass

View file

@ -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):

View file

@ -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')

View file

@ -21,6 +21,7 @@
from weboob.tools.test import BackendTest
class BoursoramaTest(BackendTest):
BACKEND = 'boursorama'

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class BouyguesTest(BackendTest):
BACKEND = 'bouygues'

View file

@ -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 = []

View file

@ -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")

View file

@ -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),

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class BredTest(BackendTest):
BACKEND = 'bred'

View file

@ -66,7 +66,6 @@ class TorrentsPage(BasePage):
yield torrent
class TorrentPage(BasePage):
def get_torrent(self):
seed = 0

View file

@ -22,6 +22,7 @@ from weboob.capabilities.base import NotLoaded
from random import choice
class BtmonTest(BackendTest):
BACKEND = 'btmon'

View file

@ -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,

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CaisseEpargneTest(BackendTest):
BACKEND = 'caissedepargne'

View file

@ -21,6 +21,7 @@
from weboob.tools.test import BackendTest
from weboob.capabilities.video import BaseVideo
class CanalPlusTest(BackendTest):
BACKEND = 'canalplus'

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CanalTPTest(BackendTest):
BACKEND = 'canaltp'

View file

@ -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

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CarrefourBanqueTest(BackendTest):
BACKEND = 'carrefourbanque'

View file

@ -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):
index = 0
@ -181,6 +191,7 @@ class OperationsPage(BasePage):
return True
class CardPage(OperationsPage):
def get_history(self):
index = 0
@ -200,6 +211,7 @@ class CardPage(OperationsPage):
tr.set_amount(tds[-1].text)
yield tr
class NoOperationsPage(OperationsPage):
def get_history(self):
return iter([])

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CICTest(BackendTest):
BACKEND = 'cic'

View file

@ -29,6 +29,7 @@ __all__ = ['HTTPSVerifiedConnection', 'HellHTTPS']
PROXY_PORT = 8080
class HTTPSVerifiedConnection(httplib.HTTPSConnection):
"""
This class allows communication via SSL, and will checks certificates

View file

@ -37,6 +37,7 @@ class LoginPage(BasePage):
self.browser['motDePasse'] = passwd.encode(self.browser.ENCODING)
self.browser.submit(nologin=True)
class AccountsPage(BasePage):
def get_list(self):
names = set()

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CmsoTest(BackendTest):
BACKEND = 'cmso'

View file

@ -26,6 +26,7 @@ import mechanize
from datetime import datetime
import re
class Cragr(BaseBrowser):
PROTOCOL = 'https'
ENCODING = 'utf-8'

View file

@ -25,6 +25,7 @@ from .base import CragrBasePage
from .tokenextractor import TokenExtractor
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
class Transaction(FrenchTransaction):
PATTERNS = [
(re.compile('^(Vp|Vt|Vrt|Virt|Vir(ement)?)\s*(?P<text>.*)', re.IGNORECASE), FrenchTransaction.TYPE_TRANSFER),
@ -44,6 +45,7 @@ class Transaction(FrenchTransaction):
(re.compile('^RET.CARTE (?P<text>.*)', re.IGNORECASE), FrenchTransaction.TYPE_WITHDRAWAL),
]
class AccountsList(CragrBasePage):
"""
Unlike most pages used with the Browser class, this class represents

View file

@ -21,6 +21,7 @@
from weboob.tools.browser import BasePage
from weboob.tools.browser import BrowserUnavailable
class CragrBasePage(BasePage):
def on_loaded(self):
# Check for an error

View file

@ -17,16 +17,19 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
class TokenExtractor:
""" Extracts texts token from an HTML document """
def __init__(self):
self.iterated_elements = []
def clear(self):
"""
Reset any content stored within a TokenExtractor object. Useful to start
a new parsing without creating a new instance.
"""
self.iterated_elements = []
def element_iterated_already(self, html_element):
if html_element in self.iterated_elements:
return True
@ -34,6 +37,7 @@ class TokenExtractor:
if ancestor in self.iterated_elements:
return True
return False
def extract_tokens(self, html_element):
if self.element_iterated_already(html_element):
return
@ -44,10 +48,12 @@ class TokenExtractor:
for token in self.split_text_into_smaller_tokens(text):
if self.token_looks_relevant(token):
yield token.strip()
@staticmethod
def split_text_into_smaller_tokens(text):
for subtext1 in text.split('\t'):
yield subtext1
@staticmethod
def token_looks_relevant(token):
return len(token.strip()) > 1

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CrAgrTest(BackendTest):
BACKEND = 'cragr'

View file

@ -37,6 +37,7 @@ class LoginPage(BasePage):
self.browser['j_password'] = password.encode('iso-8859-15')
self.browser.submit(nologin=True)
class LoggedPage(BasePage):
def get_error(self):
div = self.document.xpath('//div[@class="errorForm-msg"]')
@ -46,6 +47,7 @@ class LoggedPage(BasePage):
msg = u', '.join([li.text.strip() for li in div[0].xpath('.//li')])
return re.sub('[\r\n\t\xa0]+', ' ', msg)
class AccountsPage(BasePage):
ACCOUNT_TYPES = {u'COMPTE NEF': Account.TYPE_CHECKING}
@ -65,6 +67,7 @@ class AccountsPage(BasePage):
yield account
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile('^(?P<text>RETRAIT DAB) (?P<dd>\d{2})-(?P<mm>\d{2})-([\d\-]+)'),
FrenchTransaction.TYPE_WITHDRAWAL),
@ -88,9 +91,11 @@ class Transaction(FrenchTransaction):
FrenchTransaction.TYPE_UNKNOWN),
]
class TransactionsPage(BasePage):
pass
class TransactionsJSONPage(BasePage):
ROW_DATE = 0
ROW_TEXT = 2
@ -104,6 +109,7 @@ class TransactionsJSONPage(BasePage):
t.set_amount(tr[self.ROW_CREDIT], tr[self.ROW_DEBIT])
yield t
class ComingTransactionsPage(BasePage):
ROW_REF = 0
ROW_TEXT = 1

View file

@ -29,6 +29,7 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
__all__ = ['LoginPage', 'AccountsPage', 'TransactionsPage', 'ComingTransactionsPage']
class LoginPage(BasePage):
def login(self, login, pin, strong_auth):
form_nb = 1 if strong_auth else 0
@ -41,6 +42,7 @@ class LoginPage(BasePage):
assert self.browser['identType'] == indentType
self.browser.submit(nologin=True)
class AccountsPage(BasePage):
ACCOUNT_TYPES = {u'COMPTE NEF': Account.TYPE_CHECKING}
@ -77,6 +79,7 @@ class AccountsPage(BasePage):
return
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile('^RETRAIT DAB (?P<text>.*?).*'),
FrenchTransaction.TYPE_WITHDRAWAL),
@ -95,6 +98,7 @@ class Transaction(FrenchTransaction):
FrenchTransaction.TYPE_UNKNOWN),
]
class TransactionsPage(BasePage):
def get_next_url(self):
# can be 'Suivant' or ' Suivant'
@ -109,6 +113,7 @@ class TransactionsPage(BasePage):
TR_TEXT = 2
TR_DEBIT = 3
TR_CREDIT = 4
def get_history(self):
for tr in self.document.xpath('//table[@id="operation"]/tbody/tr'):
tds = tr.findall('td')
@ -129,6 +134,7 @@ class TransactionsPage(BasePage):
yield t
class ComingTransactionsPage(BasePage):
COM_TR_COMMENT = 0
COM_TR_DATE = 1

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CreditCooperatifTest(BackendTest):
BACKEND = 'creditcooperatif'

View file

@ -34,6 +34,7 @@ __all__ = ['LoginPage', 'AccountsPage', 'TransactionsPage']
class LoginPage(BasePage):
pass
class CDNBasePage(BasePage):
def get_from_js(self, pattern, end, is_list=False):
"""
@ -69,6 +70,7 @@ class CDNBasePage(BasePage):
def get_execution(self):
return self.get_from_js("name: 'execution', value: '", "'")
class AccountsPage(CDNBasePage):
COL_HISTORY = 2
COL_ID = 4
@ -113,6 +115,7 @@ class AccountsPage(CDNBasePage):
return iter(accounts)
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile(r'^(?P<text>RET DAB \w+ .*?) LE (?P<dd>\d{2})(?P<mm>\d{2})$'),
FrenchTransaction.TYPE_WITHDRAWAL),

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CreditDuNordTest(BackendTest):
BACKEND = 'creditdunord'

View file

@ -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(nr=0)
@ -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):
index = 0
@ -181,6 +191,7 @@ class OperationsPage(BasePage):
return True
class CardPage(OperationsPage):
def get_history(self):
index = 0
@ -200,6 +211,7 @@ class CardPage(OperationsPage):
tr.set_amount(tds[-1].text)
yield tr
class NoOperationsPage(OperationsPage):
def get_history(self):
return iter([])

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class CreditMutuelTest(BackendTest):
BACKEND = 'creditmutuel'
@ -28,5 +29,3 @@ class CreditMutuelTest(BackendTest):
if len(l) > 0:
a = l[0]
list(self.backend.iter_history(a))

View file

@ -45,6 +45,7 @@ class DailymotionBackend(BaseBackend, ICapVideo, ICapCollection):
return self.browser.get_video(_id)
SORTBY = ['relevance', 'rated', 'visited', None]
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
with self.browser:
return self.browser.search_videos(pattern, self.SORTBY[sortby])

View file

@ -85,6 +85,7 @@ class IndexPage(BasePage):
self.browser.logger.warning('Unable to parse rating: %s' % div.attrib['style'])
return 0
class VideoPage(BasePage):
def get_video(self, video=None):
if video is None:

View file

@ -167,7 +167,7 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContent):
date=com.date,
parent=parent,
content=com.body,
signature=com.signature + \
signature=com.signature +
'<br />'.join(['Score: %d' % com.score,
'URL: %s' % com.url]),
children=[],

View file

@ -33,6 +33,8 @@ from .pages.wiki import WikiEditPage
from .tools import id2url, url2id
# Browser
class DLFP(BaseBrowser):
DOMAIN = 'linuxfr.org'
PROTOCOL = 'https'

View file

@ -23,8 +23,10 @@ from logging import warning
from weboob.tools.browser import BasePage
class Message(object):
TIMESTAMP_REGEXP = re.compile(r'(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})')
def __init__(self, id, timestamp, login, message, is_me):
self.id = id
self.timestamp = timestamp
@ -40,6 +42,7 @@ class Message(object):
else:
warning('Unable to parse timestamp "%s"' % timestamp)
class BoardIndexPage(BasePage):
def is_logged(self):
return True

View file

@ -20,6 +20,7 @@
from weboob.tools.browser import BasePage
class DLFPPage(BasePage):
def is_logged(self):
for form in self.document.getiterator('form'):
@ -28,6 +29,7 @@ class DLFPPage(BasePage):
return True
class IndexPage(DLFPPage):
def get_login_token(self):
form = self.parser.select(self.document.getroot(), 'form#new_account_sidebar', 1)
@ -35,5 +37,6 @@ class IndexPage(DLFPPage):
if i.attrib['name'] == 'authenticity_token':
return i.attrib['value']
class LoginPage(DLFPPage):
pass

View file

@ -26,10 +26,12 @@ from ..tools import url2id
from .index import DLFPPage
class RSSComment(DLFPPage):
def on_loaded(self):
pass
class Content(object):
TAGGABLE = False
@ -50,6 +52,7 @@ class Content(object):
def is_taggable(self):
return False
class Comment(Content):
def __init__(self, article, div, reply_id):
Content.__init__(self, article.browser)
@ -105,6 +108,7 @@ class Comment(Content):
def __repr__(self):
return u"<Comment id=%r author=%r title=%r>" % (self.id, self.author, self.title)
class Article(Content):
TAGGABLE = True
@ -149,11 +153,13 @@ class Article(Content):
for c in comment.iter_all_comments():
yield c
class CommentPage(DLFPPage):
def get_comment(self):
article = Article(self.browser, self.url, None)
return Comment(article, self.parser.select(self.document.getroot(), 'li.comment', 1), 0)
class ContentPage(DLFPPage):
def on_loaded(self):
self.article = None
@ -192,9 +198,11 @@ class ContentPage(DLFPPage):
def get_tag_url(self):
return self.parser.select(self.document.getroot(), 'div.tag_in_place', 1).find('a').attrib['href']
class NewCommentPage(DLFPPage):
pass
class NewTagPage(DLFPPage):
def _is_tag_form(self, form):
return form.action.endswith('/tags')
@ -204,6 +212,7 @@ class NewTagPage(DLFPPage):
self.browser['tags'] = tag
self.browser.submit()
class NodePage(DLFPPage):
def get_errors(self):
try:

View file

@ -21,6 +21,7 @@ from weboob.tools.browser import BrokenPageError
from .index import DLFPPage
class WikiEditPage(DLFPPage):
def get_body(self):
try:

View file

@ -31,9 +31,11 @@ REGEXPS = {'/users/%s/journaux/%s': 'D%s.%s',
'/forums/%s/posts/%s': 'B%s.%s',
}
def f2re(f):
return '.*' + f.replace('%s', '([^ /]+)')
def rssid(entry):
m = RSSID_RE.match(entry.id)
if not m:
@ -53,6 +55,7 @@ def rssid(entry):
else:
return '%s.%s' % (ind, m.group(2))
def id2url(id):
m = ID2URL_RE.match(id)
if not m:
@ -67,6 +70,7 @@ def id2url(id):
else:
return url_re % m.group(3)
def url2id(url):
for url_re, id_re in REGEXPS.iteritems():
m = re.match(f2re(url_re), url)
@ -75,6 +79,7 @@ def url2id(url):
return id_re % m.groups()
def id2threadid(id):
m = ID2URL_RE.match(id)
if m:

View file

@ -26,7 +26,7 @@ __all__ = ['StartPage']
class StartPage(BasePage):
name = [u"Temperatur", u"Wind", u"Luftdruck", u"Luftfeuchtigkeit",\
name = [u"Temperatur", u"Wind", u"Luftdruck", u"Luftfeuchtigkeit",
u"Niederschlag", u"Globalstrahlung", u"Schneehoehe"]
unit = [u"°C", u"km/h", u"hPa", u"%", u"mm", u"W/m²", u"cm"]
@ -54,7 +54,7 @@ class StartPage(BasePage):
lastvalue.level = float(text.split('\n')[2].split('hPa')[0])
if i == 3:
text = paraph.xpath('span/font[@size="4"]/b')[0].text
lastvalue.level = float(text.split('\n')[2].split(u'%')[0]\
lastvalue.level = float(text.split('\n')[2].split(u'%')[0]
.split(':')[1])
if i == 4:
text = paraph.xpath('b/font[@size="4"]/span')[0].text

View file

@ -65,6 +65,7 @@ class EHentaiBackend(BaseBackend, ICapGallery, ICapCollection):
ID_REGEXP = r'/?\d+/[\dabcdef]+/?'
URL_REGEXP = r'.+/g/(%s)' % ID_REGEXP
def get_gallery(self, _id):
match = re.match(r'^%s$' % self.URL_REGEXP, _id)
if match:

View file

@ -21,10 +21,12 @@ from weboob.capabilities.gallery import BaseGallery, BaseImage
__all_ = ['EHentaiGallery', 'EHentaiImage']
class EHentaiGallery(BaseGallery):
def __init__(self, *args, **kwargs):
BaseGallery.__init__(self, *args, **kwargs)
class EHentaiImage(BaseImage):
def __init__(self, *args, **kwargs):
BaseImage.__init__(self, *args, **kwargs)

View file

@ -34,6 +34,7 @@ from .video import EuroparlVideo
__all__ = ['VideoPage']
class VideoPage(BasePage):
def get_video(self, video=None):
if video is None:

View file

@ -47,4 +47,3 @@ class EuroparlVideo(BaseVideo):
if m:
return u'http://www.europarl.europa.eu/ep-live/en/plenary/video?debate=%s' % _id
return None

View file

@ -29,6 +29,7 @@ from .pages.accounts_list import GlobalAccountsList, AccountsList, AccountHistor
__all__ = ['Fortuneo']
class Fortuneo(BaseBrowser):
DOMAIN_LOGIN = 'www.fortuneo.fr'
DOMAIN = 'www.fortuneo.fr'

View file

@ -52,6 +52,7 @@ class Transaction(FrenchTransaction):
(re.compile('^(?P<category>REMISE CHEQUES)(?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
]
class AccountHistoryPage(BasePage):
def get_operations(self, _id):
"""history, see http://docs.weboob.org/api/capabilities/bank.html?highlight=transaction#weboob.capabilities.bank.Transaction"""
@ -85,6 +86,7 @@ class AccountHistoryPage(BasePage):
yield operation
class AccountsList(BasePage):
def on_loaded(self):
warn = self.document.xpath('//div[@id="message_renouvellement_mot_passe"]')
@ -156,6 +158,7 @@ class AccountsList(BasePage):
yield account
class GlobalAccountsList(BasePage):
pass

View file

@ -25,6 +25,7 @@ from weboob.tools.browser import BasePage, BrowserUnavailable
__all__ = ['LoginPage']
class LoginPage(BasePage):
def login(self, login, passwd):
msgb = self.document.xpath(".//*[@id='message_client']/text()")

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class FortuneoTest(BackendTest):
BACKEND = 'fortuneo'

View file

@ -21,6 +21,7 @@
from logging import debug
from weboob.tools.test import BackendTest
class FourChanTest(BackendTest):
BACKEND = 'fourchan'

View file

@ -21,6 +21,7 @@
from weboob.tools.test import BackendTest
from weboob.capabilities.video import BaseVideo
class PluzzTest(BackendTest):
BACKEND = 'francetelevisions'

View file

@ -37,6 +37,7 @@ class LoginPage(BasePage):
self.browser['LoginPortletFormPassword1'] = passwd.encode(self.browser.ENCODING)
self.browser.submit(nologin=True)
class AccountsPage(BasePage):
ACCOUNT_TYPES = {u'Solde des comptes bancaires - Groupama Banque': Account.TYPE_CHECKING,
u'Epargne bancaire constituée - Groupama Banque': Account.TYPE_SAVINGS,
@ -89,6 +90,7 @@ class Transaction(FrenchTransaction):
(re.compile('(?P<text>Int .*)'), FrenchTransaction.TYPE_BANK),
]
class TransactionsPage(BasePage):
def get_history(self):
count = 0

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class GanAssurancesTest(BackendTest):
BACKEND = 'ganassurances'

View file

@ -19,6 +19,7 @@
from weboob.tools.test import BackendTest
class GazelleTest(BackendTest):
BACKEND = 'gazelle'

View file

@ -37,6 +37,7 @@ from .video import GDCVaultVideo
__all__ = ['VideoPage']
class VideoPage(BasePage):
def get_video(self, video=None):
if video is None:

View file

@ -41,4 +41,3 @@ class GDCVaultVideo(BaseVideo):
if m:
return u'http://www.gdcvault.com/play/%s#slides' % _id
return u'http://www.gdcvault.com/play/%s' % _id

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class GeolocIPTest(BackendTest):
BACKEND = 'geolocip'

View file

@ -23,6 +23,8 @@ from weboob.tools.browser import BaseBrowser
from .pages import ValidationPage, HomePage, HistoryPage, StoryPage, AuthorPage
# Browser
class HDSBrowser(BaseBrowser):
ENCODING = 'ISO-8859-1'
DOMAIN = 'histoires-de-sexe.net'

View file

@ -33,6 +33,7 @@ __all__ = ['HSBC']
class NotLoggedPage(BasePage):
pass
class HSBC(BaseBrowser):
DOMAIN = 'client.hsbc.fr'
PROTOCOL = 'https'

View file

@ -73,6 +73,7 @@ class AccountsListPage(BasePage):
return iter(accounts)
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile('^VIR(EMENT)? (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER),
(re.compile('^PRLV (?P<text>.*)'), FrenchTransaction.TYPE_ORDER),
@ -85,6 +86,7 @@ class Transaction(FrenchTransaction):
(re.compile('^REMISE (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
]
class HistoryPage(BasePage):
def get_next_link(self):
return None
@ -92,6 +94,7 @@ class HistoryPage(BasePage):
def get_operations(self, num_page, date_guesser):
raise NotImplementedError()
class CPTHistoryPage(HistoryPage):
def get_operations(self, num_page, date_guesser):
for script in self.document.getiterator('script'):
@ -105,6 +108,7 @@ class CPTHistoryPage(HistoryPage):
op._coming = (re.match('\d+/\d+/\d+', m.group(2)) is None)
yield op
class CardHistoryPage(HistoryPage):
def get_next_link(self):
ok = False

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class HSBCTest(BackendTest):
BACKEND = 'hsbc'

View file

@ -218,6 +218,8 @@ dict_hex = {'&#xE1;': u'á',
'&#xE2;': u'â',
'&#xE7;': u'ç'
}
def latin2unicode(word):
for key in dict_hex.keys():
word = word.replace(key,dict_hex[key])

View file

@ -187,6 +187,7 @@ class PersonPage(BasePage):
person.thumbnail_url = thumbnail_url
return person
class FilmographyPage(BasePage):
''' Page of detailed filmography of a person, sorted by type of role
This page is easier to parse than the main person page filmography

View file

@ -19,6 +19,7 @@
from weboob.tools.test import BackendTest
class ImdbTest(BackendTest):
BACKEND = 'imdb'

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class INATest(BackendTest):
BACKEND = 'ina'

View file

@ -31,6 +31,7 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
__all__ = ['AccountsList']
class Transaction(FrenchTransaction):
PATTERNS = [(re.compile(u'^retrait dab (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{4}) (?P<text>.*)'), FrenchTransaction.TYPE_WITHDRAWAL),
(re.compile(u'^carte (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{4}) (?P<text>.*)'), Transaction.TYPE_CARD),

View file

@ -23,6 +23,7 @@ from weboob.tools.capabilities.messages.GenericBackend import GenericNewspaperBa
from .browser import NewspaperInrocksBrowser
from .tools import rssid
class NewspaperInrocksBackend(GenericNewspaperBackend, ICapMessages):
MAINTAINER = u'Julien Hebert'
EMAIL = 'juke@free.fr'

View file

@ -23,6 +23,7 @@ from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage, t
try_remove_from_selector_list, \
drop_comments, NoneMainDiv
class ArticlePage(GenericNewsPage):
"ArticlePage object for inrocks"
def on_loaded(self):

View file

@ -20,6 +20,7 @@
from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage
class InrocksTvPage(GenericNewsPage):
"ArticlePage object for inrocks"
def on_loaded(self):

View file

@ -20,6 +20,7 @@
import re
def id2url(_id):
"return an url from an id"
regexp2 = re.compile("(\w+).([0-9]+).(.*$)")

View file

@ -50,12 +50,12 @@ class IpinfodbBackend(BaseBackend, ICapGeolocIp):
if 'Invalid IP or domain name' in content:
raise Exception('Bad parameter')
else:
tab = {'City' : 'NA' ,\
'Country name' : 'NA' ,\
'Region' : 'NA' ,\
'Latitude' : 'NA' ,\
'Longitude' : 'NA' ,\
'hostname' : 'NA' ,\
tab = {'City' : 'NA' ,
'Country name' : 'NA' ,
'Region' : 'NA' ,
'Latitude' : 'NA' ,
'Longitude' : 'NA' ,
'hostname' : 'NA' ,
'zipcode' : 'NA'}
line = ''
for line in content.split('\n'):

View file

@ -20,6 +20,7 @@
from weboob.tools.test import BackendTest
class IpinfodbTest(BackendTest):
BACKEND = 'ipinfodb'

View file

@ -21,6 +21,7 @@ from weboob.tools.test import BackendTest
from random import choice
class IsohuntTest(BackendTest):
BACKEND = 'isohunt'

View file

@ -125,7 +125,7 @@ class TorrentPage(BasePage):
for span in self.document.getiterator('span'):
# sometimes there are others span, this is not so sure but the size of the children list
# is enough to know if this is the right span
if (span.attrib.get('class', '') == 'folder' \
if (span.attrib.get('class', '') == 'folder'
or span.attrib.get('class', '') == 'folderopen') \
and len(span.getchildren()) > 2:
size = span.getchildren()[1].tail

View file

@ -23,6 +23,7 @@ from weboob.capabilities.base import NotLoaded
import urllib
from random import choice
class KickassTest(BackendTest):
BACKEND = 'kickass'

View file

@ -63,7 +63,7 @@ class LCLBrowser(BaseBrowser):
assert self.agency.isdigit()
if not self.is_on_page(LoginPage):
self.location('%s://%s/outil/UAUT/Authentication/authenticate' \
self.location('%s://%s/outil/UAUT/Authentication/authenticate'
% (self.PROTOCOL, self.DOMAIN),
no_login=True)
@ -71,7 +71,7 @@ class LCLBrowser(BaseBrowser):
not self.is_logged() or \
(self.is_on_page(LoginPage) and self.page.is_error()) :
raise BrowserIncorrectPassword("invalid login/password.\nIf you did not change anything, be sure to check for password renewal request\non the original web site.\nAutomatic renewal will be implemented later.")
self.location('%s://%s/outil/UWSP/Synthese' \
self.location('%s://%s/outil/UWSP/Synthese'
% (self.PROTOCOL, self.DOMAIN),
no_login=True)

View file

@ -136,6 +136,7 @@ class ContractsPage(BasePage):
self.browser.select_form(predicate=lambda form: form.attrs.get('id', '') == 'mainForm')
self.browser.submit()
class AccountsPage(BasePage):
def on_loaded(self):
warn = self.document.xpath('//div[@id="attTxt"]')
@ -222,6 +223,7 @@ class Transaction(FrenchTransaction):
(re.compile('^(?P<category>REM CHQ) (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
]
class AccountHistoryPage(BasePage):
def get_table(self):
tables=self.document.findall("//table[@class='tagTab pyjama']")
@ -303,6 +305,7 @@ class AccountHistoryPage(BasePage):
operations.append(operation)
return operations
class CBHistoryPage(AccountHistoryPage):
def get_table(self):
# there is only one table on the page
@ -320,6 +323,7 @@ class CBHistoryPage(AccountHistoryPage):
tr.type = tr.TYPE_CARD
yield tr
class CBListPage(CBHistoryPage):
def get_cards(self):
cards = []

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