/
wikipedia_family.py
245 lines (226 loc) · 10.6 KB
/
wikipedia_family.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# -*- coding: utf-8 -*-
"""Family module for Wikipedia."""
#
# (C) Pywikibot team, 2004-2018
#
# Distributed under the terms of the MIT license.
#
from __future__ import absolute_import, division, unicode_literals
from pywikibot import family
# The Wikimedia family that is known as Wikipedia, the Free Encyclopedia
class Family(family.SubdomainFamily, family.WikimediaFamily):
"""Family module for Wikipedia."""
name = 'wikipedia'
closed_wikis = [
# See https://noc.wikimedia.org/conf/highlight.php?file=closed.dblist
'aa', 'advisory', 'cho', 'ho', 'hz', 'ii', 'kj', 'kr', 'mh', 'mo',
'mus', 'ng', 'quality', 'strategy', 'ten', 'usability'
]
removed_wikis = [
# See https://noc.wikimedia.org/conf/highlight.php?file=deleted.dblist
'dk', 'ru-sib', 'tlh', 'tokipona', 'zh_cn', 'zh_tw',
]
languages_by_size = [
'en', 'ceb', 'sv', 'de', 'fr', 'nl', 'ru', 'it', 'es', 'pl', 'war',
'vi', 'ja', 'zh', 'pt', 'uk', 'ar', 'fa', 'sr', 'ca', 'no', 'id', 'fi',
'sh', 'ko', 'hu', 'cs', 'ro', 'eu', 'ms', 'tr', 'eo', 'hy', 'bg', 'da',
'he', 'sk', 'zh-min-nan', 'kk', 'min', 'ce', 'hr', 'lt', 'et', 'be',
'sl', 'el', 'gl', 'az', 'ur', 'simple', 'nn', 'azb', 'uz', 'la', 'th',
'hi', 'ka', 'vo', 'ta', 'cy', 'ast', 'mk', 'tg', 'lv', 'mg', 'oc',
'tt', 'bs', 'ky', 'tl', 'sq', 'af', 'new', 'zh-yue', 'te', 'br',
'be-tarask', 'bn', 'pms', 'ml', 'lb', 'jv', 'ht', 'sco', 'mr', 'ga',
'sw', 'pnb', 'ba', 'is', 'nds', 'my', 'cv', 'fy', 'su', 'lmo', 'an',
'ne', 'yo', 'pa', 'gu', 'io', 'bar', 'scn', 'als', 'bpy', 'ku', 'kn',
'ckb', 'ia', 'qu', 'arz', 'mn', 'wuu', 'bat-smg', 'si', 'wa', 'gd',
'or', 'yi', 'nap', 'am', 'cdo', 'bug', 'hsb', 'map-bms', 'mai', 'fo',
'mzn', 'xmf', 'li', 'sah', 'eml', 'ilo', 'vec', 'sa', 'os', 'sd',
'mrj', 'mhr', 'hif', 'ps', 'roa-tara', 'diq', 'hak', 'bcl',
'zh-classical', 'frr', 'pam', 'ace', 'nso', 'szl', 'se', 'km', 'nv',
'mi', 'rue', 'nah', 'nds-nl', 'vls', 'bh', 'gan', 'crh', 'sc', 'vep',
'bo', 'glk', 'co', 'tk', 'so', 'fiu-vro', 'myv', 'kv', 'as', 'csb',
'lrc', 'gv', 'shn', 'zea', 'udm', 'ay', 'ie', 'pcd', 'sn', 'ug', 'nrm',
'stq', 'lez', 'lad', 'kw', 'mwl', 'gn', 'gom', 'rm', 'lij', 'haw',
'koi', 'ab', 'ha', 'mt', 'fur', 'frp', 'lfn', 'dsb', 'lo', 'ang', 'ln',
'ext', 'cbk-zam', 'dv', 'dty', 'kab', 'olo', 'ksh', 'gag', 'pi', 'pag',
'pfl', 'av', 'bxr', 'bjn', 'xal', 'krc', 'gor', 'pap', 'kaa', 'za',
'pdc', 'rw', 'tyv', 'to', 'kl', 'nov', 'jam', 'arc', 'kbd', 'tpi',
'kbp', 'tet', 'ig', 'ki', 'na', 'jbo', 'lbe', 'roa-rup', 'ty', 'kg',
'mdf', 'wo', 'bi', 'lg', 'zu', 'srn', 'atj', 'tcy', 'chr', 'ltg',
'inh', 'sm', 'om', 'xh', 'pih', 'cu', 'rmy', 'tw', 'bm', 'tn', 'chy',
'rn', 'got', 'sat', 'ts', 'tum', 'ak', 'st', 'ny', 'ch', 'ss', 'pnt',
'fj', 'ady', 'iu', 'ee', 'ks', 've', 'ik', 'sg', 'ff', 'dz', 'ti',
'cr', 'din',
]
# Sites we want to edit but not count as real languages
test_codes = ['test', 'test2']
# Templates that indicate a category redirect
# Redirects to these templates are automatically included
category_redirect_templates = {
'_default': (),
'ar': ('تحويل تصنيف',),
'arz': ('تحويل تصنيف',),
'bn': ('বিষয়শ্রেণী পুনর্নির্দেশ',),
'bs': ('Category redirect',),
'cs': ('Zastaralá kategorie',),
'da': ('Kategoriomdirigering',),
'en': ('Category redirect',),
'es': ('Categoría redirigida',),
'eu': ('Kategoria birzuzendu',),
'fa': ('رده بهتر',),
'fr': ('Catégorie redirigée',),
'gv': ('Aastiurey ronney',),
'hi': ('श्रेणी अनुप्रेषित',),
'hu': ('Kat-redir',),
'id': ('Alih kategori',),
'ja': ('Category redirect',),
'ko': ('분류 넘겨주기',),
'mk': ('Премести категорија',),
'ml': ('Category redirect',),
'ms': ('Pengalihan kategori',),
'mt': ('Rindirizzament kategorija',),
'ne': ('श्रेणी अनुप्रेषण',),
'no': ('Kategoriomdirigering',),
'pt': ('Redirecionamento de categoria',),
'ro': ('Redirect categorie',),
'ru': ('Переименованная категория',),
'sco': ('Category redirect',),
'sh': ('Prekat',),
'simple': ('Category redirect',),
'sl': ('Preusmeritev kategorije',),
'sr': ('Category redirect',),
'sq': ('Kategori e zhvendosur',),
'sv': ('Kategoriomdirigering',),
'tl': ('Category redirect',),
'tr': ('Kategori yönlendirme',),
'uk': ('Categoryredirect',),
'ur': ('زمرہ رجوع مکرر',),
'vi': ('Đổi hướng thể loại',),
'yi': ('קאטעגאריע אריבערפירן',),
'zh': ('分类重定向',),
'zh-yue': ('分類彈去',),
}
# families that redirect their interlanguage links here.
interwiki_forwarded_from = [
'commons',
'incubator',
'meta',
'species',
'strategy',
'test',
'wikimania'
]
# Global bot allowed languages on
# https://meta.wikimedia.org/wiki/BPI#Current_implementation
# & https://meta.wikimedia.org/wiki/Special:WikiSets/2
cross_allowed = [
'ab', 'ace', 'ady', 'af', 'ak', 'als', 'am', 'an', 'ang', 'ar',
'arc', 'arz', 'as', 'ast', 'av', 'ay', 'az', 'ba', 'bar',
'bat-smg', 'bcl', 'be', 'be-tarask', 'bg', 'bh', 'bi', 'bjn', 'bm',
'bo', 'bpy', 'bug', 'bxr', 'ca', 'cbk-zam', 'cdo', 'ce', 'ceb',
'ch', 'chr', 'chy', 'ckb', 'co', 'cr', 'crh', 'cs', 'csb', 'cu',
'cv', 'cy', 'da', 'diq', 'dsb', 'dz', 'ee', 'el', 'eml', 'en',
'eo', 'et', 'eu', 'ext', 'fa', 'ff', 'fi', 'fj', 'fo', 'frp',
'frr', 'fur', 'ga', 'gag', 'gan', 'gd', 'glk', 'gn', 'gor', 'got',
'gu', 'gv', 'ha', 'hak', 'haw', 'he', 'hi', 'hif', 'hr', 'hsb', 'ht',
'hu', 'hy', 'ia', 'ie', 'ig', 'ik', 'ilo', 'io', 'iu', 'ja', 'jam',
'jbo', 'jv', 'ka', 'kaa', 'kab', 'kdb', 'kg', 'ki', 'kk', 'kl',
'km', 'kn', 'ko', 'koi', 'krc', 'ks', 'ku', 'kv', 'kw', 'ky', 'la',
'lad', 'lb', 'lbe', 'lez', 'lfn', 'lg', 'li', 'lij', 'lmo', 'ln', 'lo',
'lt', 'ltg', 'lv', 'map-bms', 'mdf', 'mg', 'mhr', 'mi', 'mk', 'ml',
'mn', 'mrj', 'ms', 'mwl', 'my', 'myv', 'mzn', 'na', 'nah', 'nap',
'nds-nl', 'ne', 'new', 'nl', 'no', 'nov', 'nrm', 'nso', 'nv', 'ny',
'oc', 'olo', 'om', 'or', 'os', 'pa', 'pag', 'pam', 'pap', 'pdc',
'pfl', 'pi', 'pih', 'pms', 'pnb', 'pnt', 'ps', 'qu', 'rm', 'rmy',
'rn', 'roa-rup', 'roa-tara', 'ru', 'rue', 'rw', 'sa', 'sah', 'sc',
'scn', 'sco', 'sd', 'se', 'sg', 'sh', 'si', 'simple', 'sk', 'sm',
'sn', 'so', 'srn', 'ss', 'st', 'stq', 'su', 'sv', 'sw', 'szl',
'ta', 'tcy', 'te', 'tet', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to',
'tpi', 'tr', 'ts', 'tt', 'tum', 'tw', 'ty', 'tyv', 'udm', 'ug',
'uz', 've', 'vec', 'vep', 'vls', 'vo', 'wa', 'war', 'wo', 'wuu',
'xal', 'xh', 'xmf', 'yi', 'yo', 'za', 'zea', 'zh', 'zh-classical',
'zh-min-nan', 'zh-yue', 'zu',
]
# On most Wikipedias page names must start with a capital letter,
# but some languages don't use this.
nocapitalize = ['jbo']
# Languages that used to be coded in iso-8859-1
latin1old = [
'de', 'en', 'et', 'es', 'ia', 'la', 'af', 'cs', 'fr', 'pt', 'sl',
'bs', 'fy', 'vi', 'lt', 'fi', 'it', 'no', 'simple', 'gl', 'eu',
'nds', 'co', 'mi', 'mr', 'id', 'lv', 'sw', 'tt', 'uk', 'vo', 'ga',
'na', 'es', 'nl', 'da', 'dk', 'sv', 'test']
# Subpages for documentation.
# TODO: List is incomplete, to be completed for missing languages.
# TODO: Remove comments for appropriate pages
doc_subpages = {
'_default': (('/doc', ),
['ar', 'bn', 'cs', 'da', 'en', 'es', 'hr',
'hu', 'id', 'ilo', 'ja', 'ms',
'pt', 'ro', 'ru', 'simple', 'sh', 'vi', 'zh']
),
'bs': ('/dok', ),
'ca': ('/ús', ),
'de': ('Doku', '/Meta'),
'dsb': ('/Dokumentacija', ),
'eu': ('txantiloi dokumentazioa', '/dok'),
'fa': ('/doc', '/توضیحات'),
# fi: no idea how to handle this type of subpage at :Metasivu:
'fi': ((), ),
'fr': ('/Documentation',),
'hsb': ('/Dokumentacija', ),
'it': ('/Man', ),
'ka': ('/ინფო', ),
'ko': ('/설명문서', ),
'no': ('/dok', ),
'nn': ('/dok', ),
'pl': ('/opis', ),
'sk': ('/Dokumentácia', ),
'sr': ('/док', ),
'sv': ('/dok', ),
'uk': ('/Документація', ),
'ur': ('/doc', '/دستاویز'),
}
# Templates that indicate an edit should be avoided
edit_restricted_templates = {
'ar': ('تحرر',),
'bs': ('Izmjena u toku',),
'cs': ('Pracuje se',),
'de': ('Inuse', 'In use', 'In bearbeitung', 'Inbearbeitung',),
'en': ('Inuse', 'In use'),
'fa': ('ویرایش',),
'fr': ('En cours', 'Plusieurs en cours', 'Correction en cours',
'Inuse', 'Remix',),
'hr': ('Radovi',),
'sr': ('Радови у току', 'Рут',),
'ur': ('زیر ترمیم',),
'zh': ('Inuse',),
}
# Archive templates that indicate an edit of non-archive bots
# should be avoided
archived_page_templates = {
'cs': ('Archiv', 'Archiv Wikipedie', 'Archiv diskuse',
'Archivace start', 'Posloupnost archivů',
'Rfa-archiv-start', 'Rfc-archiv-start',),
'de': ('Archiv',),
}
def get_known_families(self, site):
"""Override the family interwiki prefixes for each site."""
# In Swedish Wikipedia 's:' is part of page title not a family
# prefix for 'wikisource'.
if site.code == 'sv':
d = self.known_families.copy()
d.pop('s')
d['src'] = 'wikisource'
return d
else:
return self.known_families
def code2encodings(self, code):
"""Return a list of historical encodings for a specific site."""
# Historic compatibility
if code == 'pl':
return 'utf-8', 'iso8859-2'
if code == 'ru':
return 'utf-8', 'iso8859-5'
if code in self.latin1old:
return 'utf-8', 'iso-8859-1'
return self.code2encoding(code)