1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
2
|
|
|
|
3
|
|
|
try: |
4
|
|
|
import logging |
5
|
|
|
import sys |
6
|
|
|
import os |
7
|
|
|
import json |
8
|
|
|
from osm_poi_matchmaker.libs.soup import save_downloaded_soup |
9
|
|
|
from osm_poi_matchmaker.libs.address import extract_street_housenumber_better_2, clean_city, clean_opening_hours |
|
|
|
|
10
|
|
|
from osm_poi_matchmaker.libs.geo import check_hu_boundary |
11
|
|
|
from osm_poi_matchmaker.utils.enums import WeekDaysLongHUUnAccented |
12
|
|
|
from osm_poi_matchmaker.utils.data_provider import DataProvider |
13
|
|
|
from osm_poi_matchmaker.utils.enums import FileType |
14
|
|
|
except ImportError as err: |
15
|
|
|
logging.error('Error %s import module: %s', __name__, err) |
16
|
|
|
logging.exception('Exception occurred') |
17
|
|
|
|
18
|
|
|
sys.exit(128) |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
class hu_foxpost(DataProvider): |
|
|
|
|
22
|
|
|
|
23
|
|
View Code Duplication |
def constains(self): |
|
|
|
|
24
|
|
|
self.link = 'https://cdn.foxpost.hu/foxpost_terminals_extended_v3.json' |
25
|
|
|
self.tags = {'brand': 'Foxpost', 'operator': 'FoxPost Zrt.', |
26
|
|
|
'operator:addr': '3200 Gyöngyös, Batsányi János utca 9.', 'ref:vatin': 'HU25034644', |
|
|
|
|
27
|
|
|
'ref:vatin:hu': '25034644-2-10', 'ref:HU:company': '10 10 020309', |
28
|
|
|
'contact:facebook': 'https://www.facebook.com/foxpostzrt', |
29
|
|
|
'contact:youtube': 'https://www.youtube.com/channel/UC3zt91sNKPimgA32Nmcu97w', |
30
|
|
|
'contact:email': '[email protected]', 'phone': '+36 1 999 03 69', |
31
|
|
|
'payment:contactless': 'yes', 'payment:mastercard': 'yes', 'payment:visa': 'yes', |
|
|
|
|
32
|
|
|
'payment:cash': 'no', } |
33
|
|
|
self.filetype = FileType.json |
34
|
|
|
self.filename = '{}.{}'.format( |
35
|
|
|
self.__class__.__name__, self.filetype.name) |
36
|
|
|
|
37
|
|
|
def types(self): |
38
|
|
|
hufoxpocso = {'amenity': 'vending_machine', |
39
|
|
|
'vending': 'parcel_pickup;parcel_mail_in'} |
40
|
|
|
hufoxpocso.update(self.tags) |
41
|
|
|
self.__types = [ |
42
|
|
|
{'poi_code': 'hufoxpocso', 'poi_name': 'Foxpost', 'poi_type': 'vending_machine_parcel_pickup_and_mail_in', |
|
|
|
|
43
|
|
|
'poi_tags': hufoxpocso, 'poi_url_base': 'https://www.foxpost.hu', 'poi_search_name': 'foxpost', |
|
|
|
|
44
|
|
|
'osm_search_distance_perfect': 1000, 'osm_search_distance_safe': 400, 'osm_search_distance_unsafe': 20}, |
|
|
|
|
45
|
|
|
] |
46
|
|
|
return self.__types |
47
|
|
|
|
48
|
|
|
def process(self): |
49
|
|
|
try: |
50
|
|
|
soup = save_downloaded_soup('{}'.format(self.link), os.path.join(self.download_cache, self.filename), |
|
|
|
|
51
|
|
|
self.filetype) |
52
|
|
|
if soup is not None: |
53
|
|
|
text = json.loads(soup) |
54
|
|
|
for poi_data in text: |
55
|
|
|
self.data.name = 'Foxpost' |
56
|
|
|
self.data.code = 'hufoxpocso' |
57
|
|
|
self.data.postcode = poi_data['zip'].strip() |
58
|
|
|
self.data.city = clean_city(poi_data['city']) |
59
|
|
|
self.data.branch = poi_data['name'] |
60
|
|
|
for i in range(0, 7): |
61
|
|
|
if poi_data['open'][WeekDaysLongHUUnAccented(i).name.lower()] is not None: |
62
|
|
|
opening, closing = clean_opening_hours( |
63
|
|
|
poi_data['open'][WeekDaysLongHUUnAccented(i).name.lower()]) |
64
|
|
|
self.data.day_open(i, opening) |
65
|
|
|
self.data.day_close(i, closing) |
66
|
|
|
else: |
67
|
|
|
self.data.day_open_close(i, None, None) |
68
|
|
|
self.data.original = poi_data['address'] |
69
|
|
|
self.data.lat, self.data.lon = check_hu_boundary( |
70
|
|
|
poi_data['geolat'], poi_data['geolng']) |
71
|
|
|
self.data.street, self.data.housenumber, self.data.conscriptionnumber = extract_street_housenumber_better_2( |
|
|
|
|
72
|
|
|
poi_data['street']) |
73
|
|
|
self.data.public_holiday_open = False |
74
|
|
|
self.data.description = poi_data.get('findme') |
75
|
|
|
self.data.add() |
76
|
|
|
except Exception as e: |
|
|
|
|
77
|
|
|
logging.exception('Exception occurred') |
78
|
|
|
|
79
|
|
|
logging.error(e) |
80
|
|
|
|