Commit 3b8c7f6b authored by Phyks (Lucas Verney)'s avatar Phyks (Lucas Verney) Committed by Vincent A

Handle viager

parent dfa4af19
......@@ -36,7 +36,8 @@ class ExplorimmoBrowser(PagesBrowser):
TYPES = {POSTS_TYPES.RENT: 'location',
POSTS_TYPES.SALE: 'vente',
POSTS_TYPES.FURNISHED_RENT: 'location'}
POSTS_TYPES.FURNISHED_RENT: 'location',
POSTS_TYPES.VIAGER: 'vente'}
RET = {HOUSE_TYPES.HOUSE: 'Maison',
HOUSE_TYPES.APART: 'Appartement',
......@@ -54,9 +55,12 @@ class ExplorimmoBrowser(PagesBrowser):
raise TypeNotSupported()
ret = []
for house_type in house_types:
if house_type in self.RET:
ret.append(self.RET.get(house_type))
if type == POSTS_TYPES.VIAGER:
ret = ['Viager']
else:
for house_type in house_types:
if house_type in self.RET:
ret.append(self.RET.get(house_type))
data = {'location': ','.join(cities).encode('iso 8859-1'),
'furnished': type == POSTS_TYPES.FURNISHED_RENT,
......
......@@ -204,7 +204,11 @@ class HousingPage2(JsonPage):
else:
return POSTS_TYPES.RENT
elif transaction == 'vente':
return POSTS_TYPES.SALE
type = Dict('characteristics/estateType')(self).lower()
if 'viager' in type:
return POSTS_TYPES.VIAGER
else:
return POSTS_TYPES.SALE
else:
return NotAvailable
......
......@@ -36,7 +36,8 @@ class LogicimmoBrowser(PagesBrowser):
TYPES = {POSTS_TYPES.RENT: 'location-immobilier',
POSTS_TYPES.SALE: 'vente-immobilier',
POSTS_TYPES.SHARING: 'recherche-colocation',
POSTS_TYPES.FURNISHED_RENT: 'location-immobilier'}
POSTS_TYPES.FURNISHED_RENT: 'location-immobilier',
POSTS_TYPES.VIAGER: 'vente-immobilier'}
RET = {HOUSE_TYPES.HOUSE: '2',
HOUSE_TYPES.APART: '1',
......@@ -55,9 +56,12 @@ class LogicimmoBrowser(PagesBrowser):
options = []
ret = []
for house_type in house_types:
if house_type in self.RET:
ret.append(self.RET.get(house_type))
if type == POSTS_TYPES.VIAGER:
ret = ['15']
else:
for house_type in house_types:
if house_type in self.RET:
ret.append(self.RET.get(house_type))
if len(ret):
options.append('groupprptypesids=%s' % ','.join(ret))
......
......@@ -76,7 +76,13 @@ class HousingPage(HTMLPage):
else:
return POSTS_TYPES.RENT
elif 'vente' in url:
return POSTS_TYPES.SALE
if(
'viager' in self.obj_text(self).lower()
and 'rente' in self.obj_text(self).lower()
):
return POSTS_TYPES.VIAGER
else:
return POSTS_TYPES.SALE
return NotAvailable
obj_advert_type = ADVERT_TYPES.PROFESSIONAL
def obj_house_type(self):
......
......@@ -64,9 +64,12 @@ class PapBrowser(PagesBrowser):
data['tags[]'] = 'meuble'
ret = []
for house_type in house_types:
if house_type in RET:
ret.append(RET.get(house_type))
if type == POSTS_TYPES.VIAGER:
ret = ['viager']
else:
for house_type in house_types:
if house_type in RET:
ret.append(RET.get(house_type))
_data = '%s%s%s' % (urlencode(data), '&typesbien%5B%5D=', '&typesbien%5B%5D='.join(ret))
return self.search_page.go(data=_data).iter_housings(
......
......@@ -2,7 +2,8 @@ from weboob.capabilities.housing import POSTS_TYPES, HOUSE_TYPES
TYPES = {POSTS_TYPES.RENT: 'location',
POSTS_TYPES.FURNISHED_RENT: 'location',
POSTS_TYPES.SALE: 'vente'}
POSTS_TYPES.SALE: 'vente',
POSTS_TYPES.VIAGER: 'vente'}
RET = {HOUSE_TYPES.HOUSE: 'maison',
HOUSE_TYPES.APART: 'appartement',
......
......@@ -159,6 +159,8 @@ class HousingPage(HTMLPage):
return POSTS_TYPES.RENT
elif 'vente' in prev_link:
return POSTS_TYPES.SALE
elif 'viager' in prev_link:
return POSTS_TYPES.VIAGER
else:
return NotAvailable
obj_advert_type = ADVERT_TYPES.PERSONAL
......
......@@ -2,7 +2,8 @@ from weboob.capabilities.housing import POSTS_TYPES, HOUSE_TYPES
TYPES = {POSTS_TYPES.RENT: 1,
POSTS_TYPES.SALE: 2,
POSTS_TYPES.FURNISHED_RENT: 1}
POSTS_TYPES.FURNISHED_RENT: 1,
POSTS_TYPES.VIAGER: 5}
RET = {HOUSE_TYPES.HOUSE: '2',
HOUSE_TYPES.APART: '1',
......
......@@ -26,7 +26,8 @@ from weboob.browser.filters.standard import (CleanText, CleanDecimal, Currency,
DateTime, Format, Regexp)
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.housing import (Housing, HousingPhoto, City,
UTILITIES, ENERGY_CLASS, POSTS_TYPES)
UTILITIES, ENERGY_CLASS, POSTS_TYPES,
ADVERT_TYPES)
from weboob.tools.capabilities.housing.housing import PricePerMeterFilter
from .constants import TYPES, RET
......@@ -64,7 +65,12 @@ class SeLogerItem(ItemElement):
# furnished.
return POSTS_TYPES.RENT
return type
obj_advert_type = NotAvailable
def obj_advert_type(self):
idTiers = CleanText('idTiers')(self)
if idTiers:
return ADVERT_TYPES.PROFESSIONAL
else:
return ADVERT_TYPES.PERSONAL
def obj_house_type(self):
idType = CleanText('idTypeBien')(self)
try:
......
......@@ -61,7 +61,8 @@ ENERGY_CLASS = enum(A=u'A', B=u'B', C=u'C', D=u'D', E=u'E', F=u'F', G=u'G')
POSTS_TYPES = enum(RENT=u'RENT',
SALE=u'SALE',
SHARING=u'SHARING',
FURNISHED_RENT=u'FURNISHED_RENT')
FURNISHED_RENT=u'FURNISHED_RENT',
VIAGER=u'VIAGER')
ADVERT_TYPES = enum(PROFESSIONAL=u'Professional', PERSONAL=u'Personal')
HOUSE_TYPES = enum(APART=u'Apartment',
HOUSE=u'House',
......
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