hu_omv.constains()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 18
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nop 1
dl 0
loc 18
rs 9.5
c 0
b 0
f 0
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 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, \
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (119/100).

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

Loading history...
10
        clean_phone_to_str
11
    from osm_poi_matchmaker.libs.geo import check_hu_boundary
12
    from osm_poi_matchmaker.libs.osm_tag_sets import POS_HU_GEN, PAY_CASH
13
    from osm_poi_matchmaker.utils.data_provider import DataProvider
14
    from osm_poi_matchmaker.utils.enums import FileType
15
except ImportError as err:
16
    logging.error('Error %s import module: %s', __name__, err)
17
    logging.exception('Exception occurred')
18
19
    sys.exit(128)
20
21
22
class hu_omv(DataProvider):
0 ignored issues
show
Coding Style Naming introduced by
Class name "hu_omv" doesn't conform to PascalCase naming style ('[^\\W\\da-z][^\\W_]+$' 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...
introduced by
Missing class docstring
Loading history...
23
24
    def constains(self):
25
        self.link = 'https://app.wigeogis.com/kunden/omvpetrom/data/getresults.php'
26
        self.tags = {'amenity': 'fuel', 'name': 'OMV', 'brand': 'OMV', 'fuel:diesel': 'yes',
27
                     'fuel:octane_95': 'yes', 'air_conditioning': 'yes', 'brand:wikidata': 'Q168238',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (101/100).

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

Loading history...
28
                     'brand:wikipedia': 'en:OMV', 'operator': 'OMV Hungária Kft.',
29
                     'operator:addr': '1117 Budapest, Október huszonharmadika utca 6-10 5. emelet 5/A.',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (104/100).

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

Loading history...
30
                     'ref:vatin:hu': '10542925-2-44', 'ref:vatin': 'HU10542925',
31
                     'ref:HU:company': '01-09-071584', 'contact:email': '[email protected]',
32
                     'contact:facebook': 'https://www.facebook.com/omvmagyarorszag',
33
                     'contact:fax': '+36 1 381 9899', 'contact:twitter': 'omv',
34
                     'contact:linkedin': 'https://www.linkedin.com/company/omv',
35
                     'contact:instagram': 'https://www.instagram.com/omv/',
36
                     'contact:youtube': 'https://www.youtube.com/user/omvofficial'}
37
        self.post = {'BRAND': 'OMV', 'CTRISO': 'HUN', 'MODE': 'NEXTDOOR', 'ANZ': '5',
38
                     'HASH': '23126a64295e2cf2a5e41f33fd4b0c416e09b0b8', 'TS': '1583951283'}
39
        self.filetype = FileType.json
40
        self.filename = '{}.{}'.format(
41
            self.__class__.__name__, self.filetype.name)
42
43
    def types(self):
44
        huomvfu = self.tags.copy()
45
        huomvfu.update(POS_HU_GEN)
46
        huomvfu.update(PAY_CASH)
47
        self.__types = [
48
            {'poi_code': 'huomvfu', 'poi_name': 'OMV', 'poi_type': 'fuel',
49
             'poi_tags': huomvfu, 'poi_url_base': 'https://www.omv.hu', 'poi_search_name': '(omv|omw|ömv|ömw|ovm|owm)',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (119/100).

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

Loading history...
50
             'osm_search_distance_perfect': 2000, 'osm_search_distance_safe': 450,
51
             'osm_search_distance_unsafe': 60},
52
        ]
53
        return self.__types
54
55
    def process(self):
56
        try:
0 ignored issues
show
unused-code introduced by
Too many nested blocks (6/5)
Loading history...
57
            soup = save_downloaded_soup('{}'.format(self.link), os.path.join(self.download_cache, self.filename),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (113/100).

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

Loading history...
58
                                        self.filetype, self.post)
59
            if soup is not None:
60
                text = json.loads(soup)
61
                for poi_data in text:
62
                    try:
63
                        self.data.name = 'OMV'
64
                        self.data.code = 'huomvfu'
65
                        if poi_data.get('postcode') is not None and poi_data.get('postcode') != '':
66
                            self.data.postcode = poi_data.get(
67
                                'postcode').strip()
68
                        if poi_data.get('town_l') is not None and poi_data.get('town_l') != '':
69
                            self.data.city = clean_city(poi_data.get('town_l'))
70
                        if poi_data.get('open_hours') is not None:
71
                            oho, ohc = clean_opening_hours(
72
                                poi_data.get('open_hours'))
73
                            if oho == '00:00' and ohc == '24:00':
74
                                self.data.nonstop = True
75
                                self.data.public_holiday_open = True
76
                                oho, ohc = None, None
77
                            else:
78
                                self.data.public_holiday_open = False
79
                        else:
80
                            oho, ohc = None, None
81
                            self.data.public_holiday_open = False
82
                        for i in range(0, 7):
83
                            self.data.day_open(i, oho)
84
                            self.data.day_close(i, ohc)
85
                        self.data.lat, self.data.lon = check_hu_boundary(
86
                            poi_data.get('y'), poi_data.get('x'))
87
                        if poi_data.get('address_l') is not None and poi_data.get('address_l') != '':
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (101/100).

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

Loading history...
88
                            self.data.original = poi_data.get('address_l')
89
                            self.data.street, self.data.housenumber, self.data.conscriptionnumber = \
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (101/100).

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

Loading history...
90
                                extract_street_housenumber_better_2(
91
                                    poi_data.get('address_l'))
92
                        if poi_data.get('telnr') is not None and poi_data.get('telnr') != '':
93
                            self.data.phone = clean_phone_to_str(
94
                                poi_data.get('telnr'))
95
                        self.data.fuel_octane_95 = True
96
                        self.data.fuel_diesel = True
97
                        self.data.fuel_octane_100 = True
98
                        self.data.fuel_diesel_gtl = True
99
                        self.data.compressed_air = True
100
                        self.data.add()
101
                    except Exception as e:
0 ignored issues
show
Best Practice introduced by
Catching very general exceptions such as Exception is usually not recommended.

Generally, you would want to handle very specific errors in the exception handler. This ensure that you do not hide other types of errors which should be fixed.

So, unless you specifically plan to handle any error, consider adding a more specific exception.

Loading history...
Coding Style Naming introduced by
Variable name "e" 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...
102
                        logging.error(e)
103
                        logging.error(poi_data)
104
                        logging.exception('Exception occurred')
105
106
        except Exception as e:
0 ignored issues
show
Best Practice introduced by
Catching very general exceptions such as Exception is usually not recommended.

Generally, you would want to handle very specific errors in the exception handler. This ensure that you do not hide other types of errors which should be fixed.

So, unless you specifically plan to handle any error, consider adding a more specific exception.

Loading history...
Coding Style Naming introduced by
Variable name "e" 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...
107
            logging.error(e)
108
            logging.exception('Exception occurred')
109