pax_global_header 0000666 0000000 0000000 00000000064 13436457030 0014517 g ustar 00root root 0000000 0000000 52 comment=3863a14eedf17551743a8bbccf0237874d7f4a16
woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/ 0000775 0000000 0000000 00000000000 13436457030 0022504 5 ustar 00root root 0000000 0000000 woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/modules/ 0000775 0000000 0000000 00000000000 13436457030 0024154 5 ustar 00root root 0000000 0000000 woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/modules/hybride/ 0000775 0000000 0000000 00000000000 13436457030 0025602 5 ustar 00root root 0000000 0000000 woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/modules/hybride/__init__.py 0000664 0000000 0000000 00000001511 13436457030 0027711 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# 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 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 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from .module import HybrideModule
__all__ = ['HybrideModule']
woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/modules/hybride/browser.py 0000664 0000000 0000000 00000003142 13436457030 0027637 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# 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 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 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from .pages import ProgramPage, EventPage
from weboob.browser import PagesBrowser, URL
from weboob.browser.profiles import Firefox
__all__ = ['HybrideBrowser']
class HybrideBrowser(PagesBrowser):
PROFILE = Firefox()
BASEURL = 'http://www.lhybride.org/'
program_page = URL('programmation/a-venir.html', ProgramPage)
event_page = URL('programmation/item/(?P<_id>.*)', EventPage)
def list_events(self, date_from, date_to=None, city=None, categories=None):
return self.program_page.go().list_events(date_from=date_from,
date_to=date_to,
city=city,
categories=categories)
def get_event(self, _id, event=None):
return self.event_page.go(_id=_id).get_event(obj=event)
woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/modules/hybride/calendar.py 0000664 0000000 0000000 00000002317 13436457030 0027730 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# 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 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 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from weboob.capabilities.calendar import BaseCalendarEvent, TRANSP, STATUS, CATEGORIES
class HybrideCalendarEvent(BaseCalendarEvent):
def __init__(self):
BaseCalendarEvent.__init__(self)
self.city = u'Lille'
self.location = u'18 rue Gosselet'
self.sequence = 1
self.transp = TRANSP.TRANSPARENT
self.status = STATUS.CONFIRMED
self.category = CATEGORIES.CINE
self.timezone = u'Europe/Paris'
woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/modules/hybride/favicon.png 0000664 0000000 0000000 00000001302 13436457030 0027731 0 ustar 00root root 0000000 0000000 PNG
IHDR @ @ iq bKGD pHYs tIME OIDATx۱A/nQZXوh'(
Z6z" ?xՉV wX`Qz%,ȰFf=dw'ďE )EU
K̔;_h'Ap (KyuM[2
:{([<z.Dg-E@R;4hfIb~-P*X2Iϒf,R8:`A9a ?1
H20ퟕt f&3{bfl\o@B
I:o- Ѯ]TS o+|n]ަ | T)k%뉉 A.W5CTȀ
lO$Pc&;%lKjI-iFcI3YI.ǁŐTJZ P8}j9J.`v?<^EN@,5Jͨ(?ߠ=Y~.0ofl(0znvGfXI
6 IGքNHRTG~_> IENDB` woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/modules/hybride/module.py 0000664 0000000 0000000 00000003625 13436457030 0027447 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# 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 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 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from weboob.tools.backend import Module
from weboob.capabilities.calendar import CapCalendarEvent, CATEGORIES
from .browser import HybrideBrowser
from .calendar import HybrideCalendarEvent
__all__ = ['HybrideModule']
class HybrideModule(Module, CapCalendarEvent):
NAME = 'hybride'
DESCRIPTION = u'hybride website'
MAINTAINER = u'Bezleputh'
EMAIL = 'carton_ben@yahoo.fr'
LICENSE = 'AGPLv3+'
VERSION = '1.6'
ASSOCIATED_CATEGORIES = [CATEGORIES.CINE]
BROWSER = HybrideBrowser
def search_events(self, query):
if self.has_matching_categories(query):
return self.browser.list_events(query.start_date,
query.end_date,
query.city,
query.categories)
def list_events(self, date_from, date_to=None):
return self.browser.list_events(date_from, date_to)
def get_event(self, _id):
return self.browser.get_event(_id)
def fill_obj(self, event, fields):
return self.browser.get_event(event.id, event)
OBJECTS = {HybrideCalendarEvent: fill_obj}
woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/modules/hybride/pages.py 0000664 0000000 0000000 00000006312 13436457030 0027255 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# 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 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 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from .calendar import HybrideCalendarEvent
import weboob.tools.date as date_util
from weboob.browser.pages import HTMLPage
from weboob.browser.elements import ItemElement, ListElement, method
from weboob.browser.filters.standard import Filter, CleanText, Env, Format, BrowserURL, Regexp, Decode
from weboob.browser.filters.html import CleanHTML
from weboob.browser.filters.html import Link
class Date(Filter):
def filter(self, text):
return date_util.parse_french_date(text)
class ProgramPage(HTMLPage):
@method
class list_events(ListElement):
item_xpath = '//div[@class="itemContainer itemContainerLast"]'
class item(ItemElement):
klass = HybrideCalendarEvent
def validate(self, obj):
return self.check_date(obj) and self.check_city(obj) and self.check_category(obj)
def check_date(self, obj):
if self.env['date_from'] and obj.start_date >= self.env['date_from']:
if not self.env['date_to']:
return True
elif obj.end_date and obj.end_date <= self.env['date_to']:
return True
elif self.env['date_to'] >= obj.start_date:
return True
return False
def check_city(self, obj):
return (not self.env['city'] or self.env['city'].upper() == obj.city.upper())
def check_category(self, obj):
return (not self.env['categories'] or obj.category in self.env['categories'])
obj_id = Regexp(Link('div/div[@class="catItemHeader"]/h3[@class="catItemTitle"]/a'),
'/programmation/item/(\d*?)-.*.html')
obj_start_date = Date(CleanText('div/div[@class="catItemHeader"]/span[@class="catItemDateCreated"]'))
obj_summary = CleanText('div/div[@class="catItemHeader"]/h3[@class="catItemTitle"]/a')
class EventPage(HTMLPage):
@method
class get_event(ItemElement):
klass = HybrideCalendarEvent
obj_id = Decode(Env('_id'))
obj_start_date = Date(CleanText('//span[@class="itemDateCreated"]'))
obj_summary = CleanText('//h2[@class="itemTitle"]')
obj_description = Format('%s\n%s',
CleanHTML('//div[@class="itemIntroText"]'),
CleanHTML('//div[@class="itemFullText"]'))
obj_url = BrowserURL('event_page', _id=Env('_id'))
woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-hybride/modules/hybride/test.py 0000664 0000000 0000000 00000002517 13436457030 0027140 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# 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 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 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from datetime import datetime
from weboob.tools.test import BackendTest, SkipTest
class HybrideTest(BackendTest):
MODULE = 'hybride'
def test_hybride_list(self):
if datetime.now() > datetime(datetime.now().year, 6, 30) and\
datetime.now() < datetime(datetime.now().year, 9, 15):
raise SkipTest("Fermeture estivale")
l = list(self.backend.list_events(datetime.now()))
assert len(l)
event = self.backend.get_event(l[0].id)
self.assertTrue(event.url, 'URL for event "%s" not found: %s' % (event.id, event.url))