able to fill photos
This commit is contained in:
parent
0b74d5a8c4
commit
58e255917c
1 changed files with 14 additions and 5 deletions
|
|
@ -17,7 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.capabilities.housing import ICapHousing, City, Housing
|
from weboob.capabilities.housing import ICapHousing, City, Housing, HousingPhoto
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import PapBrowser
|
from .browser import PapBrowser
|
||||||
|
|
@ -37,11 +37,13 @@ class PapBackend(BaseBackend, ICapHousing):
|
||||||
|
|
||||||
def search_housings(self, query):
|
def search_housings(self, query):
|
||||||
cities = [c.id for c in query.cities if c.backend == self.name]
|
cities = [c.id for c in query.cities if c.backend == self.name]
|
||||||
|
if len(cities) == 0:
|
||||||
|
return list()
|
||||||
|
|
||||||
with self.browser:
|
with self.browser:
|
||||||
for housing in self.browser.search_housings(cities,
|
return self.browser.search_housings(cities,
|
||||||
query.area_min, query.area_max,
|
query.area_min, query.area_max,
|
||||||
query.cost_min, query.cost_max):
|
query.cost_min, query.cost_max)
|
||||||
yield housing
|
|
||||||
|
|
||||||
def get_housing(self, housing):
|
def get_housing(self, housing):
|
||||||
if isinstance(housing, Housing):
|
if isinstance(housing, Housing):
|
||||||
|
|
@ -63,5 +65,12 @@ class PapBackend(BaseBackend, ICapHousing):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.get_housing(housing.id)
|
return self.browser.get_housing(housing.id)
|
||||||
|
|
||||||
|
def fill_photo(self, photo, fields):
|
||||||
|
with self.browser:
|
||||||
|
if 'data' in fields and photo.url and not photo.data:
|
||||||
|
photo.data = self.browser.readurl(photo.url)
|
||||||
|
return photo
|
||||||
|
|
||||||
OBJECTS = {Housing: fill_housing,
|
OBJECTS = {Housing: fill_housing,
|
||||||
|
HousingPhoto: fill_photo,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue