Mechanical Edits/Mateusz Konieczny - bot account/remove history tags recording revert as an object tag/

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.

This edit will remove unneded and confusing history=* tags, remains of old software.


Most values of this tag are pointless, confusing, unwelcome. Removing it manually (either in organized fashion or while editing affected objects) is a pointless waste of time when it is possible to automate it.

Checking what that is by mappers encountering it and learning about it is a pointless waste of time. Removing this tags from current object version would mostly eliminate this.

Making it a discardable key is not viable as some values can have some potential use (history=monument and similar mistaggings of historic=*), mass removing them silently is not OK.

Removing via JOSM validator is also sometimes that would involve precious human attention that can be used far more beneficially than handling (semi)manual removal of worthless tags.

Yes, making an edit requires modifying objects. The same would happen if mapper would remove them manually.

Also, removal of this values would make history=monument and similar mistaggings of historic=* more visible (for example on taginfo), making rescue of that data easier.


I, Mateusz Konieczny using my bot account


message via OSM I will respond also to PMs to the bot account, though messaging my main account is preferable as I will get notifications in OSM editors.

English and Polish languages are preferable, for other I need to use an automatic translator.



Also merges of such values

  • history=Retrieved from v7;Retrieved from v3


All tags not listed above, such as

will not be modified.


Around 40 000 objects.

state before a mechanical edit:

state after a mechanical edit:

Changeset would be described and tagged with tags that mark it as automatic, provide link to discussion approving edit etc

Source code =

import re
from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task
import wikimedia_connection.wikimedia_connection as wikimedia_connection
import wikibrain.wikimedia_link_issue_reporter
import osm_handling_config.global_config as osm_handling_config

def edit_element(tags):
    if tags.get('history') == None:
        return tags
    if is_history_tag_for_removal(tags.get('history')):
        tags.pop('history', None)
        #tags["operator:wikidata"] = tags.get('wikidata')
    return tags

def is_history_tag_for_removal(history_tag_value):
    if ";" in history_tag_value:
        for part in history_tag_value.split(";"):
            if not is_history_tag_part_what_i_remove(part):
                return False
            return True
        return is_history_tag_part_what_i_remove(history_tag_value)
def is_history_tag_part_what_i_remove(part):
    if part == "retrieved using undelete JOSM plugin":
        return True
    if'^Retrieved from v\d+$', part) != None:
        return True
    return False

def main():
    if is_history_tag_for_removal("memorial"):
        raise "unexpected"
    if is_history_tag_for_removal("memorial;Retrieved from v1"):
        raise "unexpected"
    if is_history_tag_for_removal("Retrieved from v1") == False:
        raise "unexpected"
    if is_history_tag_for_removal("Retrieved from v1;Retrieved from v110101010") == False:
        raise "unexpected"
    if is_history_tag_for_removal("Retrieved from v;Retrieved from v110101010"):
        raise "unexpected"
out body;
out skel qt;
        changeset_comment='remove useless history tags left by an ancient editing software',




This is a single run that will not be repeated.


Please write at bot approval thread . Note that in case of opt-out exactly the same edit will be made manually for objects where bot opt-out was used.