Example #1
0
    def run(self):
        """Run the bot."""
        tosend = {
            'language': self.imagePage.site.lang.encode('utf-8'),
            'image': self.imagePage.title(with_ns=False).encode('utf-8'),
            'newname': self.newname.encode('utf-8'),
            'project': self.imagePage.site.family.name.encode('utf-8'),
            'username': '',
            'commonsense': '1',
            'remove_categories': '1',
            'ignorewarnings': '1',
            'doit': 'Uitvoeren'
        }

        pywikibot.output(tosend)
        CH = pageTextPost('https://commonshelper.toolforge.org/index.php',
                          tosend)
        pywikibot.output('Got CH desc.')

        tablock = CH.split('<textarea ')[1].split('>')[0]
        CH = CH.split('<textarea ' + tablock + '>')[1].split('</textarea>')[0]
        CH = CH.replace('&times;', '×')
        CH = self.fixAuthor(CH)
        pywikibot.output(CH)

        # I want every picture to be tagged with the bottemplate so i can check
        # my contributions later.
        CH = ('\n\n{{BotMoveToCommons|%s.%s|year={{subst:CURRENTYEAR}}'
              '|month={{subst:CURRENTMONTHNAME}}|day={{subst:CURRENTDAY}}}}' %
              (self.imagePage.site.lang, self.imagePage.site.family.name) + CH)

        if self.category:
            CH = CH.replace(
                '{{subst:Unc}} <!-- Remove this line once you have '
                'added categories -->', '')
            CH += '[[Category:' + self.category + ']]'

        bot = UploadRobot(url=self.imagePage.get_file_url(),
                          description=CH,
                          use_filename=self.newname,
                          keep_filename=True,
                          verify_description=False,
                          ignore_warning=True,
                          target_site=self.image_repo)
        bot.run()

        # Should check if the image actually was uploaded
        if pywikibot.Page(self.image_repo, 'Image:' + self.newname).exists():
            # Get a fresh copy, force to get the page so we don't run into edit
            # conflicts
            imtxt = self.imagePage.get(force=True)

            # Remove the move to commons templates
            if self.imagePage.site.lang in moveToCommonsTemplate:
                for moveTemplate in moveToCommonsTemplate[
                        self.imagePage.site.lang]:
                    imtxt = re.sub(r'(?i)\{\{' + moveTemplate + r'[^\}]*\}\}',
                                   '', imtxt)

            # add {{NowCommons}}
            if self.imagePage.site.lang in nowCommonsTemplate:
                addTemplate = nowCommonsTemplate[
                    self.imagePage.site.lang] % self.newname
            else:
                addTemplate = nowCommonsTemplate['_default'] % self.newname

            commentText = i18n.twtranslate(
                self.imagePage.site, 'commons-file-now-available', {
                    'localfile': self.imagePage.title(with_ns=False),
                    'commonsfile': self.newname
                })

            pywikibot.showDiff(self.imagePage.get(), imtxt + addTemplate)
            self.imagePage.put(imtxt + addTemplate, comment=commentText)

            self.gen = pagegenerators.FileLinksGenerator(self.imagePage)
            self.preloadingGen = pagegenerators.PreloadingGenerator(self.gen)

            moveSummary = i18n.twtranslate(
                self.imagePage.site, 'commons-file-moved', {
                    'localfile': self.imagePage.title(with_ns=False),
                    'commonsfile': self.newname
                })

            # If the image is uploaded under a different name, replace all
            # instances
            if self.imagePage.title(with_ns=False) != self.newname:
                imagebot = ImageRobot(
                    generator=self.preloadingGen,
                    oldImage=self.imagePage.title(with_ns=False),
                    newImage=self.newname,
                    summary=moveSummary,
                    always=True,
                    loose=True)
                imagebot.run()

            # If the user want to delete the page and
            # the user has sysops privilege, delete the page, otherwise
            # it will be marked for deletion.
            if self.delete_after_done:
                self.imagePage.delete(moveSummary, False)
        return
Example #2
0
    def run(self):
        commons = pywikibot.Site('commons', 'commons')
        comment = i18n.twtranslate(self.site, 'imagetransfer-nowcommons_notice')

        for page in self.getPageGenerator():
            if self.getOption('use_hash'):
                # Page -> Has the namespace | commons image -> Not
                images_list = page    # 0 -> local image, 1 -> commons image
                page = pywikibot.Page(self.site, images_list[0])
            else:
                # If use_hash is true, we have already print this before, no need
                self.current_page = page
            try:
                localImagePage = pywikibot.FilePage(self.site, page.title())
                if localImagePage.fileIsShared():
                    pywikibot.output(u'File is already on Commons.')
                    continue
                sha1 = localImagePage.latest_file_info.sha1
                if self.getOption('use_hash'):
                    filenameOnCommons = images_list[1]
                else:
                    filenameOnCommons = self.findFilenameOnCommons(
                        localImagePage)
                if not filenameOnCommons and not self.getOption('use_hash'):
                    pywikibot.output(u'NowCommons template not found.')
                    continue
                commonsImagePage = pywikibot.FilePage(commons, 'Image:%s'
                                                      % filenameOnCommons)
                if (localImagePage.title(withNamespace=False) ==
                        commonsImagePage.title(withNamespace=False) and
                        self.getOption('use_hash')):
                    pywikibot.output(
                        u'The local and the commons images have the same name')
                if (localImagePage.title(withNamespace=False) !=
                        commonsImagePage.title(withNamespace=False)):
                    usingPages = list(localImagePage.usingPages())
                    if usingPages and usingPages != [localImagePage]:
                        pywikibot.output(color_format(
                            '"{lightred}{0}{default}" is still used in {1} pages.',
                            localImagePage.title(withNamespace=False),
                            len(usingPages)))
                        if self.getOption('replace') is True:
                                pywikibot.output(color_format(
                                    'Replacing "{lightred}{0}{default}" by '
                                    '"{lightgreen}{1}{default}\".',
                                    localImagePage.title(withNamespace=False),
                                    commonsImagePage.title(withNamespace=False)))
                                bot = ImageBot(
                                    pg.FileLinksGenerator(localImagePage),
                                    localImagePage.title(withNamespace=False),
                                    commonsImagePage.title(withNamespace=False),
                                    '', self.getOption('replacealways'),
                                    self.getOption('replaceloose'))
                                bot.run()
                                # If the image is used with the urlname the
                                # previous function won't work
                                is_used = bool(list(pywikibot.FilePage(
                                    self.site, page.title()).usingPages(total=1)))
                                if is_used and self.getOption('replaceloose'):
                                    bot = ImageBot(
                                        pg.FileLinksGenerator(
                                            localImagePage),
                                        localImagePage.title(
                                            withNamespace=False, asUrl=True),
                                        commonsImagePage.title(
                                            withNamespace=False),
                                        '', self.getOption('replacealways'),
                                        self.getOption('replaceloose'))
                                    bot.run()
                                # refresh because we want the updated list
                                usingPages = len(list(pywikibot.FilePage(
                                    self.site, page.title()).usingPages()))
                                if usingPages > 0 and self.getOption('use_hash'):
                                    # just an enter
                                    pywikibot.input(
                                        u'There are still %s pages with this \
                                        image, confirm the manual removal from them please.'
                                        % usingPages)

                        else:
                            pywikibot.output(u'Please change them manually.')
                        continue
                    else:
                        pywikibot.output(color_format(
                            'No page is using "{lightgreen}{0}{default}" '
                            'anymore.',
                            localImagePage.title(withNamespace=False)))
                commonsText = commonsImagePage.get()
                if self.getOption('replaceonly') is False:
                    if sha1 == commonsImagePage.latest_file_info.sha1:
                        pywikibot.output(
                            u'The image is identical to the one on Commons.')
                        if (len(localImagePage.getFileVersionHistory()) > 1 and
                                not self.getOption('use_hash')):
                            pywikibot.output(
                                u"This image has a version history. Please \
                                delete it manually after making sure that the \
                                old versions are not worth keeping.""")
                            continue
                        if self.getOption('always') is False:
                            format_str = color_format(
                                '\n\n>>>> Description on {lightpurple}%s'
                                '{default} <<<<\n')
                            pywikibot.output(format_str % page.title())
                            pywikibot.output(localImagePage.get())
                            pywikibot.output(format_str %
                                             commonsImagePage.title())
                            pywikibot.output(commonsText)
                            if pywikibot.input_yn(
                                    u'Does the description on Commons contain '
                                    'all required source and license\n'
                                    'information?',
                                    default=False, automatic_quit=False):
                                localImagePage.delete(
                                    '%s [[:commons:Image:%s]]'
                                    % (comment, filenameOnCommons), prompt=False)
                        else:
                            localImagePage.delete(
                                comment + ' [[:commons:Image:%s]]'
                                % filenameOnCommons, prompt=False)
                    else:
                        pywikibot.output(
                            u'The image is not identical to the one on Commons.')
            except (pywikibot.NoPage, pywikibot.IsRedirectPage) as e:
                pywikibot.output(u'%s' % e[0])
                continue
Example #3
0
    def run(self):
        """Run the bot."""
        commons = self.commons
        comment = self.summary

        for page in self.generator:
            self.current_page = page
            try:
                localImagePage = pywikibot.FilePage(self.site, page.title())
                if localImagePage.fileIsShared():
                    pywikibot.output(u'File is already on Commons.')
                    continue
                sha1 = localImagePage.latest_file_info.sha1
                filenameOnCommons = self.findFilenameOnCommons(localImagePage)
                if not filenameOnCommons:
                    pywikibot.output(u'NowCommons template not found.')
                    continue
                commonsImagePage = pywikibot.FilePage(
                    commons, 'Image:%s' % filenameOnCommons)
                if (localImagePage.title(withNamespace=False) !=
                        commonsImagePage.title(withNamespace=False)):
                    usingPages = list(localImagePage.usingPages())
                    if usingPages and usingPages != [localImagePage]:
                        pywikibot.output(
                            color_format(
                                '"{lightred}{0}{default}" is still used in {1} pages.',
                                localImagePage.title(withNamespace=False),
                                len(usingPages)))
                        if self.getOption('replace') is True:
                            pywikibot.output(
                                color_format(
                                    'Replacing "{lightred}{0}{default}" by '
                                    '"{lightgreen}{1}{default}\".',
                                    localImagePage.title(withNamespace=False),
                                    commonsImagePage.title(
                                        withNamespace=False)))
                            bot = ImageBot(
                                pg.FileLinksGenerator(localImagePage),
                                localImagePage.title(withNamespace=False),
                                commonsImagePage.title(withNamespace=False),
                                '', self.getOption('replacealways'),
                                self.getOption('replaceloose'))
                            bot.run()
                            # If the image is used with the urlname the
                            # previous function won't work
                            is_used = bool(
                                list(
                                    pywikibot.FilePage(
                                        self.site,
                                        page.title()).usingPages(total=1)))
                            if is_used and self.getOption('replaceloose'):
                                bot = ImageBot(
                                    pg.FileLinksGenerator(localImagePage),
                                    localImagePage.title(withNamespace=False,
                                                         asUrl=True),
                                    commonsImagePage.title(
                                        withNamespace=False), '',
                                    self.getOption('replacealways'),
                                    self.getOption('replaceloose'))
                                bot.run()
                            # refresh because we want the updated list
                            usingPages = len(
                                list(
                                    pywikibot.FilePage(
                                        self.site, page.title()).usingPages()))

                        else:
                            pywikibot.output(u'Please change them manually.')
                        continue
                    else:
                        pywikibot.output(
                            color_format(
                                'No page is using "{lightgreen}{0}{default}" '
                                'anymore.',
                                localImagePage.title(withNamespace=False)))
                commonsText = commonsImagePage.get()
                if self.getOption('replaceonly') is False:
                    if sha1 == commonsImagePage.latest_file_info.sha1:
                        pywikibot.output(
                            u'The image is identical to the one on Commons.')
                        if len(localImagePage.getFileVersionHistory()) > 1:
                            pywikibot.output(
                                'This image has a version history. Please '
                                'delete it manually after making sure that the '
                                'old versions are not worth keeping.')
                            continue
                        if self.getOption('always') is False:
                            format_str = color_format(
                                '\n\n>>>> Description on {lightpurple}%s'
                                '{default} <<<<\n')
                            pywikibot.output(format_str % page.title())
                            pywikibot.output(localImagePage.get())
                            pywikibot.output(format_str %
                                             commonsImagePage.title())
                            pywikibot.output(commonsText)
                            if pywikibot.input_yn(
                                    u'Does the description on Commons contain '
                                    'all required source and license\n'
                                    'information?',
                                    default=False,
                                    automatic_quit=False):
                                localImagePage.delete(
                                    '%s [[:commons:Image:%s]]' %
                                    (comment, filenameOnCommons),
                                    prompt=False)
                        else:
                            localImagePage.delete(
                                comment +
                                ' [[:commons:Image:%s]]' % filenameOnCommons,
                                prompt=False)
                    else:
                        pywikibot.output(
                            u'The image is not identical to the one on Commons.'
                        )
            except (pywikibot.NoPage, pywikibot.IsRedirectPage) as e:
                pywikibot.output(u'%s' % e[0])
                continue
            else:
                self._treat_counter += 1
        if not self._treat_counter:
            pywikibot.output('No transcluded files found for %s.' %
                             self.ncTemplates()[0])
        self.exit()
Example #4
0
    def run(self):
        """Run the bot."""
        commons = self.commons
        comment = self.summary

        for page in self.generator:
            self.current_page = page
            try:
                local_file_page = pywikibot.FilePage(self.site, page.title())
                if local_file_page.file_is_shared():
                    pywikibot.output('File is already on Commons.')
                    continue
                sha1 = local_file_page.latest_file_info.sha1
                file_on_commons = self.find_file_on_commons(local_file_page)
                if not file_on_commons:
                    pywikibot.output('NowCommons template not found.')
                    continue
                commons_file_page = pywikibot.FilePage(
                    commons, 'File:' + file_on_commons)
                if (local_file_page.title(with_ns=False) !=
                        commons_file_page.title(with_ns=False)):
                    using_pages = list(local_file_page.using_pages())
                    if using_pages and using_pages != [local_file_page]:
                        pywikibot.output(
                            color_format(
                                '"{lightred}{0}{default}" '
                                'is still used in {1} pages.',
                                local_file_page.title(with_ns=False),
                                len(using_pages)))
                        if self.opt.replace:
                            pywikibot.output(
                                color_format(
                                    'Replacing "{lightred}{0}{default}" by '
                                    '"{lightgreen}{1}{default}\".',
                                    local_file_page.title(with_ns=False),
                                    commons_file_page.title(with_ns=False)))
                            bot = ImageBot(
                                local_file_page.usingPages(),
                                local_file_page.title(with_ns=False),
                                commons_file_page.title(with_ns=False),
                                always=self.opt.replacealways,
                                loose=self.opt.replaceloose)
                            bot.run()
                            # If the image is used with the urlname the
                            # previous function won't work
                            is_used = bool(
                                list(
                                    pywikibot.FilePage(
                                        self.site,
                                        page.title()).using_pages(total=1)))
                            if is_used and self.opt.replaceloose:
                                bot = ImageBot(
                                    local_file_page.usimgPages(),
                                    local_file_page.title(with_ns=False,
                                                          as_url=True),
                                    commons_file_page.title(with_ns=False),
                                    always=self.opt.replacealways,
                                    loose=self.opt.replaceloose)
                                bot.run()
                            # refresh because we want the updated list
                            using_pages = len(
                                list(
                                    pywikibot.FilePage(
                                        self.site,
                                        page.title()).using_pages()))

                        else:
                            pywikibot.output('Please change them manually.')
                        continue
                    pywikibot.output(
                        color_format(
                            'No page is using "{lightgreen}{0}{default}" '
                            'anymore.', local_file_page.title(with_ns=False)))
                commons_text = commons_file_page.get()
                if not self.opt.replaceonly:
                    if sha1 == commons_file_page.latest_file_info.sha1:
                        pywikibot.output(
                            'The file is identical to the one on Commons.')
                        if len(local_file_page.get_file_history()) > 1:
                            pywikibot.output(
                                'This file has a version history. Please '
                                'delete it manually after making sure that '
                                'the old versions are not worth keeping.')
                            continue
                        if self.opt.always is False:
                            format_str = color_format(
                                '\n\n>>>> Description on {lightpurple}%s'
                                '{default} <<<<\n')
                            pywikibot.output(format_str % page.title())
                            pywikibot.output(local_file_page.get())
                            pywikibot.output(format_str %
                                             commons_file_page.title())
                            pywikibot.output(commons_text)
                            if pywikibot.input_yn(
                                    'Does the description on Commons contain '
                                    'all required source and license\n'
                                    'information?',
                                    default=False,
                                    automatic_quit=False):
                                local_file_page.delete(
                                    '{} [[:commons:File:{}]]'.format(
                                        comment, file_on_commons),
                                    prompt=False)
                        else:
                            local_file_page.delete(
                                comment + ' [[:commons:File:{}]]'.format(
                                    file_on_commons),
                                prompt=False)
                    else:
                        pywikibot.output('The file is not identical to '
                                         'the one on Commons.')
            except (NoPageError, IsRedirectPageError) as e:
                pywikibot.output(str(e[0]))
                continue
            else:
                self.counter['read'] += 1
        if not self.counter['read']:
            pywikibot.output('No transcluded files found for {}.'.format(
                self.nc_templates_list()[0]))
        self.exit()
Example #5
0
    def run(self):
        """Run the bot."""
        commons = self.commons
        comment = self.summary

        for page in self.generator:
            self.current_page = page
            try:
                localImagePage = pywikibot.FilePage(self.site, page.title())
                if localImagePage.fileIsShared():
                    pywikibot.output(u'File is already on Commons.')
                    continue
                sha1 = localImagePage.latest_file_info.sha1
                filenameOnCommons = self.findFilenameOnCommons(localImagePage)
                if not filenameOnCommons:
                    pywikibot.output(u'NowCommons template not found.')
                    continue
                commonsImagePage = pywikibot.FilePage(commons, 'Image:%s'
                                                      % filenameOnCommons)
                if (localImagePage.title(withNamespace=False) !=
                        commonsImagePage.title(withNamespace=False)):
                    usingPages = list(localImagePage.usingPages())
                    if usingPages and usingPages != [localImagePage]:
                        pywikibot.output(color_format(
                            '"{lightred}{0}{default}" is still used in {1} pages.',
                            localImagePage.title(withNamespace=False),
                            len(usingPages)))
                        if self.getOption('replace') is True:
                                pywikibot.output(color_format(
                                    'Replacing "{lightred}{0}{default}" by '
                                    '"{lightgreen}{1}{default}\".',
                                    localImagePage.title(withNamespace=False),
                                    commonsImagePage.title(withNamespace=False)))
                                bot = ImageBot(
                                    pg.FileLinksGenerator(localImagePage),
                                    localImagePage.title(withNamespace=False),
                                    commonsImagePage.title(withNamespace=False),
                                    '', self.getOption('replacealways'),
                                    self.getOption('replaceloose'))
                                bot.run()
                                # If the image is used with the urlname the
                                # previous function won't work
                                is_used = bool(list(pywikibot.FilePage(
                                    self.site, page.title()).usingPages(total=1)))
                                if is_used and self.getOption('replaceloose'):
                                    bot = ImageBot(
                                        pg.FileLinksGenerator(
                                            localImagePage),
                                        localImagePage.title(
                                            withNamespace=False, asUrl=True),
                                        commonsImagePage.title(
                                            withNamespace=False),
                                        '', self.getOption('replacealways'),
                                        self.getOption('replaceloose'))
                                    bot.run()
                                # refresh because we want the updated list
                                usingPages = len(list(pywikibot.FilePage(
                                    self.site, page.title()).usingPages()))

                        else:
                            pywikibot.output(u'Please change them manually.')
                        continue
                    else:
                        pywikibot.output(color_format(
                            'No page is using "{lightgreen}{0}{default}" '
                            'anymore.',
                            localImagePage.title(withNamespace=False)))
                commonsText = commonsImagePage.get()
                if self.getOption('replaceonly') is False:
                    if sha1 == commonsImagePage.latest_file_info.sha1:
                        pywikibot.output(
                            u'The image is identical to the one on Commons.')
                        if len(localImagePage.getFileVersionHistory()) > 1:
                            pywikibot.output(
                                'This image has a version history. Please '
                                'delete it manually after making sure that the '
                                'old versions are not worth keeping.')
                            continue
                        if self.getOption('always') is False:
                            format_str = color_format(
                                '\n\n>>>> Description on {lightpurple}%s'
                                '{default} <<<<\n')
                            pywikibot.output(format_str % page.title())
                            pywikibot.output(localImagePage.get())
                            pywikibot.output(format_str %
                                             commonsImagePage.title())
                            pywikibot.output(commonsText)
                            if pywikibot.input_yn(
                                    u'Does the description on Commons contain '
                                    'all required source and license\n'
                                    'information?',
                                    default=False, automatic_quit=False):
                                localImagePage.delete(
                                    '%s [[:commons:Image:%s]]'
                                    % (comment, filenameOnCommons), prompt=False)
                        else:
                            localImagePage.delete(
                                comment + ' [[:commons:Image:%s]]'
                                % filenameOnCommons, prompt=False)
                    else:
                        pywikibot.output(
                            u'The image is not identical to the one on Commons.')
            except (pywikibot.NoPage, pywikibot.IsRedirectPage) as e:
                pywikibot.output(u'%s' % e[0])
                continue
            else:
                self._treat_counter += 1
        if not self._treat_counter:
            pywikibot.output(
                'No transcluded files found for %s.' % self.ncTemplates()[0])
        self.exit()
Example #6
0
    def run(self):
        """Run the bot."""
        commons = pywikibot.Site('commons', 'commons')
        comment = i18n.twtranslate(self.site,
                                   'imagetransfer-nowcommons_notice')

        for page in self.getPageGenerator():
            if self.getOption('use_hash'):
                # Page -> Has the namespace | commons image -> Not
                images_list = page  # 0 -> local image, 1 -> commons image
                page = pywikibot.Page(self.site, images_list[0])
            else:
                # If use_hash is true, we have already print this before, no need
                self.current_page = page
            try:
                localImagePage = pywikibot.FilePage(self.site, page.title())
                if localImagePage.fileIsShared():
                    pywikibot.output(u'File is already on Commons.')
                    continue
                sha1 = localImagePage.latest_file_info.sha1
                if self.getOption('use_hash'):
                    filenameOnCommons = images_list[1]
                else:
                    filenameOnCommons = self.findFilenameOnCommons(
                        localImagePage)
                if not filenameOnCommons and not self.getOption('use_hash'):
                    pywikibot.output(u'NowCommons template not found.')
                    continue
                commonsImagePage = pywikibot.FilePage(
                    commons, 'Image:%s' % filenameOnCommons)
                if (localImagePage.title(withNamespace=False)
                        == commonsImagePage.title(withNamespace=False)
                        and self.getOption('use_hash')):
                    pywikibot.output(
                        u'The local and the commons images have the same name')
                if (localImagePage.title(withNamespace=False) !=
                        commonsImagePage.title(withNamespace=False)):
                    usingPages = list(localImagePage.usingPages())
                    if usingPages and usingPages != [localImagePage]:
                        pywikibot.output(
                            color_format(
                                '"{lightred}{0}{default}" is still used in {1} pages.',
                                localImagePage.title(withNamespace=False),
                                len(usingPages)))
                        if self.getOption('replace') is True:
                            pywikibot.output(
                                color_format(
                                    'Replacing "{lightred}{0}{default}" by '
                                    '"{lightgreen}{1}{default}\".',
                                    localImagePage.title(withNamespace=False),
                                    commonsImagePage.title(
                                        withNamespace=False)))
                            bot = ImageBot(
                                pg.FileLinksGenerator(localImagePage),
                                localImagePage.title(withNamespace=False),
                                commonsImagePage.title(withNamespace=False),
                                '', self.getOption('replacealways'),
                                self.getOption('replaceloose'))
                            bot.run()
                            # If the image is used with the urlname the
                            # previous function won't work
                            is_used = bool(
                                list(
                                    pywikibot.FilePage(
                                        self.site,
                                        page.title()).usingPages(total=1)))
                            if is_used and self.getOption('replaceloose'):
                                bot = ImageBot(
                                    pg.FileLinksGenerator(localImagePage),
                                    localImagePage.title(withNamespace=False,
                                                         asUrl=True),
                                    commonsImagePage.title(
                                        withNamespace=False), '',
                                    self.getOption('replacealways'),
                                    self.getOption('replaceloose'))
                                bot.run()
                            # refresh because we want the updated list
                            usingPages = len(
                                list(
                                    pywikibot.FilePage(
                                        self.site, page.title()).usingPages()))
                            if usingPages > 0 and self.getOption('use_hash'):
                                # just an enter
                                pywikibot.input(
                                    u'There are still %s pages with this \
                                        image, confirm the manual removal from them please.'
                                    % usingPages)

                        else:
                            pywikibot.output(u'Please change them manually.')
                        continue
                    else:
                        pywikibot.output(
                            color_format(
                                'No page is using "{lightgreen}{0}{default}" '
                                'anymore.',
                                localImagePage.title(withNamespace=False)))
                commonsText = commonsImagePage.get()
                if self.getOption('replaceonly') is False:
                    if sha1 == commonsImagePage.latest_file_info.sha1:
                        pywikibot.output(
                            u'The image is identical to the one on Commons.')
                        if (len(localImagePage.getFileVersionHistory()) > 1
                                and not self.getOption('use_hash')):
                            pywikibot.output(
                                u"This image has a version history. Please \
                                delete it manually after making sure that the \
                                old versions are not worth keeping."
                                "")
                            continue
                        if self.getOption('always') is False:
                            format_str = color_format(
                                '\n\n>>>> Description on {lightpurple}%s'
                                '{default} <<<<\n')
                            pywikibot.output(format_str % page.title())
                            pywikibot.output(localImagePage.get())
                            pywikibot.output(format_str %
                                             commonsImagePage.title())
                            pywikibot.output(commonsText)
                            if pywikibot.input_yn(
                                    u'Does the description on Commons contain '
                                    'all required source and license\n'
                                    'information?',
                                    default=False,
                                    automatic_quit=False):
                                localImagePage.delete(
                                    '%s [[:commons:Image:%s]]' %
                                    (comment, filenameOnCommons),
                                    prompt=False)
                        else:
                            localImagePage.delete(
                                comment +
                                ' [[:commons:Image:%s]]' % filenameOnCommons,
                                prompt=False)
                    else:
                        pywikibot.output(
                            u'The image is not identical to the one on Commons.'
                        )
            except (pywikibot.NoPage, pywikibot.IsRedirectPage) as e:
                pywikibot.output(u'%s' % e[0])
                continue