|
1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
try: |
|
4
|
|
|
import logging |
|
5
|
|
|
import sys |
|
6
|
|
|
import json |
|
7
|
|
|
from osm_poi_matchmaker.dao.data_handlers import insert_poi_dataframe |
|
8
|
|
|
from osm_poi_matchmaker.libs.address import clean_city, clean_phone_to_str |
|
9
|
|
|
from osm_poi_matchmaker.libs.geo import check_hu_boundary |
|
10
|
|
|
from osm_poi_matchmaker.libs.poi_dataset import POIDataset |
|
11
|
|
|
from osm_poi_matchmaker.utils.data_provider import DataProvider |
|
12
|
|
|
from osm_poi_matchmaker.utils.enums import FileType |
|
13
|
|
|
except ImportError as err: |
|
14
|
|
|
logging.error('Error %s import module: %s', __name__, err) |
|
15
|
|
|
logging.exception('Exception occurred') |
|
16
|
|
|
|
|
17
|
|
|
sys.exit(128) |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
class hu_cib_bank(DataProvider): |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
View Code Duplication |
def __init__(self, session, download_cache, prefer_osm_postcode, link, name): |
|
|
|
|
|
|
23
|
|
|
self.session = session |
|
24
|
|
|
self.download_cache = download_cache |
|
25
|
|
|
self.link = link |
|
26
|
|
|
self.tags = {'brand': 'CIB Bank', 'operator': 'CIB Bank Zrt.', 'operator:addr': '1027 Budapest, Medve u 4-14.', |
|
|
|
|
|
|
27
|
|
|
'bic': 'CIBHHUHB', 'ref:vatin': 'HU10136915', 'ref:vatin:hu': '10136915-4-44', |
|
28
|
|
|
'ref:HU:company': '01 10 041004', 'brand:wikidata': 'Q839566', |
|
29
|
|
|
'brand:wikipedia': 'hu:CIB Bank', } |
|
30
|
|
|
self.prefer_osm_postcode = prefer_osm_postcode |
|
31
|
|
|
self.name = name |
|
32
|
|
|
self.filetype = FileType.json |
|
33
|
|
|
self.filename = '{}.{}'.format( |
|
34
|
|
|
self.__class__.__name__, self.filetype.name) |
|
35
|
|
|
|
|
36
|
|
|
def types(self): |
|
37
|
|
|
hucibbank = {'amenity': 'bank', 'atm': 'yes', |
|
38
|
|
|
'air_conditioning': 'yes', } |
|
39
|
|
|
hucibbank.update(self.tags) |
|
40
|
|
|
hucibatm = {'amenity': 'atm'} |
|
41
|
|
|
hucibatm.update(self.tags) |
|
42
|
|
|
data = [ |
|
43
|
|
|
{'poi_code': 'hucibbank', 'poi_name': 'CIB Bank', 'poi_type': 'bank', 'poi_tags': hucibbank, |
|
|
|
|
|
|
44
|
|
|
'poi_url_base': 'https://www.cib.hu', 'poi_search_name': '(cib bank|cib)', |
|
45
|
|
|
'poi_search_avoid_name': '(raiffeisen|otp|k&h|budapest)', |
|
46
|
|
|
'osm_search_distance_perfect': 300, 'osm_search_distance_safe': 100, |
|
47
|
|
|
'osm_search_distance_unsafe': 40}, |
|
48
|
|
|
{'poi_code': 'hucibatm', 'poi_name': 'CIB Bank ATM', 'poi_type': 'atm', 'poi_tags': hucibatm, |
|
|
|
|
|
|
49
|
|
|
'poi_url_base': 'https://www.cib.hu', 'poi_search_name': '(cib bank atm|cib atm)', |
|
50
|
|
|
'poi_search_avoid_name': '(raiffeisen|otp|k&h|budapest)', |
|
51
|
|
|
'osm_search_distance_perfect': 50, 'osm_search_distance_safe': 30, |
|
52
|
|
|
'osm_search_distance_unsafe': 10} |
|
53
|
|
|
] |
|
54
|
|
|
return data |
|
55
|
|
|
|
|
56
|
|
|
def process(self): |
|
57
|
|
|
try: |
|
58
|
|
|
if self.link: |
|
59
|
|
|
with open(self.link, 'r') as f: |
|
|
|
|
|
|
60
|
|
|
text = json.load(f) |
|
61
|
|
|
data = POIDataset() |
|
62
|
|
|
for poi_data in text['availableLocations']: |
|
63
|
|
|
if 'locationStatus' in poi_data and poi_data['locationStatus'] == 'IN_SERVICE': |
|
|
|
|
|
|
64
|
|
|
if self.name == 'CIB Bank': |
|
65
|
|
|
data.name = 'CIB Bank' |
|
66
|
|
|
data.code = 'hucibbank' |
|
67
|
|
|
data.public_holiday_open = False |
|
68
|
|
|
else: |
|
69
|
|
|
data.name = 'CIB Bank ATM' |
|
70
|
|
|
data.code = 'hucibatm' |
|
71
|
|
|
data.public_holiday_open = True |
|
72
|
|
|
data.lat, data.lon = check_hu_boundary(poi_data['location']['lat'], |
|
73
|
|
|
poi_data['location']['lon']) |
|
74
|
|
|
data.city = clean_city(poi_data['city']) |
|
75
|
|
|
data.postcode = poi_data.get('zip').strip() |
|
76
|
|
|
data.housenumber = poi_data['streetNo'].strip() |
|
77
|
|
|
data.street = poi_data['streetName'].strip() |
|
78
|
|
|
data.branch = poi_data['name'] |
|
79
|
|
|
if 'phone' in poi_data and poi_data['phone'] != '': |
|
80
|
|
|
data.phone = clean_phone_to_str( |
|
81
|
|
|
poi_data['phone']) |
|
82
|
|
|
if 'email' in poi_data and poi_data['email'] != '': |
|
83
|
|
|
data.email = poi_data['email'].strip() |
|
84
|
|
|
data.original = poi_data['fullAddress'] |
|
85
|
|
|
data.add() |
|
86
|
|
|
if data is None or data.lenght() < 1: |
|
87
|
|
|
logging.warning('Resultset is empty. Skipping ...') |
|
88
|
|
|
else: |
|
89
|
|
|
insert_poi_dataframe(self.session, data.process()) |
|
90
|
|
|
except Exception as e: |
|
|
|
|
|
|
91
|
|
|
logging.exception('Exception occurred') |
|
92
|
|
|
|
|
93
|
|
|
logging.error(e) |
|
94
|
|
|
logging.error(poi_data) |
|
|
|
|
|
|
95
|
|
|
|