Beispiel #1
0
    def check_page(self, pagename):
        """Check one page."""
        pywikibot.output("\nChecking %s" % pagename)
        sys.stdout.flush()
        page1 = Page(self.original, pagename)
        txt1 = page1.text

        for site in self.sites:
            if self.options.dest_namespace:
                prefix = namespaces(site)[int(self.options.dest_namespace)]
                if prefix:
                    prefix += ':'
                new_pagename = prefix + page1.titleWithoutNamespace()
                pywikibot.output("\nCross namespace, new title: %s"
                                 % new_pagename)
            else:
                new_pagename = pagename

            page2 = Page(site, new_pagename)
            if page2.exists():
                txt2 = page2.text
            else:
                txt2 = ''

            if str(site) in config.replicate_replace:
                txt_new = multiple_replace(txt1,
                                           config.replicate_replace[str(site)])
                if txt1 != txt_new:
                    pywikibot.output(
                        'NOTE: text replaced using config.sync_replace')
                    pywikibot.output('%s %s %s' % (txt1, txt_new, txt2))
                    txt1 = txt_new

            if txt1 != txt2:
                pywikibot.output("\n %s DIFFERS" % site)
                self.differences[site].append(pagename)

        if self.options.replace:
            page2.text = txt1
            page2.save(self.put_message(site))
        else:
            sys.stdout.write('.')
            sys.stdout.flush()
Beispiel #2
0
    def check_page(self, pagename):
        """Check one page."""
        pywikibot.output("\nChecking %s" % pagename)
        sys.stdout.flush()
        page1 = Page(self.original, pagename)
        txt1 = page1.text

        for site in self.sites:
            if self.options.dest_namespace:
                prefix = namespaces(site)[int(self.options.dest_namespace)]
                if prefix:
                    prefix += ':'
                new_pagename = prefix + page1.titleWithoutNamespace()
                pywikibot.output("\nCross namespace, new title: %s" %
                                 new_pagename)
            else:
                new_pagename = pagename

            page2 = Page(site, new_pagename)
            if page2.exists():
                txt2 = page2.text
            else:
                txt2 = ''

            if str(site) in config.replicate_replace:
                txt_new = multiple_replace(txt1,
                                           config.replicate_replace[str(site)])
                if txt1 != txt_new:
                    pywikibot.output(
                        'NOTE: text replaced using config.sync_replace')
                    pywikibot.output('%s %s %s' % (txt1, txt_new, txt2))
                    txt1 = txt_new

            if txt1 != txt2:
                pywikibot.output("\n %s DIFFERS" % site)
                self.differences[site].append(pagename)

        if self.options.replace:
            page2.text = txt1
            page2.save(self.put_message(site))
        else:
            sys.stdout.write('.')
            sys.stdout.flush()
Beispiel #3
0
def getPageSrcDstFromTitle(src, dst, pageTitle):
    p = Page(src, pageTitle)
    ns = p.namespace()

    # specific case for "Project pages"
    # TODO : use an option !
    if (ns.id == 4 or ns.id == 102):
        if (ns.subpages):
            subPage = pageTitle.split("/", 1)
            if (len(subPage) > 1):
                title = subPage[1]
            else:
                title = pageTitle
    else:
        title = pageTitle

    newPage = Page(dst, title)

    if (newPage.site != dst):
        newPage = Page(dst, newPage.titleWithoutNamespace(), ns.id)

    return (p, newPage, ns)