class item(ItemElement): klass = Account obj_id = CleanText(Dict('id')) obj_label = CleanText(Dict('label')) obj_balance = CleanText(Dict('balance'))
def obj_type(self): return self.page.ACCOUNT_TYPES.get( Dict('TypeCompte')(self), Account.TYPE_UNKNOWN)
def obj_amount(self): amount = CleanDecimal(Dict('Montant/Valeur'))(self) return -amount if Dict('Montant/CodeSens')( self) == "D" else amount
def condition(self): if self.env['only_station']: return Dict('entryPointType')(self.el) == 'StopArea' and Dict('reseau')(self.el)[0] return True
def obj_balance(self): absolut_amount = CleanDecimal(Dict('Solde/Valeur'))(self) if CleanText(Dict('Solde/CodeSens'))(self) == 'D': return -absolut_amount return absolut_amount
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
def condition(self): return Dict('value', default=None)(self)
class item(ItemElement): klass = City obj_id = Id(Dict('id')) obj_name = Dict('value')
def is_pro(self, subid): if self.doc and Dict('id')( self.doc[0]) == subid and Dict('offerNature')(self.doc[0]): return True
class item(ItemElement): klass = City obj_id = Dict('Value') obj_name = Dict('Name')
def obj_amount(self): assert not (Dict('Débit')(self) and Dict('Credit')(self)), "cannot have both debit and credit" if Dict('Credit')(self): return CleanDecimal.US(Dict('Credit'))(self) return -CleanDecimal.US(Dict('Débit'))(self)
def obj_price(self): price = CleanDecimal(Dict('price'), default=NotAvailable)(self) if price: return price / 100 return NotAvailable
def obj_income(self): if Dict('type')(self) == 'purchase': return False else: # type is 'refund' return True
class item(ItemElement): klass = Transaction obj_date = Date(CleanText(Dict("date"))) obj_label = CleanText(Dict("label")) obj_amount= CleanDecimal(Dict("amount"))
def obj_DPE(self): DPE = Dict('characteristics/energyConsumptionCategory', default="")(self) return getattr(ENERGY_CLASS, DPE, NotAvailable)
def obj_url(self): billdate = urlencode({'billDate': Dict('dueDate')(self)}) url = 'https://espaceclientpro.orange.fr/api/contract/%s/bill/%s/facture?billId=&%s' % ( Env('subid')(self), Dict('mainDir')( self.el['documents'][0]), billdate) return url
def obj_GES(self): GES = Dict('characteristics/greenhouseGasEmissionCategory', default="")(self) return getattr(ENERGY_CLASS, GES, NotAvailable)
class item(ItemElement): klass = City obj_id = Dict('Params/ci') obj_name = Dict('Display')
class item(ItemElement): klass = City obj_id = Dict('label') obj_name = Dict('label')
class get_housing(ItemElement): klass = Housing def is_agency(self): return Dict('agency/isParticulier')(self) == 'false' obj_id = Env('_id') 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 def obj_advert_type(self): if self.is_agency: return ADVERT_TYPES.PROFESSIONAL else: return ADVERT_TYPES.PERSONAL 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 obj_title = Dict('characteristics/titleWithTransaction') obj_location = Format('%s %s %s', Dict('location/address'), Dict('location/cityLabel'), Dict('location/postalCode')) def obj_cost(self): cost = TypeDecimal(Dict('characteristics/price'))(self) if cost == 0: cost = TypeDecimal(Dict('characteristics/priceMin'))(self) return cost obj_currency = BaseCurrency.get_currency('€') def obj_utilities(self): are_fees_included = Dict('characteristics/areFeesIncluded', default=None)(self) if are_fees_included: return UTILITIES.INCLUDED else: return UTILITIES.EXCLUDED obj_text = CleanHTML(Dict('characteristics/description')) obj_url = BrowserURL('housing_html', _id=Env('_id')) def obj_area(self): area = TypeDecimal(Dict('characteristics/area'))(self) if area == 0: area = TypeDecimal(Dict('characteristics/areaMin'))(self) return area obj_date = FromTimestamp(Dict('characteristics/date')) obj_bedrooms = TypeDecimal(Dict('characteristics/bedroomCount')) 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 obj_price_per_meter = PricePerMeterFilter() 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 def obj_DPE(self): DPE = Dict('characteristics/energyConsumptionCategory', default="")(self) return getattr(ENERGY_CLASS, DPE, NotAvailable) def obj_GES(self): GES = Dict('characteristics/greenhouseGasEmissionCategory', default="")(self) return getattr(ENERGY_CLASS, GES, NotAvailable) 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
class item(ItemElement): klass = City obj_id = Dict('id') obj_name = Dict('name')
def is_agency(self): return Dict('agency/isParticulier')(self) == 'false'
def obj__type_point(self): key = Dict('entryPointType', default=None)(self) if key: return self.MapCategorieToTypePoint[key]
def obj_cost(self): cost = TypeDecimal(Dict('characteristics/price'))(self) if cost == 0: cost = TypeDecimal(Dict('characteristics/priceMin'))(self) return cost
def obj_currency(self): return CleanText(Dict('Devise'))(self).upper()
def obj_area(self): area = TypeDecimal(Dict('characteristics/area'))(self) if area == 0: area = TypeDecimal(Dict('characteristics/areaMin'))(self) return area
def obj_original_currency(self): return CleanText(Dict('Montant/Devise'))(self).upper()
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
def next_offset(self): offset = Dict('OffsetSortie')(self.doc) if offset: assert Dict('EstComplete')(self.doc) == 'false' return offset
def condition(self): return Dict('id', default=None)(self)