-
Notifications
You must be signed in to change notification settings - Fork 1
/
m-votes.py
1344 lines (1138 loc) · 61.7 KB
/
m-votes.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
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
This bot creates a pages with current results of various votings on pl.wikipedia
Call: time python pwb.py masti/m-votes.py -page:'!' -outpage:'votes.html'; cp ~/pw/core/masti/html/votes.html ~/public_html/votes.html
Use global -simulate option for test purposes. No changes to live wiki
will be done.
The following parameters are supported:
¶ms;
-always If used, the bot won't ask if it should file the message
onto user talk page.
-text: Use this text to be added; otherwise 'Test' is used
-replace: Dont add text but replace it
-top Place additional text on top of the page
-summary: Set the action summary message for the edit.
-outpage Results page; otherwise "Wikipedysta:mastiBot/test" is used
"""
#
# (C) Pywikibot team, 2006-2016
#
# Distributed under the terms of the MIT license.
#
from __future__ import absolute_import, unicode_literals
__version__ = '$Id: c1795dd2fb2de670c0b4bddb289ea9d13b1e9b3f $'
#
import pywikibot
from pywikibot import pagegenerators
from pywikibot.bot import (
SingleSiteBot, ExistingPageBot, NoRedirectPageBot, AutomaticTWSummaryBot)
from pywikibot.tools import issue_deprecation_warning
import re
import urllib
#import urllib.parse
from datetime import datetime
from time import strftime
import difflib
# This is required for the text that is shown when you run this script
# with the parameter -help.
docuReplacements = {
'¶ms;': pagegenerators.parameterHelp
}
voteResults = {}
class BasicBot(
# Refer pywikobot.bot for generic bot classes
SingleSiteBot, # A bot only working on one site
# CurrentPageBot, # Sets 'current_page'. Process it in treat_page method.
# # Not needed here because we have subclasses
ExistingPageBot, # CurrentPageBot which only treats existing pages
NoRedirectPageBot, # CurrentPageBot which only treats non-redirects
AutomaticTWSummaryBot, # Automatically defines summary; needs summary_key
):
"""
An incomplete sample bot.
@ivar summary_key: Edit summary message key. The message that should be used
is placed on /i18n subdirectory. The file containing these messages
should have the same name as the caller script (i.e. basic.py in this
case). Use summary_key to set a default edit summary message.
@type summary_key: str
"""
summary_key = 'basic-changing'
def __init__(self, generator, **kwargs):
"""
Constructor.
@param generator: the page generator that determines on which pages
to work
@type generator: generator
"""
# Add your own options to the bot and set their defaults
# -always option is predefined by BaseBot class
self.availableOptions.update({
'replace': False, # delete old text and write the new text
'summary': None, # your own bot summary
'text': 'Test', # add this text from option. 'Test' is default
'top': False, # append text on top of the page
'outpage': u'User:mastiBot/test', #default output page
'test': False, #switch on test functionality
'KA': False, #switch on ArbCom voting
'KAmonth': None, #ArbCom voting month eg. 2017-09
'KAplaces': 4, #ArbCom plac to be won
})
# call constructor of the super class
super(BasicBot, self).__init__(site=True, **kwargs)
# handle old -dry paramter
self._handle_dry_param(**kwargs)
# assign the generator to the bot
self.generator = generator
def _handle_dry_param(self, **kwargs):
"""
Read the dry parameter and set the simulate variable instead.
This is a private method. It prints a deprecation warning for old
-dry paramter and sets the global simulate variable and informs
the user about this setting.
The constuctor of the super class ignores it because it is not
part of self.availableOptions.
@note: You should ommit this method in your own application.
@keyword dry: deprecated option to prevent changes on live wiki.
Use -simulate instead.
@type dry: bool
"""
if 'dry' in kwargs:
issue_deprecation_warning('dry argument',
'pywikibot.config.simulate', 1)
# use simulate variable instead
pywikibot.config.simulate = True
pywikibot.output('config.simulate was set to True')
def run(self):
if self.getOption('KA'):
KAvotesResult = self.KAvotes(u'Wikipedia:Komitet Arbitrażowy/Wybór członków/' + self.getOption('KAmonth') + u'/Całość')
#KAvotesResult = self.KAvotes(u'Wikipedysta:masti/KA')
if KAvotesResult:
voteResults['KA'] = KAvotesResult
# test only
#pywikibot.output(u'KAvotesResult: %s' % KAvotesResult)
#PUvotesResult = self.PUvotes(u'Wikipedysta:MastiBot/Przyznawanie_uprawnień')
PUvotesResult = self.PUvotes(u'Wikipedia:Przyznawanie_uprawnień')
if PUvotesResult:
voteResults['PU'] = PUvotesResult
if self.getOption('test'):
pywikibot.output(u'PUvotesResult: %s' % PUvotesResult)
PDAvotesResult = self.PDAvotes(u'Wikipedia:Propozycje do Dobrych Artykułów', u'PDA')
if PDAvotesResult:
voteResults['PDA'] = PDAvotesResult
if self.getOption('test'):
pywikibot.output(u'PDAvotesResult: %s' % PDAvotesResult)
PAMvotesResult = self.PDAvotes(u'Wikipedia:Propozycje do Artykułów na Medal', u'PAM')
if PAMvotesResult:
voteResults['PAM'] = PAMvotesResult
if self.getOption('test'):
pywikibot.output(u'PAMvotesResult: %s' % PAMvotesResult)
INMvotesResult = self.INMvotes(u'Wikipedia:Propozycje do Ilustracji na Medal')
if INMvotesResult:
voteResults['INM'] = INMvotesResult
if self.getOption('test'):
pywikibot.output(u'INMvotesResult: %s' % INMvotesResult)
LNMvotesResult = self.LNMvotes(u'Wikipedia:Propozycje do List na Medal')
if LNMvotesResult:
voteResults['LNM'] = LNMvotesResult
if self.getOption('test'):
pywikibot.output(u'LNMvotesResult: %s' % LNMvotesResult)
PDGAvotesResult = self.PDGAvotes(u'Wikipedia:Propozycje do Grup Artykułów')
if PDGAvotesResult:
voteResults['PDGA'] = PDGAvotesResult
if self.getOption('test'):
pywikibot.output(u'LNMvotesResult: %s' % LNMvotesResult)
if self.getOption('test'):
pywikibot.output(u'voteResults: %s' % voteResults)
self.generateresultspage( voteResults )
if self.getOption('test'):
pywikibot.output(u'****END OF PROGRAM***')
"""
KA related part
"""
"""
Tylko na czas wyborów
"""
def KAvotes(self, pagename):
#generate Przyznawanie uprawnień page list of voting subpages as list
#test
#pywikibot.output(u'***KAvotes')
votesL = []
votespage = pywikibot.Page(pywikibot.Site(), pagename)
text = votespage.text
if not text:
return(None)
kaR = re.compile(r'\{\{Wikipedia:Komitet Arbitrażowy\/Wybór członków\/' + self.getOption('KAmonth') + u'\/(?P<puname>.*)}}')
#kaR = re.compile(r'\{\{\/(?P<puname>.*)}}')
if self.getOption('test'):
pywikibot.output(u'kaR: %s' % kaR)
kafound = False
kalist = kaR.finditer(text)
for ka in kalist:
subpage = ka.group('puname').strip()
#test
#pywikibot.output(subpage)
if not u'Całość' in subpage:
kafound = True
votesL.append(self.KASingleVote(subpage))
# test
#pywikibot.output(u'Subpage: %s votesL: %s' % (subpage, votesL[len(votesL)-1]))
return(votesL)
def KASingleVote(self, pagename):
#generate Single Vote result as tuple (wikipedysta, error, (za, przeciw, neutral, netto, %))
if self.getOption('test'):
pywikibot.output(u'****generateKAvoteresult:' + pagename)
votespage = pywikibot.Page(pywikibot.Site(), u'Wikipedia:Komitet Arbitrażowy/Wybór członków/' + self.getOption('KAmonth') + u'/' + pagename)
#votespage = pywikibot.Page(pywikibot.Site(), u'Wikipedysta:masti/KA/' + pagename)
text = votespage.text
if not text:
return(None)
#removeDisabledParts
text = pywikibot.textlib.removeDisabledParts(text)
if self.getOption('test'):
pywikibot.output(u'Vote text:\n%s' % text)
# vote counting regexp
forR = re.compile(r'={4}\s*?Za:?\s*?={4}\n(?P<forvotes>.*?)={4}',re.S)
againstR = re.compile(r'={4}\s*?Przeciw:?\s*?={4}\n(?P<againstvotes>.*?)={4}',re.S)
abstainR = re.compile(r'={4}\s*?Wstrzymuję się:?\s*?={4}\n(?P<abstainvotes>.*?)={4}',re.S)
try:
# count For votes
votesection = forR.search(text).group('forvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
forvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'For votes count: %i' % forvotes)
# count Against votes
votesection = againstR.search(text).group('againstvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
againstvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'Against votes count: %i' % againstvotes)
# count Abstain votes
votesection = abstainR.search(text).group('abstainvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
abstainvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'Abstain votes count: %i' % abstainvotes)
#pywikibot.output(u'Sumvotes: %i' % forvotes + againstvotes)
if forvotes + againstvotes > 0:
percentvotes = forvotes / float(forvotes + againstvotes)
else:
percentvotes = 0
if self.getOption('test'):
#pywikibot.output(u'Sum of votes count: %i' % sumvotes)
pywikibot.output(u'Percentage: %f' % percentvotes)
return( (pagename, False, (forvotes, againstvotes, abstainvotes, forvotes-againstvotes, percentvotes)) )
except:
pywikibot.output(u'***ERROR - cannot analyse votes: %s' % pagename)
return( (pagename, True, ()) )
"""
PU related part
"""
def PUvotes(self, pagename):
#generate Przyznawanie uprawnień page list of voting subpages as list
if self.getOption('test'):
pywikibot.output(u'***PUvotes')
votesL = []
votespage = pywikibot.Page(pywikibot.Site(), pagename)
text = votespage.text
if not text:
return(None)
puR = re.compile(r'\{\{(Wikipedia:Przyznawanie uprawnień)?\/(?P<puname>.*)}}')
pufound = False
pulist = puR.finditer(text)
for pu in pulist:
subpage = pu.group('puname').strip()
if self.getOption('test'):
pywikibot.output(subpage)
if not u'Wstęp' in subpage:
pufound = True
votesL.append(self.PUSingleVote(subpage))
if self.getOption('test'):
pywikibot.output(u'Subpage: %s votesL: %s' % (subpage, votesL[len(votesL)-1]))
return(votesL)
def PUSingleVote(self, pagename):
#generate Single Vote result as tuple (wikipedysta, error, (za, przeciw, neutral, netto, %, data))
if self.getOption('test'):
pywikibot.output(u'****generatePUvoteresult:' + pagename)
votespage = pywikibot.Page(pywikibot.Site(), u'Wikipedia:Przyznawanie uprawnień/' + pagename)
text = votespage.text
if not text:
return(None)
# find end of voting string
try:
eovR = re.compile(r'\{\{Ramy czasowe zdarzenia.*?stop\s*?=\s*?(?P<eofv>.*?)\|')
endofvotinglist = eovR.search(text)
endofvoting = endofvotinglist.group('eofv').strip()
if self.getOption('test'):
pywikibot.output(u'End of Voting: %s' % endofvoting)
except:
endofvoting = u'brak danych'
#removeDisabledParts
text = pywikibot.textlib.removeDisabledParts(text)
if self.getOption('test'):
pywikibot.output(u'Vote text:\n%s' % text)
# vote counting regexp
forR = re.compile(r'={4}\s*?Za\s*?={4}\n(?P<forvotes>.*?)={4}',re.S)
againstR = re.compile(r'={4}\s*?Przeciw\s*?={4}\n(?P<againstvotes>.*?)={4}',re.S)
abstainR = re.compile(r'={4}\s*?Wstrzymuję się\s*?={4}\n(?P<abstainvotes>.*?)={4}',re.S)
try:
# count For votes
votesection = forR.search(text).group('forvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
forvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'For votes count: %i' % forvotes)
# count Against votes
votesection = againstR.search(text).group('againstvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
againstvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'Against votes count: %i' % againstvotes)
# count Abstain votes
votesection = abstainR.search(text).group('abstainvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
abstainvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'Abstain votes count: %i' % abstainvotes)
if forvotes + againstvotes > 0:
percentvotes = forvotes / float(forvotes + againstvotes)
else:
percentvotes = 0
if self.getOption('test'):
#pywikibot.output(u'Sum of votes count: %i' % sumvotes)
pywikibot.output(u'Percentage: %f' % percentvotes)
return( (pagename, False, (forvotes, againstvotes, abstainvotes, forvotes-againstvotes, percentvotes, endofvoting)) )
except:
pywikibot.output(u'***ERROR - cannot analyse votes: %s' % pagename)
return( (pagename, True, ()) )
def CountVotes(self, voteslist):
#count votes in list
if self.getOption('test'):
pywikibot.output(u'****CountVotes:' + voteslist)
#voteR = re.compile(r'#(\s*?[^\s\n;#]+)')
voteR = re.compile(r'^#[^:](?P<vote>[^\n]*)', re.M)
voteL = voteR.finditer(voteslist)
count = 0
for v in voteL:
if v.group('vote'):
count += 1
return( count )
"""
PDA related part
"""
def PDAvotes(self, pagename, pdapam):
#generate Propozycje do Dobrych Artykułów page list of voting subpages as list
if self.getOption('test'):
pywikibot.output(u'***PDAvotes')
votesL = []
votespage = pywikibot.Page(pywikibot.Site(), pagename)
text = votespage.text
if not text:
return(None)
pdaR = re.compile(r'\{\{(Wikipedia:Propozycje do Dobrych Artykułów|Wikipedia:Propozycje do Artykułów na Medal)?\/(?P<subpage>.*?)}}')
pdafound = False
pdalist = pdaR.finditer(text)
for pda in pdalist:
subpage = pda.group('subpage').strip()
if self.getOption('test'):
pywikibot.output(subpage)
if (not subpage.startswith(u'przyznawanie')) and (not subpage.startswith(u'weryfikacja')) and (not subpage.startswith(u'dyskusje przedłużone')):
pdafound = True
votesL.append(self.PDASingleVote(subpage, pdapam))
if self.getOption('test'):
pywikibot.output(u'Subpage: %s votesL: %s' % (subpage, votesL[len(votesL)-1]))
return(votesL)
def PDASingleVote(self, pagename, pdapam):
#generate Single Vote result as tuple (strona, error, (sprawdzający, data))
if self.getOption('test'):
pywikibot.output(u'****generatePDAvoteresult:' + pagename)
if u'PDA' in pdapam:
votespage = pywikibot.Page(pywikibot.Site(), u'Wikipedia:Propozycje do Dobrych Artykułów/' + pagename)
#votespage = pywikibot.Page(pywikibot.Site(), u'Wikipedysta:MastiBot/test')
else:
votespage = pywikibot.Page(pywikibot.Site(), u'Wikipedia:Propozycje do Artykułów na Medal/' + pagename)
text = votespage.text
if not text:
return(None)
# find end of voting string
try:
eovR = re.compile(r'\{\{Ramy czasowe zdarzenia.*?stop\s*?=\s*?(?P<eofv>.*?)\|')
endofvotinglist = eovR.search(text)
endofvoting = endofvotinglist.group('eofv').strip()
if self.getOption('test'):
pywikibot.output(u'End of Voting: %s' % endofvoting)
except:
endofvoting = u'brak danych'
#removeDisabledParts
text = pywikibot.textlib.removeDisabledParts(text)
if self.getOption('test'):
pywikibot.output(u'Vote text:\n%s' % text)
# vote counting regexp
verR = re.compile(r'(;|=+) *Sprawdzone przez[^\n]*?\n+(?P<verifiers>.*)', re.S)
try:
# count verifiers votes
votesection = verR.search(text).group('verifiers')
if self.getOption('test'):
pywikibot.output(u'Vote section: %s' % votesection)
vervotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'Ver votes count: %i' % vervotes)
return( (pagename, False, (vervotes, endofvoting)) )
except:
pywikibot.output(u'***ERROR - cannot analyse votes: %s' % pagename)
return( (pagename, True, ()) )
"""
INM related part
"""
def INMvotes(self, pagename):
#generate Propozycje do Ilustracji na Medal page list of voting subpages as list
if self.getOption('test'):
pywikibot.output(u'***INMvotes')
votesL = []
votespage = pywikibot.Page(pywikibot.Site(), pagename)
text = votespage.text
if not text:
return(None)
inmR = re.compile(r'\{\{(Wikipedia:Propozycje do Ilustracji na Medal)?\/(?P<subpage>.*?)}}')
inmfound = False
inmlist = inmR.finditer(text)
for inm in inmlist:
subpage = inm.group('subpage').strip()
if self.getOption('test'):
pywikibot.output(subpage)
if (not subpage.startswith(u'przyznawanie')) and (not subpage.startswith(u'weryfikacja')) and (not subpage.startswith(u'dyskusje przedłużone')):
inmfound = True
votesL.append(self.INMSingleVote(subpage))
if self.getOption('test'):
pywikibot.output(u'Subpage: %s votesL: %s' % (subpage, votesL[len(votesL)-1]))
return(votesL)
def INMSingleVote(self, pagename):
#generate Single Vote result as tuple (strona, error, (za, przeciw, netto, procent, data))
if self.getOption('test'):
pywikibot.output(u'****generatePDAvoteresult:' + pagename)
votespage = pywikibot.Page(pywikibot.Site(), u'Wikipedia:Propozycje do Ilustracji na Medal/' + pagename)
text = votespage.text
if not text:
return(None)
# find end of voting string
try:
eovR = re.compile(r'\{\{Ramy czasowe zdarzenia.*?stop\s*?=\s*?(?P<eofv>.*?)\|')
endofvotinglist = eovR.search(text)
endofvoting = endofvotinglist.group('eofv').strip()
if self.getOption('test'):
pywikibot.output(u'End of Voting: %s' % endofvoting)
except:
endofvoting = u'brak danych'
# vote counting regexp
forR = re.compile(r"\*\s*?'''Głosy za( odebraniem medalu)?:'''\s*?\n+(?P<forvotes>.*?)\n\*\s*?'''", re.S)
againstR = re.compile(r"\*\s*?'''Głosy przeciw( odebraniu medalu)?:'''\s*?\n+(?P<againstvotes>.*?)\n\*\s*?'''", re.S)
#removeDisabledParts
text = pywikibot.textlib.removeDisabledParts(text)
if self.getOption('test'):
pywikibot.output(u'Vote text:\n%s' % text)
try:
# count For votes
votesection = forR.search(text).group('forvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
forvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'For votes count: %i' % forvotes)
# count Against votes
votesection = againstR.search(text).group('againstvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
againstvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'Against votes count: %i' % againstvotes)
#calculate netto
netto = forvotes - againstvotes
if self.getOption('test'):
pywikibot.output(u'Netto votes count: %i' % netto)
#calculate percentage
if forvotes + againstvotes > 0:
percentvotes = forvotes / float(forvotes + againstvotes)
else:
percentvotes = 0
if self.getOption('test'):
#pywikibot.output(u'Sum of votes count: %i' % sumvotes)
pywikibot.output(u'Percentage: %f' % percentvotes)
return( (pagename, False, (forvotes, againstvotes, netto, percentvotes, endofvoting)) )
except:
pywikibot.output(u'***ERROR - cannot analyse votes: %s' % pagename)
return( (pagename, True, ()) )
"""
LNM related part
"""
def LNMvotes(self, pagename):
#generate Wikipedia:Propozycje do List na Medal page list of voting subpages as list
#test
#pywikibot.output(u'***LNMvotes')
votesL = []
votespage = pywikibot.Page(pywikibot.Site(), pagename)
text = votespage.text
if not text:
return(None)
#test
#pywikibot.output(u'*** LNM:\n%s' % text)
lnmR = re.compile(r'\{\{(Wikipedia:Propozycje do List na Medal)?\/(?P<subpage>.*?)}}')
lmfound = False
lnmlist = lnmR.finditer(text)
for lnm in lnmlist:
subpage = lnm.group('subpage').strip()
#test
#pywikibot.output(subpage)
if (not subpage.startswith(u'przyznawanie')) and (not subpage.startswith(u'weryfikacja') ) :
lnmfound = True
votesL.append(self.LNMSingleVote(subpage))
# test
#pywikibot.output(u'Subpage: %s votesL: %s' % (subpage, votesL[len(votesL)-1]))
return(votesL)
def LNMSingleVote(self, pagename):
#generate Single Vote result as tuple (strona, error, (za, przeciw, netto, procent, data))
if self.getOption('test'):
pywikibot.output(u'****generateLNMvoteresult:' + pagename)
votespage = pywikibot.Page(pywikibot.Site(), u'Wikipedia:Propozycje do List na Medal/' + pagename)
text = votespage.text
if not text:
return(None)
# find end of voting string
try:
eovR = re.compile(r'\{\{Ramy czasowe zdarzenia.*?stop\s*?=\s*?(?P<eofv>.*?)\|')
endofvotinglist = eovR.search(text)
endofvoting = endofvotinglist.group('eofv').strip()
if self.getOption('test'):
pywikibot.output(u'End of Voting: %s' % endofvoting)
except:
endofvoting = u'brak danych'
# vote counting regexp
forR = re.compile(r"\*\s*?'''Głosy za:'''\s*?\n+(?P<forvotes>.*?)\n\*\s*?'''", re.S)
againstR = re.compile(r"\*\s*?'''Głosy przeciw:'''\s*?\n+(?P<againstvotes>.*?)\n\*\s*?'''", re.S)
#removeDisabledParts
text = pywikibot.textlib.removeDisabledParts(text)
if self.getOption('test'):
pywikibot.output(u'Vote text:\n%s' % text)
forvotes = ''
againstvotes = ''
netto = ''
percentvotes = ''
try:
# count For votes
votesection = forR.search(text).group('forvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
forvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'For votes count: %i' % forvotes)
# count Against votes
votesection = againstR.search(text).group('againstvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
againstvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'Against votes count: %i' % againstvotes)
#calculate netto
netto = forvotes - againstvotes
if self.getOption('test'):
pywikibot.output(u'Netto votes count: %i' % netto)
#calculate percentage
if forvotes + againstvotes > 0:
percentvotes = forvotes / float(forvotes + againstvotes)
else:
percentvotes = 0
if self.getOption('test'):
#pywikibot.output(u'Sum of votes count: %i' % sumvotes)
pywikibot.output(u'Percentage: %f' % percentvotes)
return( (pagename, False, (forvotes, againstvotes, netto, percentvotes, endofvoting)) )
except:
pywikibot.output(u'***ERROR - cannot analyse votes: %s' % pagename)
return( (pagename, True, ()) )
"""
PDGA related part
"""
def PDGAvotes(self, pagename):
#generate Wikipedia:Propozycje do Grup Artykułów page list of voting subpages as list
#test
#pywikibot.output(u'***PDGAvotes')
votesL = []
votespage = pywikibot.Page(pywikibot.Site(), pagename)
text = votespage.text
if not text:
return(None)
#removeDisabledParts
text = pywikibot.textlib.removeDisabledParts(text)
if self.getOption('test'):
pywikibot.output(u'Vote text:\n%s' % text)
if self.getOption('test'):
pywikibot.output(u'*** PDGA:\n%s' % text)
pdgaR = re.compile(r'\{\{(Wikipedia:Propozycje do Grup Artykułów)?\/(?P<subpage>.*?)}}')
pdgafound = False
pdgalist = pdgaR.finditer(text)
for pdga in pdgalist:
subpage = pdga.group('subpage').strip()
if self.getOption('test'):
pywikibot.output(subpage)
if (not subpage.startswith(u'przyznawanie')) and (not subpage.startswith(u'weryfikacja') ) :
pdgafound = True
votesL.append(self.PDGASingleVote(subpage))
if self.getOption('test'):
pywikibot.output(u'Subpage: %s votesL: %s' % (subpage, votesL[len(votesL)-1]))
return(votesL)
def PDGASingleVote(self, pagename):
#generate Single Vote result as tuple (strona, error, (za, przeciw, netto, procent, data))
if self.getOption('test'):
pywikibot.output(u'****generateLNMvoteresult:' + pagename)
votespage = pywikibot.Page(pywikibot.Site(), u'Wikipedia:Propozycje do Grup Artykułów/' + pagename)
text = votespage.text
if not text:
return(None)
# find end of voting string
try:
eovR = re.compile(r'\{\{Ramy czasowe zdarzenia.*?stop\s*?=\s*?(?P<eofv>.*?)\|')
endofvotinglist = eovR.search(text)
endofvoting = endofvotinglist.group('eofv').strip()
if self.getOption('test'):
pywikibot.output(u'End of Voting: %s' % endofvoting)
except:
endofvoting = u'brak danych'
# vote counting regexp
forR = re.compile(r"\*\s*?'''Głosy za:'''\s*?\n+(?P<forvotes>.*?)\n\*\s*?'''", re.S)
againstR = re.compile(r"\*\s*?'''Głosy przeciw:'''\s*?\n+(?P<againstvotes>.*?)\n\*\s*?'''", re.S)
#removeDisabledParts
text = pywikibot.textlib.removeDisabledParts(text)
if self.getOption('test'):
pywikibot.output(u'Vote text:\n%s' % text)
forvotes = ''
againstvotes = ''
netto = ''
percentvotes = ''
try:
# count For votes
votesection = forR.search(text).group('forvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
forvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'For votes count: %i' % forvotes)
# count Against votes
votesection = againstR.search(text).group('againstvotes')
#pywikibot.output(u'Vote section: %s' % votesection)
againstvotes = self.CountVotes(votesection)
if self.getOption('test'):
pywikibot.output(u'Against votes count: %i' % againstvotes)
#calculate netto
netto = forvotes - againstvotes
if self.getOption('test'):
pywikibot.output(u'Netto votes count: %i' % netto)
#calculate percentage
if forvotes + againstvotes > 0:
percentvotes = forvotes / float(forvotes + againstvotes)
else:
percentvotes = 0
if self.getOption('test'):
#pywikibot.output(u'Sum of votes count: %i' % sumvotes)
pywikibot.output(u'Percentage: %f' % percentvotes)
return( (pagename, False, (forvotes, againstvotes, netto, percentvotes, endofvoting)) )
except:
pywikibot.output(u'***ERROR - cannot analyse votes: %s' % pagename)
return( (pagename, True, ()) )
"""
Main page related part
"""
def mainheader(self):
#prepare main page header
header = u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
header += u'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl" dir="ltr">\n'
header += u' <head>\n'
header += u' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n'
header += u' <title>Głosowania - tools.wikimedia.pl</title>\n'
header += u' <link rel="stylesheet" type="text/css" href="/~masti/modern.css" />\n'
#header += u' <style type="text/css">\n'
#header += u'table.wikitable td, table.wikitable th {\n'
#header += u' padding: 5px;\n'
#header += u'}\n'
#header += u'table.wikitable tr:nth-child(odd) {\n'
#header += u' background-color: #F9F9F9;\n'
#header += u'}\n'
#header += u' </style>\n'
header += u' </head>\n'
header += u'<body>\n'
header += u'\n'
header += u' <!-- heading -->\n'
header += u' <div id="mw_header">\n'
header += u' <h1 id="firstHeading">Głosowania</h1>\n'
header += u' </div>\n'
header += u'\n'
header += u' <div id="mw_main">\n'
header += u' <div id="mw_contentwrapper">\n'
header += u'\n'
header += u' <!-- content -->\n'
header += u' <div id="mw_content">\n'
header += u'\n'
header += u' <p>Rzeczywiste wyniki mogą się różnić od podanych poniżej (ktoś może nie mieć prawa głosu, zagłosować w nieprawidłowy sposób lub źle skomentować czyjś głos)! Strona jest aktualizowana co pięć minut.</p>\n'
header += u' <p><small>Komunikat <i>nie można odczytać danych</i> pojawia się w dwóch przypadkach:\n'
header += u' <ul>\n'
header += u' <li>na liście głosowań jest podlinkowane przekierowanie, a nie strona głosowania,</li>\n'
header += u' <li>domyślny układ głosowania został zmieniony (bot nie może znaleźć sekcji z głosami).</li>\n'
header += u' </ul>\n'
header += u' </small></p>\n'
#header += u' <p><center>***** Statystyki są w fazie eksperymentalnej. Wszelkie zauważone problemy proszę zgłaszać w <a href="http://pl.wikipedia.org/wiki/Dyskusja_wikipedysty:masti">dyskusji operatora.</a> *****</center>\n'
#header += u' </p>\n'
# add creation time
header += u' <p>Ostatnia aktualizacja: <b>' + strftime('%A %d %B %Y %X %Z') + u'</b></p>\n'
header += u'\n'
#header += u' <p><center><FORM>\n'
#header += u' <INPUT TYPE="button" onClick="history.go(0)" VALUE="ODŚWIEŻ">\n'
#header += u' </FORM>\n'
#header += u' </center></p>\n'
header += u'<center><b><a class="external text" href="http://tools.wikimedia.pl/~masti/' + self.getOption('outpage') + u'">ODŚWIEŻ</a></b></center>'
return(header)
def mainfooter(self):
#prepare main page footer
footer = u' </div><!-- mw_content -->\n'
footer += u' </div><!-- mw_contentwrapper -->\n'
footer += u'\n'
footer += u' </div><!-- main -->\n'
footer += u'\n'
footer += u' <div class="mw_clear"></div>\n'
footer += u'\n'
footer += u' <!-- personal portlet -->\n'
footer += u' <div class="portlet" id="p-personal">\n'
footer += u' <div class="pBody">\n'
footer += u' <ul>\n'
footer += u' <li><a href="http://pl.wikipedia.org">wiki</a></li>\n'
footer += u' <li><a href="/">tools</a></li>\n'
footer += u' <li><a href="/~masti/">masti</a></li>\n'
footer += u' </ul>\n'
footer += u' </div>\n'
footer += u' </div>\n'
footer += u'<div class="stopka">layout by <a href="../~beau/">Beau</a></div>\n'
footer += u'</body></html>\n'
return(footer)
'''
KA section
'''
def KAheader(self):
header = u' <h2><a name="ka"></a>Komitet Arbitrażowy</h2>\n'
header += u' <p><div class="detail"><a href="//pl.wikipedia.org/wiki/Plik:Information_icon.svg" class="image" title="Information icon.svg"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/35/Information_icon.svg/15px-Information_icon.svg.png" border="0" height="15" width="15"></a> <i>Zobacz więcej na osobnej stronie: <a href="//pl.wikipedia.org/wiki/Wikipedia:Komitet_Arbitra%C5%BCowy/Wyb%C3%B3r_cz%C5%82onk%C3%B3w/' + self.getOption('KAmonth') + u'" title="Wikipedia:Komitet Arbitrażowy/Wybór członków/' + self.getOption('KAmonth') + u'">Wikipedia:Komitet Arbitrażowy/Wybór członków/' + self.getOption('KAmonth') + u'</a>.</i></p>\n'
header += u'<p> Liczba miejsc do obsadzenia: %s</p></div>' % self.getOption('KAplaces')
return(header)
def KAtableheader(self):
header = u' <table class="votestable">\n'
header += u' <tr>\n'
header += u' <th>Pozycja</th>\n'
header += u' <th>wikipedysta</th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_support_vote.svg" class="image" title="Liczba głosów za"><img alt="+" src="//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/15px-Symbol_support_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_oppose_vote.svg" class="image" title="Liczba głosów przeciw"><img alt="-" src="//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/15px-Symbol_oppose_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_neutral_vote.svg" class="image" title="Liczba głosów wstrzymuję się"><img alt="?" src="//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_neutral_vote.svg/15px-Symbol_neutral_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th>netto</th>\n'
header += u' <th>%</th>\n'
header += u' </tr>\n'
return(header)
def KAtablefooter(self):
footer = u' </table>\n'
return(footer)
'''
PU section
'''
def PUheader(self):
header = u' <h2><a name="pu"></a>Przyznawanie uprawnień</h2>\n'
header += u' <div class="detail"><a href="//pl.wikipedia.org/wiki/Plik:Information_icon.svg" class="image" title="Information icon.svg"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/35/Information_icon.svg/15px-Information_icon.svg.png" border="0" height="15" width="15"></a> <i>Zobacz więcej na osobnej stronie: <a href="//pl.wikipedia.org/wiki/Wikipedia%3APrzyznawanie%20uprawnie%C5%84" title="Wikipedia:Przyznawanie uprawnień">Wikipedia:Przyznawanie uprawnień</a>.</i></div>\n'
return(header)
def PUtableheader(self):
header = u' <table class="wikitable vote">\n'
header += u' <tr>\n'
header += u' <th>wikipedysta</th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_support_vote.svg" class="image" title="Liczba głosów za"><img alt="+" src="//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/15px-Symbol_support_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_oppose_vote.svg" class="image" title="Liczba głosów przeciw"><img alt="-" src="//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/15px-Symbol_oppose_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_neutral_vote.svg" class="image" title="Liczba głosów wstrzymuję się"><img alt="?" src="//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_neutral_vote.svg/15px-Symbol_neutral_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th>netto</th>\n'
header += u' <th>%</th>\n'
header += u' <th>data zakończenia</th>\n'
header += u' </tr>\n'
return(header)
def PUtablefooter(self):
footer = u' </table>\n'
return(footer)
'''
PDA Section
'''
def PDAheader(self):
header = u' <h2><a name="pdda"></a>Propozycje do Dobrych Artykułów</h2>\n'
header += u' <div class="detail"><a href="//pl.wikipedia.org/wiki/Plik:Information_icon.svg" class="image" title="Information icon.svg"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/35/Information_icon.svg/15px-Information_icon.svg.png" border="0" height="15" width="15"></a> <i>Zobacz więcej na osobnej stronie: <a href="//pl.wikipedia.org/wiki/Wikipedia%3APropozycje%20do%20Dobrych%20Artyku%C5%82%C3%B3w" title="Wikipedia:Propozycje do Dobrych Artykułów">Wikipedia:Propozycje do Dobrych Artykułów</a>.</i></div>\n'
return(header)
def PDAtableheader(self):
header = u'<table class="wikitable">\n'
header += u' <tr>\n'
header += u' <th>strona</th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:FlaggedRevs-2-1.svg" class="image" title="Liczba osób sprawdzających"><img alt="FlaggedRevs-2-1.svg" src="//upload.wikimedia.org/wikipedia/commons/thumb/5/52/FlaggedRevs-2-1.svg/18px-FlaggedRevs-2-1.svg.png" width="18" height="18"></a></th>\n'
header += u' <th>data zakończenia</th>\n'
header += u' </tr>\n'
return(header)
def PDAtablefooter(self):
footer = u' </table>\n'
return(footer)
'''
PAM section
'''
def PAMheader(self):
header = u' <h2><a name="panm"></a>Propozycje do Artykułów na Medal</h2>\n'
header += u' <div class="detail"><a href="//pl.wikipedia.org/wiki/Plik:Information_icon.svg" class="image" title="Information icon.svg"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/35/Information_icon.svg/15px-Information_icon.svg.png" border="0" height="15" width="15"></a> <i>Zobacz więcej na osobnej stronie: <a href="//pl.wikipedia.org/wiki/Wikipedia%3APropozycje%20do%20Artyku%C5%82%C3%B3w%20na%20Medal" title="Wikipedia:Propozycje do Artykułów na Medal">Wikipedia:Propozycje do Artykułów na Medal</a>.</i></div>\n'
return(header)
def PAMtableheader(self):
header = u'<table class="wikitable">\n'
header += u' <tr>\n'
header += u' <th>strona</th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:FlaggedRevs-2-1.svg" class="image" title="Liczba osób sprawdzających"><img alt="FlaggedRevs-2-1.svg" src="//upload.wikimedia.org/wikipedia/commons/thumb/5/52/FlaggedRevs-2-1.svg/18px-FlaggedRevs-2-1.svg.png" width="18" height="18"></a></th>\n'
header += u' <th>data zakończenia</th>\n'
header += u' </tr>\n'
return(header)
def PAMtablefooter(self):
footer = u' </table>\n'
return(footer)
'''
INM section
'''
def INMheader(self):
header = u' <h2><a name="gnm"></a>Propozycje do Ilustracji na Medal</h2>\n'
header += u' <div class="detail"><a href="//pl.wikipedia.org/wiki/Plik:Information_icon.svg" class="image" title="Information icon.svg"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/35/Information_icon.svg/15px-Information_icon.svg.png" border="0" height="15" width="15"></a> <i>Zobacz więcej na osobnej stronie: <a href="//pl.wikipedia.org/wiki/Wikipedia%3APropozycje%20do Ilustracji%20na%20Medal" title="Wikipedia:Propozycje do Ilustracji na Medal">Wikipedia:Propozycje do Ilustracji na Medal</a>.</i></div>\n'
return(header)
def INMtableheader(self):
header = u'<table class="wikitable">\n'
header += u' <tr>\n'
header += u' <th>strona</th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_support_vote.svg" class="image" title="Liczba głosów za"><img alt="+" src="//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/15px-Symbol_support_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_oppose_vote.svg" class="image" title="Liczba głosów przeciw"><img alt="-" src="//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/15px-Symbol_oppose_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th>netto</th>\n'
header += u' <th>%</th>\n'
header += u' <th>data zakończenia</th>\n'
header += u' </tr>'
return(header)
def INMtablefooter(self):
footer = u' </table>\n'
return(footer)
'''
LNM section
'''
def LNMheader(self):
header = u' <h2><a name="plnm"></a>Propozycje do List na Medal</h2>\n'
header += u' <div class="detail"><a href="//pl.wikipedia.org/wiki/Plik:Information_icon.svg" class="image" title="Information icon.svg"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/35/Information_icon.svg/15px-Information_icon.svg.png" border="0" height="15" width="15"></a> <i>Zobacz więcej na osobnej stronie: <a href="//pl.wikipedia.org/wiki/Wikipedia%3APropozycje%20do%20List%20na%20Medal" title="Wikipedia:Propozycje do List na Medal">Wikipedia:Propozycje do List na Medal</a>.</i></div>\n'
return(header)
def LNMtableheader(self):
header = u'<table class="wikitable">\n'
header += u' <tr>\n'
header += u' <th>strona</th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_support_vote.svg" class="image" title="Liczba głosów za"><img alt="+" src="//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/15px-Symbol_support_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th><a href="//pl.wikipedia.org/wiki/Plik:Symbol_oppose_vote.svg" class="image" title="Liczba głosów przeciw"><img alt="-" src="//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/15px-Symbol_oppose_vote.svg.png" border="0" height="15" width="15"></a></th>\n'
header += u' <th>netto</th>\n'
header += u' <th>%</th>\n'
header += u' <th>data zakończenia</th>\n'
header += u' </tr>'
return(header)
def LNMtablefooter(self):
footer = u' </table>\n'
return(footer)
'''
PDGA section
'''
def PDGAheader(self):
header = u' <h2><a name="plnm"></a>Propozycje do Grup Artykułów</h2>\n'
header += u' <div class="detail"><a href="//pl.wikipedia.org/wiki/Plik:Information_icon.svg" class="image" title="Information icon.svg"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/35/Information_icon.svg/15px-Information_icon.svg.png" border="0" height="15" width="15"></a> <i>Zobacz więcej na osobnej stronie: <a href="//pl.wikipedia.org/wiki/Wikipedia%3APropozycje%20do%20Grup%20Artyku%C5%82%C3%B3w" title="Wikipedia:Propozycje do Grup Artykułów">Wikipedia:Propozycje do Grup Artykułów</a>.</i></div>\n'
return(header)
def PDGAtableheader(self):
header = u'<table class="wikitable">\n'