generate_osm_xml()   F
last analyzed

Complexity

Conditions 90

Size

Total Lines 265
Code Lines 215

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 90
eloc 215
nop 2
dl 0
loc 265
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Complexity

Complex classes like osm_poi_matchmaker.libs.file_output.generate_osm_xml() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

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 math
7
    import os
8
    import datetime
9
    from urllib.parse import quote
10
    from osm_poi_matchmaker.dao.data_structure import OSM_object_type
11
    from osm_poi_matchmaker.utils import config
12
    from osm_poi_matchmaker.libs.address import clean_url
13
    from osm_poi_matchmaker.libs.osm import relationer, timestamp_now
0 ignored issues
show
Unused Code introduced by
Unused timestamp_now imported from osm_poi_matchmaker.libs.osm
Loading history...
14
    from osm_poi_matchmaker.libs.compare_strings import compare_strings
15
    from sqlalchemy.orm import scoped_session, sessionmaker
16
    from osm_poi_matchmaker.dao.poi_base import POIBase
0 ignored issues
show
introduced by
Imports from package osm_poi_matchmaker are not grouped
Loading history...
17
    from lxml import etree
18
    import lxml
19
except ImportError as err:
20
    logging.error('Error %s import module: %s', __name__, err)
21
    logging.exception('Exception occurred')
22
23
    sys.exit(128)
24
25
POI_TAGS = {'poi_name': 'name', 'poi_city': 'addr:city', 'poi_postcode': 'addr:postcode',
26
            'poi_addr_street': 'addr:street', 'poi_addr_housenumber': 'addr:housenumber',
27
            'poi_conscriptionnumber': 'addr:conscriptionnumber', 'poi_branch': 'branch', 'poi_email': 'email'}
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (110/100).

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

Loading history...
28
29
POI_YESNO_TAGS = {'poi_fuel_adblue': 'fuel:adblue', 'poi_fuel_octane_100': 'fuel:octane_100',
30
                  'poi_fuel_octane_98': 'fuel:octane_98', 'poi_fuel_octane_95': 'fuel:octane_95',
31
                  'poi_fuel_diesel_gtl': 'fuel:GTL_diesel', 'poi_fuel_diesel': 'fuel:diesel',
32
                  'poi_fuel_lpg': 'fuel:lpg', 'poi_fuel_e85': 'fuel:e85', 'poi_rent_lpg_bottles': 'rent:lpg_bottles',
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...
33
                  'poi_compressed_air': 'compressed_air', 'poi_restaurant': 'restaurant', 'poi_food': 'food',
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...
34
                  'poi_truck': 'truck', 'poi_authentication_app': 'authentication:app',
35
                  'poi_authentication_membership_card': 'authentication:membership_card', 'poi_fee': 'fee',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/100).

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

Loading history...
36
                  'poi_parking_fee': 'parking_fee', 'poi_motorcar': 'motorcar'}
37
38
POI_EV_TAGS = {'poi_capacity': 'capacity',
39
               'poi_socket_chademo': 'socket:chademo', 'poi_socket_chademo_output': 'socket:chademo:output',
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (108/100).

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

Loading history...
40
               'poi_socket_type2_combo': 'socket:type2_combo',
41
               'poi_socket_type2_combo_output': 'socket:type2_combo:output',
42
               'poi_socket_type2_cable': 'socket:type2_cable',
43
               'poi_socket_type2_cable_output': 'socket:type2_cable:output',
44
               'poi_socket_type2': 'socket:type2', 'poi_socket_type2_output': 'socket:type2:output',
45
               'poi_manufacturer': 'manufacturer', 'poi_model': 'model'}
46
47
TESTCASE_GEN_KEYS = ('original', 'poi_postcode', 'poi_city', 'poi_addr_street', 'poi_addr_housenumber', 'poi_conscriptionnumber')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (129/100).

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

Loading history...
48
49
TIMESTAMP_FORMAT = '{:{dfmt}T{tfmt}Z}'
50
DATE_FOTMAT = '%Y-%m-%d'
51
TIME_FORMAT = '%H:%M:%S'
52
53
54
def ascii_numcoder(text):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
55
    output = ''
56
    for i in text:
57
        if i in range(0, 10, 1):
58
            output += i
59
        else:
60
            output += str(ord(i))
61
    return output
62
63
64
def save_csv_file(path: str, file: str, data, message: str):
65
    """Save Pandas dataframe to a CSV file
66
67
    Args:
68
        path (str): Path of newly created CVS file
69
        file (str): Filename of newly created CVS file
70
        data (pd.DataFrame): Pandas dataframe to write
71
        message (str): Addtion information to display
72
    """
73
    try:
74
        # Save file to CSV file
75
        logging.info('Saving {%s to file: %s', message, file)
76
        res = data.to_csv(os.path.join(path, file))
0 ignored issues
show
Unused Code introduced by
The variable res seems to be unused.
Loading history...
77
        logging.info('The %s was sucessfully saved', file)
78
    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...
79
        logging.error(e)
80
        logging.exception('Exception occurred')
81
82
83
def add_osm_node(osm_id: int, node_data: dict, prefix: str = 'poi') -> dict:
84
    """Generate OpenStreetMap node header information as string
85
86
    Args:
87
        osm_id (int): OpenStreetMap ID
88
        node_data (dict): [description]
89
        prefix (str): Prefix for field names in database
90
91
    Returns:
92
        str: [description]
93
    """
94
    logging.info(node_data.to_string())
95
    if node_data.get('osm_timestamp') is None:
96
        osm_timestamp = datetime.datetime.now()
97
    else:
98
        osm_timestamp = node_data.get('osm_timestamp')
99
    osm_version = '99999' if node_data.get('osm_version') is None else node_data.get('osm_version')
100
    osm_data = {'action': 'modify', 'id': str(osm_id),
101
                'lat': '{}'.format(node_data.get('{}_lat'.format(prefix))),
102
                'lon': '{}'.format(node_data.get('{}_lon'.format(prefix))),
103
                'user': '{}'.format('osm_poi_matchmaker'), 'uid': '{}'.format('8635934'), 'version': '{}'.format(osm_version),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (126/100).

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

Loading history...
104
                'timestamp': TIMESTAMP_FORMAT.format(osm_timestamp, dfmt=DATE_FOTMAT, tfmt=TIME_FORMAT)}
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...
105
    logging.info(osm_data)
106
    return osm_data
107
108
109
def list_osm_node(osm_id: int, node_data: dict, prefix='poi') -> dict:
110
    """Generate OpenStreetMap node header information as string
111
112
    Args:
113
        osm_id (int): OpenStreetMap ID
114
        node_data (dict): [description]
115
        prefix (str): Prefix for field names in database
116
117
    Returns:
118
        str: [description]
119
    """
120
    logging.debug(node_data)
121
    osm_user = 'osm_poi_matchmaker' if node_data.get('osm_user') is None else node_data.get('osm_user')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (103/100).

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

Loading history...
122
    osm_user_id = '8635934' if node_data.get('osm_user_id') is None else node_data.get('osm_user_id')
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...
123
    if node_data.get('osm_timestamp') is None:
124
        osm_timestamp = datetime.datetime.now()
125
    else:
126
        osm_timestamp = node_data.get('osm_timestamp')
127
    osm_version = '99999' if node_data.get('osm_version') is None else node_data.get('osm_version')
128
    osm_data = {'id': str(osm_id),
129
                'lat': '{}'.format(node_data.get('{}_lat'.format(prefix))),
130
                'lon': '{}'.format(node_data.get('{}_lon'.format(prefix))),
131
                'user': '{}'.format(osm_user), 'uid': '{}'.format(osm_user_id), 'version': '{}'.format(osm_version),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (116/100).

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

Loading history...
132
                'timestamp': TIMESTAMP_FORMAT.format(osm_timestamp, dfmt=DATE_FOTMAT, tfmt=TIME_FORMAT)}
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...
133
    logging.debug(osm_data)
134
    return osm_data
135
136
137
def add_osm_way(osm_id: int, node_data: dict) -> dict:
138
    """Generate OpenStreetMap way header information as dictionary
139
140
    Args:
141
        osm_id (int): [description]
142
        node_data (dict): [description]
143
144
    Returns:
145
        str: [description]
146
    """
147
    if node_data.get('osm_timestamp') is None:
148
        osm_timestamp = datetime.datetime.now()
149
    else:
150
        osm_timestamp = node_data.get('osm_timestamp')
151
    osm_version = '99999' if node_data.get('osm_version') is None else node_data.get('osm_version')
152
    osm_data = {'action': 'modify', 'id': str(osm_id),
153
                'user': '{}'.format('osm_poi_matchmaker'), 'uid': '{}'.format('8635934'),
154
                'version': '{}'.format(osm_version),
155
                'timestamp': TIMESTAMP_FORMAT.format(osm_timestamp, dfmt=DATE_FOTMAT, tfmt=TIME_FORMAT)}
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...
156
    return osm_data
157
158
159
def add_osm_link_comment(osm_id: int, osm_type) -> str:
160
    """Create OpenStreetMap osm.org link from OSM object
161
162
    Args:
163
        osm_id (int): [description]
164
        osm_type ([type]): [description]
165
166
    Returns:
167
        str: [description]
168
    """
169
    osm_comment = ' OSM link: https://osm.org/{}/{} '.format(osm_type.name, str(osm_id))
170
    return osm_comment
171
172
173
def generate_osm_xml(df, session=None):
0 ignored issues
show
Coding Style Naming introduced by
Argument 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...
Comprehensibility introduced by
This function exceeds the maximum number of variables (38/15).
Loading history...
174
    """Crete OpenStreetMap (OSM XML) file from passed Panda Dataframe
175
176
    Args:
177
        df ([type]): [description]
178
        session ([type], optional): [description]. Defaults to None.
179
180
    Returns:
181
        [type]: [description]
182
    """
183
    db = POIBase('{}://{}:{}@{}:{}/{}'.format(config.get_database_type(), config.get_database_writer_username(),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (112/100).

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

Loading history...
Coding Style Naming introduced by
Variable name "db" 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...
184
                                              config.get_database_writer_password(),
185
                                              config.get_database_writer_host(),
186
                                              config.get_database_writer_port(),
187
                                              config.get_database_poi_database()))
188
    pgsql_pool = db.pool
189
    session_factory = sessionmaker(pgsql_pool)
190
    Session = scoped_session(session_factory)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "Session" 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...
191
    session = Session()
192
    osm_xml_data = etree.Element('osm', version='0.6', generator='JOSM')
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'Element' 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...
193
    default_osm_id = -1
194
    current_osm_id = default_osm_id
195
    added_nodes = []
196
    try:
0 ignored issues
show
unused-code introduced by
Too many nested blocks (10/5)
Loading history...
unused-code introduced by
Too many nested blocks (6/5)
Loading history...
unused-code introduced by
Too many nested blocks (7/5)
Loading history...
197
        for index, row in df.iterrows():
0 ignored issues
show
introduced by
Possibly unused variable 'index'
Loading history...
198
            tags = {}
199
            osm_live_tags = {}
200
            main_data = {}
201
            current_osm_id = default_osm_id if row.get('osm_id') is None else row.get('osm_id')
202
            osm_version = '99999' if row.get('osm_version') is None else row.get('osm_version')
0 ignored issues
show
introduced by
Possibly unused variable 'osm_version'
Loading history...
203
            if row.get('osm_node') is None or row.get('osm_node') == OSM_object_type.node:
204
                try:
205
                    josm_object = 'n{}'.format(current_osm_id)
206
                    main_data = etree.SubElement(osm_xml_data, 'node', add_osm_node(current_osm_id, row))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (105/100).

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

Loading history...
introduced by
Module 'lxml.etree' has no 'SubElement' 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...
207
                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...
208
                    logging.exception('Exception occurred')
209
            elif row.get('osm_node') is not None and row.get('osm_node') == OSM_object_type.way:
210
                try:
211
                    main_data = etree.SubElement(osm_xml_data, 'way', add_osm_way(current_osm_id, row))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (103/100).

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

Loading history...
introduced by
Module 'lxml.etree' has no 'SubElement' 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...
212
                    josm_object = 'w{}'.format(current_osm_id)
213
                # Add way nodes without any modification)
214
                    node_data = []
215
                    for n in row.get('osm_nodes'):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" 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...
216
                        data = etree.SubElement(main_data, 'nd', ref=str(n))
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'SubElement' 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...
introduced by
Possibly unused variable 'data'
Loading history...
217
                    if session is not None:
218
                        # Go through the list except the last value (which is same as the first)
219
                        for n in row.get('osm_nodes'):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" 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...
220
                            # Add nodes only when it is not already added.
221
                            if n not in added_nodes:
222
                                added_nodes.append(n)
223
                                way_node = db.query_from_cache(n, OSM_object_type.node)
224
                                if way_node is not None:
225
                                    node_data = etree.SubElement(osm_xml_data, 'node',
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'SubElement' 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...
226
                                                                 list_osm_node(n, way_node, 'osm'))
227
                                    if node_data.get('osm_live_tags') is not None and \
228
                                       node_data.get('osm_live_tags') != '':
229
                                        node_osm_live_tags = node_data.get('osm_live_tags')
230
                                        for k, v in sorted(node_osm_live_tags).items():
0 ignored issues
show
Coding Style Naming introduced by
Variable name "v" 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...
231
                                            xml_node_tags = etree.SubElement(node_data, 'tag', k=k, v='{}'.format(v))
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...
introduced by
Module 'lxml.etree' has no 'SubElement' 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...
232
                except TypeError as e:
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...
233
                    logging.warning('Missing nodes on this way: %s.', row.get('osm_id'))
234
                    logging.exception('Exception occurred')
235
            elif row.get('osm_node') is not None and row.get('osm_node') == OSM_object_type.relation:
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...
236
                try:
237
                    main_data = etree.SubElement(osm_xml_data, 'relation', add_osm_way(current_osm_id, row))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (108/100).

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

Loading history...
introduced by
Module 'lxml.etree' has no 'SubElement' 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...
238
                    josm_object = 'r{}'.format(current_osm_id)
239
                    relations = relationer(row.get('osm_nodes'))
240
                    for i in relations:
241
                        data = etree.SubElement(main_data, 'member', type=i.get('type'), ref=i.get('ref'),
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (106/100).

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

Loading history...
introduced by
Module 'lxml.etree' has no 'SubElement' 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...
242
                                                role=i.get('role'))
243
                except TypeError as e:
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...
244
                    logging.warning('Missing nodes on this relation: %s.', row['osm_id'])
245
                    logging.exception('Exception occurred')
246
            # Add already existing node, way, relation OpenStreetMap reference as comment
247
            try:
248
                if current_osm_id > 0:
249
                    osm_xml_data.append(etree.Comment(add_osm_link_comment(current_osm_id, row.get('osm_node'))))
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...
introduced by
Module 'lxml.etree' has no 'Comment' 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...
250
                # Add original POI coordinates as comment
251
                comment = etree.Comment(' Original coordinates: {} '.format(row.get('poi_geom')))
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'Comment' 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...
252
                osm_xml_data.append(comment)
253
                if 'poi_distance' in row:
254
                    if row.get('poi_distance') is not None:
255
                        comment = etree.Comment(' OSM <-> POI distance: {} m'.format(row.get('poi_distance')))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (110/100).

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

Loading history...
introduced by
Module 'lxml.etree' has no 'Comment' 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...
256
                    else:
257
                        comment = etree.Comment(' OSM <-> POI distance: Non exist')
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'Comment' 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...
258
                    osm_xml_data.append(comment)
259
                if 'poi_good' in row and 'poi_bad' in row:
260
                    comment = etree.Comment(' Checker good: {}; bad {}'.format(row.get('poi_good'), row.get('poi_bad')))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (120/100).

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

Loading history...
introduced by
Module 'lxml.etree' has no 'Comment' 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...
261
                    osm_xml_data.append(comment)
262
                # Using already definied OSM tags if exists
263
                if row.get('osm_live_tags') is not None:
264
                    tags.update(row.get('osm_live_tags').copy())
265
                    logging.critical(row.get('osm_live_tags'))
266
                    osm_live_tags.update(row.get('osm_live_tags').copy())
267
                # Adding POI common tags
268
                if row.get('poi_tags') is not None:
269
                    tags.update(row.get('poi_tags'))
270
                # Save live name tags if preserve name is enabled
271
            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...
272
                logging.exception('Exception occurred')
273
            try:
274
                if row.get('preserve_original_name') is True:
275
                    preserved_name = tags.get('name')
276
            except KeyError as e:
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...
277
                logging.debug('No name tag is specified to save in original OpenStreetMap data.')
278
            try:
279
                # Overwriting with data from data providers
280
                for k, v in POI_TAGS.items():
0 ignored issues
show
Coding Style Naming introduced by
Variable name "v" 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...
281
                    if row.get(k) is not None:
282
                        tags[v] = row.get(k)
283
            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...
284
                logging.exception('Exception occurred')
285
            try:
286
                if config.get_geo_alternative_opening_hours():
287
                    alternative_oh_tag = config.get_geo_alternative_opening_hours_tag()
288
                    # Alternative opening_hours handling for COVID-19 code path
289
                    if tags.get('opening_hours') is not None and tags.get('opening_hours') != '':
290
                        if row.get('poi_opening_hours') is not None and row.get('poi_opening_hours') != '':
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/100).

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

Loading history...
291
                            if tags.get('opening_hours') == row.get('poi_opening_hours'):
292
                                tags[alternative_oh_tag] = 'same'
293
                            else:
294
                                tags[alternative_oh_tag] = row.get('poi_opening_hours')
295
                    else:
296
                        if row.get('poi_opening_hours') is not None and row.get('poi_opening_hours') != '':
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/100).

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

Loading history...
297
                            tags['opening_hours'] = row.get('poi_opening_hours')
298
                            tags[alternative_oh_tag] = 'same'
299
                else:
300
                    # Alternative opening_hours handling for NON COVID-19 code path: just simply add opening_hours to tags
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (122/100).

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

Loading history...
301
                    if row.get('poi_opening_hours') is not None and row.get('poi_opening_hours') != '':
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (103/100).

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

Loading history...
302
                        tags['opening_hours'] = row.get('poi_opening_hours')
303
            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...
304
                logging.exception('Exception occurred')
305
            try:
306
                # If we got POI phone tag use it as OSM contact:phone tag
307
                if row.get('poi_phone') is not None and row.get('poi_phone') != '':
308
                    tags['contact:phone'] = row.get('poi_phone')
309
            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...
310
                logging.exception('Exception occurred')
311
            try:
312
                # If we got POI website tag use it as OSM contact:website tag
313
                if row.get('poi_url_base') is not None and row.get('poi_website') is not None:
314
                    if row['poi_url_base'] in row.get('poi_website'):
315
                        # The POI website contains the base URL use the POI website field only
316
                        tags['contact:website'] = clean_url('{}'.format((row.get('poi_website'))))
317
                    else:
318
                        # The POI website does not contain the base URL use the merged base URL and POI website field
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...
319
                        tags['contact:website'] = clean_url('{}/{}'.format(row.get('poi_url_base'), row.get('poi_website')))
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...
320
                # If only the base URL is available
321
                elif row.get('poi_url_base') is not None:
322
                    tags['contact:website'] = row.get('poi_url_base')
323
            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...
324
                logging.exception('Exception occurred')
325
            try:
326
                # Short URL for source
327
                if row['poi_url_base'] is not None:
328
                    source_url = 'source:{}:date'.format(row.get('poi_url_base').split('/')[2])
329
                else:
330
                    source_url = 'source:website:date'
331
                tags[source_url] = '{:{dfmt}}'.format(datetime.datetime.now(), dfmt=DATE_FOTMAT)
332
            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...
333
                logging.exception('Exception occurred')
334
            try:
335
                # Write back the saved name tag
336
                if 'preserved_name' in locals():
337
                    tags['name'] = preserved_name
338
                # Rewrite old contact tags to contact:* tag form
339
                tags_rewrite = ['website', 'phone', 'email', 'facebook', 'instagram', 'youtube', 'pinterest', 'fax']
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (116/100).

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

Loading history...
340
                for tr in tags_rewrite:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "tr" 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...
341
                    if tr in tags:
342
                        # Never overwrite already existing contact:* tags
343
                        if 'contact:' + tr in tags:
344
                            # We already have this contact:* tag so remove the simple contact tag
345
                            tags.pop(tr, None)
346
                        else:
347
                            # Rewrite simple contact tag to contact:* tag
348
                            tags['contact:' + tr] = tags.pop(tr, None)
349
            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...
350
                logging.exception('Exception occurred')
351
            try:
352
                if row.get('poi_description') is not None and row.get('poi_description') != '':
353
                    tags['description'] = row.get('poi_description')
354
            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...
355
                logging.exception('Exception occurred')
356
            try:
357
                # Write tags with yes/no value
358
                for k, v in POI_YESNO_TAGS.items():
0 ignored issues
show
Coding Style Naming introduced by
Variable name "v" 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...
359
                    if row.get(k) is not None and row.get(k) != '':
360
                        tags[v] = 'yes' if row.get(k) is True else 'no'
361
                for k, v in POI_EV_TAGS.items():
0 ignored issues
show
Coding Style Naming introduced by
Variable name "v" 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...
362
                    if row.get(k) is not None and row.get(k) != '':
363
                        if isinstance(row.get(k), float):
364
                            if not math.isnan(row.get(k)):
365
                                tags[v] = int(row.get(k))
366
                        else:
367
                            tags[v] = row.get(k)
368
            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...
369
                logging.exception('Exception occurred')
370
            try:
371
                # This is a new POI - will add fix me tag to the new items.
372
                if row.get('poi_new') is not None and row.get('poi_new') is True:
373
                    tags['fixme'] = 'verify import'
374
                # Remove unwanted addr:country from file output as we discussed in Issue #33
375
                tags.pop('addr:country', None)
376
                # tags['import'] = 'osm_poi_matchmaker'
377
                # Rendering tags to the XML file and JOSM magic link
378
            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...
379
                logging.exception('Exception occurred')
380
            try:
381
                josm_link = ''
382
                comment = '\nKey\t\t\t\tStatus\t\tNew value\t\tOSM value\n'
383
                for k, v in sorted(tags.items()):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "v" 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...
384
                    xml_tags = etree.SubElement(main_data, 'tag', k=k, v='{}'.format(v))
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'SubElement' 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...
Unused Code introduced by
The variable xml_tags seems to be unused.
Loading history...
385
                    josm_link = '{}|{}={}'.format(josm_link, k, v)
386
                    # Add original POI tags as comment
387
                    try:
388
                        if isinstance(v, str):
389
                            v = v.replace('-', '\-').replace('\n', '')
0 ignored issues
show
Bug introduced by
A suspicious escape sequence \- was found. Did you maybe forget to add an r prefix?

Escape sequences in Python are generally interpreted according to rules similar to standard C. Only if strings are prefixed with r or R are they interpreted as regular expressions.

The escape sequence that was used indicates that you might have intended to write a regular expression.

Learn more about the available escape sequences. in the Python documentation.

Loading history...
Coding Style Naming introduced by
Variable name "v" 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...
390
                        w = osm_live_tags[k]
0 ignored issues
show
Coding Style Naming introduced by
Variable name "w" 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...
391
                    except KeyError:
392
                        comment += "{:32} N\t\t'{}'\n".format(k, v)
393
                    else:
394
                        if isinstance(w, str):
395
                            w = w.replace('-', '\-').replace('\n', '')
0 ignored issues
show
Bug introduced by
A suspicious escape sequence \- was found. Did you maybe forget to add an r prefix?

Escape sequences in Python are generally interpreted according to rules similar to standard C. Only if strings are prefixed with r or R are they interpreted as regular expressions.

The escape sequence that was used indicates that you might have intended to write a regular expression.

Learn more about the available escape sequences. in the Python documentation.

Loading history...
Coding Style Naming introduced by
Variable name "w" 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...
396
                        comment += "{:32} {}\t\t'{}'\t\t\t'{}'\n".format(k, compare_strings(v, w), v, w)
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...
397
                comment = etree.Comment(comment)
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'Comment' 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...
398
            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...
399
                logging.exception('Exception occurred')
400
            try:
401
                osm_xml_data.append(comment)
402
            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...
403
                logging.exception('Exception occurred')
404
            try:
405
                # URL encode link and '--' in comment
406
                josm_link = quote(josm_link)
407
                josm_link = josm_link.replace('--', '%2D%2D')
408
                comment = etree.Comment(' JOSM magic link: {}?new_layer=false&objects={}&addtags={} '.format
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (108/100).

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

Loading history...
introduced by
Module 'lxml.etree' has no 'Comment' 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...
409
                                        ('http://localhost:8111/load_object', josm_object, josm_link))
0 ignored issues
show
introduced by
The variable josm_object does not seem to be defined for all execution paths.
Loading history...
Coding Style introduced by
This line is too long as per the coding-style (102/100).

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

Loading history...
410
                osm_xml_data.append(comment)
411
            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...
412
                logging.exception('Exception occurred')
413
            try:
414
                test_case = {k: row.get(k, None) for k in TESTCASE_GEN_KEYS}
415
                comment = etree.Comment("ˇ'original': '{t[original]}', 'postcode': '{t[poi_postcode]}', 'city': '{t[poi_city]}', 'street': '{t[poi_addr_street]}', 'housenumber': '{t[poi_addr_housenumber]}', 'conscriptionnumber': '{t[poi_conscriptionnumber]}'°".format(t=test_case))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (281/100).

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

Loading history...
introduced by
Module 'lxml.etree' has no 'Comment' 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...
416
                osm_xml_data.append(comment)
417
            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...
418
                logging.exception('Exception occurred')
419
            try:
420
                osm_xml_data.append(xml_node_tags)
0 ignored issues
show
introduced by
The variable xml_node_tags does not seem to be defined for all execution paths.
Loading history...
421
            except UnboundLocalError as e:
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...
422
                logging.debug('Unbound local error extra node tags')
423
            try:
424
                osm_xml_data.append(main_data)
425
                # Next deafult OSM id is one more less for non existing objects
426
                default_osm_id -= 1
427
            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...
428
                logging.exception('Exception occurred')
429
    except ValueError as e:
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...
430
        logging.error(e)
431
        logging.exception('Exception occurred')
432
433
    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...
434
        logging.error(e)
435
        logging.exception('Exception occurred')
436
437
    return lxml.etree.tostring(osm_xml_data, pretty_print=True, xml_declaration=True, encoding="UTF-8")
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (103/100).

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

Loading history...
introduced by
Module 'lxml.etree' has no 'tostring' 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...
438