def _convert_document_to_advert(self, document): ''' Преобразовывает документ в объявление. @param document: dict @return: Advert ''' if document is None: return None advert = Advert() advert.id = document['_id'] for field_name in self.FIELDS: setattr(advert, field_name, document[field_name]) return advert
def parse(self, advert_node): ''' Возвращает заполненное объявление. @param advert_node: Element @return: Advert ''' advert = Advert() advert.external_id = self._get_external_id(advert_node) advert.type = self._get_type(advert_node) advert.district = self._get_district(advert_node) advert.address = self._get_address(advert_node) advert.floor_number = self._get_floor_number(advert_node) advert.floor_count = self._get_floor_count(advert_node) advert.area = self._get_area(advert_node) advert.room_count = self._get_room_count(advert_node) advert.price = self._get_price(advert_node) advert.publication_date = self._get_publication_datetime(advert_node) return advert