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

[ovh] Syntax for pep8 + cosmetic changes

parent 04970b09
......@@ -16,6 +16,9 @@
#
# 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
import time
from requests.exceptions import HTTPError, TooManyRedirects
from datetime import datetime, timedelta
......@@ -30,8 +33,11 @@ from .pages import LoginPage, ProfilePage, BillsPage
class OvhBrowser(LoginBrowser, StatesMixin):
BASEURL = 'https://www.ovh.com'
login = URL(r'/auth/',
r'/manager/web/', LoginPage)
login = URL(
r'/auth/',
r'/manager/web/',
LoginPage,
)
profile = URL(r'/engine/api/me', ProfilePage)
documents = URL(r'/engine/2api/sws/billing/bills\?count=0&date=(?P<fromDate>.*)&dateTo=(?P<toDate>.*)&offset=0', BillsPage)
......@@ -66,8 +72,7 @@ class OvhBrowser(LoginBrowser, StatesMixin):
if not self.page.is_logged():
raise BrowserIncorrectPassword("Login / Password or authentication pin_code incorrect")
else:
return
return
self.login.go()
......@@ -89,9 +94,13 @@ class OvhBrowser(LoginBrowser, StatesMixin):
@need_login
def get_subscription_list(self):
return self.profile.stay_or_go().get_subscriptions()
self.profile.stay_or_go()
return self.page.get_subscriptions()
@need_login
def iter_documents(self, subscription):
return self.documents.stay_or_go(fromDate=(datetime.now() - timedelta(days=2*365)).strftime("%Y-%m-%dT00:00:00Z"),
toDate=time.strftime("%Y-%m-%dT%H:%M:%S.999Z")).get_documents(subid=subscription.id)
self.documents.stay_or_go(
fromDate=(datetime.now() - timedelta(days=2 * 365)).strftime("%Y-%m-%dT00:00:00Z"),
toDate=time.strftime("%Y-%m-%dT%H:%M:%S.999Z"),
)
return self.page.get_documents(subid=subscription.id)
......@@ -37,9 +37,11 @@ class OvhModule(Module, CapDocument):
EMAIL = 'vparedes@budget-insight.com'
LICENSE = 'LGPLv3+'
VERSION = '1.6'
CONFIG = BackendConfig(Value('login', label='Account ID'),
ValueBackendPassword('password', label='Password'),
Value('pin_code', label='Code PIN / Email', required=False, default=''))
CONFIG = BackendConfig(
ValueBackendPassword('login', label='Account ID'),
ValueBackendPassword('password', label='Password'),
Value('pin_code', label='Code PIN / Email', required=False, default=''),
)
BROWSER = OvhBrowser
......
......@@ -48,7 +48,7 @@ class LoginPage(HTMLPage):
return CleanText('//form[@class="pagination-centered"]/div[@class="error"]')(self.doc)
# There is 2 double auth method
# One activated by the user, that we don't handle,
# One activated by the user, that we don't handle,
# The other, spawning sometimes at first login, that we can handle.
def check_user_double_auth(self):
......
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