osm_poi_matchmaker.utils.data_provider   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 39
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A DataProvider.__init__() 0 12 1
A DataProvider.constains() 0 3 1
A DataProvider.types() 0 3 1
A DataProvider.process() 0 2 1
A DataProvider.export_list() 0 5 3
1
# -*- coding: utf-8 -*-
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
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, \
0 ignored issues
show
Unused Code introduced by
Unused clean_city imported from osm_poi_matchmaker.libs.address
Loading history...
Unused Code introduced by
Unused clean_javascript_variable imported from osm_poi_matchmaker.libs.address
Loading history...
Unused Code introduced by
Unused clean_opening_hours_2 imported from osm_poi_matchmaker.libs.address
Loading history...
Unused Code introduced by
Unused clean_phone imported from osm_poi_matchmaker.libs.address
Loading history...
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:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
best-practice introduced by
Too many instance attributes (10/7)
Loading history...
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
0 ignored issues
show
Coding Style Naming introduced by
Attribute name "POI_COMMON_TAGS" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
29
        self.headers = None
30
        self.post = None
31
        self.__types = None
32
        self.constains()
33
        self.data = POIDataset()
34
35
    def constains(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
36
        self.POI_COMMON_TAGS = ""
37
        self.link = ''
38
39
    def types(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
40
        self.__types = []
41
        return self.__types
42
43
    def process(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
44
        pass
45
46
    def export_list(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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