Code Duplication    Length = 58-59 lines in 2 locations

osm_poi_matchmaker/dataproviders/hu_emobi_ev.py 1 location

@@ 22-80 (lines=59) @@
19
    sys.exit(128)
20
21
22
class hu_emobi_ev(DataProvider):
23
24
    def constains(self):
25
        self.link = os.path.join(config.get_directory_cache_url(), 'hu_emobi_ev.csv')
26
        self.POI_COMMON_TAGS = ""
27
        self.filetype = FileType.csv
28
        self.filename = '{}.{}'.format(self.__class__.__name__, self.filetype.name)
29
30
    def types(self):
31
        self.__types = [{'poi_code': 'huemobichs', 'poi_name': 'e-töltőpont', 'poi_type': 'charging_station',
32
                         'poi_tags': "{'amenity': 'charging_station', 'authentication:app': 'yes',"
33
                                     "'authentication:none': 'yes', 'authentication:membership_card': 'yes', "
34
                                     "'operator': 'e-Mobi Elektromobilitás Nonprofit Kft.', "
35
                                     "'operator:addr': '1037 Budapest, Montevideo utca 2/C', 'fee': 'yes',"
36
                                     "'parking:fee': 'no', 'opening_hours': '24/7', 'ref:vatin': 'HU25539431', "
37
                                     "'ref:vatin:hu': ' 25539431-2-41', 'ref:HU:company': '01 09 281052', "
38
                                     "'alt_name': 'e-mobi', 'contact:website': 'https://e-mobi.hu/hu',"
39
                                     "'contact:email': '[email protected]', 'contact:phone': '+36 80 210 012', "
40
                                     "'contact:facebook': 'https://www.facebook.com/elektromobilitas' }",
41
                         'poi_url_base': 'https://e-mobi.hu/', 'poi_search_name': '(e-mobi|emobi|e-töltőpont)',
42
                         'osm_search_distance_perfect': 50, 'osm_search_distance_safe': 30,
43
                         'osm_search_distance_unsafe': 10},
44
                        ]
45
        return self.__types
46
47
    def process(self):
48
        try:
49
            csv = pd.read_csv(self.link, encoding='UTF-8', sep=';', skiprows=1)
50
            if csv is not None:
51
                poi_dict = csv.to_dict('records')
52
                for poi_data in poi_dict:
53
                    self.data.name = 'e-töltőpont'
54
                    self.data.code = 'huemobichs'
55
                    self.data.ref = poi_data.get('Mobiliti azonosító')
56
                    self.data.branch = poi_data.get('Töltőpont neve')
57
                    self.data.postcode = poi_data.get('Irányító szám')
58
                    self.data.city = clean_city(poi_data.get('Település'))
59
                    self.data.street, self.data.housenumber, self.data.conscriptionnumber = \
60
                        extract_street_housenumber_better_2(poi_data.get('Cím'))
61
                    self.data.original = poi_data.get('Cím')
62
                    temp = poi_data.get('GPS koordináták')
63
                    if temp is None:
64
                        continue
65
                    else:
66
                        self.data.lat, self.data.lon = temp.split(',')
67
                    self.data.lat, self.data.lon = check_hu_boundary(self.data.lat, self.data.lon)
68
                    self.data.socket_chademo = poi_data.get('Darab (CHAdeMO)')
69
                    self.data.socket_chademo_output = poi_data.get('Teljesítmény (CHAdeMO)')
70
                    self.data.socket_type2_combo = poi_data.get('Darab (CCS)')
71
                    self.data.socket_type2_combo_output = poi_data.get('Teljesítmény (CCS)')
72
                    self.data.socket_type2_cable = poi_data.get('Darab (Type 2)')
73
                    self.data.socket_type2_cable_output = poi_data.get('Teljesítmény (Type 2)')
74
                    self.data.manufacturer = poi_data.get('Töltő típusa')
75
                    self.data.model = None
76
                    self.data.capacity = poi_data.get('Kapacitás')
77
                    self.data.add()
78
        except Exception as e:
79
            logging.error(traceback.print_exc())
80
            logging.error(e)
81

osm_poi_matchmaker/dataproviders/hu_mobiliti_ev.py 1 location

@@ 22-79 (lines=58) @@
19
    sys.exit(128)
20
21
22
class hu_mobiliti_ev(DataProvider):
23
24
    def constains(self):
25
        self.link = os.path.join(config.get_directory_cache_url(), 'hu_mobiliti_ev.csv')
26
        self.POI_COMMON_TAGS = ""
27
        self.filetype = FileType.csv
28
        self.filename = '{}.{}'.format(self.__class__.__name__, self.filetype.name)
29
30
    def types(self):
31
        self.__types = [{'poi_code': 'humobilchs', 'poi_name': 'Mobiliti', 'poi_type': 'charging_station',
32
                         'poi_tags': "{'amenity': 'charging_station', 'authentication:app': 'yes',"
33
                                     "'authentication:none': 'yes', 'authentication:membership_card': 'yes', "
34
                                     "'operator': 'NKM Mobilitás Kft.', "
35
                                     "'operator:addr': '1081 Budapest, II. János Pál pápa tér 20.', 'fee': 'yes',"
36
                                     "'parking:fee': 'no', 'opening_hours': '24/7', 'ref:vatin': 'HU23443486', "
37
                                     "'ref:vatin:hu': '23443486-2-42', 'ref:HU:company': '01-09-965868', "
38
                                     "'contact:website': 'https://www.mobiliti.hu/emobilitas',"
39
                                     "'contact:email': '[email protected]', 'contact:phone': '+36 62 565 758'}",
40
                         'poi_url_base': 'https://www.mobiliti.hu', 'poi_search_name': '(mobility)',
41
                         'osm_search_distance_perfect': 50, 'osm_search_distance_safe': 30,
42
                         'osm_search_distance_unsafe': 10},
43
                        ]
44
        return self.__types
45
46
    def process(self):
47
        try:
48
            csv = pd.read_csv(self.link, encoding='UTF-8', sep=';', skiprows=1)
49
            if csv is not None:
50
                poi_dict = csv.to_dict('records')
51
                for poi_data in poi_dict:
52
                    self.data.name = 'Mobiliti'
53
                    self.data.code = 'humobilchs'
54
                    self.data.ref = poi_data.get('Mobiliti azonosító')
55
                    self.data.branch = poi_data.get('Töltőpont neve')
56
                    self.data.postcode = poi_data.get('Irányító szám')
57
                    self.data.city = clean_city(poi_data.get('Település'))
58
                    self.data.street, self.data.housenumber, self.data.conscriptionnumber = \
59
                        extract_street_housenumber_better_2(poi_data.get('Cím'))
60
                    self.data.original = poi_data.get('Cím')
61
                    temp = poi_data.get('GPS koordináták')
62
                    if temp is None:
63
                        continue
64
                    else:
65
                        self.data.lat, self.data.lon = temp.split(',')
66
                    self.data.lat, self.data.lon = check_hu_boundary(self.data.lat, self.data.lon)
67
                    self.data.socket_chademo = poi_data.get('Darab (CHAdeMO)')
68
                    self.data.socket_chademo_output = poi_data.get('Teljesítmény (CHAdeMO)')
69
                    self.data.socket_type2_combo = poi_data.get('Darab (CCS)')
70
                    self.data.socket_type2_combo_output = poi_data.get('Teljesítmény (CCS)')
71
                    self.data.socket_type2_cable = poi_data.get('Darab (Type 2)')
72
                    self.data.socket_type2_cable_output = poi_data.get('Teljesítmény (Type 2)')
73
                    self.data.manufacturer = poi_data.get('Töltő típusa')
74
                    self.data.model = None
75
                    self.data.capacity = poi_data.get('Kapacitás')
76
                    self.data.add()
77
        except Exception as e:
78
            logging.error(traceback.print_exc())
79
            logging.error(e)
80