Passed
Push — master ( ea0d3c...cc0a45 )
by KAMI
03:34
created

hu_rossmann.constains()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 1
dl 0
loc 5
rs 10
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 re
0 ignored issues
show
Unused Code introduced by
The import re seems to be unused.
Loading history...
8
    import json
9
    from osm_poi_matchmaker.libs.soup import save_downloaded_soup
10
    from osm_poi_matchmaker.libs.address import extract_street_housenumber_better_2, clean_city, \
11
        extract_javascript_variable, clean_opening_hours
12
    from osm_poi_matchmaker.libs.geo import check_hu_boundary
13
    from osm_poi_matchmaker.libs.osm_tag_sets import POS_HU_GEN, PAY_CASH
14
    from osm_poi_matchmaker.utils.enums import WeekDaysLong
15
    from osm_poi_matchmaker.utils.data_provider import DataProvider
16
    from osm_poi_matchmaker.utils.enums import FileType
17
except ImportError as err:
18
    logging.error('Error %s import module: %s', __name__, err)
19
    logging.exception("Exception occurred")
20
    sys.exit(128)
21
22
23
class hu_rossmann(DataProvider):
0 ignored issues
show
Coding Style Naming introduced by
Class name "hu_rossmann" 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...
24
25
    def constains(self):
26
        self.link = 'https://www.rossmann.hu/uzletkereso'
27
        self.POI_COMMON_TAGS = ""
28
        self.filetype = FileType.html
29
        self.filename = '{}.{}'.format(self.__class__.__name__, self.filetype.name)
30
31 View Code Duplication
    def types(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
32
        self.__types = [{'poi_code': 'hurossmche', 'poi_name': 'Rossmann', 'poi_type': 'chemist',
33
                 'poi_tags': "{'shop': 'chemist', 'operator': 'Rossmann Magyarország Kft.', \
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation (add 8 spaces).
Loading history...
34
                 'operator:addr': '2225 Üllő, Zsaróka út 8.', 'ref:vatin:hu': '11149769-2-44', \
35
                 'ref:vatin': 'HU11149769', 'brand':'Rossmann',  'brand:wikidata': 'Q316004', \
36
                 'brand:wikipedia': 'de:Dirk Rossmann GmbH', 'contact:email': '[email protected]', \
37
                 'phone': '+36 29 889-800;+36 70 4692 800', 'contact:facebook':'https://www.facebook.com/Rossmann.hu', \
38
                 'contact:youtube': 'https://www.youtube.com/channel/UCmUCPmvMLL3IaXRBtx7-J7Q', \
39
                 'contact:instagram':'https://www.instagram.com/rossmann_hu', " + POS_HU_GEN + PAY_CASH + "'air_conditioning': 'yes'}",
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (135/100).

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

Loading history...
40
                 'poi_url_base': 'https://www.rossmann.hu', 'poi_search_name': 'rossmann', 'osm_search_distance_perfect': 2000, 'osm_search_distance_safe': 200, 'osm_search_distance_unsafe': 3}]
0 ignored issues
show
Coding Style introduced by
Wrong continued indentation (add 8 spaces).
Loading history...
Coding Style introduced by
This line is too long as per the coding-style (194/100).

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

Loading history...
41
        return self.__types
42
43
    def process(self):
44
        try:
45
            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...
46
                                        self.filetype,  None, self.verify_link)
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
Loading history...
47
            if soup is not None:
48
                # parse the html using beautiful soap and store in variable `soup`
49
                text = json.loads(extract_javascript_variable(soup, 'places'))
50
                for poi_data in text:
51
                    poi_data = poi_data['addresses'][0]
52
                    # Assign: code, postcode, city, name, branch, website, original, street, housenumber, conscriptionnumber, ref, geom
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (135/100).

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

Loading history...
53
                    self.data.name = 'Rossmann'
54
                    self.data.code = 'hurossmche'
55
                    self.data.city = clean_city(poi_data['city'])
56
                    self.data.postcode = poi_data.get('zip').strip()
57
                    for i in range(0, 7):
58
                        if poi_data['business_hours'][WeekDaysLong(i).name.lower()] is not None:
59
                            opening, closing = clean_opening_hours(poi_data['business_hours'][WeekDaysLong(i).name.lower()])
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (124/100).

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

Loading history...
60
                            self.data.day_open_close(i, opening, closing)
61
                        else:
62
                            self.data.day_open_close(i, None, None)
63
                    self.data.lat, self.data.lon = check_hu_boundary(poi_data['position'][0], poi_data['position'][1])
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (118/100).

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

Loading history...
64
                    self.data.street, self.data.housenumber, self.data.conscriptionnumber = extract_street_housenumber_better_2(
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (128/100).

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

Loading history...
65
                        poi_data['address'])
66
                    self.data.original = poi_data['address']
67
                    self.data.public_holiday_open = False
68
                    self.data.add()
69
        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...
70
            logging.exception("Exception occurred")
71
            logging.error(e)
72