The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit afd26e29 authored by Vincent A's avatar Vincent A

[lesterrains] modernize

parent a8e32cc9
Pipeline #3717 failed with stages
in 63 minutes and 2 seconds
......@@ -2,20 +2,20 @@
# Copyright(C) 2019 Guntra
#
# This file is part of a weboob module.
# This file is part of a woob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# 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 weboob module is distributed in the hope that it will be useful,
# 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 weboob module. If not, see <http://www.gnu.org/licenses/>.
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from .module import LesterrainsModule
......
......@@ -2,26 +2,28 @@
# Copyright(C) 2019 Guntra
#
# This file is part of a weboob module.
# This file is part of a woob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# 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 weboob module is distributed in the hope that it will be useful,
# 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 weboob module. If not, see <http://www.gnu.org/licenses/>.
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.browser import PagesBrowser, URL
from weboob.browser.filters.standard import CleanText, Lower, Regexp
from weboob.capabilities.housing import (TypeNotSupported, POSTS_TYPES, HOUSE_TYPES)
from weboob.tools.compat import urlencode
from woob.browser import PagesBrowser, URL
from woob.browser.filters.standard import CleanText, Lower, Regexp
from woob.capabilities.housing import TypeNotSupported, POSTS_TYPES, HOUSE_TYPES
from woob.tools.compat import urlencode
from .pages import CitiesPage, SearchPage, HousingPage
......@@ -34,14 +36,14 @@ class LesterrainsBrowser(PagesBrowser):
RET = {
HOUSE_TYPES.LAND: 'Terrain seul'
}
cities = URL('/api/get-search.php\?q=(?P<city>.*)', CitiesPage)
search = URL('/index.php\?mode_aff=liste&ongletAccueil=Terrains&(?P<query>.*)&distance=0', SearchPage)
cities = URL(r'/api/get-search.php\?q=(?P<city>.*)', CitiesPage)
search = URL(r'/index.php\?mode_aff=liste&ongletAccueil=Terrains&(?P<query>.*)&distance=0', SearchPage)
housing = URL(
'/index.php\?page=terrains&mode_aff=un_terrain&idter=(?P<_id>\d+).*',
'/index.php\?page=terrains&mode_aff=maisonterrain&idter=(?P<_id>\d+).*',
r'/index.php\?page=terrains&mode_aff=un_terrain&idter=(?P<_id>\d+).*',
r'/index.php\?page=terrains&mode_aff=maisonterrain&idter=(?P<_id>\d+).*',
HousingPage
)
def get_cities(self, pattern):
return self.cities.open(city=pattern).get_cities()
......@@ -52,7 +54,7 @@ def _get_departement(city):
def _get_ville(city):
return city.split(';')[1]
for city in cities:
query = urlencode({
"departement": _get_departement(city),
......@@ -66,4 +68,4 @@ def _get_ville(city):
yield house
def get_housing(self, _id, housing=None):
return self.housing.go(_id = _id).get_housing(obj=housing)
\ No newline at end of file
return self.housing.go(_id=_id).get_housing(obj=housing)
......@@ -2,24 +2,24 @@
# Copyright(C) 2019 Guntra
#
# This file is part of a weboob module.
# This file is part of a woob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# 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 weboob module is distributed in the hope that it will be useful,
# 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 weboob module. If not, see <http://www.gnu.org/licenses/>.
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.tools.backend import Module
from weboob.capabilities.housing import CapHousing
from woob.tools.backend import Module
from woob.capabilities.housing import CapHousing
from .browser import LesterrainsBrowser
......@@ -41,7 +41,7 @@ class LesterrainsModule(Module, CapHousing):
MAINTAINER = 'Guntra'
EMAIL = 'guntra@example.com'
LICENSE = 'LGPLv3+'
VERSION = '1.6'
VERSION = '3.1'
BROWSER = LesterrainsBrowser
def search_city(self, pattern):
......@@ -60,4 +60,4 @@ def search_housings(self, query):
)
def get_housing(self, housing):
return self.browser.get_housing(housing)
\ No newline at end of file
return self.browser.get_housing(housing)
......@@ -2,32 +2,33 @@
# Copyright(C) 2019 Guntra
#
# This file is part of a weboob module.
# This file is part of a woob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# 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 weboob module is distributed in the hope that it will be useful,
# 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 weboob module. If not, see <http://www.gnu.org/licenses/>.
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.browser.filters.standard import (
from woob.browser.filters.standard import (
CleanDecimal, CleanText,
Date, Format, Lower, Regexp, QueryValue
)
from weboob.browser.filters.json import Dict
from weboob.browser.filters.html import Attr, AbsoluteLink
from weboob.browser.elements import ItemElement, ListElement, DictElement, method
from weboob.browser.pages import JsonPage, HTMLPage, pagination
from weboob.capabilities.base import Currency, NotAvailable
from weboob.capabilities.housing import (
from woob.browser.filters.json import Dict
from woob.browser.filters.html import Attr, AbsoluteLink
from woob.browser.elements import ItemElement, ListElement, DictElement, method
from woob.browser.pages import JsonPage, HTMLPage, pagination
from woob.capabilities.base import Currency, NotAvailable
from woob.capabilities.housing import (
Housing, HousingPhoto, City,
POSTS_TYPES, HOUSE_TYPES, ADVERT_TYPES, UTILITIES
)
......@@ -50,11 +51,10 @@ class get_cities(DictElement):
class item(ItemElement):
klass = City
obj_id = Dict('id') & CleanText() & Lower()
obj_name= Dict('value') & CleanText()
obj_name = Dict('value') & CleanText()
class SearchPage(HTMLPage):
@pagination
@method
class iter_housings(ListElement):
......@@ -86,14 +86,14 @@ def obj_area(self):
min_area = CleanDecimal(
Regexp(
CleanText('.//div[@class="presentationItem"]/h3'),
'surface de (\d+) m²',
r'surface de (\d+) m²',
default=0
)
)(self)
max_area = CleanDecimal(
Regexp(
CleanText('.//div[@class="presentationItem"]/h3'),
'à (\d+) m²',
r'à (\d+) m²',
default=0
)
)(self)
......@@ -108,10 +108,11 @@ def obj_area(self):
)
obj_currency = Currency.get_currency('€')
obj_date = Date(
CleanText(
'.//div[@class="presentationItem"]//span[@class="majItem"]',
replace=[("Mise à jour : ", "")]),
default=NotAvailable
CleanText(
'.//div[@class="presentationItem"]//span[@class="majItem"]',
replace=[("Mise à jour : ", "")]
),
default=NotAvailable
)
obj_location = CleanText(
'.//div[@class="presentationItem"]/h2/a/span',
......@@ -174,7 +175,7 @@ def obj_cost(self):
CleanDecimal(
CleanText(
'./td[3]',
replace=[(".","")]
replace=[(".", "")]
)
)(land)
)
......
......@@ -2,29 +2,28 @@
# Copyright(C) 2019 Guntra
#
# This file is part of a weboob module.
# This file is part of a woob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# 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 weboob module is distributed in the hope that it will be useful,
# 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 weboob module. If not, see <http://www.gnu.org/licenses/>.
# along with this woob module. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from weboob.capabilities.housing import Query, ADVERT_TYPES, POSTS_TYPES
from weboob.tools.capabilities.housing.housing_test import HousingTest
from weboob.tools.test import BackendTest
from woob.capabilities.housing import Query, ADVERT_TYPES, POSTS_TYPES
from woob.tools.capabilities.housing.housing_test import HousingTest
from woob.tools.test import BackendTest
class LesterrainsTest(BackendTest, HousingTest):
MODULE = 'lesterrains'
# Fields to be checked for values across all items in housings list
FIELDS_ALL_HOUSINGS_LIST = [
......
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