• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pywikibot.handle_args函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pywikibot.handle_args函数的典型用法代码示例。如果您正苦于以下问题:Python handle_args函数的具体用法?Python handle_args怎么用?Python handle_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了handle_args函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    # Generate the question text
    questions = '\n'
    questionlist = {}
    pywikibot.handle_args(*args)
    site = pywikibot.Site()

    if (site.lang not in list(templates.keys()) and
            site.lang not in list(done.keys())):
        pywikibot.output(
            '\nScript is not localised for {0}. Terminating program.'
            ''.format(site))
    else:
        for i, t in enumerate(pywikibot.translate(site.lang, templates)):
            questions += (u'%s) %s\n' % (i, t))
            questionlist[i] = t
        bot = CleaningBot(questions, questionlist)
        bot.run()
开发者ID:magul,项目名称:pywikibot-core,代码行数:26,代码来源:followlive.py


示例2: main

def main(args):

    letter = None
    force_dump = False
    bot_args = []


    for arg in args:

        print('\u05D0'.encode('utf-8'))
        #print(arg.decode('utf-8'))
        l = re.compile(r'^-letter:(.+)$').match(arg)
        print(l)
        if l:
            letter = l.group(1)
        elif arg == '--get-dump':
            force_dump = True  # download the latest dump if it doesnt exist
        else:
            bot_args.append(arg)
    print(bot_args)
    pywikibot.handle_args(bot_args)
    site = pywikibot.Site('he', 'wiktionary')

    if force_dump \
            or not os.path.exists(DUMP_FILE) \
            or file_age_by_days(DUMP_FILE) > 30:
        get_dump()

    all_wiktionary = XmlDump(DUMP_FILE).parse()

    all_wiktionary = filter(lambda page: page.ns == '0' \
                                         and not page.title.endswith('(שורש)') \
                                         and not re.compile(r'[a-zA-Z]').search(page.title) \
                                         and (not letter or page.title.startswith(letter))
                                         and not page.isredirect,
                            all_wiktionary)
    gen = (pywikibot.Page(site, p.title) for p in all_wiktionary)
    gen = pagegenerators.PreloadingGenerator(gen)

    words = []
    for page in gen:

        if not page.exists() or page.isRedirectPage():
            continue

        for lex in hewiktionary.lexeme_title_regex_grouped.findall(page.get()):
            words.append("* [[%s#%s|%s]]" % (page.title(),lex,lex))

    report_content = 'סך הכל %s ערכים\n' % str(len(words))
    report_content +=  '\n'.join(['%s' % p for p in words])
    report_content += "\n\n[[קטגוריה: ויקימילון - תחזוקה]]"

    if letter:
        report_page = pywikibot.Page(site, 'ויקימילון:תחזוקה/%s/%s' % ('רשימת_כל_המילים',letter))
    else:
        report_page = pywikibot.Page(site, 'ויקימילון:תחזוקה/%s' % ('רשימת_כל_המילים'))
    report_page.text = report_content
    report_page.save("סריקה עם בוט ")
开发者ID:eranroz,项目名称:hewiktionary_checker,代码行数:58,代码来源:list_all_lexemas.py


示例3: main

def main(*args):
    """Script entry point."""
    env = None
    if args:
        import pywikibot
        pywikibot.handle_args(args)
        env = locals()

    import code
    code.interact("""Welcome to the Pywikibot interactive shell!""", local=env)
开发者ID:donkaban,项目名称:pywiki-bot,代码行数:10,代码来源:shell.py


示例4: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    gen = None
    options = {}

    # Process global args and prepare generator args parser
    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()

    bot_class = TouchBot
    for arg in local_args:
        if arg == '-purge':
            bot_class = PurgeBot
        elif arg == '-redir':
            pywikibot.output(u'-redirect option is deprecated, '
                             'do not use it anymore.')
        elif not genFactory.handleArg(arg) and arg.startswith("-"):
            options[arg[1:].lower()] = True

    gen = genFactory.getCombinedGenerator()
    if gen:
        preloadingGen = pagegenerators.PreloadingGenerator(gen)
        bot = bot_class(generator=preloadingGen, **options)
        pywikibot.Site().login()
        bot.run()
    else:
        pywikibot.showHelp()
开发者ID:xZise,项目名称:pywikibot-core,代码行数:34,代码来源:touch.py


示例5: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    local_args = pywikibot.handle_args(args)

    start = local_args[0] if local_args else '!'

    mysite = pywikibot.Site()
    try:
        mysite.disambcategory()
    except pywikibot.Error as e:
        pywikibot.bot.suggest_help(exception=e)
        return False

    generator = pagegenerators.CategorizedPageGenerator(
        mysite.disambcategory(), start=start, content=True, namespaces=[0])

    bot = DisambiguationRedirectBot(generator=generator)
    bot.run()
开发者ID:AbdealiJK,项目名称:pywikibot-core,代码行数:25,代码来源:disambredir.py


示例6: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    all = False
    new = False
    sysop = False
    for arg in pywikibot.handle_args(args):
        if arg in ('-all', '-update'):
            all = True
        elif arg == '-new':
            new = True
        elif arg == '-sysop':
            sysop = True
    if all:
        refresh_all(sysop=sysop)
    elif new:
        refresh_new(sysop=sysop)
    else:
        site = pywikibot.Site()
        watchlist = refresh(site, sysop=sysop)
        pywikibot.output(u'{0:d} pages in the watchlist.'.format(len(watchlist)))
        for page in watchlist:
            try:
                pywikibot.stdout(page.title())
            except pywikibot.InvalidTitle:
                pywikibot.exception()
开发者ID:runt18,项目名称:pywikibot-core,代码行数:32,代码来源:watchlist.py


示例7: main

def main(*args):
    generator = None
    local_args = pywikibot.handle_args(args)
    site = pywikibot.Site()
    if str(site) != "commons:commons":
        pywikibot.warning("The script has not been tested on sites other that "
                          "commons:commons.")

    gen_factory = pagegenerators.GeneratorFactory(site)
    for local_arg in local_args:
        if gen_factory.handleArg(local_arg):
            continue
        arg, sep, value = local_arg.partition(':')
        if arg in ('-showcats',):
            options[arg[1:]] = True
        else:
            raise ValueError('Unknown argument: ' + local_arg)

    generator = gen_factory.getCombinedGenerator(gen=generator)
    if not generator:
        pywikibot.bot.suggest_help(missing_generator=True)
    else:
        pregenerator = pagegenerators.PreloadingGenerator(generator)
        for i, page in enumerate(pregenerator):
            if page.exists():
                log = handle_page(page)
                pywikibot.output('\n'.join(log))
                pywikibot.output("")
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:28,代码来源:simple_bot.py


示例8: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()
    options = {}
    for arg in local_args:
        if genFactory.handleArg(arg):
            continue
        option, sep, value = arg.partition(':')
        option = option[1:] if option.startswith('-') else None
        if option == 'summary':
            options[option] = value
        else:
            options[option] = True

    site = pywikibot.Site()

    generator = genFactory.getCombinedGenerator()
    if generator:
        generator = pagegenerators.PreloadingGenerator(generator)
        bot = IWBot(generator=generator, site=site, **options)
        bot.run()
    else:
        suggest_help(missing_generator=True)
        return False
开发者ID:PersianWikipedia,项目名称:pywikibot-core,代码行数:32,代码来源:interwikidata.py


示例9: main

def main(*args):

    # Process global args and prepare generator args parser
    local_args = pywikibot.handle_args(args)
    googlecat = False
    collectionid = False
    for arg in local_args:
        if arg.startswith('-googlecat'):
            if len(arg) == 10:
                googlecat = pywikibot.input(
                    u'Please enter the category you want to work on:')
            else:
                googlecat = arg[11:]
        elif arg.startswith('-collectionid'):
            if len(arg) == 13:
                collectionid = pywikibot.input(
                    u'Please enter the collectionid you want to work on:')
            else:
                collectionid = arg[14:]
        #else:
        #    generator_factory.handleArg(arg)

    if googlecat and collectionid:
        imageFindBot = ImageFindBot(googlecat, collectionid)
        imageFindBot.run()
    else:
        pywikibot.output(u'Usage: pwb.py add_google_images.py -googlecat:<category name> -collectionid:Q<123>')
开发者ID:multichill,项目名称:toollabs,代码行数:27,代码来源:add_google_images.py


示例10: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    # Process global args and prepare generator args parser
    local_args = pywikibot.handle_args(args)
    gen = pagegenerators.GeneratorFactory()

    options = {}
    for arg in local_args:
        if (
                arg.startswith('-pageage:') or
                arg.startswith('-lastedit:')):
            key, val = arg.split(':', 1)
            options[key[1:]] = int(val)
        elif gen.handleArg(arg):
            pass
        else:
            options[arg[1:].lower()] = True

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

    bot = NewItemRobot(generator, **options)
    bot.run()
    return True
开发者ID:metakgp,项目名称:batman,代码行数:33,代码来源:newitem.py


示例11: main

def main(*args):
    """
    Do a query and have the bot process the items
    :param args:
    :return:
    """

    # The queries for paintings without a creator, all or a specific collection
    query = u'SELECT ?item WHERE { ?item wdt:P31 wd:Q3305213 . MINUS { ?item wdt:P170 [] } }'
    querycollection = u"""SELECT ?item WHERE { ?item wdt:P31 wd:Q3305213 .
                                 ?item wdt:P195 wd:%s .
                                 MINUS { ?item wdt:P170 [] }
                           }"""

    for arg in pywikibot.handle_args(args):
        print arg
        if arg.startswith('-collectionid'):
            if len(arg) == 13:
                collectionid = pywikibot.input(
                        u'Please enter the collectionid you want to work on:')
            else:
                collectionid = arg[14:]
            query = querycollection % (collectionid,)

    repo = pywikibot.Site().data_repository()
    generator = pagegenerators.PreloadingItemGenerator(pagegenerators.WikidataSPARQLPageGenerator(query, site=repo))

    paintingBot = PaintingBot(generator, change=False)
    paintingBot.run()
开发者ID:multichill,项目名称:toollabs,代码行数:29,代码来源:painting_add_creator.py


示例12: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    options = {}
    total = None

    local_args = pywikibot.handle_args(args)

    for arg in local_args:
        arg, sep, value = arg.partition(':')
        if arg == '-total':
            total = value
        else:
            options[arg[1:]] = True

    site = pywikibot.Site()
    gen = pagegenerators.UnusedFilesGenerator(total=total, site=site)
    gen = pagegenerators.PreloadingGenerator(gen)

    bot = UnusedFilesBot(site, generator=gen, **options)
    try:
        bot.run()
    except pywikibot.Error as e:
        pywikibot.bot.suggest_help(exception=e)
        return False
    else:
        return True
开发者ID:magul,项目名称:pywikibot-core,代码行数:33,代码来源:unusedfiles.py


示例13: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    all = False
    new = False
    sysop = False
    for arg in pywikibot.handle_args(args):
        if arg in ('-all', '-update'):
            all = True
        elif arg == '-new':
            new = True
        elif arg == '-sysop':
            sysop = True
    if all:
        refresh_all(sysop=sysop)
    elif new:
        refresh_new(sysop=sysop)
    else:
        site = pywikibot.Site()
        refresh(site, sysop=sysop)

        watchlist = get(site)
        pywikibot.output(u'%i pages in the watchlist.' % len(watchlist))
        for pageName in watchlist:
            pywikibot.output(pageName, toStdout=True)
开发者ID:donkaban,项目名称:pywiki-bot,代码行数:31,代码来源:watchlist.py


示例14: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    options = {}

    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()

    for arg in local_args:
        if arg == '-always':
            options['always'] = True
        elif arg == '-titlecase':
            options['titlecase'] = True
        else:
            genFactory.handleArg(arg)

    gen = genFactory.getCombinedGenerator()
    if gen:
        preloadingGen = pagegenerators.PreloadingGenerator(gen)
        bot = CapitalizeBot(preloadingGen, **options)
        bot.run()
        return True
    else:
        pywikibot.bot.suggest_help(missing_generator=True)
        return False
开发者ID:KaiCode2,项目名称:pywikibot-core,代码行数:31,代码来源:capitalize_redirects.py


示例15: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    # Process global arguments to determine desired site
    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()

    # If dry is True, doesn't do any real changes, but only show
    # what would have been changed.
    dry = False
    targetpagesingles = u''
    targetpagedoubles = u''
    url = u''

    # Parse command line arguments
    for arg in local_args:
        if arg.startswith("-dry"):
            dry = True
        if arg.startswith("-targetpagesingles"):
            targetpagesingles = arg[len('-targetpagesingles:'):]
        if arg.startswith("-targetpagedoubles"):
            targetpagedoubles = arg[len('-targetpagedoubles:'):]
        if arg.startswith("-url"):
            url = arg[len('-url:'):]
        else:
            genFactory.handleArg(arg)

    bot = StaticBot(dry, targetpagesingles, targetpagedoubles, url)
    bot.run()
开发者ID:FO-nTTaX,项目名称:liquipedia-scripts,代码行数:35,代码来源:prizepoolbotsmashggdoubles.py


示例16: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    # This temporary string is used to read the title
    # of the page that should be unlinked.
    page_title = None
    options = {}

    for arg in pywikibot.handle_args(args):
        if arg.startswith('-namespace:'):
            if 'namespaces' not in options:
                options['namespaces'] = []
            try:
                options['namespaces'].append(int(arg[11:]))
            except ValueError:
                options['namespaces'].append(arg[11:])
        elif arg == '-always':
            options['always'] = True
        else:
            page_title = arg

    if page_title:
        page = pywikibot.Page(pywikibot.Site(), page_title)
        bot = UnlinkBot(page, **options)
        bot.run()
        return True
    else:
        pywikibot.bot.suggest_help(missing_parameters=['page title'])
        return False
开发者ID:happy5214,项目名称:pywikibot-core,代码行数:35,代码来源:unlink.py


示例17: mainloop

def mainloop():
    limit = None
    entities = sorted(const.PROPERTY_IDS.keys())

    for arg in wp.handle_args():
        if arg.startswith('-limit'):
            limit = int(arg[len('-limit:'):])
        elif arg.startswith("-entities"):
            entities = arg[len("-entities:"):].split(",")

    const.MUSICBRAINZ_CLAIM.setTarget(const.MUSICBRAINZ_WIKIDATAPAGE)
    today = datetime.datetime.today()
    date = wp.WbTime(year=today.year, month=today.month, day=today.day)
    const.RETRIEVED_CLAIM.setTarget(date)
    setup_db()

    for entitytype in entities:
        processed_table_query = create_processed_table_query(entitytype)
        create_table(processed_table_query)

    bot = Bot()

    while True:
        const.WIKIDATA.login()
        for entitytype in entities:
            entity_type_loop(bot, entitytype, limit)
        bot.update_rate_limits()
        sleep(settings.sleep_time_in_seconds)
开发者ID:mineo,项目名称:mb2wikidatabot,代码行数:28,代码来源:common.py


示例18: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    options = {}
    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()

    for arg in local_args:
        if genFactory.handleArg(arg):
            continue
        if arg.startswith('-summary:'):
            options['summary'] = arg[9:]
        elif arg.startswith('-tmp:'):
            options['tmp'] = arg[5:]
        elif arg == '-force':
            options['force'] = True
        elif arg == '-always':
            options['always'] = True

    gen = genFactory.getCombinedGenerator()
    if gen:
        bot = BadgesBot(generator=gen, **options)
        bot.run()
    else:
        pywikibot.showHelp()
开发者ID:edgarskos,项目名称:wiki,代码行数:31,代码来源:badges.py


示例19: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    options = {}

    for arg in pywikibot.handle_args(args):
        if arg == '-replacealways':
            options['replace'] = True
            options['replacealways'] = True
        elif arg == '-hash':
            options['use_hash'] = True
        elif arg == '-autonomous':
            pywikibot.warning(u"The '-autonomous' argument is DEPRECATED,"
                              u" use '-always' instead.")
            options['always'] = True
        elif arg.startswith('-'):
            if arg[1:] in ('always', 'replace', 'replaceloose', 'replaceonly'):
                options[arg[1:]] = True

    bot = NowCommonsDeleteBot(**options)
    bot.run()
开发者ID:KaiCode2,项目名称:pywikibot-core,代码行数:27,代码来源:nowcommons.py


示例20: main

def main(*args):
    """
    Process command line arguments and invoke bot.

    If args is an empty list, sys.argv is used.

    @param args: command line arguments
    @type args: list of unicode
    """
    global __simulate, __sys_argv

    unknown_args = pywikibot.handle_args(args)
    if unknown_args:
        pywikibot.bot.suggest_help(unknown_parameters=unknown_args)
        return False

    __simulate = pywikibot.config.simulate
    __sys_argv = sys.argv

    site = pywikibot.Site()
    site.login()
    chan = '#' + site.code + '.' + site.family.name

    bot_user_name = pywikibot.config.usernames[pywikibot.config.family][
        pywikibot.config.mylang]
    for key, value in bot_config.items():
        if hasattr(value, 'format'):
            bot_config[key] = value.format(username=bot_user_name)

    bot = ScriptWUIBot(site, chan, site.user() + "_WUI", "irc.wikimedia.org")
    try:
        bot.start()
    except BaseException:
        bot.t.cancel()
        raise
开发者ID:magul,项目名称:pywikibot-core,代码行数:35,代码来源:script_wui.py



注:本文中的pywikibot.handle_args函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pywikibot.input函数代码示例发布时间:2022-05-26
下一篇:
Python pywikibot.handleArgs函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap