Static Wikipedia February 2008 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu

Web Analytics
Cookie Policy Terms and Conditions User:DhanakBot/szubcsonk.py - Wikipédia

User:DhanakBot/szubcsonk.py

A Wikipédiából, a szabad lexikonból.

#!/usr/bin/python
# -*- coding: utf-8  -*-
"""
-ro                csak olvasás mód teszteléshez, nem módosít a lapokon

Ez a bot a magyar wikipédia szubcsonk lapjainak adminisztrációját
segíti. Végigmegy a {{szubcsonk}} sablonnal megjelölt szócikkeken,
csoportosítja őket aszerint, hogy a jelzést mikor helyezték el, az
eredményként kapott listát pedig kiteszi a [[Segítség:Szubcsonk]] lap
\"Aktuális szubcsonkok\" szakaszába.
"""

import sys, re, datetime
import wikipedia, date, pagegenerators


site = wikipedia.getSite()
monthptrn = "(?:" + '|'.join(date.makeMonthNamedList(site.language(), '%s')) + ")"
dateptrn  = r"[0-9]{4}\. *" + monthptrn + r" *[0-9]{1,2}\."


class SzubcsonkBot:
    def __init__(self, gen, readOnly = False):
        self.gen = gen
        self.readOnly = readOnly
        self.substubs = {}

        self.substubRe = re.compile(r"\{\{szubcsonk\|(" + dateptrn + ").*?\}\}", re.IGNORECASE)
        self.fixSubstubRe = re.compile(r"(?<=\{\{szubcsonk)(?=\}\})", re.IGNORECASE)

    def run(self):
        self.collectStubs()
        if len(self.substubs):
            self.listStubs()
            self.chgTemplate()

    def collectStubs(self):
        for page in self.gen:
            try:
                self.substubs.setdefault(self.getTimestamp(page), []).append(page.title())
            except wikipedia.NoPage:
                wikipedia.output(u"HIBA: Nem találom a %s lapot" % page.title())
                continue
            except wikipedia.IsRedirectPage:
                continue

    def getTimestamp(self, page):
        unknown = "Ismeretlen";
        
        text = page.get()
        match = self.substubRe.search(text)
        if match:
            return match.group(1)

        if self.readOnly:
            return unknown
        
        (newText, count) = self.fixSubstubRe.subn("|~~~~~", text, count = 1)
        if count == 0:
            wikipedia.output((u"HIBA: A %s lapon nem találtam " +
                              u"megfelelő szubcsonk jelzést") % page.title())
            return unknown

        page.put(newText, u"Robot: szubcsonkjelzés-időbélyeg pótlása")

        text = page.get(force = True)
        match = self.substubRe.search(text)
        if match:
            return match.group(1)
        else:
            wikipedia.output(u"HIBA: Az időbélyeget nem sikerült pótolnom")
            return unknown
       

    def listStubs(self):
        listText = u"\n"
        dates = self.substubs.keys()
        dates.sort(datesort)
        for date in dates:
            listText += "=== %s ===\n" % date
            for page in self.substubs[date]:
                listText += "* [[%s]]\n" % page

        wikipedia.output(listText)
                
        if not self.readOnly:
            listPage = wikipedia.Page(site, u"Segítség:Szubcsonk")
            oldText = listPage.get()
            listRe = re.compile("(?<=" + re.escape(u"<!-- szubcsonk lista eleje -->") +
                                ").*?(?=" + re.escape(u"<!-- szubcsonk lista vége -->") + ")",
                                flags = re.DOTALL)
            newText = listRe.sub(listText, oldText)
            if newText != oldText:
                listPage.put(newText, u"Robot: szubcsonklista frissítése")

    def chgTemplate(self):
        if self.readOnly:
            return
        for pageName in iter([u"Sablon:Szubcsonkok", u"Sablon:Tennivalók-lista/szubcsonkok"]):
            tmpl = wikipedia.Page(site, pageName)
            oldText = tmpl.get()
            groupRe = re.compile("(?<=" + re.escape("<!-- kezdet:") + "([<=>][0-9])" + re.escape(" -->") +
                                 ").*?(?=" + re.escape(u"<!-- vég:") + "\\1" + re.escape(" -->") + ")",
                                 flags = re.DOTALL)
            newText = groupRe.sub(self.listStubsOfGivenAge, oldText)
            if newText != oldText:
                wikipedia.showDiff(oldText, newText)
                tmpl.put(newText, u"Robot: szubcsonklista frissítése")

    def listStubsOfGivenAge(self, match):
        op = match.group(1)[0]
        if op == "=":
            op = "==" 
        delta = datetime.timedelta(int(match.group(1)[1]))
        today = datetime.date.today()
        
        dates = self.substubs.keys()
        dates.sort(datesort)
        liststr = ""
        for date in dates:
            if not eval("today - str2date(date) %s delta" % op):
                continue
            for page in self.substubs[date]:
                if liststr != "":
                    liststr += ", "
                liststr += "[[" + page + "]]";

        if liststr == "":
            liststr = "''nincs ilyen szubcsonk''"
        return liststr


def datesort(date1, date2):
    return cmp(str2date(date1), str2date(date2))


monthIdx = date.formats['MonthName'][site.language()]
def str2date(date):
    datere = re.compile("([0-9]{4}). (" + monthptrn + ") ([0-9]{1,2}).")
    m = datere.match(date)
    if m:
        return datetime.date(int(m.group(1)), monthIdx(m.group(2)), int(m.group(3)))
    else:
        return datetime.date.today()


def main():
    readOnly = False
    for arg in sys.argv[1:]:
        arg = wikipedia.argHandler(arg, 'szubcsonk')
        if arg:
            if arg == '-ro':
                readOnly = True
            else:
                wikipedia.output(u"Nem várt argumentum: " + arg)
                sys.exit(1)
    
    tmpl = wikipedia.Page(site, u"Sablon:Szubcsonk")
    gen = pagegenerators.PreloadingGenerator(
        pagegenerators.ReferringPageGenerator(tmpl, onlyTemplateInclusion = True))

    SzubcsonkBot(gen, readOnly = readOnly).run()


if __name__ == "__main__":
    try:
        main()
        
    finally:
        wikipedia.stopme()
Static Wikipedia 2008 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2007 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2006 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu