Ejemplo n.º 1
0
 def get_offices(self):
     points = []
     items_tree = ET.fromstring(get_url(self.__offices_xml_url))
     for item in items_tree.iter('item'):
         point = self.__parse_office(item)
         if point:
             points.append(point)
     page = PQ(get_url(self.__regional_offices_page_url))
     point = None
     for item in map(PQ, page('#content_internal span:eq(0)').children()):
         if item[0].tag not in self.__regional_offices_tags:
             continue
         if item[0].tag == 'h2':
             point = Point()
             point.prov = self.uid
             point.type = TYPE_OFFICE
             point.name = trim_spaces_and_commas(normalize_text(item.text()))
             point.check_information = CHECK_OFFICIAL
             continue
         if not point:
             continue
         item_html = replace_br(item.html(), ';;;')
         sub_items = PQ(item_html).text().split(';;;')
         point.address, point.place = split_address_place(sub_items[0])
         for sub_item in map(normalize_text, sub_items[1:]):
             if sub_item.startswith(u'т.ф.:'):
                 point.phone = normalize_phones(sub_item[len(u'т.ф.:'):].split(','))
         warning_not_official_coordinates(point)
         points.append(point)
         point = None
     return points
Ejemplo n.º 2
0
 def __get_point_coordinate(self, point_address, coordinates):
     lower_point_address = point_address.lower()
     for lat, lng, address, place in coordinates:
         for token in address.split():
             if trim_spaces_and_commas(token.lower()) not in lower_point_address:
                 break
         else:
             return lat, lng
     return None, None
Ejemplo n.º 3
0
    def __parse_base_atm_terminals(self, item, map_points, point_type, start_names):
        point = Point()
        point.prov = self.uid
        point.type = point_type
        if not item('.name').text().split()[0].startswith(start_names):
            return None

        point.address, point.place = split_address_place(' '.join(item('.name').text().strip().split()[1:]))
        point.place = trim_spaces_and_commas(normalize_text(item('.addres strong').text()))
        point.check_information = CHECK_OFFICIAL

        for lat, lng, name, address, place in map_points:
            if (name in start_names) and\
               (point.address and address and point.address in address) and\
               (point.place in place if point.place and place else True):
                point.lat = lat
                point.lng = lng
                point.check_coordinates = CHECK_OFFICIAL
                break
        else:
            warning_not_official_coordinates(point)
        return point