Mechanical Edits/Mateusz Konieczny - bot account/remove useless note=FIXME in Poland

From OpenStreetMap Wiki
Jump to navigation Jump to search

Page content created as advised on Automated_Edits_code_of_conduct#Document_and_discuss_your_plans.

Who

I, Mateusz Konieczny using my bot account

contact

message via OSM I will respond also to PMs to the bot account. In both cases I will be notified about incoming PMs via email and notifications in OSM editors.

What

note=FIXME -> (no replacement)

Why

This tag is useless contentless remmant of old imports.

Numbers

197 objects - http://overpass-turbo.eu/s/Yl6

How

  • Editing is limited to objects in Poland.

state before a mechanical edit:

state after a mechanical edit:

  • no tags

example based on https://www.openstreetmap.org/node/683209040

Bot source code

Bot is using https://github.com/matkoniecz/osm_bot_abstraction_layer library, this code is GNU GPLv3 licensed

from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task

def transformation():
    return {
        'from': {"note": "FIXME"},
        'to': {},
    }

def edit_element(tags):
    for key, value in transformation()['from'].items():
        if tags.get(key) != (value):
            return tags

    for key in transformation()['from'].keys():
        tags.pop(key, None)

    for key, value in transformation()['to'].items():
        tags[key] = value
    return tags

def escape_overpass_query_text(text):
    return "'" +text.replace("\\", "\\\\").replace("'", "\\'") + "'"

def dictionary_to_overpass_tag_filter(tag_dictionary):
    returned = ""
    for key, value in tag_dictionary.items():
        returned += "[" + escape_overpass_query_text(key) + "=" + escape_overpass_query_text(value) + "]"
    return returned

def main(tag_dictionary):
    run_simple_retagging_task(
        max_count_of_elements_in_one_changeset=500,
        objects_to_consider_query="""
[out:xml][timeout:25000];
area[name='Polska']->.searchArea;
(
  nwr""" + dictionary_to_overpass_tag_filter(tag_dictionary['from']) + """(area.searchArea);
);
out body;
>;
out skel qt;
""",
        objects_to_consider_query_storage_file='//home/mateusz/Desktop/tmp/retag.osm',
        is_in_manual_mode=False,
        changeset_comment='remove useless note=FIXME (automatyczna edycja)',
        discussion_url='https://forum.openstreetmap.org/viewtopic.php?pid=801946#p801946',
        osm_wiki_documentation_page='https://wiki.openstreetmap.org/wiki/Mechanical_Edits/Mateusz_Konieczny_-_bot_account/remove useless note=FIXME in Poland',
        edit_element_function=edit_element,
    )

main(transformation())

Discussion

Discussed with Polish OSM community at https://forum.openstreetmap.org/viewtopic.php?pid=801946#p801946 and also in Polish Telegram channel

Repetition

One time run.

Opt-out

Please write at https://forum.openstreetmap.org/viewtopic.php?pid=801946#p801946 . In case of opt-outs exactly such edit will be made manually.