Exemple #1
0
    def run(self, text):
        titles = [
            util.getword("seealso"),
            util.getword("srcs"),
            util.getword("refs"),
            util.getword("li"),
            util.getword("exl")
        ]

        after = 0
        before = 1
        while True:
            if after > len(titles) - 2:
                break
            if before > len(titles) - 1:
                break

            if util.titlein(titles[after], text) == False:
                after += 1
                if after == before:
                    before += 1
                continue
            elif util.titlein(titles[before], text) == False:
                before += 1
                continue
            if util.titlebefore(titles[after], titles[before], text) == False:
                self.error_count += 1
                break
            after += 1
            before += 1

        return self.error_count
Exemple #2
0
    def run(self, page):
        nono = ["{{iihfranking"]
        if page.text.count("<ref/>") == 0 and page.text.count(
                "<ref />") == 0 and page.text.count("<ref>") == 0:
            self.error_count += 1
            if util.titlein(util.getword("refs"), page.text):
                page.text = page.text.split("\n")
                for l, line in enumerate(page.text):
                    if util.titlein(util.getword("refs"), line):
                        page.text.pop(l)
                        break
                for l, line in enumerate(page.text):
                    if "{{" + util.getword(
                            "refs") in line or "{{" + util.getwordlc(
                                "refs") in line or "<references" in line:
                        page.text.pop(l)
                        break
            else:
                page.text = page.text.split("\n")
                for l, line in enumerate(page.text):
                    if util.titlein(util.getword("srcs"), line):
                        page.text.pop(l)
                        break
                for l, line in enumerate(page.text):
                    if "{{" + util.getword(
                            "refs") in line or "{{" + util.getwordlc(
                                "refs") in line or "<references" in line:
                        page.text.pop(l)
                        break
            page.text = '\n'.join(page.text)

        return self.error_count
Exemple #3
0
    def run(self, text):
        if util.titlein(util.getword("srcs"), text) and util.titlein(
                util.getword("refs"), text) and util.titleline(
                    util.getword("srcs"), text) > util.titleline(
                        util.getword("refs"), text):
            self.error_count += 1

        return self.error_count
Exemple #4
0
 def addrefs2(self, text, article):
     line = util.titleline(util.getword("refs"), text)
     text = text.split("\n")
     text[line] = text[line]+"\n{{"+util.getword("refs")+"}}"
     self.error_count = 1
     self.comment0 = self.comment01
     text = '\n'.join(text)
     return text
Exemple #5
0
    def run(self, text):
        r0 = 0
        r1 = 0
        r2 = 0
        r3 = 0
        r0 = text.count("{{" + util.getword("refs") + "}}")
        r1 = text.count("{{" + util.getwordlc("refs") + "}}")
        r2 = text.count("{{" + util.getword("refs") + "|")
        f3 = text.count("{{" + util.getwordlc("refs") + "|")

        if r0 + r1 + r2 + r3 > 1:
            self.error_count += 1

        return self.error_count
Exemple #6
0
    def run(self, page):
        brackets = re.findall(r"\[(.*?)\]", page.text)
        for item in brackets:
            if '||' in item and util.getword(
                    "img"
            ) not in item and util.getword(
                    "file"
            ) not in item and 'Image:' not in item and 'File:' not in item:
                self.error_count += 1
                olditem = '[' + item + ']]'
                item = '[' + item + ']]'
                item = item.replace('||', '|')
                logger.info('twovlines invalid link found: ' + page.title() +
                            '\n' + olditem + ' --> ' + item)
                page.text = page.text.replace(olditem, item)

        return self.error_count
Exemple #7
0
    def addrefs0(self, text, article):
        srclist = ["*", "{{IMDb-h", "#",
        util.getwordlc("bref"), util.getword("bref"),
        util.getwordlc("wref"), util.getword("wref"),
        util.getwordlc("mref"), util.getword("mref"),
        util.getwordlc("sref"), util.getword("sref"),
        util.getwordlc("nref"), util.getword("nref"),
        util.getwordlc("commons"), util.getword("commons"),
        "{{"+util.getword("refs"), "{{"+util.getwordlc("refs"),
        "<references", "{{Käännös|", "{{käännös|"]

        nono = ["[["+util.getwordc("cat"), "{{Tynkä", "{{tynkä", "{{AAKKOSTUS", "{{DEFAULTSORT", "{{OLETUSAAKKOSTUS"]

        feed = util.listend(text, util.getword("srcs"), srclist, nono)

        if util.tagwithoutend('\n'.join(text[feed[0]:feed[1]])):
            war.append_warning(self.warning01)

        if feed[0] == feed[1]:
            war.append_warning(self.warning00)

        if feed[1] != None and feed[2] == False:
            self.error_count = 1
            text = text.split("\n")
            nl00 = "\n"
            if text[feed[0]] == "":
                nl00 = ""
            text[feed[0]] = text[feed[0]]+nl00+"{{"+util.getword("refs")+"}}"
            text = '\n'.join(text)
            self.comment0 = self.comment01

        elif feed[1] != None and feed[2]:
            nl0 = "\n"
            nl1 = ""
            self.error_count = 1
            text = text.split("\n")
            if text[feed[1]] != "":
                nl0 = "\n\n"
            if text[feed[1]+1] != "":
                nl1 += "\n\n"

            text[feed[1]] = text[feed[1]]+"\n\n"+"==="+util.getword("refs")+"===\n"+"{{"+util.getword("refs")+"}}"+nl1
            text = '\n'.join(text)
            self.comment0 = self.comment00

        return text
Exemple #8
0
    def run(self, text):
        if util.titlein(util.getword("refs"), text) and "<ref" not in text:
            self.error_count += 1

        if "{{" + util.getword(
                "refs"
        ) + "|" in text and "<ref" not in text or "{{" + util.getwordlc(
                "refs") + "|" in text and "<ref" not in text:
            self.error_count += 1

        if "{{" + util.getword(
                "refs"
        ) + "}}" in text and "<ref" not in text or "{{" + util.getwordlc(
                "refs") + "}}" in text and "<ref" not in text:
            self.error_count += 1

        return self.error_count
Exemple #9
0
    def addrefs1(self, text, article):
        targetline = None

        pos = None
        nono = ["{{", util.getwordc("cat"),
        util.getwordlcc("cat"),]

        unwanted = ["{{"+util.getword("commons"), "{{"+util.getwordlc("commons"), "*", "#",
        "<ref>", "</ref>", "\n", "\t", "\b", "\a", "\r", "|}"]

        text = text.split("\n")
        firstcat = len(text)
        for l, line in enumerate(text):
            if util.getwordlcc("cat") in line or util.getwordc("cat") in line:
                firstcat = l
                pos = l
                break

        for l, line in reversed(list(enumerate(text[:firstcat]))):
            if util.anymatch(unwanted, line):
                minus = len(text)-l
                pos = len(text)-minus+1
                break

            elif util.zeromatch(nono, line) and util.zeromatch(nono, text[l-1]) and line != "":
                minus = len(text)-l
                pos = len(text)-minus+1
                break

        if pos == len(text):
            pos -= 1

        if pos != None:
            nl = ""
            if text[pos] != "":
                nl = "\n"
            text[pos] = text[pos]+nl+"\n=="+util.getword("srcs")+"==\n{{"+util.getword("refs")+"}}\n"

        text = '\n'.join(text)
        self.error_count = 1
        self.comment0 = self.comment02

        return text
Exemple #10
0
    def addrefs3(self, text, article):
        srclist = ["*", "{{IMDb-h", "#",
        util.getwordlc("bref"), util.getword("bref"),
        util.getwordlc("wref"), util.getword("wref"),
        util.getwordlc("mref"), util.getword("mref"),
        util.getwordlc("sref"), util.getword("sref"),
        util.getwordlc("nref"), util.getword("nref"),
        util.getwordlc("commons"), util.getword("commons"),
        "{{"+util.getword("refs"), "{{"+util.getwordlc("refs"),
        "<references", "{{Käännös|", "{{käännös|"]

        nono = ["[["+util.getwordc("cat"), "{{Tynkä", "{{tynkä", "{{AAKKOSTUS", "{{DEFAULTSORT", "{{OLETUSAAKKOSTUS"]

        text = text.split("\n")

        feed0 = util.listend('\n'.join(text), util.getword("refs"), srclist, nono)

        if feed0[0] == feed0[1]:
            war.append_warning(self.warning00)

        refsec = '\n'.join(text[feed0[0]:feed0[1]+1])


        for l,t in zip(range(feed0[0], feed0[1]+1), range(0, feed0[1]-feed0[0]+1)):
            text.pop(l-t)


        feed = util.listend('\n'.join(text), util.getword("srcs"), srclist, nono)

        if util.tagwithoutend('\n'.join(text[feed[0]:feed[1]])):
            war.append_warning(self.warning01)

        if feed[0] == feed[1]:
            war.append_warning(self.warning00)

        if feed[1] != None:
            nl0 = "\n"
            nl1 = "\n"
            self.error_count = 1

            text[feed[1]] = text[feed[1]]+nl0+refsec+"\n"+nl1
            text = '\n'.join(text)
            self.comment0 = self.comment03
        return text
Exemple #11
0
    def run(self, page):
        self.error_count += page.text.count("[[Category:")
        self.error_count += page.text.count("[[category:")
        #self.error_count += page.text.count("[[File:")
        #self.error_count += page.text.count("[[file:")
        #self.error_count += page.text.count("[[Image:")
        #self.error_count += page.text.count("[[image:")
        self.error_count += page.text.count("{{Reflist")
        self.error_count += page.text.count("{{reflist")
        self.error_count += page.text.count("{{Reflist|")
        self.error_count += page.text.count("{{reflist|")

        page.text = page.text.replace("[[Category:", "[["+util.getwordc("cat"))#.replace("[[File:", "[["+util.getwordc("file")).replace("[[Image:", "[["+util.getwordc("img"))
        page.text = page.text.replace("[[category:", "[["+util.getwordc("cat"))#.replace("[[file:", "[["+util.getwordc("file")).replace("[[image:", "[["+util.getwordc("img"))
        page.text = page.text.replace("{{Reflist", "{{"+util.getword("refs")).replace("{{reflist", "{{"+util.getword("refs")).replace("{{Reflist|", "{{"+util.getword("refs")+"|").replace("{{reflist|", "{{"+util.getword("refs")+"|")

        return self.error_count
Exemple #12
0
    def run(self, page):
        article = page.title

        nono = ["<references/>", "<references />", "<references>",
        "{{"+util.getword("refs"), "{{"+util.getwordlc("refs"), "{{reflist", "{{Reflist"]

        if util.titlein(util.getword("refs"), page.text) and util.titlein(util.getword("srcs"), page.text) and not util.titlebefore(util.getword("srcs"), util.getword("refs"), page.text, subtitles=False):
            page.text = self.addrefs3(page.text, article)

        if "<ref>" not in page.text and "</ref>" not in page.text:
            return self.error_count

        if util.andop(nono, page.text):
            return self.error_count

        elif util.titlein(util.getword("refs"), page.text) and util.titlein(util.getword("srcs"), page.text) and "{{"+util.getword("refs") not in page.text and "{{"+util.getwordlc("refs") not in page.text:
            page.text = self.addrefs2(page.text, article)
        elif util.titlein(util.getword("srcs"), page.text) and "{{"+util.getword("refs") not in page.text and "{{"+util.getwordlc("refs") not in page.text:
            page.text = self.addrefs0(page.text, article)

        elif util.titlein(util.getword("srcs"), page.text) == False:
            page.text = self.addrefs1(page.text, article)

        return self.error_count
Exemple #13
0
    def run(self, page):
        template = None
        if "{{commonscat|" in page.text and util.titlein(
                util.getword("exl"), page.text) and not util.insec(
                    "{{commonscat|", util.getword("exl"), page.text
                ) or "{{Commonscat|" in page.text and util.titlein(
                    util.getword("exl"), page.text) and not util.insec(
                        "{{Commonscat|", util.getword("exl"), page.text):
            page.text = page.text.split("\n")
            for l in range(0, len(page.text)):
                if "{{commonscat|" in page.text[
                        l] or "{{Commonscat|" in page.text[l]:
                    template = page.text[l]
                    page.text.pop(l)
                    break
            if template != None:
                self.error_count += 1
                page.text[util.titleline(util.getword("exl"), '\n'.join(
                    page.text))] = page.text[util.titleline(
                        util.getword("exl"), '\n'.join(
                            page.text))] + "\n" + template
            page.text = '\n'.join(page.text)

        return self.error_count
Exemple #14
0
    def run(self, page):
        if page.text.count("<ref/>") < 1 and "{{" + util.getwordlc(
                "refs") + "|sarakkeet}}" in page.text and "{{" + util.getword(
                    "refs") + "|sarakkeet}}" in page.text:
            self.error_count = 1
            page.text = page.text.replace(
                "{{" + util.getwordlc("refs") + "|sarakkeet}}",
                "{{" + util.getword("refs") + "}}")
            page.text = page.text.replace(
                "{{" + util.getword("refs") + "|sarakkeet}}",
                "{{" + util.getword("refs") + "}}")
            self.comments0 = self.comment01

        else:
            self.error_count += page.text.count("{{" + util.getwordlc("refs") +
                                                "}}")
            self.error_count += page.text.count("{{" + util.getwordlc("refs") +
                                                "|")
            page.text = page.text.replace("{{" + util.getwordlc("refs") + "}}",
                                          "{{" + util.getword("refs") + "}}")
            page.text = page.text.replace("{{" + util.getwordlc("refs") + "|",
                                          "{{" + util.getword("refs") + "|")

        return self.error_count
Exemple #15
0
    def run(self, text):
        self.wm = "osion siirto tuottaa ongelmia"
        text = text.split("\n")
        secs = self.getsec(text)

        srclist = [
            "*", "{{IMDb-h", "#",
            util.getwordlc("bref"),
            util.getword("bref"),
            util.getwordlc("wref"),
            util.getword("wref"),
            util.getwordlc("mref"),
            util.getword("mref"),
            util.getwordlc("sref"),
            util.getword("sref"),
            util.getwordlc("nref"),
            util.getword("nref"),
            util.getwordlc("commons"),
            util.getword("commons"), "{{" + util.getword("refs"),
            "{{" + util.getwordlc("refs"), "<references", "===", "{{Käännös|",
            "{{käännös|"
        ]

        nono = [
            "[[" + util.getwordc("cat"), "{{Tynkä", "{{tynkä", "{{AAKKOSTUS",
            "{{DEFAULTSORT", "{{OLETUSAAKKOSTUS"
        ]

        secsl = [
            util.getword("srcs"),
            util.getword("refs"),
            util.getword("li"),
            util.getword("exl"),
            util.getword("seealso")
        ]

        for l, sec in enumerate(secs):
            if len(sec) > 0 and sec[0].replace(
                    "=", "") in secsl and l != len(secs) - 1:
                feed = util.listend('\n'.join(text), sec[0].replace("=", ""),
                                    srclist, nono)
                if feed[1] - feed[0] + 1 != self.getlen(sec):
                    self.error_count += 1
                    self.wm = sec[0].replace("=", "") + ", " + self.wm

        return self.error_count
Exemple #16
0
    def run(self, page):
        srclist = ["*", "{{IMDb-h", "#",
        util.getwordlc("bref"), util.getword("bref"),
        util.getwordlc("wref"), util.getword("wref"),
        util.getwordlc("mref"), util.getword("mref"),
        util.getwordlc("sref"), util.getword("sref"),
        util.getwordlc("nref"), util.getword("nref"),
        util.getwordlc("commons"), util.getword("commons"),
        "{{"+util.getword("refs"), "{{"+util.getwordlc("refs"),
        "<references/>", "<references />",
        "==="+util.getword("refs")+"===", "{{Käännös|", "{{käännös|"]
        nono = ["[["+util.getwordc("cat"), "{{Tynkä", "{{tynkä", "{{AAKKOSTUS", "{{DEFAULTSORT", "{{OLETUSAAKKOSTUS"]

        if util.titlein(util.getword("srcs"), page.text) and util.titlein(util.getword("exl"), page.text) and util.titlepos(util.getword("srcs"), page.text) > util.titlepos(util.getword("exl"), page.text) or util.titlein(util.getword("srcs"), page.text) and util.titlein(util.getword("li"), page.text) and util.titlepos(util.getword("srcs"), page.text) > util.titlepos(util.getword("li"), page.text):

            feed = util.listend(page.text, util.getword("srcs"), srclist, nono)

            if feed[0] == feed[1]:
                war.append_warning(self.warning0)

            if util.tagwithoutend('\n'.join(page.text[feed[0]:feed[1]])):
                war.append_warning(self.warning1)

            page.text = page.text.split("\n")
            srcsec = page.text[feed[0]:feed[1]+1]

            page.text = util.removefromlist(srcsec, page.text)
            print(page.text)
            srcsec = '\n'.join(srcsec)
            n1 = "\n"

            if util.titlein(util.getword("li"), '\n'.join(page.text)):
                if page.text[util.titleline(util.getword("li"), '\n'.join(page.text))-1] == "":
                    n1 = ""
                page.text[util.titleline(util.getword("li"), '\n'.join(page.text))] = n1+srcsec+"\n\n"+page.text[util.titleline(util.getword("li"), '\n'.join(page.text))]
            elif util.titlein(util.getword("exl"), '\n'.join(page.text)):
                if page.text[util.titleline(util.getword("exl"), '\n'.join(page.text))-1] == "":
                    n1 = ""
                page.text[util.titleline(util.getword("exl"), '\n'.join(page.text))] = n1+srcsec+"\n\n"+page.text[util.titleline(util.getword("exl"), '\n'.join(page.text))]
            page.text = '\n'.join(page.text)
            self.error_count += 1


        return self.error_count
Exemple #17
0
    def run(self, page):
        srclist = [
            "*", "{{IMDb-h", "#",
            util.getwordlc("bref"),
            util.getword("bref"),
            util.getwordlc("wref"),
            util.getword("wref"),
            util.getwordlc("mref"),
            util.getword("mref"),
            util.getwordlc("sref"),
            util.getword("sref"),
            util.getwordlc("nref"),
            util.getword("nref"),
            util.getwordlc("commons"),
            util.getword("commons")
        ]
        nono = [
            "[[" + util.getwordc("cat"), "{{Tynkä", "{{tynkä", "{{AAKKOSTUS",
            "{{DEFAULTSORT", "{{OLETUSAAKKOSTUS"
        ]

        if util.titlein(util.getword("seealso"),
                        page.text) and "http://" in page.text and util.titlein(
                            util.getword("exl"),
                            page.text) == False or util.titlein(
                                util.getword("seealso"), page.text
                            ) and "https://" in page.text and util.titlein(
                                util.getword("exl"), page.text) == False:
            feed = util.listend(page.text, util.getword("seealso"), srclist,
                                nono)

            if feed[0] == feed[1]:
                war.append_warning(self.warning1)

            if util.tagwithoutend('\n'.join(page.text[feed[0]:feed[1]])):
                war.append_warning(self.warning2)

            page.text = page.text.split("\n")
            seealsosec = '\n'.join(page.text[feed[0]:feed[1] + 1])

            if "[[" in seealsosec and "http://" in seealsosec or "[[" in seealsosec and "https://" in seealsosec:
                war.append_warning(self.warning0)
            if "http://" in seealsosec or "https://" in seealsosec:
                page.text[feed[0]] = "==" + util.getword("exl") + "=="
                self.error_count += 1

            page.text = '\n'.join(page.text)
        return self.error_count
Exemple #18
0
    def run(self, text):
        for line in text.split("\n"):
            if util.titlein(util.getword("srcs"), line) and "===" in line:
                self.error_count += 1

        return self.error_count