osm_poi_matchmaker.libs.poi_qc   A
last analyzed

Complexity

Total Complexity 18

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 53
dl 0
loc 68
rs 10
c 0
b 0
f 0
wmc 18

7 Methods

Rating   Name   Duplication   Size   Complexity  
A POIQC.__is_name_metaphone_road_around() 0 6 2
A POIQC.__init__() 0 10 1
A POIQC.process() 0 2 1
A POIQC.__is_in_water() 0 6 2
A POIQC.__check() 0 6 2
B POIQC.__custom_opening_hours() 0 8 8
A POIQC.__is_name_road_around() 0 6 2
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
    import sqlalchemy
0 ignored issues
show
Unused Code introduced by
The import sqlalchemy seems to be unused.
Loading history...
7
    from sqlalchemy.orm import scoped_session, sessionmaker
0 ignored issues
show
Unused Code introduced by
Unused scoped_session imported from sqlalchemy.orm
Loading history...
Unused Code introduced by
Unused sessionmaker imported from sqlalchemy.orm
Loading history...
8
    import geopandas as gpd
0 ignored issues
show
Unused Code introduced by
Unused geopandas imported as gpd
Loading history...
9
except ImportError as err:
10
    logging.error('Error %s import module: %s', __name__, err)
11
    logging.exception('Exception occurred')
12
13
    sys.exit(128)
14
15
16
class POIQC:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
best-practice introduced by
Too many instance attributes (8/7)
Loading history...
17
18
    def __init__(self, db, lon, lat, opening_hours=None, street=None):
0 ignored issues
show
best-practice introduced by
Too many arguments (6/5)
Loading history...
19
        self.__db = db
20
        self.__lon = lon
21
        self.__lat = lat
22
        self.__good = []
23
        self.__bad = []
24
        self.__distance = 1
25
        self.__opening_hours = opening_hours
26
        self.__street = street
27
        self.__check()
28
29
    def __check(self):
30
        self.__is_in_water()
31
        self.__is_name_road_around()
32
        self.__is_name_metaphone_road_around()
33
        if self.__opening_hours is not None:
34
            self.__custom_opening_hours()
35
36
    def process(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
37
        return self.__good, self.__bad
38
39
    def __is_in_water(self):
40
        data = self.__db.query_poi_in_water(self.__lon, self.__lat)
41
        if data.empty:
42
            self.__good.append('not_in_water')
43
        else:
44
            self.__bad.append('in_water')
45
46
    def __custom_opening_hours(self):
47
        if self.__opening_hours is not None:
48
            if 'comment' in self.__opening_hours or 'status' in self.__opening_hours or \
0 ignored issues
show
best-practice introduced by
Too many boolean expressions in if statement (6/5)
Loading history...
49
               'dawn' in self.__opening_hours or 'sunrise' in self.__opening_hours or \
50
               'sunset' in self.__opening_hours or 'dusk' in self.__opening_hours:
51
                self.__bad.append('custom_opening_hours')
52
            else:
53
                self.__good.append('standard_opening_hours')
54
55
    def __is_name_road_around(self):
56
        data = self.__db.query_name_road_around(self.__lon, self.__lat, self.__street, True, 'name')
57
        if data.empty:
58
            self.__bad.append('street_is_not_around')
59
        else:
60
            self.__good.append('street_is_around')
61
62
    def __is_name_metaphone_road_around(self):
63
        data = self.__db.query_name_road_around(self.__lon, self.__lat, self.__street, True, 'metaphone')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (105/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
64
        if data.empty:
65
            self.__bad.append('street_metaphone_is_not_around')
66
        else:
67
            self.__good.append('street_metaphone_is_around')
68