コード例 #1
0
    def check_old(self):
        now = self.site.getcurrenttime()
        oldestRev = None
        newArt = False
        if self.oldid:
            oldestRev = self.oldid
        else:
            for revision in self.page.getVersionHistory():
                if (now - revision[1]).days > self.maxday:
                    break
                oldestRev = revision
            else:
                createRev = oldestRev
                newArt = True

            if not newArt:
                createRev = self.page.getVersionHistory(reverseOrder=True,
                                                        total=1)[0]

            if newArt:
                article_creation_desc = msg[
                    "dykchecker-creation-new-desc"].format(self.maxday)
                article_creation_eval = self.evaluate(True)
            else:
                article_creation_desc = msg["dykchecker-creation-desc"]
                article_creation_eval = self.neutral()

            self.results.append(
                AttrObject(text=msg["dykchecker-creation"],
                           desc=msg[article_creation_desc],
                           cl=article_creation_eval,
                           value=msg['dykchecker-creation-value'].format(
                               createRev[0], createRev[1], createRev[2],
                               (now - createRev[1]).days)))

            if newArt:
                return

        result = AttrObject(text=msg["dykchecker-old-revision"],
                            desc=msg["dykchecker-old-revision-desc"].format(
                                self.ratio, self.maxday))

        if oldestRev is None:
            result.cl = self.evaluate(False)
            result.value = msg['dykchecker-old-revision-not-exist'].format(
                self.maxday)
        else:
            if self.oldid:
                text = oldestRev[3]
            else:
                text = self.page.getOldVersion(oldestRev[0], get_redirect=True)
            text = self.textEngine.remove(text)
            length = self.textEngine.length(text)[0]
            ratio = float(self.length) / float(length)
            result.cl = self.evaluate(ratio >= (self.ratio + 1))
            result.value = msg['dykchecker-old-revision-value'].format(
                oldestRev[0], oldestRev[1], (now - oldestRev[1]).days, length,
                ratio - 1.0)
        self.results.append(result)
コード例 #2
0
ファイル: model.py プロジェクト: nullzero/wpcgi
    def check_old(self):
        now = self.site.getcurrenttime()
        oldestRev = None
        newArt = False
        if self.oldid:
            oldestRev = self.oldid
        else:
            for revision in self.page.getVersionHistory():
                if (now - revision[1]).days > self.maxday:
                    break
                oldestRev = revision
            else:
                createRev = oldestRev
                newArt = True

            if not newArt:
                createRev = self.page.getVersionHistory(reverseOrder=True, total=1)[0]

            if newArt:
                article_creation_desc = msg["dykchecker-creation-new-desc"].format(self.maxday)
                article_creation_eval = self.evaluate(True)
            else:
                article_creation_desc = msg["dykchecker-creation-desc"]
                article_creation_eval = self.neutral()

            self.results.append(
                AttrObject(text=msg["dykchecker-creation"],
                           desc=msg[article_creation_desc],
                           cl=article_creation_eval,
                           value=msg['dykchecker-creation-value'].format(
                               createRev[0], createRev[1], createRev[2], (now - createRev[1]).days
                           )
                )
            )

            if newArt:
                return

        result = AttrObject(text=msg["dykchecker-old-revision"],
                            desc=msg["dykchecker-old-revision-desc"].format(self.ratio, self.maxday))

        if oldestRev is None:
            result.cl = self.evaluate(False)
            result.value = msg['dykchecker-old-revision-not-exist'].format(self.maxday)
        else:
            if self.oldid:
                text = oldestRev[3]
            else:
                text = self.page.getOldVersion(oldestRev[0], get_redirect=True)
            text = self.textEngine.remove(text)
            length = self.textEngine.length(text)[0]
            ratio = float(self.length) / float(length)
            result.cl = self.evaluate(ratio >= (self.ratio + 1))
            result.value = msg['dykchecker-old-revision-value'].format(
                oldestRev[0], oldestRev[1], (now - oldestRev[1]).days, length, ratio - 1.0
            )
        self.results.append(result)
コード例 #3
0
    def dorender(self):
        self.textEngine = TextEngine()
        self.text = self.page.get()

        self.check_info()
        self.check_ref()
        self.check_length()
        self.check_old()

        result = AttrObject(cl=self.evaluate(not self.failed),
                            text=msg['dykchecker-summary'],
                            desc='')

        if self.failed:
            result.value = msg['dykchecker-summary-fail']
        else:
            result.value = msg['dykchecker-summary-pass']

        self.results.insert(0, result)

        self.results = enumerate(self.results)
コード例 #4
0
ファイル: model.py プロジェクト: nullzero/wpcgi
    def dorender(self):
        self.textEngine = TextEngine()
        self.text = self.page.get()

        self.check_info()
        self.check_ref()
        self.check_length()
        self.check_old()

        result = AttrObject(cl=self.evaluate(not self.failed),
                            text=msg['dykchecker-summary'],
                            desc='')

        if self.failed:
            result.value = msg['dykchecker-summary-fail']
        else:
            result.value = msg['dykchecker-summary-pass']

        self.results.insert(0, result)

        self.results = enumerate(self.results)