Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
devel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bezleputh
devel
Commits
cd1e3791
Commit
cd1e3791
authored
Apr 01, 2019
by
Bezleputh
Committed by
ntome
Apr 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[biplan] Delete module concert hall is closing
parent
d1c033b4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
377 deletions
+0
-377
__init__.py
modules/biplan/__init__.py
+0
-24
browser.py
modules/biplan/browser.py
+0
-49
calendar.py
modules/biplan/calendar.py
+0
-44
favicon.png
modules/biplan/favicon.png
+0
-0
module.py
modules/biplan/module.py
+0
-72
pages.py
modules/biplan/pages.py
+0
-154
test.py
modules/biplan/test.py
+0
-34
No files found.
modules/biplan/__init__.py
deleted
100644 → 0
View file @
d1c033b4
# -*- 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 <http://www.gnu.org/licenses/>.
from
.module
import
BiplanModule
__all__
=
[
'BiplanModule'
]
modules/biplan/browser.py
deleted
100644 → 0
View file @
d1c033b4
# -*- 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 <http://www.gnu.org/licenses/>.
from
weboob.browser
import
PagesBrowser
,
URL
from
.pages
import
ProgramPage
,
EventPage
__all__
=
[
'BiplanBrowser'
]
class
BiplanBrowser
(
PagesBrowser
):
BASEURL
=
'https://www.lebiplan.org'
program_page
=
URL
(
'/fr/biplan-prog-(?P<_category>.*).php'
,
ProgramPage
)
event_page
=
URL
(
'/(?P<_id>.*).html'
,
EventPage
)
def
list_events_concert
(
self
,
date_from
,
date_to
=
None
,
city
=
None
,
categories
=
None
):
return
self
.
program_page
.
go
(
_category
=
'concert'
)
.
list_events
(
date_from
=
date_from
,
date_to
=
date_to
,
city
=
city
,
categories
=
categories
,
is_concert
=
True
)
def
list_events_theatre
(
self
,
date_from
,
date_to
=
None
,
city
=
None
,
categories
=
None
):
return
self
.
program_page
.
go
(
_category
=
'theatre'
)
.
list_events
(
date_from
=
date_from
,
date_to
=
date_to
,
city
=
city
,
categories
=
categories
,
is_concert
=
False
)
def
get_event
(
self
,
_id
,
event
=
None
):
return
self
.
event_page
.
go
(
_id
=
_id
)
.
get_event
(
obj
=
event
)
modules/biplan/calendar.py
deleted
100644 → 0
View file @
d1c033b4
# -*- 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 <http://www.gnu.org/licenses/>.
from
weboob.capabilities.calendar
import
BaseCalendarEvent
,
TRANSP
,
STATUS
,
CATEGORIES
class
BiplanCalendarEvent
(
BaseCalendarEvent
):
def
__init__
(
self
):
BaseCalendarEvent
.
__init__
(
self
)
self
.
city
=
u'LILLE'
self
.
location
=
u'19, rue Colbert'
self
.
sequence
=
1
self
.
transp
=
TRANSP
.
TRANSPARENT
self
.
status
=
STATUS
.
CONFIRMED
self
.
timezone
=
u'Europe/Paris'
class
BiplanCalendarEventConcert
(
BiplanCalendarEvent
):
def
__init__
(
self
):
BiplanCalendarEvent
.
__init__
(
self
)
self
.
category
=
CATEGORIES
.
CONCERT
class
BiplanCalendarEventTheatre
(
BiplanCalendarEvent
):
def
__init__
(
self
):
BiplanCalendarEvent
.
__init__
(
self
)
self
.
category
=
CATEGORIES
.
THEATRE
modules/biplan/favicon.png
deleted
100644 → 0
View file @
d1c033b4
16.2 KB
modules/biplan/module.py
deleted
100644 → 0
View file @
d1c033b4
# -*- 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 <http://www.gnu.org/licenses/>.
from
weboob.tools.backend
import
Module
from
weboob.capabilities.calendar
import
CapCalendarEvent
,
CATEGORIES
import
itertools
from
.browser
import
BiplanBrowser
from
.
calendar
import
BiplanCalendarEvent
__all__
=
[
'BiplanModule'
]
class
BiplanModule
(
Module
,
CapCalendarEvent
):
NAME
=
'biplan'
DESCRIPTION
=
u'lebiplan.org website'
MAINTAINER
=
u'Bezleputh'
EMAIL
=
'carton_ben@yahoo.fr'
LICENSE
=
'AGPLv3+'
VERSION
=
'1.6'
ASSOCIATED_CATEGORIES
=
[
CATEGORIES
.
CONCERT
,
CATEGORIES
.
THEATRE
]
BROWSER
=
BiplanBrowser
def
search_events
(
self
,
query
):
if
self
.
has_matching_categories
(
query
):
theatre_events
=
[]
concert_events
=
[]
if
CATEGORIES
.
CONCERT
in
query
.
categories
:
concert_events
=
self
.
browser
.
list_events_concert
(
query
.
start_date
,
query
.
end_date
,
query
.
city
,
query
.
categories
)
if
CATEGORIES
.
THEATRE
in
query
.
categories
:
theatre_events
=
self
.
browser
.
list_events_theatre
(
query
.
start_date
,
query
.
end_date
,
query
.
city
,
query
.
categories
)
items
=
list
(
itertools
.
chain
(
concert_events
,
theatre_events
))
items
.
sort
(
key
=
lambda
o
:
o
.
start_date
)
return
items
def
list_events
(
self
,
date_from
,
date_to
=
None
):
items
=
list
(
itertools
.
chain
(
self
.
browser
.
list_events_concert
(
date_from
,
date_to
),
self
.
browser
.
list_events_theatre
(
date_from
,
date_to
)))
items
.
sort
(
key
=
lambda
o
:
o
.
start_date
)
return
items
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
=
{
BiplanCalendarEvent
:
fill_obj
}
modules/biplan/pages.py
deleted
100644 → 0
View file @
d1c033b4
# -*- 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 <http://www.gnu.org/licenses/>.
from
__future__
import
unicode_literals
import
re
from
datetime
import
datetime
,
time
import
weboob.tools.date
as
date_util
from
.calendar
import
BiplanCalendarEventConcert
,
BiplanCalendarEventTheatre
from
weboob.browser.elements
import
ItemElement
,
SkipItem
,
ListElement
,
method
from
weboob.browser.pages
import
HTMLPage
from
weboob.browser.filters.standard
import
Filter
,
CleanText
,
Env
,
Regexp
,
CombineDate
from
weboob.browser.filters.html
import
Link
,
CleanHTML
class
BiplanPrice
(
Filter
):
def
filter
(
self
,
el
):
index
=
1
if
len
(
el
)
>
1
else
0
content
=
CleanText
.
clean
(
CleanText
(
'.'
,
[
'HORAIRES'
])(
el
[
index
]))
a_price
=
content
.
split
(
' - '
)[
-
1
]
parsed_price
=
re
.
findall
(
r"\d*\,\d+|\d+"
,
" "
.
join
(
a_price
))
if
parsed_price
and
len
(
parsed_price
)
>
0
:
return
float
(
parsed_price
[
0
]
.
replace
(
','
,
'.'
))
return
float
(
0
)
class
BiplanDate
(
Filter
):
def
filter
(
self
,
el
):
content
=
CleanText
.
clean
(
CleanText
(
CleanHTML
(
'.'
),
[
'*'
])(
el
[
0
]))
a_date
=
content
[
0
:
content
.
index
(
' - '
)]
for
fr
,
en
in
date_util
.
DATE_TRANSLATE_FR
:
a_date
=
fr
.
sub
(
en
,
a_date
)
try
:
_month
=
datetime
.
strptime
(
a_date
,
"
%
A
%
d
%
B"
)
.
month
if
(
datetime
.
now
()
.
month
>
_month
):
a_date
+=
u'
%
i'
%
(
datetime
.
now
()
.
year
+
1
)
else
:
a_date
+=
u'
%
i'
%
(
datetime
.
now
()
.
year
)
except
ValueError
:
pass
return
datetime
.
strptime
(
a_date
,
"
%
A
%
d
%
B
%
Y"
)
class
StartTime
(
Filter
):
def
filter
(
self
,
el
):
index
=
1
if
len
(
el
)
>
1
else
0
content
=
CleanText
.
clean
(
CleanText
(
'.'
,
[
'HORAIRES'
])(
el
[
index
]))
_content
=
content
.
split
(
' - '
)
a_time
=
_content
[
2
]
if
len
(
_content
)
>
2
else
_content
[
0
]
regexp
=
re
.
compile
(
r'(?P<hh>\d+)h?(?P<mm>\d+)'
)
m
=
regexp
.
search
(
a_time
)
if
m
:
return
time
(
int
(
m
.
groupdict
()[
'hh'
]
or
0
),
int
(
m
.
groupdict
()[
'mm'
]
or
0
))
return
time
(
0
,
0
)
class
EndTime
(
Filter
):
def
filter
(
self
,
el
):
return
time
.
max
class
ProgramPage
(
HTMLPage
):
@
method
class
list_events
(
ListElement
):
item_xpath
=
'//div[@class="ligne"]'
class
item
(
ItemElement
):
def
klass
(
self
):
return
BiplanCalendarEventConcert
()
if
self
.
env
[
'is_concert'
]
else
BiplanCalendarEventTheatre
()
def
condition
(
self
):
return
(
self
.
el
.
xpath
(
'./div'
)
and
CleanText
(
'./div/a/img/@src'
)(
self
)[
-
1
]
!=
'/'
)
def
validate
(
self
,
obj
):
return
(
self
.
is_valid_event
(
obj
,
self
.
env
[
'city'
],
self
.
env
[
'categories'
])
and
self
.
is_event_in_valid_period
(
obj
.
start_date
,
self
.
env
[
'date_from'
],
self
.
env
[
'date_to'
]))
def
is_valid_event
(
self
,
event
,
city
,
categories
):
if
city
and
city
!=
''
and
city
.
upper
()
!=
event
.
city
.
upper
():
return
False
if
categories
and
len
(
categories
)
>
0
and
event
.
category
not
in
categories
:
return
False
return
True
def
is_event_in_valid_period
(
self
,
event_date
,
date_from
,
date_to
):
if
event_date
>=
date_from
:
if
not
date_to
:
return
True
else
:
if
event_date
<=
date_to
:
return
True
return
False
obj_id
=
Regexp
(
Link
(
'./div/a'
),
'/(.*?).html'
)
obj_start_date
=
CombineDate
(
BiplanDate
(
'div/div/b'
),
StartTime
(
'div/div/b'
))
obj_end_date
=
CombineDate
(
BiplanDate
(
'div/div/b'
),
EndTime
(
'.'
))
obj_price
=
BiplanPrice
(
'div/div/b'
)
obj_summary
=
CleanText
(
"div/div/div/a/strong"
)
class
EventPage
(
HTMLPage
):
encoding
=
u'utf-8'
@
method
class
get_event
(
ItemElement
):
klass
=
BiplanCalendarEventConcert
if
Env
(
'is_concert'
)
else
BiplanCalendarEventTheatre
def
parse
(
self
,
el
):
_div
=
"//div/div/div[@id='popup']"
div
=
el
.
xpath
(
"
%
s"
%
_div
)[
0
]
if
self
.
obj
.
id
:
event
=
self
.
obj
event
.
url
=
self
.
page
.
url
event
.
description
=
CleanHTML
(
"
%
s/div/div[@class='presentation-popup']"
%
_div
)(
self
)
raise
SkipItem
()
self
.
env
[
'is_concert'
]
=
(
div
.
attrib
[
'class'
]
!=
'theatre-popup'
)
self
.
env
[
'url'
]
=
self
.
page
.
url
obj_id
=
Env
(
'_id'
)
base
=
"//div[@id='popup']"
obj_price
=
BiplanPrice
(
"
%
s/div/b"
%
base
)
obj_start_date
=
CombineDate
(
BiplanDate
(
"
%
s/div/b"
%
base
),
StartTime
(
"
%
s/div/b"
%
base
))
obj_end_date
=
CombineDate
(
BiplanDate
(
"
%
s/div/b"
%
base
),
EndTime
(
"."
))
obj_url
=
Env
(
'url'
)
obj_summary
=
CleanText
(
'
%
s/div/div/span'
%
base
)
obj_description
=
CleanHTML
(
'
%
s/div/div[@class="presentation-popup"]'
%
base
)
modules/biplan/test.py
deleted
100644 → 0
View file @
d1c033b4
# -*- 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 <http://www.gnu.org/licenses/>.
from
datetime
import
datetime
from
weboob.tools.test
import
BackendTest
,
SkipTest
class
BiplanTest
(
BackendTest
):
MODULE
=
'biplan'
def
test_biplan_list
(
self
):
if
datetime
.
now
()
>
datetime
(
datetime
.
now
()
.
year
,
7
,
14
)
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
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment