Ho y܂RNA:l6H ^vb 953 x[R@Za
tĭ82KgrRse7"¡toK{VE
G}ㄯÅ J+v 3V@LA-F0<ϤG.Z/g]H;)ek˩qCetb]uzvhhce[tN:ޟVtfF`e`v(q}+8m[z>M-naUny>Rtu!A49p`5D:V~gޞw'}u5HEI5j.@1!`wprN*uW_3VP8U9Px8Â89mK)O_ľ+ ^7-Cj7)'8Mc+tOVH,lCnߚik;ziN:`-д86u<>T ^9>TVnDZ${r<KHAԎ|9- NŚ*=:vn%jϦ$iRlO9Wڔ{d[uһLb7CEiV`"+]h|LaP!\
}"9 ox"AI
֤l^
>
mZ@gacąn+h]*n0p8 ^&+~&3H:,
t9A`657L|^`Av0`fV`=NA["5iaEAh1438+>sJo~9/s0!9$:H8|dXj;|*|AdVDv>`3>&G9-}-5oys]&-OJGdx'n k+,)
g
k=-tm fpˑ,Q~tj' Z{յ8cܒOr0&ֿũb[RZ+SPqA 8vF#i{YsFgT:t'
#<6e#n~ozEs&;KJVtĻ/s'Y",S':k oks)JWIM"l\
s H!"<ڔ. 1<
&^h㯂Q5oEɔ`Q/0z3i8:."ȋh5lsG#`Y-Z?'@ 0=U,>:W(EQ̑H(, ®Yqx.#I3BQ
`kW3/G9LvJ(b6QE&fN)E=" [QcGH NCF_|iI^ޮT5sBmjV 2CI;?Yu IENDB` woob-6d52c0c92f2617476fe0b131c1eebba68676b2fb-modules-myfoncia/modules/myfoncia/module.py 0000664 0000000 0000000 00000005027 13514067645 0030140 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2017 Phyks (Lucas Verney)
#
# This file is part of a weboob module.
#
# This weboob 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 weboob 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 weboob module. If not, see .
from __future__ import unicode_literals
from weboob.tools.backend import Module, BackendConfig
from weboob.capabilities.base import find_object
from weboob.capabilities.bill import (CapDocument, Bill, DocumentNotFound,
Subscription)
from weboob.tools.value import Value, ValueBackendPassword
from .browser import MyFonciaBrowser
__all__ = ['MyFonciaModule']
class MyFonciaModule(Module, CapDocument):
NAME = 'myfoncia'
DESCRIPTION = u'Foncia billing capabilities'
MAINTAINER = u'Phyks (Lucas Verney)'
EMAIL = 'phyks@phyks.me'
LICENSE = 'LGPLv3+'
VERSION = '1.6'
CONFIG = BackendConfig(
Value(
'login',
label='Email address or Foncia ID'
),
ValueBackendPassword(
'password',
label='Password'
)
)
BROWSER = MyFonciaBrowser
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_subscriptions()
def iter_documents(self, subscription):
if isinstance(subscription, Subscription):
subscription_id = subscription.id
else:
subscription_id = subscription
return self.browser.get_documents(subscription_id)
def get_document(self, bill):
return find_object(
self.iter_documents(bill.split("#")[0]),
id=bill,
error=DocumentNotFound
)
def download_document(self, bill):
if not isinstance(bill, Bill):
bill = self.get_document(bill)
if not bill.url:
return None
return self.browser.open(bill.url).content
woob-6d52c0c92f2617476fe0b131c1eebba68676b2fb-modules-myfoncia/modules/myfoncia/pages.py 0000664 0000000 0000000 00000007164 13514067645 0027756 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2017 Phyks (Lucas Verney)
#
# This file is part of a weboob module.
#
# This weboob 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 weboob 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 weboob module. If not, see .
from __future__ import unicode_literals
from weboob.browser.pages import HTMLPage, LoggedPage
from weboob.browser.filters.standard import CleanDecimal, CleanText, Date, Env, Format
from weboob.browser.filters.html import Attr, Link, XPathNotFound
from weboob.browser.elements import ItemElement, ListElement, method
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.bill import Bill, Subscription
from weboob.tools.compat import urljoin
class LoginPage(HTMLPage):
def do_login(self, username, password):
form = self.get_form('//form[@class="Form"]')
form["username"] = username
form["_password"] = password
form.submit()
class MonBienPage(LoggedPage, HTMLPage):
@method
class get_subscriptions(ListElement):
item_xpath = '//li[has-class("MyPropertiesSelector-item") and not(has-class("MyPropertiesSelector-item--add"))]'
class item(ItemElement):
klass = Subscription
def obj_id(self):
link = Link('./a')(self)
return link[link.rfind('/') + 1:]
obj_label = Format(
'%s - %s (%s)',
CleanText('.//strong[has-class("MyPropertiesSelector-item-title")]'),
CleanText('.//span[has-class("MyPropertiesSelector-item-desc")][1]'),
CleanText('.//span[has-class("MyPropertiesSelector-item-desc")][last()]')
)
def obj_subscriber(self):
subscriber = CleanText('//a[has-class("MainNav-item-logged")]')(self)
subscriber = subscriber.replace('Bonjour', '').strip()
return subscriber
class MesChargesPage(LoggedPage, HTMLPage):
@method
class get_documents(ListElement):
item_xpath = '//article[@data-taffy="utility_record"]'
class item(ItemElement):
klass = Bill
obj_id = Format(
'%s#%s',
Env('subscription'),
Attr('.', 'id')
)
obj_price = CleanDecimal('.//span[has-class("nbPrice")]',
replace_dots=(',', '€'))
obj_currency = u'EUR'
def obj_income(self):
price = CleanText('.//span[has-class("nbPrice")]')(self)
return not price.startswith('−')
obj_label = CleanText('.//p[has-class("TeaserRow-desc")]')
obj_date = Date(CleanText('.//p[has-class("TeaserRow-date")]'),
dayfirst=True)
obj_duedate = obj_date
obj_format = "pdf"
def obj_url(self):
try:
return urljoin(
self.page.browser.BASEURL,
Link('.//a[has-class("Download")]')(self)
)
except XPathNotFound:
return NotAvailable
woob-6d52c0c92f2617476fe0b131c1eebba68676b2fb-modules-myfoncia/modules/myfoncia/test.py 0000664 0000000 0000000 00000003337 13514067645 0027634 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2017 Phyks (Lucas Verney)
#
# This file is part of a weboob module.
#
# This weboob 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 weboob 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 weboob module. If not, see .
from __future__ import unicode_literals
from weboob.tools.test import BackendTest
class MyFonciaTest(BackendTest):
MODULE = 'myfoncia'
def test_subscriptions(self):
"""
Test listing of subscriptions.
"""
subscriptions = list(self.backend.iter_subscription())
self.assertTrue(list(subscriptions), msg="Failed to list accounts.")
def test_documents(self):
"""
Test listing all available documents.
"""
for subscription in self.backend.iter_subscription():
documents = self.backend.iter_documents(subscription.id)
self.assertTrue(list(documents), msg="Failed to list documents.")
def test_download(self):
"""
Test downloading all documents.
"""
for subscription in self.backend.iter_subscription():
for bill in self.backend.iter_documents(subscription.id):
self.backend.download_document(bill.id)