Commit a685c04d authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[orange] Syntax for pep8 + cosmetic changes

parent 11a35ddc
......@@ -38,28 +38,35 @@ __all__ = ['OrangeBillBrowser']
class OrangeBillBrowser(LoginBrowser):
BASEURL = 'https://espaceclientv3.orange.fr'
home_page = URL('https://businesslounge.orange.fr/$', HomePage)
loginpage = URL('https://login.orange.fr/\?service=sosh&return_url=https://www.sosh.fr/',
'https://login.orange.fr/front/login', LoginPage)
home_page = URL(r'https://businesslounge.orange.fr/$', HomePage)
loginpage = URL(
r'https://login.orange.fr/\?service=sosh&return_url=https://www.sosh.fr/',
r'https://login.orange.fr/front/login',
LoginPage,
)
password_page = URL(r'https://login.orange.fr/front/password', PasswordPage)
contracts = URL('https://espaceclientpro.orange.fr/api/contracts\?page=1&nbcontractsbypage=15', ContractsPage)
contracts = URL(r'https://espaceclientpro.orange.fr/api/contracts\?page=1&nbcontractsbypage=15', ContractsPage)
subscriptions = URL(r'https://espaceclientv3.orange.fr/js/necfe.php\?zonetype=bandeau&idPage=gt-home-page', SubscriptionsPage)
manage_cgi = URL('https://eui.orange.fr/manage_eui/bin/manage.cgi', ManageCGI)
manage_cgi = URL(r'https://eui.orange.fr/manage_eui/bin/manage.cgi', ManageCGI)
# is billspage deprecated ?
billspage = URL('https://m.espaceclientv3.orange.fr/\?page=factures-archives',
'https://.*.espaceclientv3.orange.fr/\?page=factures-archives',
'https://espaceclientv3.orange.fr/\?page=factures-archives',
'https://espaceclientv3.orange.fr/\?page=facture-telecharger',
'https://espaceclientv3.orange.fr/maf.php',
'https://espaceclientv3.orange.fr/\?idContrat=(?P<subid>.*)&page=factures-historique',
'https://espaceclientv3.orange.fr/\?page=factures-historique&idContrat=(?P<subid>.*)',
BillsPage)
bills_api_pro = URL('https://espaceclientpro.orange.fr/api/contract/(?P<subid>\d+)/bills\?count=(?P<count>)',
BillsApiProPage)
billspage = URL(
r'https://m.espaceclientv3.orange.fr/\?page=factures-archives',
r'https://.*.espaceclientv3.orange.fr/\?page=factures-archives',
r'https://espaceclientv3.orange.fr/\?page=factures-archives',
r'https://espaceclientv3.orange.fr/\?page=facture-telecharger',
r'https://espaceclientv3.orange.fr/maf.php',
r'https://espaceclientv3.orange.fr/\?idContrat=(?P<subid>.*)&page=factures-historique',
r'https://espaceclientv3.orange.fr/\?page=factures-historique&idContrat=(?P<subid>.*)',
BillsPage,
)
bills_api_pro = URL(
r'https://espaceclientpro.orange.fr/api/contract/(?P<subid>\d+)/bills\?count=(?P<count>)',
BillsApiProPage,
)
bills_api_par = URL(r'https://sso-f.orange.fr/omoi_erb/facture/v2.0/billsAndPaymentInfos/users/current/contracts/(?P<subid>\d+)', BillsApiParPage)
doc_api_par = URL(r'https://sso-f.orange.fr/omoi_erb/facture/v1.0/pdf')
......@@ -67,6 +74,10 @@ class OrangeBillBrowser(LoginBrowser):
doc_api_pro = URL('https://espaceclientpro.orange.fr/api/contract/(?P<subid>\d+)/bill/(?P<dir>.*)/(?P<fact_type>.*)/\?(?P<billparams>)')
profile = URL('/\?page=profil-infosPerso', ProfilePage)
def __init__(self, *args, **kwargs):
super(OrangeBillBrowser, self).__init__(*args, **kwargs)
self.is_new_website = False
def do_login(self):
assert isinstance(self.username, basestring)
assert isinstance(self.password, basestring)
......@@ -86,6 +97,11 @@ class OrangeBillBrowser(LoginBrowser):
if error_message:
raise BrowserPasswordExpired(error_message)
self.location(self.BASEURL)
print('location done / is_here : %s' % self.new_website.is_here())
if self.new_website.is_here():
self.is_new_website = True
def get_nb_remaining_free_sms(self):
raise NotImplementedError()
......
......@@ -17,13 +17,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this weboob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.capabilities.bill import DocumentTypes, CapDocument, Subscription, Document, SubscriptionNotFound, DocumentNotFound
from weboob.capabilities.base import find_object, NotAvailable
from weboob.capabilities.account import CapAccount
from weboob.capabilities.profile import CapProfile
from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import ValueBackendPassword, Value
from weboob.tools.value import ValueBackendPassword
from .browser import OrangeBillBrowser
......@@ -38,8 +39,10 @@ class OrangeModule(Module, CapAccount, CapDocument, CapProfile):
VERSION = '1.6'
DESCRIPTION = 'Orange French mobile phone provider'
LICENSE = 'LGPLv3+'
CONFIG = BackendConfig(Value('login', label='Login'),
ValueBackendPassword('password', label='Password'))
CONFIG = BackendConfig(
ValueBackendPassword('login', label='Login'),
ValueBackendPassword('password', label='Password'),
)
BROWSER = OrangeBillBrowser
def __init__(self, *args, **kwargs):
......@@ -49,7 +52,10 @@ class OrangeModule(Module, CapAccount, CapDocument, CapProfile):
accepted_document_types = (DocumentTypes.BILL,)
def create_default_browser(self):
return self.create_browser(self.config['login'].get(), self.config['password'].get())
return self.create_browser(
self.config['login'].get(),
self.config['password'].get(),
)
def iter_subscription(self):
return self.browser.get_subscription_list()
......
......@@ -52,7 +52,7 @@ class BillsApiProPage(LoggedPage, JsonPage):
class item(ItemElement):
klass = Bill
obj_date = Date(Dict('dueDate'), parse_func=parse_french_date, default=NotAvailable)
obj_date = Date(Dict('dueDate'), parse_func=parse_french_date, default=NotAvailable)
obj_price = CleanDecimal(Dict('amountIncludingTax'))
obj_format = 'pdf'
......@@ -78,7 +78,7 @@ class BillsApiParPage(LoggedPage, JsonPage):
class item(ItemElement):
klass = Bill
obj_date = Date(Dict('date'), default=NotAvailable)
obj_date = Date(Dict('date'), default=NotAvailable)
obj_price = Eval(lambda x: x / 100, CleanDecimal(Dict('amount')))
obj_format = 'pdf'
......@@ -109,7 +109,7 @@ class BillsPage(LoggedPage, HTMLPage):
klass = Bill
obj_type = DocumentTypes.BILL
obj_format = u"pdf"
obj_format = "pdf"
# TableCell('date') can have other info like: 'duplicata'
obj_date = Date(CleanText('./td[@headers="ec-dateCol"]/text()[not(preceding-sibling::br)]'), parse_func=parse_french_date, dayfirst=True)
......@@ -134,12 +134,12 @@ class BillsPage(LoggedPage, HTMLPage):
# Only when a list of documents is present
obj__url_base = Regexp(CleanText('.//ul[@class="liste"]/script', default=None), '.*?contentList[\d]+ \+= \'<li><a href=".*\"(.*?idDocument=2)"', default=None)
def obj_url(self):
if Field('_url_base')(self):
# URL won't work if HTML is not unescape
return HTMLParser().unescape(str(Field('_url_base')(self)))
else :
return Link(TableCell(Field('_cell')(self))(self)[0].xpath('./a'), default=NotAvailable)(self)
return Link(TableCell(Field('_cell')(self))(self)[0].xpath('./a'), default=NotAvailable)(self)
obj__label_base = Regexp(CleanText('.//ul[@class="liste"]/script', default=None), '.*</span>(.*?)</a.*', default=None)
......@@ -150,6 +150,7 @@ class BillsPage(LoggedPage, HTMLPage):
return CleanText(TableCell(Field('_cell')(self))(self)[0].xpath('.//span[@class="ec_visually_hidden"]'))(self)
obj__ht = CleanDecimal(TableCell('ht', default=NotAvailable), replace_dots=True, default=NotAvailable)
def obj_vat(self):
if Field('_ht')(self) is NotAvailable or Field('price')(self) is NotAvailable:
return
......
......@@ -44,11 +44,13 @@ class ProfilePage(LoggedPage, HTMLPage):
# Nom
# Prénom
if CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[contains(text(), "Civilité")]]')(self.doc):
pr.name = Format('%s %s %s',
CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[contains(text(), "Civilité")]]/following::span[1]'),
CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[contains(text(), "Nom :")]]/following::span[1]'),
CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[contains(text(), "Prénom :")]]/following::span[1]')
)(self.doc)
pr.name = Format(
'%s %s %s',
CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[contains(text(), "Civilité")]]/following::span[1]'),
CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[contains(text(), "Nom :")]]/following::span[1]'),
CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[contains(text(), "Prénom :")]]/following::span[1]')
)(self.doc)
# Prénom / Nom
elif CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[contains(text(), "Prénom / Nom")]]')(self.doc):
pr.name = CleanText('//p[contains(@class, "panelAccount-label")]/span[strong[contains(text(), "Prénom / Nom")]]/following::span[1]')(self.doc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment