osm_poi_matchmaker.libs.pandas   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 41
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 9

1 Function

Rating   Name   Duplication   Size   Complexity  
C save_downloaded_pd() 0 33 9
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 requests
0 ignored issues
show
Unused Code introduced by
The import requests seems to be unused.
Loading history...
7
    import os
8
    import pandas as pd
9
    from osm_poi_matchmaker.utils import config
10
    from osm_poi_matchmaker.libs.soup import download_content
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
18
def save_downloaded_pd(link, file, verify=config.get_download_verify_link(), headers=None):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Unused Code introduced by
The argument headers seems to be unused.
Loading history...
19
    if config.get_download_use_cached_data() is True and os.path.isfile(file):
20
        df = pd.read_csv(file)
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...
21
    else:
22
        if link is not None:
23
            cvs = download_content(link, verify, None, None, 'utf-16')
24
            if cvs is not None:
25
                logging.info('We got content, write to file.')
26
                if not os.path.exists(config.get_directory_cache_url()):
27
                    os.makedirs(config.get_directory_cache_url())
28
                with open(file, mode='w', encoding='utf-8') as code:
29
                    code.write(cvs)
30
                df = pd.read_csv(file, encoding='UTF-8', sep='\t', skiprows=0)
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...
31
            else:
32
                if os.path.exists(file):
33
                    logging.info(
34
                        'The %s link returned error code other than 200 but there is an already downloaded file. Try to open it.',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (130/100).

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

Loading history...
35
                        link)
36
                    df = pd.read_csv(file, encoding='UTF-8', sep='\t', skiprows=0)
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...
37
                else:
38
                    logging.warning(
39
                        'Skipping dataset: %s. There is not downloadable URL, nor already downbloaded file.', link)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (115/100).

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

Loading history...
40
        else:
41
            if os.path.exists(file):
42
                df = pd.read_csv(file, encoding='UTF-8', sep='\t', skiprows=0)
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...
43
                logging.info(
44
                    'Using file only: %s. There is not downloadable URL only just the file. Do not forget to update file manually!',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (132/100).

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

Loading history...
45
                    file)
46
            else:
47
                logging.warning(
48
                    'Cannot use download and file: %s. There is not downloadable URL, nor already downbloaded file.',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (117/100).

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

Loading history...
49
                    file)
50
    return df
0 ignored issues
show
introduced by
The variable df does not seem to be defined for all execution paths.
Loading history...
51