pax_global_header 0000666 0000000 0000000 00000000064 14042356110 0014506 g ustar 00root root 0000000 0000000 52 comment=18d41565f955028f9fcd2f6cc437f5f1cb717401
woob-18d41565f955028f9fcd2f6cc437f5f1cb717401-modules-onlinenet/ 0000775 0000000 0000000 00000000000 14042356110 0022772 5 ustar 00root root 0000000 0000000 woob-18d41565f955028f9fcd2f6cc437f5f1cb717401-modules-onlinenet/modules/ 0000775 0000000 0000000 00000000000 14042356110 0024442 5 ustar 00root root 0000000 0000000 woob-18d41565f955028f9fcd2f6cc437f5f1cb717401-modules-onlinenet/modules/onlinenet/ 0000775 0000000 0000000 00000000000 14042356110 0026435 5 ustar 00root root 0000000 0000000 woob-18d41565f955028f9fcd2f6cc437f5f1cb717401-modules-onlinenet/modules/onlinenet/__init__.py 0000664 0000000 0000000 00000001513 14042356110 0030546 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2016 Edouard Lambert
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this woob module. If not, see .
from .module import OnlinenetModule
__all__ = ['OnlinenetModule']
woob-18d41565f955028f9fcd2f6cc437f5f1cb717401-modules-onlinenet/modules/onlinenet/browser.py 0000664 0000000 0000000 00000003221 14042356110 0030470 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2016 Edouard Lambert
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this woob module. If not, see .
from woob.browser import LoginBrowser, URL, need_login
from woob.exceptions import BrowserIncorrectPassword
from .pages import LoginPage, ProfilPage, DocumentsPage
class OnlinenetBrowser(LoginBrowser):
BASEURL = 'https://console.online.net/en/'
TIMEOUT = 60
login = URL('login', LoginPage)
profil = URL('account/edit', ProfilPage)
documents = URL('bill/list', DocumentsPage)
def do_login(self):
self.login.go()
self.page.login(self.username, self.password)
if self.login.is_here():
raise BrowserIncorrectPassword
@need_login
def get_subscription_list(self):
return self.profil.stay_or_go().get_list()
@need_login
def iter_documents(self, subscription):
for b in self.documents.stay_or_go().get_bills():
yield b
for d in self.documents.stay_or_go().get_documents():
yield d
woob-18d41565f955028f9fcd2f6cc437f5f1cb717401-modules-onlinenet/modules/onlinenet/module.py 0000664 0000000 0000000 00000005221 14042356110 0030274 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2016 Edouard Lambert
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this woob module. If not, see .
from __future__ import unicode_literals
from woob.capabilities.bill import DocumentTypes, CapDocument, Subscription, Document, SubscriptionNotFound, DocumentNotFound
from woob.capabilities.base import find_object, NotAvailable
from woob.tools.backend import Module, BackendConfig
from woob.tools.value import ValueBackendPassword, Value
from .browser import OnlinenetBrowser
__all__ = ['OnlinenetModule']
class OnlinenetModule(Module, CapDocument):
NAME = 'onlinenet'
DESCRIPTION = 'Online.net'
MAINTAINER = 'Edouard Lambert'
EMAIL = 'elambert@budget-insight.com'
LICENSE = 'LGPLv3+'
VERSION = '3.1'
CONFIG = BackendConfig(
Value('login', label='Identifiant'),
ValueBackendPassword('password', label='Mot de passe'),
)
BROWSER = OnlinenetBrowser
accepted_document_types = (DocumentTypes.BILL, DocumentTypes.OTHER,)
def create_default_browser(self):
return self.create_browser(self.config['login'].get(), self.config['password'].get())
def iter_subscription(self):
return self.browser.get_subscription_list()
def get_subscription(self, _id):
return find_object(self.iter_subscription(), id=_id, error=SubscriptionNotFound)
def get_document(self, _id):
subid = _id.rsplit('_', 1)[0]
subscription = self.get_subscription(subid)
return find_object(self.iter_documents(subscription), id=_id, error=DocumentNotFound)
def iter_documents(self, subscription):
if not isinstance(subscription, Subscription):
subscription = self.get_subscription(subscription)
return self.browser.iter_documents(subscription)
def download_document(self, document):
if not isinstance(document, Document):
document = self.get_document(document)
if document._url is NotAvailable:
return
return self.browser.open(document._url).content
woob-18d41565f955028f9fcd2f6cc437f5f1cb717401-modules-onlinenet/modules/onlinenet/pages.py 0000664 0000000 0000000 00000007205 14042356110 0030112 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2016 Edouard Lambert
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this woob module. If not, see .
from __future__ import unicode_literals
import re
from woob.browser.pages import HTMLPage, LoggedPage
from woob.browser.filters.standard import CleanText, CleanDecimal, Env, Format, Date
from woob.browser.filters.html import Attr, TableCell
from woob.browser.elements import ListElement, ItemElement, TableElement, method
from woob.capabilities.bill import DocumentTypes, Bill, Document, Subscription
from woob.capabilities.base import NotAvailable
class LoginPage(HTMLPage):
def login(self, login, password):
form = self.get_form('//form[contains(@action, "/login_check")]')
form['_username'] = login
form['_password'] = password
form.submit()
class ProfilPage(LoggedPage, HTMLPage):
@method
class get_list(ListElement):
class item(ItemElement):
klass = Subscription
obj_subscriber = Format(
'%s %s',
CleanText('//label[@for="form_firstname"]/../following-sibling::div'),
CleanText('//label[@for="form_firstname"]/../following-sibling::div')
)
obj_id = Env('username')
obj_label = obj_id
def parse(self, el):
self.env['username'] = self.page.browser.username
class DocumentsPage(LoggedPage, HTMLPage):
@method
class get_bills(TableElement):
item_xpath = '//h3[contains(text(), "bills")]/following-sibling::table//tr[position() > 1]'
head_xpath = '//h3[contains(text(), "bills")]/following-sibling::table//tr/th'
col_id = 'Id'
col_date = 'Date'
col_price = 'Total TTC'
class item(ItemElement):
klass = Bill
obj_id = Format('%s_%s', Env('username'), CleanDecimal(TableCell('id')))
obj__url = Attr('.//a[contains(text(), "PDF")]', 'href', default=NotAvailable)
obj_date = Date(CleanText(TableCell('date')))
obj_format = 'pdf'
obj_label = Format('Facture %s', CleanDecimal(TableCell('id')))
obj_type = DocumentTypes.BILL
obj_price = CleanDecimal(TableCell('price'))
obj_currency = 'EUR'
def condition(self):
return CleanText(TableCell('id'))(self) != "No bills"
def parse(self, el):
self.env['username'] = self.page.browser.username
@method
class get_documents(ListElement):
item_xpath = '//a[contains(@href, ".pdf")]'
class item(ItemElement):
klass = Document
obj_id = Format('%s_%s', Env('username'), Env('docid'))
obj__url = Attr('.', 'href')
obj_format = 'pdf'
obj_label = CleanText('.')
obj_type = DocumentTypes.OTHER
def parse(self, el):
self.env['username'] = self.page.browser.username
self.env['docid'] = re.sub('[^a-zA-Z0-9-_*.]', '', CleanText('.')(self))