Skip to content
Commits on Source (12)
......@@ -141,7 +141,7 @@ def push_content(self, content):
# add the note to user history
# t= is supposed to be unique? a constant works fine
self.socket.open(note=content.id, t='WEBOOB')
self.socket.open(note=content.id, t='WOOB')
return content
# deleting a note is done in /socket.io route
......
......@@ -32,7 +32,7 @@
class CodimdModule(Module, CapContent):
NAME = 'codimd'
DESCRIPTION = 'CodiMD'
DESCRIPTION = 'HedgeDoc'
MAINTAINER = 'Vincent A'
EMAIL = 'dev@indigo.re'
LICENSE = 'LGPLv3+'
......@@ -41,7 +41,7 @@ class CodimdModule(Module, CapContent):
BROWSER = CodimdBrowser
CONFIG = BackendConfig(
Value('baseurl', label='URL of the CodiMD instance', default='https://hackmd.io/'),
Value('baseurl', label='URL of the HedgeDoc instance', default='https://demo.hedgedoc.org/'),
ValueBackendPassword('login', label='Email or LDAP username', default=''),
ValueBackendPassword('password', label='Password', default=''),
)
......
......@@ -46,7 +46,7 @@ class NotePage(RawPage):
def get_title(self):
return unquote(
re.search(
r'filename=(?P<q>"?)(?P<name>.*?)(?P=q)',
r'filename=(?P<q>"?)(?P<name>.*?)(?P=q)(;|$)',
self.response.headers['Content-Disposition']
)['name']
)
......
......@@ -26,6 +26,10 @@
class CodimdTest(BackendTest):
MODULE = 'codimd'
def login_cb(self, backend_name, value):
# accept empty credentials, that should be ok for features.md on the main domain
return ''
def test_get_simple(self):
content = self.backend.get_content('features')
assert content
......@@ -34,4 +38,8 @@ def test_get_simple(self):
assert content.title == 'Features.md'
assert content.content
assert content.content.startswith('# Features')
assert (
content.content.startswith('# Features')
# newer versions have yaml frontmatter
or '\n# Features' in content.content
)
......@@ -156,12 +156,8 @@ def _history_on_page(self):
if not script_l:
return
script = script_l[0].text
jvalues = re.search(r"window.x_axis_values=([^;]+)", script)[1]
xvalues = json.loads(jvalues)
jvalues = re.search(r"window.y_axis_values=([^;]+)", script)[1]
yvalues = json.loads(jvalues)
xvalues = json.loads(script_l[0].attrib["data-x-axis-values"])
yvalues = json.loads(script_l[0].attrib["data-y-axis-values"])
xvalues, yvalues = self._tweak_values(xvalues, yvalues)
if all(yv == 0 for yv in yvalues):
......
......@@ -21,8 +21,9 @@
from woob.browser import LoginBrowser, URL, need_login
from woob.exceptions import BrowserIncorrectPassword, BrowserUnavailable
from woob.tools.capabilities.bill.documents import sorted_documents, merge_iterators
from .pages import LoginPage, HomePage, ConsolePage, SuiviPage, DocumentsPage, ProfilePage
from .pages import LoginPage, HomePage, ConsolePage, SuiviPage, DocumentsPage, ProfilePage, ContractPage
class FreeBrowser(LoginBrowser):
......@@ -35,6 +36,7 @@ class FreeBrowser(LoginBrowser):
documents = URL(r'/liste-factures.pl(?P<urlid>.*)', DocumentsPage)
profile = URL(r'/modif_infoscontact.pl(?P<urlid>.*)', ProfilePage)
address = URL(r'/show_adresse.pl(?P<urlid>.*)', ProfilePage)
contracts = URL(r"/afficher-cgv.pl(?P<urlid>.*)", ContractPage)
def __init__(self, *args, **kwargs):
LoginBrowser.__init__(self, *args, **kwargs)
......@@ -79,7 +81,14 @@ def get_subscription_list(self):
@need_login
def iter_documents(self, subscription):
return self.documents.stay_or_go(urlid=self.urlid).get_documents(subid=subscription.id)
self.contracts.stay_or_go(urlid=self.urlid)
contracts_iterator = sorted_documents(self.page.iter_documents(subscription_id=subscription.id))
self.documents.stay_or_go(urlid=self.urlid)
bills_iterator = sorted_documents(self.page.get_documents(subid=subscription.id))
for doc in merge_iterators(contracts_iterator, bills_iterator):
yield doc
@need_login
def get_profile(self):
......
......@@ -20,10 +20,10 @@
from __future__ import unicode_literals
from woob.browser.pages import HTMLPage, LoggedPage, RawPage
from woob.browser.filters.standard import CleanDecimal, CleanText, Env, Format, Regexp
from woob.browser.filters.standard import CleanDecimal, CleanText, Env, Format, Field, Eval, Regexp, QueryValue, Slugify, Date
from woob.browser.elements import ListElement, ItemElement, method
from woob.browser.filters.html import Attr
from woob.capabilities.bill import DocumentTypes, Bill, Subscription
from woob.browser.filters.html import Link
from woob.capabilities.bill import DocumentTypes, Bill, Subscription, Document
from woob.capabilities.profile import Profile
from woob.capabilities.base import NotAvailable
from woob.tools.date import parse_french_date
......@@ -88,9 +88,8 @@ class get_documents(ListElement):
class item(ItemElement):
klass = Bill
obj_id = Format('%s_%s', Env('subid'), Regexp(Attr('./span[1]/a', 'href'),
r'(?<=.facture=)([^*]+)'))
obj_url = Attr('./span[1]/a', 'href', default=NotAvailable)
obj_id = Format('%s_%s', Env('subid'), QueryValue(Field("url"), "no_facture"))
obj_url = Link("./span[1]/a", default=NotAvailable)
obj_date = Env('date')
obj_format = 'pdf'
obj_label = Format("Facture %s", CleanText("./span[2]"))
......@@ -114,3 +113,34 @@ def get_profile(self, subscriber):
def set_address(self, profile):
assert len(self.doc.xpath('//p/strong[contains(text(), " ")]')) == 1, 'There are several addresses.'
profile.address = CleanText('//p/strong[contains(text(), " ")]')(self.doc) or NotAvailable
class ContractPage(LoggedPage, HTMLPage):
@method
class iter_documents(ListElement):
item_xpath = (
'//div[has-class("monabo")]//ul[has-class("no_arrow")]/li[not(@class)]//a'
)
class item(ItemElement):
klass = Document
obj_url = Link(".")
obj_date = Date(
CleanText(
'ancestor::div[contains(@class, "monabo")]//strong/span[@class="red"]'
),
dayfirst=True,
)
obj_id = Format(
"%s_%s_%s",
Env("subscription_id"),
Eval(lambda t: t.strftime("%Y%m%d"), Field("date")),
Slugify(Regexp(Field("url"), r"([^/]+)\.pdf")),
)
obj_type = DocumentTypes.CONTRACT
obj_label = Format(
"%s (%s)",
CleanText("ancestor::li"),
Regexp(Field("url"), r"([^/]+)\.pdf"),
)
obj_format = "pdf"
......@@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
# flake8: compatible
from base64 import b64decode, b64encode
import math
from io import BytesIO
......@@ -29,10 +31,9 @@
class LutimBrowser(PagesBrowser):
BASEURL = 'https://lut.im'
VERIFY = False # XXX SNI is not supported
image_page = URL('/(?P<id>.+)', ImagePage)
upload_page = URL('/', UploadPage)
image_page = URL('(?P<id>.+)', ImagePage)
upload_page = URL('', UploadPage)
def __init__(self, base_url, *args, **kw):
PagesBrowser.__init__(self, *args, **kw)
......@@ -46,12 +47,12 @@ def fetch(self, paste):
def post(self, paste, max_age=0):
bin = b64decode(paste.contents)
name = paste.title or 'file' # filename is mandatory
name = paste.title or 'file' # filename is mandatory
filefield = {'file': (name, BytesIO(bin))}
params = {'format': 'json'}
if max_age:
params['delete-day'] = int(math.ceil(max_age / 86400.))
self.location('/', data=params, files=filefield)
self.location(self.BASEURL, data=params, files=filefield)
assert self.upload_page.is_here()
info = self.page.fetch_info()
paste.id = urljoin(self.base_url, info['short'])
......@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
# flake8: compatible
import re
......@@ -34,7 +35,7 @@
class LutimModule(Module, CapPaste):
NAME = 'lutim'
DESCRIPTION = u'lutim website'
DESCRIPTION = u"Lutim (Let's Upload That IMage)"
MAINTAINER = u'Vincent A'
EMAIL = 'dev@indigo.re'
LICENSE = 'AGPLv3+'
......@@ -42,7 +43,7 @@ class LutimModule(Module, CapPaste):
BROWSER = LutimBrowser
CONFIG = BackendConfig(Value('base_url', label='Hoster base URL', default='https://lut.im/'))
CONFIG = BackendConfig(Value('base_url', label='Hoster base URL'))
@property
def base_url(self):
......@@ -58,9 +59,9 @@ def can_post(self, contents, title=None, public=None, max_age=None):
if public:
return 0
elif max_age and max_age < 86400:
return 0 # it cannot be shorter than one day
return 0 # it cannot be shorter than one day
elif re.search(r'[^a-zA-Z0-9=+/\s]', contents):
return 0 # not base64, thus not binary
return 0 # not base64, thus not binary
else:
mime = image_mime(contents, ('gif', 'jpeg', 'png'))
return 20 * int(mime is not None)
......
......@@ -17,8 +17,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
# flake8: compatible
import re
from woob.browser.pages import JsonPage, RawPage
from woob.capabilities.base import UserError
......
# -*- coding: utf-8 -*-
# Copyright(C) 2010-2014 Florent Fourcot
# Copyright(C) 2021 Florent Fourcot
#
# 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 Affero General Public License as published by
# 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 Affero General Public License for more details.
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# You should have received a copy of the GNU Lesser General Public License
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from .module import SachsenLevelModule
from .module import PayFitModule
__all__ = ['SachsenLevelModule']
__all__ = ['PayFitModule']
# -*- coding: utf-8 -*-
# Copyright(C) 2021 Florent Fourcot
#
# 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 <http://www.gnu.org/licenses/>.
from woob.browser import LoginBrowser, need_login, URL
from woob.browser.exceptions import ClientError
from woob.browser.profiles import Firefox
from woob.exceptions import BrowserIncorrectPassword
from woob.capabilities.base import find_object
from woob.capabilities.bill import DocumentNotFound
from .pages import LoginPage, AccountListPage, UserInfoPage, DocumentsPage, CategoryPage
class PayFitBrowser(LoginBrowser):
BASEURL = 'https://api.payfit.com/'
PROFILE = Firefox()
login = URL('/auth/signin', LoginPage)
account_list = URL('/hr/individuals/accounts/list', AccountListPage) # GET
user_info = URL('/hr/user/info', UserInfoPage) # POST
set_account = URL('/auth/updateCurrentAccount')
document_list = URL('/files/files', DocumentsPage)
category_info = URL('/files/category', CategoryPage)
download = URL(r'/files/file/(?P<id>\w+)\?attachment=1')
def do_login(self):
data = {"email": self.username,
"password": self.password,
"remember": False}
try:
self.login.go(json=data)
except ClientError:
raise BrowserIncorrectPassword()
@need_login
def iter_documents(self, subscription):
employee_id, company_id = subscription.id.split("-")
self.set_account.go(params={"companyId": company_id, "employeeId": employee_id})
self.category_info.go(params={"name": "payslip", "country": subscription._country})
payslip_id = self.page.get_id()
self.document_list.go(json={"employeeIds": [employee_id],
"companyIds": [company_id],
"categoryIds": [payslip_id]})
yield from self.page.iter_documents()
@need_login
def iter_subscription(self):
self.account_list.go()
for company, employee in self.page.iter_accounts():
self.set_account.go(params={"companyId": company["id"], "employeeId": employee["id"]})
self.user_info.go(data={})
yield from self.page.get_subscription(company, employee)
@need_login
def get_document(self, id):
return find_object(self.iter_documents(None), id=id,
error=DocumentNotFound)
# -*- coding: utf-8 -*-
# Copyright(C) 2021 Florent Fourcot
#
# 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 <http://www.gnu.org/licenses/>.
import hashlib
import hmac
from woob.tools.backend import Module, BackendConfig
from woob.capabilities.base import find_object
from woob.capabilities.bill import CapDocument, SubscriptionNotFound,\
Document, DocumentNotFound
from woob.tools.value import Value, ValueBackendPassword
from .browser import PayFitBrowser
__all__ = ['PayFitModule']
class PayFitModule(Module, CapDocument):
NAME = 'payfit'
DESCRIPTION = 'payfit website'
MAINTAINER = 'Florent Fourcot'
EMAIL = 'woob@flo.fourcot.fr'
LICENSE = 'LGPLv3+'
VERSION = '3.1'
BROWSER = PayFitBrowser
CONFIG = BackendConfig(Value('login', label='Email address', required=True),
ValueBackendPassword('password', label='Password'))
def create_default_browser(self):
mac = hmac.new(self.config['password'].get().encode(), msg=b'', digestmod=hashlib.sha256)
return self.create_browser(self.config['login'].get(), mac.hexdigest())
def get_document(self, _id):
_, sub_id = _id.split("-", maxsplit=1)
return find_object(self.iter_documents(sub_id), id=_id,
error=DocumentNotFound)
def get_subscription(self, _id):
return find_object(self.browser.iter_subscription(), id=_id,
error=SubscriptionNotFound)
def iter_documents(self, subscription):
if isinstance(subscription, str):
subscription = self.get_subscription(subscription)
return self.browser.iter_documents(subscription)
def iter_subscription(self):
return self.browser.iter_subscription()
def download_document(self, doc):
if not isinstance(doc, Document):
doc = self.get_document(doc)
return self.browser.open(doc.url).content
# -*- coding: utf-8 -*-
# Copyright(C) 2021 Florent Fourcot
#
# 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 <http://www.gnu.org/licenses/>.
from woob.browser.pages import LoggedPage, JsonPage
from woob.browser.elements import ItemElement, DictElement, method
from woob.browser.filters.json import Dict
from woob.capabilities.bill import Subscription, Document
from woob.browser.filters.standard import Date, BrowserURL, Format
class LoginPage(JsonPage):
pass
class UserInfoPage(LoggedPage, JsonPage):
def get_subscription(self, company, employee):
subscription = Subscription()
subscription.id = f"{employee['id']}-{company['id']}"
subscription.label = f"{self.get('jobName')} - {self.get('companyName')}"
subscription.subscriber = self.get('fullName')
subscription._country = self.get('companyCountry')
yield subscription
class AccountListPage(LoggedPage, JsonPage):
def iter_accounts(self):
for account in self.doc:
employee = account["accountInfo"]
company = account["companyInfo"]
if "employeeId" not in account["account"]:
continue
employee["id"] = account["account"]["employeeId"]
company["id"] = account["account"]["companyId"]
yield company, employee
class DocumentsPage(LoggedPage, JsonPage):
@method
class iter_documents(DictElement):
class item(ItemElement):
klass = Document
obj_date = Date(Dict('createdAt'))
obj_format = Dict('type')
obj_label = Dict('name')
obj_id = Format("%s-%s-%s", Dict('id'), Dict('employeeId'), Dict('companyId'))
obj_url = BrowserURL('download', id=Dict('id'))
class CategoryPage(LoggedPage, JsonPage):
def get_id(self):
return self.get('id')
"NewspaperPresseuropModule init"
# -*- coding: utf-8 -*-
# Copyright(C) 2012 Florent Fourcot
#
# 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 Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from .module import NewspaperPresseuropModule
__all__ = ['NewspaperPresseuropModule']
"browser for presseurop website"
# -*- coding: utf-8 -*-
# Copyright(C) 2012 Florent Fourcot
#
# 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 Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from datetime import date, datetime, time
from .pages import PresseuropPage
from woob.browser.browsers import AbstractBrowser
from woob.browser.url import URL
class NewspaperPresseuropBrowser(AbstractBrowser):
"NewspaperPresseuropBrowser class"
PARENT = 'genericnewspaper'
BASEURL = 'http://www.voxeurop.eu'
presseurop_page = URL("/.*", PresseuropPage)
def __init__(self, *args, **kwargs):
self.weboob = kwargs['weboob']
super(NewspaperPresseuropBrowser, self).__init__(*args, **kwargs)
def get_daily_date(self, _id):
self.location(_id)
return self.page.get_daily_date()
def get_daily_infos(self, _id):
url = "http://www.voxeurop.eu/fr/today/" + _id
self.location(url)
title = self.page.get_title()
article_date = date(*[int(x)
for x in _id.split('-')])
article_time = time(0, 0, 0)
article_datetime = datetime.combine(article_date, article_time)
return url, title, article_datetime
# -*- coding: utf-8 -*-
# Copyright(C) 2012 Florent Fourcot
#
# 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 Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
"backend for http://www.presseurop.eu"
from woob.capabilities.messages import CapMessages, Thread
from woob.tools.backend import AbstractModule
from woob.tools.backend import BackendConfig
from woob.tools.value import Value
from .browser import NewspaperPresseuropBrowser
from .tools import rssid, url2id
from woob.tools.newsfeed import Newsfeed
class NewspaperPresseuropModule(AbstractModule, CapMessages):
MAINTAINER = u'Florent Fourcot'
EMAIL = 'weboob@flo.fourcot.fr'
VERSION = '3.1'
LICENSE = 'AGPLv3+'
STORAGE = {'seen': {}}
NAME = 'presseurop'
DESCRIPTION = u'Presseurop website'
BROWSER = NewspaperPresseuropBrowser
RSSID = staticmethod(rssid)
URL2ID = staticmethod(url2id)
RSSSIZE = 300
PARENT = 'genericnewspaper'
CONFIG = BackendConfig(Value('lang', label='Lang of articles',
choices={'fr': 'fr', 'de': 'de', 'en': 'en',
'cs': 'cs', 'es': 'es', 'it': 'it', 'nl': 'nl',
'pl': 'pl', 'pt': 'pt', 'ro': 'ro'},
default='fr'))
def __init__(self, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)
self.RSS_FEED = 'http://www.voxeurop.eu/%s/rss.xml' % self.config['lang'].get()
def iter_threads(self):
daily = []
for article in Newsfeed(self.RSS_FEED, self.RSSID).iter_entries():
if "/news-brief/" in article.link:
day = self.browser.get_daily_date(article.link)
if day and (day not in daily):
localid = url2id(article.link)
daily.append(day)
id, title, date = self.browser.get_daily_infos(day)
id = id + "#" + localid
thread = Thread(id)
thread.title = title
thread.date = date
yield(thread)
elif day is None:
thread = Thread(article.link)
thread.title = article.title
thread.date = article.datetime
yield(thread)
else:
thread = Thread(article.link)
thread.title = article.title
thread.date = article.datetime
yield(thread)
"ArticlePage object for presseurope"
# -*- coding: utf-8 -*-
# Copyright(C) 2012 Florent Fourcot
#
# 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 Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from woob.browser.pages import AbstractPage
from woob.browser.filters.html import CSS, CleanHTML
class PresseuropPage(AbstractPage):
"PresseuropPage object for presseurop"
_selector = CSS
PARENT = 'genericnewspaper'
PARENT_URL = 'generic_news_page'
def on_loaded(self):
self.main_div = self.doc.getroot()
self.element_title_selector = "title"
self.element_author_selector = "a[rel=author], div.profilecartoontext>p>a"
self.element_body_selector = "div.block, div.panel, div.bodytext"
def get_body(self):
element_body = self.get_element_body()
self.try_drop_tree(element_body, "li.button-social")
self.try_drop_tree(element_body, "div.sharecount")
self.try_drop_tree(element_body, "p.ruledtop")
self.try_drop_tree(element_body, "p.ctafeedback")
self.try_drop_tree(element_body, "aside.articlerelated")
self.try_drop_tree(element_body, "div.sharecount")
self.try_drop_tree(element_body, "iframe")
self.clean_relativ_urls(element_body, "http://presseurop.eu")
return CleanHTML('.')(element_body)
def get_title(self):
title = super(self.__class__, self).get_title()
title = title.split('|')[0]
return title
def get_author(self):
author = super(self.__class__, self).get_author()
try:
source = self.doc.getroot().xpath(
"//span[@class='sourceinfo']/a")[0]
source = source.text
author = author + " | " + source
return author
except:
return author
def get_daily_date(self):
plink = self.doc.getroot().xpath("//p[@class='w200']")
if len(plink) > 0:
link = plink[0].xpath('a')[0]
date = link.attrib['href'].split('/')[3]
return date
return None
# -*- coding: utf-8 -*-
# Copyright(C) 2012 Florent Fourcot
#
# 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 Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from woob.tools.test import BackendTest
from woob.tools.value import Value
class PresseuropTest(BackendTest):
MODULE = 'presseurop'
def setUp(self):
if not self.is_backend_configured():
self.backend.config['lang'] = Value(value='fr')
def test_new_messages(self):
for message in self.backend.iter_unread_messages():
pass