Created
March 4, 2019 18:10
-
-
Save nyurik/f0a14a49971e765e782f0a1368a1b093 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
fixes['osmlinks'] = { | |
'regex': True, | |
'nocase': True, | |
'msg': { | |
# '_default': 'Param cleanup, remove obsolete lang parameters - template detects it automatically', | |
'_default': 'Tag template cleanup - format combinations, use proper {{Tag}} template with params, remove kl= and vl= (handled automatically)', | |
}, | |
'replacements': [ | |
(r'\n? *\| *images *= *\n', '\n'), | |
(r'\n? *\| *templatename *= *\n', '\n'), | |
(r'\n? *\| *displayName *= *[a-zA-Z:]+ *\n', r'\n'), | |
(r'\n? *\| *category *= *[a-zA-Z:]+ *\n', r'\n'), | |
# (r'\n? *\| *lang(uage)? *= *(|pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant) *\n', | |
# r'\n'), | |
# (r'\|\n *lang(uage)? *= *(|pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant) *\|\n', | |
# r'|\n'), | |
# (r'\| *lang(uage)? *= *(|pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant) *(}}|\|)', | |
# r'\3'), | |
(r'{{(template:)?(pl:)?KeyDescription', r'{{KeyDescription'), | |
(r'{{(template:)?(pl:)?ValueDescription', r'{{ValueDescription'), | |
(r'{{(template:)?(pl:)?RelationDescription', r'{{RelationDescription'), | |
(r'(\n?) *\| *dir *= *(rtl|ltr)?\n', r'\n'), | |
(r'(\n?) *\| *rtl *= *(yes)?\n', r'\n'), | |
(r'(\n?) *\| *languagelinks *= *(yes)?\n', r'\n'), | |
(r'(\| *)Descripción( *=)', r'\1description\2'), | |
(r'(\| *)Description( *=)', r'\1description\2'), | |
(r'(\| *)Descrizione( *=)', r'\1description\2'), | |
(r'(\| *)Gruppe( *=)', r'\1group\2'), | |
(r'(\| *)csoport( *=)', r'\1group\2'), | |
(r'(\| *)Csoport( *=)', r'\1group\2'), | |
(r'(\| *)Image_caption( *=)', r'\1image_caption\2'), | |
(r'(\| *)image_description( *=)', r'\1image_caption\2'), | |
(r'(\| *)Status( *=)', r'\1status\2'), | |
(r'(\| *)Wikidata( *=)', r'\1wikidata\2'), | |
(r'(\| *)combinatin( *=)', r'\1combination\2'), | |
(r'(\| *)combinations( *=)', r'\1combination\2'), | |
(r'(\| *)combinazioni( *=)', r'\1combination\2'), | |
(r'(\| *)descripción( *=)', r'\1description\2'), | |
(r'(\| *)descrition( *=)', r'\1description\2'), | |
(r'(\| *)descrizione( *=)', r'\1description\2'), | |
(r'(\| *)descrição( *=)', r'\1description\2'), | |
(r'(\| *)groupe( *=)', r'\1group\2'), | |
(r'(\| *)gruppo( *=)', r'\1group\2'), | |
(r'(\| *)image caption( *=)', r'\1image_caption\2'), | |
(r'(\| *)image\+caption( *=)', r'\1image_caption\2'), | |
(r'(\| *)image-caption( *=)', r'\1image_caption\2'), | |
(r'(\| *)image_capture( *=)', r'\1image_caption\2'), | |
(r'(\| *)image_cation( *=)', r'\1image_caption\2'), | |
(r'(\| *)imagea_caption( *=)', r'\1image_caption\2'), | |
(r'(\| *)imahe_caption( *=)', r'\1image_caption\2'), | |
(r'(\| *)nArea( *=)', r'\1onArea\2'), | |
(r'(\| *)poska nazwa( *=)', r'\1polska nazwa\2'), | |
(r'(\| *)reqiures( *=)', r'\1requires\2'), | |
(r'(\| *)required( *=)', r'\1requires\2'), | |
(r'(\| *)requises( *=)', r'\1requires\2'), | |
(r'(\| *)rerquires( *=)', r'\1requires\2'), | |
(r'(\| *)see also( *=)', r'\1seeAlso\2'), | |
(r'(\| *)statusLink( *=)', r'\1statuslink\2'), | |
(r'(\| *)status_link( *=)', r'\1statuslink\2'), | |
(r'(\| *)widata( *=)', r'\1wikidata\2'), | |
(r'(\| *)wikdata( *=)', r'\1wikidata\2'), | |
(r'(\| *)Описание( *=)', r'\1description\2'), | |
(r'(\| *)poska nazwa( *=)', r'\1polska nazwa\2'), | |
(r'(\| *)imnplies( *=)', r'\1implies\2'), | |
(r'(\| *)impies( *=)', r'\1implies\2'), | |
(r'(\| *)implase( *=)', r'\1implies\2'), | |
(r'(\| *)implied( *=)', r'\1implies\2'), | |
(r'(\| *)Implies( *=)', r'\1implies\2'), | |
(r'(\| *)inmplies( *=)', r'\1implies\2'), | |
(r'(\| *)Leírás( *=)', r'\1description\2'), | |
(r'(\| *)leírás( *=)', r'\1description\2'), | |
(r'(\| *)image:desc( *=)', r'\1image_caption\2'), | |
(r'\n? *\| *wikipedia *= *\n', '\n'), | |
(r'\n? *\| *rendering *= *\n', '\n'), | |
(r'\n? *\| *iconRelation *= *\n', '\n'), | |
(r'(\| *)proposal( *=)', r'\1statuslink\2'), | |
(r'\n? *\| *url_pattern *= *\n(\||\})', r'\n\1'), | |
(r'\n? *\| *class *= *\n(\||\})', r'\n\1'), | |
(r'\n? *\| *float *= *\n(\||\})', r'\n\1'), | |
(r'\n? *\| *style *= *\n(\||\})', r'\n\1'), | |
(r'\n? *\| *groups *= *\n(\||\})', r'\n\1'), | |
(r'\n? *\| *onClosedWay *= *\n(\||\})', r'\n\1'), | |
# (r'\n? *\| *website *= *\n(\||\})', r'\n\1'), | |
(r'{(?:[A-Z][A-Z]:)?Template(?::[a-zA-Z-]+)?:Tag', r'{Tag'), | |
(r'{(?:[A-Z][A-Z]:)?Template(?::[a-zA-Z-]+)?:Key', r'{Key'), | |
(r'( *\| *(?:combination|implies|seealso|requires) *= *)(.*}} *<br[ /]*> *{{.*}})', r'\1* \2'), | |
(r'( *\| *(?:combination|implies|seealso|requires) *= *.*}}) *<br[ /]*> *({{.*}})', r'\1\n* \2'), | |
(r'( *\| *(?:combination|implies|seealso|requires) *= *.*}}) *<br[ /]*> *({{.*}})', r'\1\n* \2'), | |
(r'( *\| *(?:combination|implies|seealso|requires) *= *.*}}) *<br[ /]*> *({{.*}})', r'\1\n* \2'), | |
(r'( *\| *(?:combination|implies|seealso|requires) *= *.*}}) *<br[ /]*> *({{.*}})', r'\1\n* \2'), | |
(r'{(?:pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant):(Tag|Key)\|', r'{\1|'), | |
(r'{{ *(Tag|Key) *\|', r'{{\1|'), | |
(r'({{(?:tag|key|tagkey)(?:\|[^{}]+)?)\|[kv]l:*=(?:pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant)(\||})', r'\1\2'), | |
(r'({{(?:tag|key|tagkey)(?:\|[^{}]+)?)\|[kv]l:*=(?:pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant)(\||})', r'\1\2'), | |
(r'({{(?:tag|key|tagkey)(?:\|[^{}]+)?)\|[kv]l:*=(?:pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant)(\||})', r'\1\2'), | |
(r'({{(?:tag|key)[^{}]*)(?: *\| *)+}}', r'\1}}'), | |
(r'({{(?:tag|key)[^{}]*)(?: *\| *)+}}', r'\1}}'), | |
(r'({{(?:tag|key)[^{}]*)(?: *\| *)+}}', r'\1}}'), | |
(r'{{ *key *\|([^{}|]+\|[{}|]+)}}', r'{{Tag|\1}}'), | |
(r'^( *(?:(?:\| *)?[a-z]* *= *\** *)|\* *)\[\[(?:(?:pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant):)?(?:key|tag):([^\n\]{}|=#]+)=?(?:\|(?:\2|(?:key|tag):\2))?\]\]( *\n| *\| *| *}})', r'\1{{Key|\2}}\3'), | |
(r'^( *(?:(?:\| *)?[a-z]* *= *\** *)|\* *)\[\[(?:(?:pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant):)?(?:key|tag):([^\n\]{}|=#]+)(=([^\n\]{}|=#]+))(?:\|(?:\2\3|(?:key|tag):\2\3))?\]\]( *\n| *\| *| *}})', r'\1{{Tag|\2|\4}}\5'), | |
# (r'\[\[(?:(?:pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant):)?Key:(wiki[a-z]+)\|([a-z]+):\1\]\]', r'{{Key|\2|:=\1}}'), | |
# (r'\[\[(?:(?:pt-br|az|bg|ca|cs|da|de|el|eo|es|en|et|fa|fi|fr|gl|hr|ht|hu|id|it|ja|ko|ms|ms|nl|no|pl|pt|ro|ru|sk|sv|tr|uk|vi|yue|zh-hans|zh-hant):)?Key:addr\|([^\]\n{}\|]+)\]\]', r'{{Key|addr}} \1'), | |
(r'{{(?:Tag|Key)\|([^\n{}\[\]\n|]+)(?:\| *)+\* *}}', r'{{Key|\1}}'), | |
(r'{{Tag\|natural\|cliff/Archive/Proposal}}', r'[[Talk:Tag:natural%3Dcliff#Tag:natural.3Dcliff.2FArchive.2FProposal|natural=cliff/Archive/Proposal]]'), | |
(r'{{(?:Tag|Key)\| *([^\n{}\[\]\n|]+)%3D([^\n{}\[\]\n|]+)}}', r'{{Tag|\1|\2}}'), | |
(r'{{(?:Tag|Key)\|([^\n{}\[\]\n|:][^\n{}\[\]\n|]*)\|([^\n{}\[\]\n|/<\']+(?:/|<|\'\')[^\n{}\[\]\n|])', r'{{Tag|\1||\2'), | |
(r'\|\|+(subkey|:+)=', r'|\1='), | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment