osm_poi_matchmaker.dataproviders.hu_aldi   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 61
dl 0
loc 73
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hu_aldi.process() 0 26 4
A hu_aldi.constains() 0 16 1
A hu_aldi.types() 0 8 1
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
    from osm_poi_matchmaker.libs.soup import save_downloaded_soup
8
    from osm_poi_matchmaker.libs.address import extract_street_housenumber_better_2, clean_city
9
    from osm_poi_matchmaker.libs.osm_tag_sets import POS_HU_GEN, PAY_CASH
10
    from osm_poi_matchmaker.utils.data_provider import DataProvider
11
    from osm_poi_matchmaker.utils.enums import FileType
12
except ImportError as err:
13
    logging.error('Error %s import module: %s', __name__, err)
14
    logging.exception('Exception occurred')
15
16
    sys.exit(128)
17
18
19
class hu_aldi(DataProvider):
0 ignored issues
show
Coding Style Naming introduced by
Class name "hu_aldi" 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...
20
21
    def constains(self):
22
        self.link = 'https://www.aldi.hu/uzletek/'
23
        self.tags = {'operator': 'ALDI Magyarország Élelmiszer Bt.',
24
                     'operator:addr': '2051 Biatorbágy, Mészárosok útja 2.', 'brand': 'Aldi',
25
                     'ref:vatin:hu': '22234663-2-44', 'ref:vatin': 'HU22234663',
26
                     'ref:HU:company': '13 06 058506', 'ref:company:HU': '13-06-058506',
27
                     'brand:wikipedia': 'hu:Aldi', 'brand:wikidata': 'Q125054',
28
                     'contact:facebook': 'https://www.facebook.com/ALDI.Magyarorszag',
29
                     'contact:youtube': 'https://www.youtube.com/user/ALDIMagyarorszag',
30
                     'contact:instagram': 'https://www.instagram.com/aldi.magyarorszag',
31
                     'air_conditioning': 'yes', }
32
        self.tags.update(POS_HU_GEN)
33
        self.tags.update(PAY_CASH)
34
        self.filetype = FileType.html
35
        self.filename = '{}.{}'.format(
36
            self.__class__.__name__, self.filetype.name)
37
38
    def types(self):
39
        hualdisup = {'shop': 'supermarket'}
40
        hualdisup.update(self.tags)
41
        self.__types = [
42
            {'poi_code': 'hualdisup', 'poi_name': 'Aldi', 'poi_type': 'shop', 'poi_tags': hualdisup,
43
             'poi_url_base': 'https://www.aldi.hu', 'poi_search_name': 'aldi'},
44
        ]
45
        return self.__types
46
47
    def process(self):
48
        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 (109/100).

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

Loading history...
49
                                    self.filetype)
50
        poi_dataset = []
51
        if soup is not None:
52
            # parse the html using beautiful soap and store in variable `soup`
53
            table = soup.find(
54
                'table', attrs={'class': 'contenttable is-header-top'})
55
            table_body = table.find('tbody')
56
            rows = table_body.find_all('tr')
57
            for row in rows:
58
                cols = row.find_all('td')
59
                cols = [element.text.strip() for element in cols]
60
                poi_dataset.append(cols)
61
            for poi_data in poi_dataset:
62
                # Assign: code, postcode, city, name, branch, website, original
63
                #         street, housenumber, conscriptionnumber, ref, geom
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 (124/100).

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

Loading history...
65
                    poi_data[2])
66
                self.data.name = 'Aldi'
67
                self.data.code = 'hualdisup'
68
                self.data.postcode = poi_data[0].strip()
69
                self.data.city = clean_city(poi_data[1])
70
                self.data.original = poi_data[2]
71
                self.data.public_holiday_open = False
72
                self.data.add()
73