Total Complexity | 7 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
|
|||
2 | |||
3 | try: |
||
4 | import logging |
||
5 | import sys |
||
6 | from osm_poi_matchmaker.dao.data_handlers import insert_poi_dataframe |
||
7 | from osm_poi_matchmaker.libs.address import clean_city, \ |
||
8 | clean_javascript_variable, clean_opening_hours_2, clean_phone |
||
9 | from osm_poi_matchmaker.libs.poi_dataset import POIDataset |
||
10 | from osm_poi_matchmaker.utils.enums import FileType |
||
11 | except ImportError as err: |
||
12 | logging.error('Error %s import module: %s', __name__, err) |
||
13 | logging.exception('Exception occurred') |
||
14 | |||
15 | sys.exit(128) |
||
16 | |||
17 | POI_DATA = '' |
||
18 | |||
19 | |||
20 | class DataProvider: |
||
21 | |||
22 | def __init__(self, session, download_cache, filetype=FileType.json, verify_link=True): |
||
23 | self.session = session |
||
24 | self.download_cache = download_cache |
||
25 | self.filename = '{}.{}'.format(self.__class__.__name__, filetype) |
||
26 | self.verify_link = verify_link |
||
27 | self.link = None |
||
28 | self.POI_COMMON_TAGS = None |
||
29 | self.headers = None |
||
30 | self.post = None |
||
31 | self.__types = None |
||
32 | self.constains() |
||
33 | self.data = POIDataset() |
||
34 | |||
35 | def constains(self): |
||
36 | self.POI_COMMON_TAGS = "" |
||
37 | self.link = '' |
||
38 | |||
39 | def types(self): |
||
40 | self.__types = [] |
||
41 | return self.__types |
||
42 | |||
43 | def process(self): |
||
44 | pass |
||
45 | |||
46 | def export_list(self): |
||
47 | if self.data is None or self.data.lenght() < 1: |
||
48 | logging.warning('Resultset is empty. Skipping ...') |
||
49 | else: |
||
50 | insert_poi_dataframe(self.session, self.data.process()) |
||
51 |