|
1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
try: |
|
4
|
|
|
import logging |
|
5
|
|
|
import sys |
|
6
|
|
|
import json |
|
7
|
|
|
import os |
|
8
|
|
|
from osm_poi_matchmaker.libs.soup import save_downloaded_soup |
|
9
|
|
|
from osm_poi_matchmaker.libs.address import extract_street_housenumber_better_2 |
|
10
|
|
|
from osm_poi_matchmaker.libs.geo import check_hu_boundary |
|
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_budapest_bank(DataProvider): |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
def constains(self): |
|
23
|
|
|
self.link = 'https://www.budapestbank.hu/info/fiokkereso/process/get_data.php?action=get_data_json' |
|
|
|
|
|
|
24
|
|
|
self.tags = {'brand': 'Budapest Bank', 'brand:wikidata': 'Q27493463', 'bic': 'BUDAHUHB', |
|
25
|
|
|
'brand:wikipedia': 'en:Budapest Bank', 'operator': 'Budapest Bank Zrt.', |
|
26
|
|
|
'operator:addr': '1138 Budapest, Váci út 193.', 'ref:vatin': 'HU10196445', |
|
27
|
|
|
'ref:vatin:hu': '10196445-4-44', 'ref:HU:company': '01 10 041037', 'air_conditioning': 'yes'} |
|
|
|
|
|
|
28
|
|
|
self.filetype = FileType.json |
|
29
|
|
|
self.filename = '{}.{}'.format( |
|
30
|
|
|
self.__class__.__name__, self.filetype.name) |
|
31
|
|
|
|
|
32
|
|
|
def types(self): |
|
33
|
|
|
hubpbank = {'amenity': 'bank', 'atm': 'yes', |
|
34
|
|
|
'air_conditioning': 'yes', } |
|
35
|
|
|
hubpbank.update(self.tags) |
|
36
|
|
|
hubpatm = {'amenity': 'atm'} |
|
37
|
|
|
hubpatm.update(self.tags) |
|
38
|
|
|
self.__types = [ |
|
39
|
|
|
{'poi_code': 'hubpbank', 'poi_name': 'Budapest Bank', 'poi_type': 'bank', |
|
40
|
|
|
'poi_tags': hubpbank, 'poi_url_base': 'https://www.budapestbank.hu', |
|
41
|
|
|
'poi_search_name': '(budapest bank|bp bank)', |
|
42
|
|
|
'poi_search_avoid_name': '(otpbank|otp|otp bank)', |
|
43
|
|
|
'osm_search_distance_perfect': 300, 'osm_search_distance_safe': 100, |
|
44
|
|
|
'osm_search_distance_unsafe': 40}, |
|
45
|
|
|
{'poi_code': 'hubpatm', 'poi_name': 'Budapest Bank ATM', 'poi_type': 'atm', |
|
46
|
|
|
'poi_tags': hubpatm, |
|
47
|
|
|
'poi_url_base': 'https://www.budapestbank.hu', |
|
48
|
|
|
'poi_search_name': '(budapest bank|budapest bank atm|bp bank|bp bank atm)', |
|
49
|
|
|
'poi_search_avoid_name': '(otp atm|otp)', |
|
50
|
|
|
'osm_search_distance_perfect': 50, 'osm_search_distance_safe': 30, |
|
51
|
|
|
'osm_search_distance_unsafe': 10}, |
|
52
|
|
|
] |
|
53
|
|
|
return self.__types |
|
54
|
|
|
|
|
55
|
|
|
def process(self): |
|
56
|
|
|
try: |
|
|
|
|
|
|
57
|
|
|
soup = save_downloaded_soup('{}'.format(self.link), os.path.join(self.download_cache, self.filename), |
|
|
|
|
|
|
58
|
|
|
self.filetype) |
|
59
|
|
|
if soup is not None: |
|
60
|
|
|
text = json.loads(soup) |
|
61
|
|
|
for poi_data in text['points']: |
|
62
|
|
|
if poi_data['fiok'] == 1: |
|
63
|
|
|
self.data.name = 'Budapest Bank' |
|
64
|
|
|
self.data.code = 'hubpbank' |
|
65
|
|
|
self.data.public_holiday_open = False |
|
66
|
|
|
else: |
|
67
|
|
|
self.data.name = 'Budapest Bank ATM' |
|
68
|
|
|
self.data.code = 'hubpatm' |
|
69
|
|
|
self.data.public_holiday_open = True |
|
70
|
|
|
self.data.postcode = poi_data['zip'] |
|
71
|
|
|
self.data.city = poi_data['city_only'] |
|
72
|
|
|
self.data.lat, self.data.lon = check_hu_boundary( |
|
73
|
|
|
poi_data['latitude'], poi_data['longitude']) |
|
74
|
|
|
self.data.street, self.data.housenumber, self.data.conscriptionnumber = \ |
|
75
|
|
|
extract_street_housenumber_better_2(poi_data['addr']) |
|
76
|
|
|
self.data.original = poi_data['address'] |
|
77
|
|
|
self.data.branch = poi_data['name'] |
|
78
|
|
|
# Processing opening hours |
|
79
|
|
|
oh = [] |
|
|
|
|
|
|
80
|
|
|
if poi_data.get('opening') is not None: |
|
81
|
|
|
opening = poi_data.get('opening').split('||') |
|
82
|
|
|
self.data.nonstop = False |
|
83
|
|
|
for i in opening: |
|
84
|
|
|
if 'H:' in i: |
|
85
|
|
|
try: |
|
86
|
|
|
op = i.replace('H:', '').split( |
|
|
|
|
|
|
87
|
|
|
'-')[0].strip() |
|
88
|
|
|
except IndexError as e: |
|
|
|
|
|
|
89
|
|
|
op = None |
|
|
|
|
|
|
90
|
|
|
self.data.mo_o = op if open is not None and op != '' else None |
|
91
|
|
|
try: |
|
92
|
|
|
cl = i.replace('H:', '').split( |
|
|
|
|
|
|
93
|
|
|
'-')[1].strip() |
|
94
|
|
|
except IndexError as e: |
|
|
|
|
|
|
95
|
|
|
cl = None |
|
|
|
|
|
|
96
|
|
|
self.data.mo_c = cl if open is not None and cl != '' else None |
|
97
|
|
|
elif 'K:' in i: |
|
98
|
|
|
try: |
|
99
|
|
|
op = i.replace('K:', '').split( |
|
|
|
|
|
|
100
|
|
|
'-')[0].strip() |
|
101
|
|
|
except IndexError as e: |
|
|
|
|
|
|
102
|
|
|
op = None |
|
|
|
|
|
|
103
|
|
|
self.data.tu_o = op if open is not None and op != '' else None |
|
104
|
|
|
try: |
|
105
|
|
|
cl = i.replace('K:', '').split( |
|
|
|
|
|
|
106
|
|
|
'-')[1].strip() |
|
107
|
|
|
except IndexError as e: |
|
|
|
|
|
|
108
|
|
|
cl = None |
|
|
|
|
|
|
109
|
|
|
self.data.tu_c = cl if open is not None and cl != '' else None |
|
110
|
|
|
elif 'Sz:' in i: |
|
111
|
|
|
try: |
|
112
|
|
|
op = i.replace('Sz:', '').split( |
|
|
|
|
|
|
113
|
|
|
'-')[0].strip() |
|
114
|
|
|
except IndexError as e: |
|
|
|
|
|
|
115
|
|
|
op = None |
|
|
|
|
|
|
116
|
|
|
self.data.we_o = op if open is not None and op != '' else None |
|
117
|
|
|
try: |
|
118
|
|
|
cl = i.replace('Sz:', '').split( |
|
|
|
|
|
|
119
|
|
|
'-')[1].strip() |
|
120
|
|
|
except IndexError as e: |
|
|
|
|
|
|
121
|
|
|
cl = None |
|
|
|
|
|
|
122
|
|
|
self.data.we_c = cl if open is not None and cl != '' else None |
|
123
|
|
|
elif 'Cs:' in i: |
|
124
|
|
|
try: |
|
125
|
|
|
op = i.replace('Cs:', '').split( |
|
|
|
|
|
|
126
|
|
|
'-')[0].strip() |
|
127
|
|
|
except IndexError as e: |
|
|
|
|
|
|
128
|
|
|
op = None |
|
|
|
|
|
|
129
|
|
|
self.data.th_o = op if open is not None and op != '' else None |
|
130
|
|
|
try: |
|
131
|
|
|
cl = i.replace('Cs:', '').split( |
|
|
|
|
|
|
132
|
|
|
'-')[1].strip() |
|
133
|
|
|
except IndexError as e: |
|
|
|
|
|
|
134
|
|
|
cl = None |
|
|
|
|
|
|
135
|
|
|
self.data.th_c = cl if open is not None and cl != '' else None |
|
136
|
|
|
elif 'P:' in i: |
|
137
|
|
|
try: |
|
138
|
|
|
op = i.replace('P:', '').split( |
|
|
|
|
|
|
139
|
|
|
'-')[0].strip() |
|
140
|
|
|
except IndexError as e: |
|
|
|
|
|
|
141
|
|
|
op = None |
|
|
|
|
|
|
142
|
|
|
self.data.fr_o = op if open is not None and op != '' else None |
|
143
|
|
|
try: |
|
144
|
|
|
cl = i.replace('P:', '').split( |
|
|
|
|
|
|
145
|
|
|
'-')[1].strip() |
|
146
|
|
|
except IndexError as e: |
|
|
|
|
|
|
147
|
|
|
cl = None |
|
|
|
|
|
|
148
|
|
|
self.data.fr_c = cl if open is not None and cl != '' else None |
|
149
|
|
|
if self.data.code == 'hubpatm': |
|
150
|
|
|
self.data.nonstop = True |
|
151
|
|
|
else: |
|
152
|
|
|
self.data.nonstop = False |
|
153
|
|
|
self.data.add() |
|
154
|
|
|
except Exception as e: |
|
|
|
|
|
|
155
|
|
|
logging.exception('Exception occurred') |
|
156
|
|
|
logging.error(e) |
|
157
|
|
|
|