Ejemplo n.º 1
0
        def next_page(self):
            page_nb = Dict('navigation/pagination/page')(self)
            max_results = Dict('navigation/counts/count')(self)
            results_per_page = Dict('navigation/pagination/resultsPerPage')(
                self)

            if int(max_results) / int(results_per_page) > int(page_nb):
                return BrowserURL('search',
                                  query=Env('query'),
                                  page_number=int(page_nb) + 1)(self)
Ejemplo n.º 2
0
        def obj_details(self):
            details = {}

            for c in Dict('categories')(self):
                if c['criteria']:
                    details[c['name']] = ' / '.join(
                        [_['value'] for _ in c['criteria']])

            for _, c in Dict('infos_acquereur')(self).items():
                for key, value in c.items():
                    details[key] = value

            return details
Ejemplo n.º 3
0
 def obj_type(self):
     transaction = Dict('characteristics/transaction')(self)
     if transaction == 'location':
         if Dict('characteristics/isFurnished')(self):
             return POSTS_TYPES.FURNISHED_RENT
         else:
             return POSTS_TYPES.RENT
     elif transaction == 'vente':
         type = Dict('characteristics/estateType')(self).lower()
         if 'viager' in type:
             return POSTS_TYPES.VIAGER
         else:
             return POSTS_TYPES.SALE
     else:
         return NotAvailable
Ejemplo n.º 4
0
        def obj_photos(self):
            photos = []

            for photo in Dict('photoList')(self):
                photos.append(HousingPhoto(photo['fullscreenUrl']))

            return photos
Ejemplo n.º 5
0
 def obj_utilities(self):
     are_fees_included = Dict('characteristics/areFeesIncluded',
                              default=None)(self)
     if are_fees_included:
         return UTILITIES.INCLUDED
     else:
         return UTILITIES.EXCLUDED
Ejemplo n.º 6
0
 def obj_address(self):
     address = Dict('address')(self)
     p = PostalAddress()
     p.street = address['street']
     p.postal_code = address['zipCode']
     p.city = address['city']
     p.full_address = Field('location')(self)
     return p
Ejemplo n.º 7
0
 def obj_photos(self):
     photos = []
     for img in Dict('characteristics/images')(self):
         m = re.search('http://thbr\.figarocms\.net.*(http://.*)', img.get('xl'))
         if m:
             photos.append(HousingPhoto(m.group(1)))
         else:
             photos.append(HousingPhoto(img.get('xl')))
     return photos
Ejemplo n.º 8
0
 def obj_type(self):
     idType = Dict('idTransactionType')(self)
     try:
         type = next(k for k, v in TYPES.items() if v == idType)
         if type == POSTS_TYPES.FURNISHED_RENT:
             # SeLoger does not let us discriminate between furnished and not furnished.
             return POSTS_TYPES.RENT
         return type
     except StopIteration:
         return NotAvailable
Ejemplo n.º 9
0
 def obj_house_type(self):
     type = Dict('characteristics/estateType')(self).lower()
     if 'appartement' in type:
         return HOUSE_TYPES.APART
     elif 'maison' in type:
         return HOUSE_TYPES.HOUSE
     elif 'parking' in type:
         return HOUSE_TYPES.PARKING
     elif 'terrain' in type:
         return HOUSE_TYPES.LAND
     else:
         return HOUSE_TYPES.OTHER
Ejemplo n.º 10
0
        class item(ItemElement):
            klass = Housing

            def condition(self):
                return (Dict('cardType')(self)
                        not in ['advertising', 'ali', 'localExpert']
                        and Dict('id', default=False)(self)
                        and Dict('classifiedURL', default=False)(self))

            obj_id = Dict('id')

            def obj_type(self):
                idType = int(Env('query_type')(self))
                type = next(k for k, v in TYPES.items() if v == idType)
                if type == POSTS_TYPES.FURNISHED_RENT:
                    # SeLoger does not let us discriminate between furnished and not furnished.
                    return POSTS_TYPES.RENT
                return type

            def obj_title(self):
                return "{} - {} - {}".format(
                    Dict('estateType')(self), " / ".join(Dict('tags')(self)),
                    Field('location')(self))

            def obj_advert_type(self):
                is_agency = Dict('contact/agencyId', default=False)(self)
                if is_agency:
                    return ADVERT_TYPES.PROFESSIONAL
                else:
                    return ADVERT_TYPES.PERSONAL

            obj_utilities = UTILITIES.EXCLUDED

            def obj_photos(self):
                photos = []
                for photo in Dict('photos')(self):
                    photos.append(HousingPhoto(photo))
                return photos

            def obj_location(self):
                quartier = Dict('districtLabel')(self)
                quartier = quartier if quartier else ''
                ville = Dict('cityLabel')(self)
                ville = ville if ville else ''
                cp = Dict('zipCode')(self)
                cp = cp if cp else ''
                return u'%s %s (%s)' % (quartier, ville, cp)

            obj_url = Dict('classifiedURL')

            obj_text = Dict('description')

            obj_cost = CleanDecimal(Dict('pricing/price', default=NotLoaded),
                                    default=NotLoaded)
            obj_currency = Currency(Dict('pricing/price', default=NotLoaded),
                                    default=NotLoaded)
            obj_price_per_meter = CleanDecimal(
                Dict('pricing/squareMeterPrice'), default=PricePerMeterFilter)
Ejemplo n.º 11
0
        def obj_type(self):
            try:
                breadcrumb = int(Dict('category_id')(self))
            except ValueError:
                breadcrumb = None

            if breadcrumb == 11:
                return POSTS_TYPES.SHARING
            elif breadcrumb == 10:

                isFurnished = CleanText(PopDetail('furnished',
                                                  default=' '))(self)

                if isFurnished.lower() == u'meublé':
                    return POSTS_TYPES.FURNISHED_RENT
                else:
                    return POSTS_TYPES.RENT
            else:
                return POSTS_TYPES.SALE
Ejemplo n.º 12
0
 def obj_GES(self):
     GES = Dict("ges", default="")(self)
     if GES['status'] > 0:
         return NotAvailable
     else:
         return getattr(ENERGY_CLASS, GES['lettre'], NotAvailable)
Ejemplo n.º 13
0
 def obj_rooms(self):
     # TODO: Why is roomCount a list?
     rooms = Dict('characteristics/roomCount', default=[])(self)
     if rooms:
         return TypeDecimal(rooms[0])(self)
     return NotAvailable
Ejemplo n.º 14
0
 def obj_currency(self):
     propertyPrice = Dict('propertyPrice')(self)
     return propertyPrice['priceUnit']
Ejemplo n.º 15
0
 def obj_DPE(self):
     DPE = Dict("energie", default="")(self)
     if DPE['status'] > 0:
         return NotAvailable
     else:
         return getattr(ENERGY_CLASS, DPE['lettre'], NotAvailable)
Ejemplo n.º 16
0
 def obj_DPE(self):
     DPE = Dict(
         'characteristics/energyConsumptionCategory',
         default=""
     )(self)
     return getattr(ENERGY_CLASS, DPE, NotAvailable)
Ejemplo n.º 17
0
 def obj_cost(self):
     propertyPrice = Dict('propertyPrice')(self)
     return decimal.Decimal(propertyPrice['prix'])
Ejemplo n.º 18
0
 def obj_GES(self):
     GES = Dict(
         'characteristics/greenhouseGasEmissionCategory',
         default=""
     )(self)
     return getattr(ENERGY_CLASS, GES, NotAvailable)
Ejemplo n.º 19
0
 def obj_title(self):
     return "{} - {} - {}".format(
         Dict('estateType')(self), " / ".join(Dict('tags')(self)),
         Field('location')(self))
Ejemplo n.º 20
0
 def obj_house_type(self):
     naturebien = Dict('propertyNatureId')(self)
     try:
         return next(k for k, v in RET.items() if v == naturebien)
     except StopIteration:
         return NotLoaded
Ejemplo n.º 21
0
 def obj_details(self):
     details = {}
     details['fees'] = Dict(
         'characteristics/fees', default=NotAvailable
     )(self)
     details['agencyFees'] = Dict(
         'characteristics/agencyFees', default=NotAvailable
     )(self)
     details['guarantee'] = Dict(
         'characteristics/guarantee', default=NotAvailable
     )(self)
     details['bathrooms'] = Dict(
         'characteristics/bathroomCount', default=NotAvailable
     )(self)
     details['creationDate'] = FromTimestamp(
                                   Dict(
                                       'characteristics/creationDate', default=NotAvailable
                                   ),
                                   default=NotAvailable
     )(self)
     details['availabilityDate'] = Dict(
         'characteristics/estateAvailabilityDate', default=NotAvailable
     )(self)
     details['exposure'] = Dict(
         'characteristics/exposure', default=NotAvailable
     )(self)
     details['heatingType'] = Dict(
         'characteristics/heatingType', default=NotAvailable
     )(self)
     details['floor'] = Dict(
         'characteristics/floor', default=NotAvailable
     )(self)
     details['bedrooms'] = Dict(
         'characteristics/bedroomCount', default=NotAvailable
     )(self)
     details['isFurnished'] = Dict(
         'characteristics/isFurnished', default=NotAvailable
     )(self)
     rooms = Dict('characteristics/roomCount', default=[])(self)
     if len(rooms):
         details['rooms'] = rooms[0]
     details['available'] = Dict(
         'characteristics/isAvailable', default=NotAvailable
     )(self)
     agency = Dict('agency', default=NotAvailable)(self)
     details['agency'] = ', '.join([
         x for x in [
             agency.get('corporateName', ''),
             agency.get('corporateAddress', ''),
             agency.get('corporatePostalCode', ''),
             agency.get('corporateCity', '')
         ] if x
     ])
     return details
Ejemplo n.º 22
0
        class item(ItemElement):
            klass = City

            obj_id = Dict('label')
            obj_name = Dict('label')
Ejemplo n.º 23
0
        class item(ItemElement):
            klass = City

            obj_id = Dict('id')
            obj_name = Dict('name')
Ejemplo n.º 24
0
 def obj_advert_type(self):
     is_agency = Dict('contact/agencyId', default=False)(self)
     if is_agency:
         return ADVERT_TYPES.PROFESSIONAL
     else:
         return ADVERT_TYPES.PERSONAL
Ejemplo n.º 25
0
        class item(ItemElement):
            klass = City

            obj_id = Dict('Params/ci')
            obj_name = Dict('Display')
Ejemplo n.º 26
0
 def obj_location(self):
     address = Dict('address')(self)
     return u'%s %s (%s)' % (address['neighbourhood'], address['city'],
                             address['zipCode'])
Ejemplo n.º 27
0
 def obj_photos(self):
     photos = []
     for photo in Dict('photos')(self):
         photos.append(HousingPhoto(photo))
     return photos
Ejemplo n.º 28
0
 def condition(self):
     return Dict('lct_parent_id')(self) != '0'
Ejemplo n.º 29
0
 def condition(self):
     return (Dict('cardType')(self)
             not in ['advertising', 'ali', 'localExpert']
             and Dict('id', default=False)(self)
             and Dict('classifiedURL', default=False)(self))
Ejemplo n.º 30
0
    class get_housing(ItemElement):
        klass = Housing

        def parse(self, el):
            self.agency_doc = el['agency']
            self.el = el['advert']

        obj_id = Dict('id')

        def obj_house_type(self):
            naturebien = Dict('propertyNatureId')(self)
            try:
                return next(k for k, v in RET.items() if v == naturebien)
            except StopIteration:
                return NotLoaded

        def obj_type(self):
            idType = Dict('idTransactionType')(self)
            try:
                type = next(k for k, v in TYPES.items() if v == idType)
                if type == POSTS_TYPES.FURNISHED_RENT:
                    # SeLoger does not let us discriminate between furnished and not furnished.
                    return POSTS_TYPES.RENT
                return type
            except StopIteration:
                return NotAvailable

        def obj_advert_type(self):
            if 'Agences' in self.agency_doc['type']:
                return ADVERT_TYPES.PROFESSIONAL
            else:
                return ADVERT_TYPES.PERSONAL

        def obj_photos(self):
            photos = []

            for photo in Dict('photoList')(self):
                photos.append(HousingPhoto(photo['fullscreenUrl']))

            return photos

        obj_title = Dict('title')

        def obj_location(self):
            address = Dict('address')(self)
            return u'%s %s (%s)' % (address['neighbourhood'], address['city'],
                                    address['zipCode'])

        def obj_address(self):
            address = Dict('address')(self)
            p = PostalAddress()
            p.street = address['street']
            p.postal_code = address['zipCode']
            p.city = address['city']
            p.full_address = Field('location')(self)
            return p

        obj_text = Dict('description')

        def obj_cost(self):
            propertyPrice = Dict('propertyPrice')(self)
            return decimal.Decimal(propertyPrice['prix'])

        def obj_currency(self):
            propertyPrice = Dict('propertyPrice')(self)
            return propertyPrice['priceUnit']

        obj_price_per_meter = PricePerMeterFilter()

        obj_area = CleanDecimal(Dict('surface'))

        def obj_url(self):
            return self.page.url

        def obj_phone(self):
            return self.agency_doc.get('agencyPhoneNumber',
                                       {}).get('value', NotAvailable)

        def obj_utilities(self):
            return NotLoaded  # TODO

        obj_bedrooms = CleanDecimal(Dict('bedroomCount'))
        obj_rooms = CleanDecimal(Dict('numberOfRooms'))