forked from eggpi/citationhunt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
834 lines (714 loc) · 31.2 KB
/
config.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
#-*- encoding: utf-8 -*-
import os
import types
from functools import reduce
# The configuration for a language is a set of key/value pairs, where the
# values may be True/False, strings or lists/dicts of strings. It is computed
# by inheriting from the global config, base config, and language-specific
# config below, in that order.
# When inheriting, for simple string or True/False keys, the "inheritor's"
# value overrides the base value, and for list/dict values, the base and
# inheritor lists are merged. There is currently no way to completely override
# a base list/dict value.
# Configuration keys that don't correspond to user-visible or snippet parsing
# behavior. Boring stuff.
_GLOBAL_CONFIG = dict(
# If running on Tools labs, keep database dumps in this directory...
archive_dir = os.path.join(os.path.expanduser('~'), 'ch_archives'),
# ...and delete dumps that are older than this many days
archive_duration_days = 90,
# Where to put various logs
log_dir = os.path.join(os.path.expanduser('~'), 'ch_logs'),
flagged_off = [],
profile = True,
stats_max_age_days = 90,
user_agent = 'citationhunt (https://tools.wmflabs.org/citationhunt)',
petscan_url = 'https://petscan.wmflabs.org',
petscan_timeout_s = 180,
petscan_depth = 10,
# The maximum number of articles to import into an intersection.
intersection_max_size = 4096,
# How long before an intersection is deleted from the database.
intersection_expiration_days = 30,
api = types.SimpleNamespace(
# Maximum number of snippets to return from our API methods.
max_returned_snippets = 200,
),
)
# A base configuration that all languages "inherit" from.
_BASE_LANG_CONFIG = dict(
# Approximate maximum length for a snippet
snippet_max_size = 800,
# Approximate minimum length for a snippet
snippet_min_size = 100,
# The elements identified by these CSS selectors are removed from the HTML
# returned by the Wikipedia API.
html_css_selectors_to_strip = [
'.hatnote',
'.noexcerpt',
'.noprint',
'.notice',
'.references',
'.gallery',
'br',
'gallery',
'table',
],
# Parameters to pass to the Wikipedia API's parse method when converting
# snippets to HTML, in addition to the snippet itself.
html_parse_parameters = {
'disabletoc': 'true',
'disableeditsection': 'true',
'wrapoutputclass': '',
},
# What to extract for each citation needed template found in the wikitext,
# either 'snippet' or 'section'
extract = 'snippet',
# Most (all?) Wikipedias support the English settings below in addition
# to the localized ones, so make sure to handle them!
# The names of templates that mark statements lacking citations. The
# first letter is case-insensitive. When adding a new language, this
# may help: https://www.wikidata.org/wiki/Q5312535
# Other templates that redirect to any of these templates are also
# processed automatically, so there's no need to list them here.
citation_needed_templates = [
'Citation needed',
],
# Citation Hunt will ignore categories if their names match one
# of these regular expressions.
category_name_regexps_blacklist = [
'^Articles',
'^Pages ',
' stubs$',
'.*[0-9]+.*',
],
# Locales that apply to this language config, to be matched against
# the Accept-Language header. This is used for:
# - choosing which config to redirect the user to when they access /
# - choosing which strings to use in the UI when they access /<lang_code>
# For the second case, the last value on this list is used as a fallback
# if no match happens; if this is empty, the fallback is the language
# code itself. Whatever the fallback is, it MUST match the name of some
# file inside the chstrings/ directory.
accept_language = [],
)
# Language-specific config, inheriting from the base config above.
_LANG_CODE_TO_CONFIG = dict(
en = dict(
# A friendly name for the language
lang_name = 'English',
# The direction of the language, either ltr or rtl
lang_dir = 'ltr',
# The database to use on Tools Labs
database = 'enwiki_p',
# The domain for Wikipedia in this language
wikipedia_domain = 'en.wikipedia.org',
# A link to an introductory article about adding citations
beginners_link = 'https://en.wikipedia.org/wiki/Help:Introduction_to_referencing_with_VisualEditor/1',
# A human-readable title for the article specified above. This gets
# interpolated into the localizable string 'beginners_hint'
beginners_link_title = 'Introduction to referencing with VisualEditor',
# A link to an introductory article about identifying reliable sources.
# Optional.
reliable_sources_link = 'https://en.wikipedia.org/wiki/Help:Introduction_to_referencing_with_VisualEditor/5',
# Some Wikipedias have specific policies for adding citations to the
# lead section of an article. This should be a link to that policy.
lead_section_policy_link = 'https://en.wikipedia.org/wiki/Wikipedia:CITELEAD',
# A human-readable title for the link above. This gets interpolated
# into the localizable string 'lead_section_hint'
lead_section_policy_link_title = 'WP:CITELEAD',
# The name of the category containing articles lacking
# citations, without the 'Category:' prefix and with underscores
# instead of spaces.
citation_needed_category = 'All_articles_with_unsourced_statements',
# The name of the category for hidden categories, without the
# 'Category:' prefix and with underscores instead of spaces.
# Categories belonging to this category are typically used for
# maintenance and will not show up on Citation Hunt.
hidden_category = 'Hidden_categories',
),
ar = dict(
lang_name = 'العربية',
lang_dir = 'rtl',
database = 'arwiki_p',
wikipedia_domain = 'ar.wikipedia.org',
beginners_link = 'https://ar.wikipedia.org/wiki/%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7:%D8%A7%D9%84%D8%A7%D8%B3%D8%AA%D8%B4%D9%87%D8%A7%D8%AF_%D8%A8%D9%85%D8%B5%D8%A7%D8%AF%D8%B1',
beginners_link_title = 'ويكيبيديا:الاستشهاد بمصادر',
reliable_sources_link = 'https://ar.wikipedia.org/wiki/%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7:%D9%85%D8%B5%D8%A7%D8%AF%D8%B1_%D9%85%D9%88%D8%AB%D9%88%D9%82_%D8%A8%D9%87%D8%A7',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'مقالات_ذات_عبارات_بحاجة_لمصادر',
hidden_category = 'تصنيفات_مخفية',
citation_needed_templates = [
'بحاجة لمصدر',
'تأكيد رأي',
'تأكيد مصدر',
'غير موثق',
'فشل التوثيق',
'مصدر ناقص',
'وثق المصدر',
],
),
pt = dict(
lang_name = 'Português',
lang_dir = 'ltr',
database = 'ptwiki_p',
wikipedia_domain = 'pt.wikipedia.org',
citation_needed_category = '!Artigos_que_carecem_de_fontes',
beginners_link = 'https://pt.wikipedia.org/wiki/ Ajuda:Tutorial/Referência',
beginners_link_title = ' Ajuda:Tutorial/Referência',
lead_section_policy_link = 'https://pt.wikipedia.org/wiki/Wikipedia:INTROREF',
lead_section_policy_link_title = 'WP:INTROREF',
accept_language = [
'pt',
'kea',
'pt-BR',
],
category_name_regexps_blacklist = [
'^!',
],
citation_needed_templates = [
'Carece de fontes',
'Sem-fontes',
'Sem-fontes-bpv',
'Sem-fontes-sobre',
],
hidden_category = '!Categorias_ocultas',
),
fa = dict(
lang_name = 'فارسی',
lang_dir = 'rtl',
database = 'fawiki_p',
wikipedia_domain = 'fa.wikipedia.org',
citation_needed_category = 'همه_مقالههای_دارای_عبارتهای_بدون_منبع',
beginners_link = 'https://fa.wikipedia.org/wiki/ویکیپدیا:شیوه_ارجاع_به_منابع',
beginners_link_title = 'ویکیپدیا:شیوه ارجاع به منابع',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_templates = [
'مدرک',
],
hidden_category = 'ردههای_پنهان',
),
fr = dict(
lang_name = 'Français',
lang_dir = 'ltr',
database = 'frwiki_p',
wikipedia_domain = 'fr.wikipedia.org',
citation_needed_category = 'Article_à_référence_nécessaire',
beginners_link = 'https://fr.wikipedia.org/wiki/Aide:Pr%C3%A9sentez_vos_sources',
beginners_link_title = 'Aide:Source',
lead_section_policy_link = 'https://fr.wikipedia.org/wiki/WP:INTRO',
lead_section_policy_link_title = 'WP:INTRO',
# Looks like there are many other interesting templates:
# https://fr.wikipedia.org/wiki/Aide:Référence_nécessaire
citation_needed_templates = [
'Inédit',
'Référence nécessaire',
'Référence souhaitée',
],
hidden_category = 'Catégorie_cachée',
html_css_selectors_to_strip = [
'.bandeau-article',
'.bandeau-section',
'.bandeau-niveau-detail',
'.bandeau-niveau-modere',
'.homonymie',
],
),
it = dict(
lang_name = 'Italiano',
lang_dir = 'ltr',
database = 'itwiki_p',
wikipedia_domain = 'it.wikipedia.org',
citation_needed_category = 'Informazioni_senza_fonte',
beginners_link = 'https://it.wikipedia.org/wiki/Aiuto:Uso_delle_fonti',
beginners_link_title = 'Aiuto:Uso_delle_fonti',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_templates = [
'Citazione necessaria',
'Senza fonte',
],
hidden_category = 'Categorie_nascoste',
),
pl = dict(
lang_name = 'Polski',
lang_dir = 'ltr',
database = 'plwiki_p',
wikipedia_domain = 'pl.wikipedia.org',
citation_needed_category = 'Artykuły_wymagające_uzupełnienia_źródeł',
beginners_link = 'https://pl.wikipedia.org/wiki/Pomoc:Przypisy',
beginners_link_title = 'Pomoc:Przypisy',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_templates = [
'fakt',
],
hidden_category = 'Ukryte_kategorie',
),
ca = dict(
lang_name = 'Català',
lang_dir = 'ltr',
database = 'cawiki_p',
wikipedia_domain = 'ca.wikipedia.org',
citation_needed_category = 'Articles_amb_referències_puntuals_demanades',
beginners_link = 'https://ca.wikipedia.org/wiki/Viquip%C3%A8dia:Guia_per_referenciar',
beginners_link_title = 'Viquipèdia:Guia per referenciar',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_templates = [
'Citació necessària',
'CC',
'CN',
],
hidden_category = 'Categories_ocultes',
),
he = dict(
lang_name = 'עברית',
lang_dir = 'rtl',
database = 'hewiki_p',
wikipedia_domain = 'he.wikipedia.org',
beginners_link = 'https://he.wikipedia.org/wiki/%D7%A2%D7%96%D7%A8%D7%94:%D7%94%D7%A2%D7%A8%D7%AA_%D7%A9%D7%95%D7%9C%D7%99%D7%99%D7%9D',
beginners_link_title = 'עזרה:הערת_שוליים',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'ויקיפדיה:_ערכים_הדורשים_מקורות',
citation_needed_templates = ['דרוש מקור'],
hidden_category = 'קטגוריות_מוסתרות',
category_name_regexps_blacklist = [
'^ויקיפדיה',
],
),
es = dict(
lang_name = 'Español',
lang_dir = 'ltr',
database = 'eswiki_p',
wikipedia_domain = 'es.wikipedia.org',
beginners_link = 'https://es.wikipedia.org/wiki/Ayuda:Introducci%C3%B3n_a_las_referencias_con_Editor_Visual/1',
beginners_link_title = 'Introducción a las referencias con Editor Visual',
lead_section_policy_link = 'https://es.wikipedia.org/wiki/Wikipedia:Secci%C3%B3n_introductoria#Referencias',
lead_section_policy_link_title = 'Wikipedia:Sección introductoria',
citation_needed_category = 'Wikipedia:Artículos_con_pasajes_que_requieren_referencias',
citation_needed_templates = [
'Añadir referencias',
'Cita requerida'
],
hidden_category = 'Wikipedia:Categorías_ocultas',
),
bn = dict(
lang_name = 'বাংলা',
lang_dir = 'ltr',
database = 'bnwiki_p',
wikipedia_domain = 'bn.wikipedia.org',
beginners_link =
'https://bn.wikipedia.org/wiki/%E0%A6%89%E0%A6%87%E0%A6%95%E0%A6%BF%E0%A6%AA%E0%A6%BF%E0%A6%A1%E0%A6%BF%E0%A6%AF%E0%A6%BC%E0%A6%BE:%E0%A6%89%E0%A7%8E%E0%A6%B8%E0%A6%A8%E0%A6%BF%E0%A6%B0%E0%A7%8D%E0%A6%A6%E0%A7%87%E0%A6%B6',
beginners_link_title = 'উইকিপিডিয়া:উৎসনির্দেশ',
lead_section_policy_link =
'https://bn.wikipedia.org/wiki/%E0%A6%89%E0%A6%87%E0%A6%95%E0%A6%BF%E0%A6%AA%E0%A6%BF%E0%A6%A1%E0%A6%BF%E0%A6%AF%E0%A6%BC%E0%A6%BE:%E0%A6%AD%E0%A7%82%E0%A6%AE%E0%A6%BF%E0%A6%95%E0%A6%BE%E0%A6%82%E0%A6%B6_%E0%A6%A8%E0%A7%80%E0%A6%A4%E0%A6%BF%E0%A6%AE%E0%A6%BE%E0%A6%B2%E0%A6%BE#.E0.A6.A4.E0.A6.A5.E0.A7.8D.E0.A6.AF.E0.A6.B8.E0.A7.82.E0.A6.A4.E0.A7.8D.E0.A6.B0',
lead_section_policy_link_title = 'WP:CITELEAD',
citation_needed_category = 'উৎসবিহীন_তথ্যসহ_সকল_নিবন্ধ',
# Some of these are not exactly [citation needed] but bnwiki is quite
# small, so they help.
citation_needed_templates = [
'তথ্যসূত্র প্রয়োজন',
'তথ্যসূত্র যাচাই',
'সত্যতা',
'Check',
'Verification needed',
'Verify source',
],
hidden_category = 'লুকায়িত_বিষয়শ্রেণীসমূহ',
category_name_regexps_blacklist = [
'.*[০১২৩৪৫৬৭৮৯].*',
],
snippet_min_size = 20,
),
cs = dict(
lang_name = 'Čeština',
lang_dir = 'ltr',
database = 'cswiki_p',
wikipedia_domain = 'cs.wikipedia.org',
beginners_link = 'https://cs.wikipedia.org/wiki/Wikipedie:Pr%C5%AFvodce/Vkl%C3%A1d%C3%A1n%C3%AD_citac%C3%AD',
beginners_link_title = 'Wikipedie:Průvodce/Vkládání citací',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'Údržba:Články_obsahující_nedoložená_tvrzení',
citation_needed_templates = [
'Není ve zdroji',
'Doplňte zdroj',
'Fakt/dne',
],
hidden_category = 'Wikipedie:Skryté_kategorie',
),
sv = dict(
lang_name = 'Svenska',
lang_dir = 'ltr',
database = 'svwiki_p',
wikipedia_domain = 'sv.wikipedia.org',
beginners_link = 'https://sv.wikipedia.org/wiki/Wikipedia:K%C3%A4llh%C3%A4nvisningar',
beginners_link_title = 'Wikipedia:Källhänvisningar',
lead_section_policy_link = 'https://sv.wikipedia.org/wiki/Wikipedia:K%C3%A4llh%C3%A4nvisningar#N.C3.A4r_beh.C3.B6ver_man_inte_ange_en_k.C3.A4lla.3F',
lead_section_policy_link_title = 'Wikipedia:Källhänvisningar',
citation_needed_category = 'Alla_artiklar_som_behöver_enstaka_källor',
citation_needed_templates = [
'kb',
'Källa behövs',
'Referens behövs',
],
hidden_category = 'Dolda_kategorier',
),
nb = dict(
lang_name = 'Norsk (bokmål)',
lang_dir = 'ltr',
database = 'nowiki_p',
wikipedia_domain = 'no.wikipedia.org',
beginners_link = 'https://no.wikipedia.org/wiki/Wikipedia:Bruk_av_kilder',
beginners_link_title = 'Wikipedia:Bruk av kilder',
lead_section_policy_link = 'https://no.wikipedia.org/wiki/Wikipedia:Bruk_av_kilder#Hvorfor_siterer_vi_kilder',
lead_section_policy_link_title = 'Wikipedia:Bruk_av_kilder',
citation_needed_category = 'Artikler_som_trenger_referanser',
citation_needed_templates = [
'Trenger referanse',
'Referanse',
],
hidden_category = 'Skjulte_kategorier',
),
ne = dict(
lang_name = 'नेपाली',
lang_dir = 'ltr',
database = 'newiki_p',
wikipedia_domain = 'ne.wikipedia.org',
beginners_link = 'https://ne.wikipedia.org/wiki/विकिपिडिया:स्रोत_उल्लेख',
beginners_link_title = 'विकिपिडिया:स्रोत_उल्लेख',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'स्रोत_नखुलेका_सामग्रीहरू_भएका_लेखहरू',
citation_needed_templates = [
'Citation needed','cn'
],
hidden_category = '',
),
nl = dict(
lang_name = 'Nederlands',
lang_dir = 'ltr',
database = 'nlwiki_p',
wikipedia_domain = 'nl.wikipedia.org',
beginners_link = 'https://nl.wikipedia.org/wiki/Wikipedia:Bronvermelding',
beginners_link_title = 'Wikipedia:Bronvermelding',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'Wikipedia:Artikel_mist_referentie',
citation_needed_templates = [
'Bron?',
],
hidden_category = 'Wikipedia:Verborgen_categorie',
),
nn = dict(
lang_name = 'Norsk (nynorsk)',
lang_dir = 'ltr',
database = 'nnwiki_p',
wikipedia_domain = 'nn.wikipedia.org',
beginners_link = 'https://nn.wikipedia.org/wiki/Wikipedia:Kjelder',
beginners_link_title = 'Wikipedia:Kjelder',
lead_section_policy_link = 'https://nn.wikipedia.org/wiki/Wikipedia:Kjelder#Korleis_oppgje_kjelder',
lead_section_policy_link_title = 'Wikipedia:Kjelder',
citation_needed_category = 'Artiklar_som_manglar_kjelder',
citation_needed_templates = [
'Treng kjelde',
],
hidden_category = 'Gøymde_kategoriar',
),
fi = dict(
lang_name = 'Suomi',
lang_dir = 'ltr',
database = 'fiwiki_p',
wikipedia_domain = 'fi.wikipedia.org',
beginners_link = 'https://fi.wikipedia.org/wiki/Ohje:L%C3%A4hteen_lis%C3%A4%C3%A4minen_visuaalisella_muokkaimella/1',
beginners_link_title = 'Lähteen lisääminen visuaalisella muokkaimella',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'Puutteelliset_lähdemerkinnät',
citation_needed_templates = [
'Lähde',
'Lähde tarkemmin',
'Kenen mukaan',
],
hidden_category = 'Piilotetut_luokat',
),
de = dict(
lang_name = 'Deutsch',
lang_dir = 'ltr',
database = 'dewiki_p',
wikipedia_domain = 'de.wikipedia.org',
beginners_link = 'https://de.wikipedia.org/wiki/Wikipedia:Literatur',
beginners_link_title = 'Wikipedia:Literatur',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
# For German, we just display the lead section of the article, so
# some of these keys don't apply
citation_needed_category = 'Wikipedia:Belege_fehlen',
citation_needed_templates = [
'Belege fehlen',
],
hidden_category = 'Kategorie:Versteckt',
extract = 'section',
snippet_max_size = 30000,
),
el = dict(
lang_name = 'Ελληνικά',
lang_dir = 'ltr',
database = 'elwiki_p',
wikipedia_domain = 'el.wikipedia.org',
beginners_link = 'https://el.wikipedia.org/wiki/Βοήθεια:Προσθήκη_παραπομπών_με_τον_VisualEditor',
beginners_link_title = 'Προσθήκη παραπομπών με τον VisualEditor',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'Λήμματα_που_χρειάζονται_παραπομπές_με_επισήμανση',
citation_needed_templates = [
'Εκκρεμεί παραπομπή',
],
hidden_category = 'Κρυμμένες_κατηγορίες',
),
hu = dict(
lang_name = 'Magyar',
lang_dir = 'ltr',
database = 'huwiki_p',
wikipedia_domain = 'hu.wikipedia.org',
beginners_link = 'https://hu.wikipedia.org/wiki/Wikipédia:Jegyzetelés',
beginners_link_title = 'Wikipédia:Jegyzetelés',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'Forrással_nem_rendelkező_lapok',
citation_needed_templates = [
'nincs forrás',
'forráskérő',
'Részben nincs forrás',
'rossz forrás',
'vitatott forrás',
],
hidden_category = 'Rejtett_kategóriák',
),
lv = dict(
lang_name = 'Latviešu',
lang_dir = 'ltr',
database = 'lvwiki_p',
wikipedia_domain = 'lv.wikipedia.org',
beginners_link = 'https://lv.wikipedia.org/wiki/Pal%C4%ABdz%C4%ABba:Atsauces',
beginners_link_title = 'Palīdzība:Atsauces',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'Raksti,_kuru_apgalvojumiem_nepieciešamas_atsauces',
citation_needed_templates = [
'Nepieciešama atsauce',
],
hidden_category = 'Slēptās_kategorijas',
),
ru = dict(
lang_name = 'Русский',
lang_dir = 'ltr',
database = 'ruwiki_p',
wikipedia_domain = 'ru.wikipedia.org',
beginners_link =
'https://ru.wikipedia.org/wiki/%D0%92%D0%B8%D0%BA%D0%B8%D0%BF%D0%B5%D0%B4%D0%B8%D1%8F:%D0%A1%D1%81%D1%8B%D0%BB%D0%BA%D0%B8_%D0%BD%D0%B0_%D0%B8%D1%81%D1%82%D0%BE%D1%87%D0%BD%D0%B8%D0%BA%D0%B8',
beginners_link_title = 'Википедия:Ссылки_на_источники',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'Википедия:Статьи_с_утверждениями_без_источников',
citation_needed_templates = [
'Нет АИ',
'Нет АИ 2',
'Нет источника',
],
hidden_category = 'Скрытые_категории',
),
ro = dict(
lang_name = 'Română',
lang_dir = 'ltr',
database = 'rowiki_p',
wikipedia_domain = 'ro.wikipedia.org',
beginners_link = 'https://ro.wikipedia.org/wiki/Wikipedia:Citarea_surselor',
beginners_link_title = 'Wikipedia:Citarea_surselor',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'Articole_care_necesită_citări_suplimentare',
citation_needed_templates = [
'Necesită citare',
],
hidden_category = 'Categorii_ascunse',
),
ml = dict(
lang_name = 'മലയാളം',
lang_dir = 'ltr',
database = 'mlwiki_p',
wikipedia_domain = 'ml.wikipedia.org',
beginners_link = 'https://ml.wikipedia.org/wiki/വിക്കിപീഡിയ:അവലംബങ്ങൾ_ഉദ്ധരിക്കേണ്ടതെങ്ങനെ',
beginners_link_title = 'വിക്കിപീഡിയ:അവലംബങ്ങൾ ഉദ്ധരിക്കേണ്ടതെങ്ങനെ',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_category = 'അവലംബം_ചേർക്കേണ്ട_വാചകങ്ങളുള്ള_ലേഖനങ്ങൾ',
citation_needed_templates = [
'തെളിവ്',
],
hidden_category = 'മറഞ്ഞിരിക്കുന്ന_വർഗ്ഗങ്ങൾ',
snippet_max_size = 1000,
),
ja = dict(
lang_name = '日本語',
lang_dir = 'ltr',
database = 'jawiki_p',
wikipedia_domain = 'ja.wikipedia.org',
beginners_link = 'https://ja.wikipedia.org/wiki/Wikipedia:出典を明記する',
beginners_link_title = 'Wikipedia:出典を明記する',
lead_section_policy_link = 'https://ja.wikipedia.org/wiki/Wikipedia:スタイルマニュアル_(導入部)#.E5.87.BA.E5.85.B8',
lead_section_policy_link_title = '導入部の出典',
citation_needed_category = '出典を必要とする記述のある記事',
citation_needed_templates = [
'出典の明記',
'要出典',
],
hidden_category = '隠しカテゴリ',
snippet_max_size = 1000,
),
zh_hant = dict(
lang_name = '繁體中文',
lang_dir = 'ltr',
accept_language = [
'zh-TW',
'zh-HK',
'zh-MO',
'zh-Hant',
],
database = 'zhwiki_p',
wikipedia_domain = 'zh.wikipedia.org',
beginners_link = 'https://zh.wikipedia.org/wiki/Wikipedia:列明来源',
beginners_link_title = 'Wikipedia:列明來源',
lead_section_policy_link = 'https://zh.wikipedia.org/wiki/Wikipedia:LEADCITE',
lead_section_policy_link_title = '序言章節的引用',
citation_needed_category = '有未列明来源语句的条目',
citation_needed_templates = [
'Unreferenced',
'Fact',
],
hidden_category = '隐藏分类',
html_parse_parameters = {
'variant': 'zh-hant',
},
),
zh_hans = dict(
lang_name = '简体中文',
lang_dir = 'ltr',
accept_language = [
'zh-CN',
'zh-SG',
'zh-Hans',
],
database = 'zhwiki_p',
wikipedia_domain = 'zh.wikipedia.org',
beginners_link = 'https://zh.wikipedia.org/wiki/Wikipedia:列明来源',
beginners_link_title = 'Wikipedia:列明来源',
lead_section_policy_link = 'https://zh.wikipedia.org/wiki/Wikipedia:LEADCITE',
lead_section_policy_link_title = '序言章节的引用',
citation_needed_category = '有未列明来源语句的条目',
citation_needed_templates = [
'Unreferenced',
'Fact',
],
hidden_category = '隐藏分类',
html_parse_parameters = {
'variant': 'zh-hans',
},
),
ko = dict(
lang_name = '한국어',
lang_dir = 'ltr',
database = 'kowiki_p',
wikipedia_domain = 'ko.wikipedia.org',
beginners_link = 'https://ko.wikipedia.org/wiki/위키백과:길라잡이',
beginners_link_title = '위키백과:길라잡이',
reliable_sources_link = 'https://ko.wikipedia.org/wiki/위키백과:신뢰할 수 있는 출처',
lead_section_policy_link = 'https://ko.wikipedia.org/wiki/위키백과:편집 지침/도입부',
lead_section_policy_link_title = '도입부 편집 지침',
hidden_category = '숨은_분류',
citation_needed_category = '출처가_필요한_글',
citation_needed_templates = [
'출처'
],
),
ur = dict(
lang_name = 'اردو',
lang_dir = 'rtl',
database = 'urwiki_p',
wikipedia_domain = 'ur.wikipedia.org',
citation_needed_category = 'ماخذ_میں_نامکمل_اندراجات',
beginners_link = 'https://ur.wikipedia.org/wiki/ویکیپیڈیا:حوالہ_دہی',
beginners_link_title = 'ویکیپیڈیا:حوالہ دہی',
lead_section_policy_link = '',
lead_section_policy_link_title = '',
citation_needed_templates = [
'حوالہ درکار',
],
hidden_category = 'پوشیدہ_زمرہ_جات',
snippet_max_size = 1200,
),
uk = dict(
lang_name = 'Українська',
lang_dir = 'ltr',
database = 'ukwiki_p',
wikipedia_domain = 'uk.wikipedia.org',
beginners_link = 'https://uk.wikipedia.org/wiki/Вікіпедія:Посилання_на_джерела/Візуальний_редактор',
beginners_link_title = 'Як посилатись на джерела у Візуальному редакторі',
lead_section_policy_link = 'https://uk.wikipedia.org/wiki/Вікіпедія:Посилання_на_джерела',
lead_section_policy_link_title = 'Вікіпедія:Посилання_на_джерела',
citation_needed_category = 'Статті_з_твердженнями_без_джерел',
citation_needed_templates = [
'Потрібне джерело',
'Fact',
'Fact2',
'Немає АД',
'Немає АД 2',
],
hidden_category = 'Приховані_категорії',
)
)
Config = types.SimpleNamespace
def _inherit(base, child):
ret = dict(base) # shallow copy
for k, v in child.items():
if k in ret:
if isinstance(v, list):
v = ret[k] + v
elif isinstance(v, dict):
v = dict(ret[k], **v)
ret[k] = v
return ret
LANG_CODES_TO_LANG_NAMES = {
lang_code: _LANG_CODE_TO_CONFIG[lang_code]['lang_name']
for lang_code in _LANG_CODE_TO_CONFIG
}
LANG_CODES_TO_ACCEPT_LANGUAGE = {
lang_code: _LANG_CODE_TO_CONFIG[lang_code].get('accept_language', [])
for lang_code in _LANG_CODE_TO_CONFIG
}
# Ugly one-liner to check whether the different accept_language are
# disjoint, since we depend on that to redirect the user to the right
# config if no lang_code is provided in the URL.
assert len(
set.union(set(), *list(LANG_CODES_TO_ACCEPT_LANGUAGE.values()))
) == sum(map(len, list(LANG_CODES_TO_ACCEPT_LANGUAGE.values())))
def make_petscan_url(cfg):
language = cfg.wikipedia_domain.replace('.wikipedia.org', '')
return (cfg.petscan_url +
'?language=' + language +
'&depth=' + str(cfg.petscan_depth) +
'&category=' + cfg.citation_needed_category)
def get_global_config():
return Config(**_GLOBAL_CONFIG)
def get_localized_config(lang_code = None):
if lang_code is None:
lang_code = os.getenv('CH_LANG')
lang_config = _LANG_CODE_TO_CONFIG[lang_code]
cfg = Config(lang_code = lang_code, **reduce(
_inherit, [_GLOBAL_CONFIG, _BASE_LANG_CONFIG, lang_config]))
cfg.lang_codes_to_lang_names = LANG_CODES_TO_LANG_NAMES
return cfg