osm_poi_matchmaker.dataproviders.hu_generic   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 75
dl 0
loc 91
rs 10
c 0
b 0
f 0
wmc 11

6 Methods

Rating   Name   Duplication   Size   Complexity  
A hu_city_postcode_from_xml.__init__() 0 5 1
A hu_city_postcode.process() 0 19 2
A hu_city_postcode.__init__() 0 3 1
A hu_city_postcode_from_xml.process() 0 13 3
A hu_street_types_from_xml.__init__() 0 5 1
A hu_street_types_from_xml.process() 0 12 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
    import os
7
    import pandas as pd
8
    from lxml import etree
9
    from osm_poi_matchmaker.dao.data_handlers import insert_city_dataframe, insert_street_type_dataframe
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...
10
    from osm_poi_matchmaker.libs.xml import save_downloaded_xml
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_COLS_CITY = ['city_post_code', 'city_name']
18
POI_COLS_STREET_TYPE = ['street_type']
19
20
21
class hu_city_postcode():
0 ignored issues
show
Coding Style Naming introduced by
Class name "hu_city_postcode" 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...
22
23
    def __init__(self, session, link):
24
        self.session = session
25
        self.link = link
26
27
    def process(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
28
        xl = pd.ExcelFile(self.link)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "xl" 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
        df = xl.parse("Települések")
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" 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...
30
        del df['Településrész']
31
        insert_city_dataframe(self.session, df)
32
        big_cities = [['Budapest', 'Bp.u.'],
33
                      ['Miskolc', 'Miskolc u.'],
34
                      ['Debrecen', 'Debrecen u.'],
35
                      ['Szeged', 'Szeged u.'],
36
                      ['Pécs', 'Pécs u.'],
37
                      ['Győr', 'Győr u.']
38
                      ]
39
        for city, sheet in big_cities:
40
            df = xl.parse(sheet)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" 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...
41
            df.columns.values[0] = 'city_post_code'
42
            df['city_name'] = city
43
            df = df[['city_post_code', 'city_name']]
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" 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...
44
            df.drop_duplicates('city_post_code', keep='first', inplace=True)
45
            insert_city_dataframe(self.session, df)
46
47
48
class hu_city_postcode_from_xml():
0 ignored issues
show
Coding Style Naming introduced by
Class name "hu_city_postcode_from_xml" 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...
49
50
    def __init__(self, session, link, download_cache, filename='hu_city_postcode.xml'):
51
        self.session = session
52
        self.link = link
53
        self.download_cache = download_cache
54
        self.filename = filename
55
56
    def process(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
57
        xml = save_downloaded_xml('{}'.format(self.link), os.path.join(
58
            self.download_cache, self.filename))
59
        insert_data = []
60
        root = etree.fromstring(xml)
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'fromstring' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects.
Loading history...
61
        for e in root.findall('zipCode'):
0 ignored issues
show
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...
62
            cities = e[1].text
63
            postcode = e[0].text.strip()
64
            for i in cities.split('|'):
65
                insert_data.append([postcode, i.strip()])
66
        df = pd.DataFrame(insert_data)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" 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...
67
        df.columns = POI_COLS_CITY
68
        insert_city_dataframe(self.session, df)
69
70
71
class hu_street_types_from_xml():
0 ignored issues
show
Coding Style Naming introduced by
Class name "hu_street_types_from_xml" 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...
72
73
    def __init__(self, session, link, download_cache, filename='hu_street_types.xml'):
74
        self.session = session
75
        self.link = link
76
        self.download_cache = download_cache
77
        self.filename = filename
78
79
    def process(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
80
        xml = save_downloaded_xml('{}'.format(self.link), os.path.join(
81
            self.download_cache, self.filename))
82
        insert_data = []
83
        root = etree.fromstring(xml)
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'fromstring' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects.
Loading history...
84
        for e in root.findall('streetType'):
0 ignored issues
show
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...
85
            if e.text is not None:
86
                street_type = e.text.strip()
87
                insert_data.append(street_type)
88
        df = pd.DataFrame(insert_data)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" 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...
89
        df.columns = POI_COLS_STREET_TYPE
90
        insert_street_type_dataframe(self.session, df)
91