How to use the pywikibot.bot.suggest_help function in pywikibot

To help you get started, we’ve selected a few pywikibot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wikimedia / pywikibot / scripts / illustrate_wikidata.py View on Github external
wdproperty = 'P18'

    for arg in local_args:
        if arg.startswith('-property'):
            if len(arg) == 9:
                wdproperty = pywikibot.input(
                    'Please enter the property you want to add:')
            else:
                wdproperty = arg[10:]
        else:
            generator_factory.handleArg(arg)

    generator = generator_factory.getCombinedGenerator(preload=True)
    if not generator:
        pywikibot.bot.suggest_help(missing_generator=True)
        return False

    bot = IllustrateRobot(generator, wdproperty)
    bot.run()
    return True
github wikimedia / pywikibot / scripts / commons_link.py View on Github external
for arg in local_args:
        if arg in ('pages', 'categories'):
            options['action'] = arg
        elif arg == '-always':
            options['always'] = True
        else:
            gen_factory.handleArg(arg)

    gen = gen_factory.getCombinedGenerator(preload=True)
    if 'action' in options and gen:
        bot = CommonsLinkBot(gen, **options)
        bot.run()
        return True

    pywikibot.bot.suggest_help(missing_action='action' not in options,
                               missing_generator=not gen)
    return False
github wikimedia / pywikibot / scripts / fixing_redirects.py View on Github external
gen = ref.articles(namespaces=0, content=True)
        if not gen:
            suggest_help(
                unknown_parameters=['-featured'],
                additional_text='Option is not available for this site.')
            return False
    else:
        gen = genFactory.getCombinedGenerator()
        if gen:
            gen = mysite.preloadpages(gen)
    if gen:
        bot = FixingRedirectBot(generator=gen)
        bot.run()
        return True
    else:
        suggest_help(missing_generator=True)
        return False
github wikimedia / pywikibot / scripts / spamremove.py View on Github external
local_args = pywikibot.handle_args(args)
    gen_factory = pagegenerators.GeneratorFactory()
    for arg in local_args:
        if arg == '-always':
            options['always'] = True
        elif arg.startswith('-protocol:'):
            protocol = arg.partition(':')[2]
        elif arg.startswith('-summary:'):
            options['summary'] = arg.partition(':')[2]
        elif gen_factory.handleArg(arg):
            continue
        else:
            spam_external_url = arg

    if not spam_external_url:
        pywikibot.bot.suggest_help(missing_parameters=['spam site'])
        return False

    link_search = pagegenerators.LinksearchPageGenerator(spam_external_url,
                                                         protocol=protocol)
    generator = gen_factory.getCombinedGenerator(gen=link_search)
    generator = pagegenerators.PreloadingGenerator(generator)

    bot = SpamRemoveBot(generator, spam_external_url, **options)
    bot.run()
github wikimedia / pywikibot / scripts / image.py View on Github external
elif old_image:
            new_image = arg
        else:
            old_image = arg

    if old_image:
        site = pywikibot.Site()
        old_imagepage = pywikibot.FilePage(site, old_image)
        gen = pagegenerators.FileLinksGenerator(old_imagepage)
        preloading_gen = pagegenerators.PreloadingGenerator(gen)
        bot = ImageRobot(preloading_gen, old_image, new_image,
                         site=site, **options)
        bot.run()
        return True
    else:
        pywikibot.bot.suggest_help(missing_parameters=['old image'])
        return False
github wikimedia / pywikibot / scripts / imagecopy.py View on Github external
local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()

    for arg in local_args:
        if arg == '-always':
            always = True
        elif arg.startswith('-setcat:'):
            category = arg[len('-setcat:'):]
        elif arg == '-delete':
            delete_after_done = True
        else:
            genFactory.handleArg(arg)

    pregenerator = genFactory.getCombinedGenerator(preload=True)
    if not pregenerator:
        pywikibot.bot.suggest_help(missing_generator=True)
        return False

    load_global_archivo()

    for page in pregenerator:
        skip = False
        if page.exists() and page.namespace() == 6 \
           and not page.isRedirectPage():
            imagepage = pywikibot.FilePage(page.site, page.title())

            # First do autoskip.
            if doiskip(imagepage.get()):
                pywikibot.output('Skipping ' + page.title())
                skip = True
            else:
                # The first upload is last in the list.
github JackPotte / JackBot / src / deprecated / OOP / Middleware.py View on Github external
"""Constructor."""
        super(SandboxBot, self).__init__(**kwargs)
        if self.getOption('delay') is None:
            d = min(15, max(5, int(self.getOption('hours') * 60)))
            self.availableOptions['delay_td'] = datetime.timedelta(minutes=d)
        else:
            d = max(5, self.getOption('delay'))
            self.availableOptions['delay_td'] = datetime.timedelta(minutes=d)

        self.site = pywikibot.Site()
        if not content.get(self.site.code) and not self.getOption('text'):
            pywikibot.error(u'No content is given for pages, exiting.')
            raise RuntimeError
        if not self.generator:
            if self.site.code not in sandboxTitle:
                pywikibot.bot.suggest_help(missing_generator=True)
                raise RuntimeError
            local_sandbox_title = sandboxTitle[self.site.code]
            if not isinstance(local_sandbox_title, list):
                local_sandbox_title = [local_sandbox_title]
            self.generator = [pywikibot.Page(self.site, page_name) for
                              page_name in local_sandbox_title]
github wikimedia / pywikibot / scripts / clean_sandbox.py View on Github external
self.availableOptions['delay_td'] = datetime.timedelta(minutes=d)

        self.site = pywikibot.Site()
        self.translated_content = self.getOption('text') or i18n.translate(
            self.site, content)
        if not self.translated_content:
            pywikibot.error('No content is given for pages, exiting.')
            raise RuntimeError
        if not self.generator:
            pages = []
            for item in sandbox_titles:
                p = self.site.page_from_repository(item)
                if p is not None:
                    pages.append(p)
            if not pages:
                pywikibot.bot.suggest_help(missing_generator=True)
                raise RuntimeError
            self.generator = pages
github wikimedia / pywikibot / scripts / commonscat.py View on Github external
CommonscatBot.getCommonscatTemplate(
                site.code)
        template_page = pywikibot.Page(site, 'Template:' + primaryCommonscat)
        generator = template_page.getReferences(namespaces=14,
                                                only_template_inclusion=True)
    else:
        generator = genFactory.getCombinedGenerator()

    if generator:
        if not genFactory.nopreload:
            generator = pagegenerators.PreloadingGenerator(generator)
        bot = CommonscatBot(generator, **options)
        bot.run()
        return True
    else:
        pywikibot.bot.suggest_help(missing_generator=True)
        return False