当前位置: 首页>>代码示例>>Python>>正文


Python pywikibot.handle_args方法代码示例

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


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

示例1: handle_args

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def handle_args(*args):
    """
    Parse and handle command line arguments to get data from the database.

    Also supports any pywikibot arguments, these are prefixed by a single "-"
    and the full list can be gotten through "-help".
    """
    parser = argparse.ArgumentParser()
    if not wlmhelpers.on_forge():
        parser.add_argument("--host", default="localhost")
        parser.add_argument("--db", default="wlm")
        parser.add_argument("--user", default="root")
        parser.add_argument("--password", default="")

    # first parse args with pywikibot, send remaining args to local handler
    return parser.parse_args(pywikibot.handle_args(args)) 
开发者ID:Vesihiisi,项目名称:COH-tools,代码行数:18,代码来源:create_mapping_tables.py

示例2: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()

    createnew = False

    for arg in local_args:
        if arg==u'-createnew':
            createnew = True
        elif genFactory.handleArg(arg):
            continue

    gen = genFactory.getCombinedGenerator()

    if not gen:
        return
    

    paintingsBot = PaintingsBot(gen, createnew=createnew)
    paintingsBot.run() 
开发者ID:multichill,项目名称:toollabs,代码行数:22,代码来源:walters_import.py

示例3: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    csvlocation = u''
    for arg in pywikibot.handle_args(args):
        csvlocation = arg

    print csvlocation
    #metworks = {}
    metworks = metWorksOnWikidata()
    dictGen = getMETGenerator(csvlocation, metworks)

    for painting in dictGen:
        pass
        #print painting

    #artDataBot = artdatabot.ArtDataBot(dictGen, create=False)
    #artDataBot.run() 
开发者ID:multichill,项目名称:toollabs,代码行数:18,代码来源:met_xml_generator.py

示例4: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    jsonlocation = u''
    for arg in pywikibot.handle_args(args):
        jsonlocation = arg

    if not jsonlocation:
        pywikibot.output(u'Need to have the location of the fng-data-dc.json')
        return

    paintingGen = getFNGPaintingGenerator(jsonlocation)

    #for painting in paintingGen:
    #    print painting

    artDataBot = artdatabot.ArtDataBot(paintingGen, create=False)
    artDataBot.run() 
开发者ID:multichill,项目名称:toollabs,代码行数:18,代码来源:fng_import.py

示例5: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
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 all global bot args
    # returns a list of non-global args
    for arg in pywikibot.handle_args(args):
        if arg:
            if arg.startswith('-file'):
                filename = arg[6:]

    bot = CiboRobot(filename)
    bot.run(filename) 
开发者ID:nemobis,项目名称:bots,代码行数:21,代码来源:museidelcibo_uploader.py

示例6: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    options = {}
    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()
    numbers = []
    for arg in local_args:
        if genFactory.handleArg(arg):
            continue

        if arg.startswith('-'):
            arg, sep, value = arg.partition(':')
            if value != '':
                options[arg[1:]] = value if not value.isdigit() else int(value)
            else:
                options[arg[1:]] = True
        elif arg.isdigit():
            numbers.append(int(arg))

    generator = genFactory.getCombinedGenerator(preload=True)

    bot = CheckWikiBot(numbers, generator, **options)
    bot.run() 
开发者ID:matejsuchanek,项目名称:pywikibot-scripts,代码行数:24,代码来源:checkwiki.py

示例7: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    options = {}
    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()
    for arg in local_args:
        if genFactory.handleArg(arg):
            continue
        if arg.startswith('-'):
            arg, sep, value = arg.partition(':')
            if value != '':
                options[arg[1:]] = value if not value.isdigit() else int(value)
            else:
                options[arg[1:]] = True

    while not options.get('template', None):
        options['template'] = pywikibot.input(
            'Type the template you would like to work on:')

    generator = genFactory.getCombinedGenerator(preload=True)
    if not generator:
        genFactory.handleArg('-transcludes:%s' % options['template'])
        generator = genFactory.getCombinedGenerator(preload=True)

    bot = TitlesMovingBot(generator=generator, **options)
    bot.run() 
开发者ID:matejsuchanek,项目名称:pywikibot-scripts,代码行数:27,代码来源:split_names_and_titles.py

示例8: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    options = {}
    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()
    for arg in local_args:
        if genFactory.handleArg(arg):
            continue
        if arg.startswith('-'):
            arg, sep, value = arg.partition(':')
            if value != '':
                options[arg[1:]] = value if not value.isdigit() else int(value)
            else:
                options[arg[1:]] = True

    generator = genFactory.getCombinedGenerator(preload=True)
    bot = WikitextFixingBot(generator=generator, **options)
    bot.run() 
开发者ID:matejsuchanek,项目名称:pywikibot-scripts,代码行数:19,代码来源:wikitext.py

示例9: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    options = {}
    skip = []
    for arg in pywikibot.handle_args(args):
        if arg.startswith('-skip:'):
            skip.append(arg.partition(':')[2])
            continue
        if arg.startswith('-'):
            arg, sep, value = arg.partition(':')
            if value != '':
                options[arg[1:]] = value if not value.isdigit() else int(value)
            else:
                options[arg[1:]] = True

    bot = WikidataRedirectsBot(skip=skip, **options)
    bot.run() 
开发者ID:matejsuchanek,项目名称:pywikibot-scripts,代码行数:18,代码来源:cleanup_redirects.py

示例10: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    options = {}
    local_args = pywikibot.handle_args(args)
    genFactory = pagegenerators.GeneratorFactory()
    genFactory.handleArg('-ns:0')
    for arg in local_args:
        if genFactory.handleArg(arg):
            continue
        if arg.startswith('-'):
            arg, sep, value = arg.partition(':')
            if value != '':
                options[arg[1:]] = value if not value.isdigit() else int(value)
            else:
                options[arg[1:]] = True

    generator = genFactory.getCombinedGenerator(preload=True)
    bot = TypoBot(generator, **options)
    bot.run() 
开发者ID:matejsuchanek,项目名称:pywikibot-scripts,代码行数:20,代码来源:typos.py

示例11: handle_args

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def handle_args(*args):
    """
    Parse and handle command line arguments to get data from the database.

    Also supports any pywikibot arguments, these are prefixed by a single "-"
    and the full list can be gotten through "-help".
    """
    parser = argparse.ArgumentParser()
    if not wlmhelpers.on_forge():
        parser.add_argument("--host", default="localhost")
        parser.add_argument("--db", default="wlm")
        parser.add_argument("--user", default="root")
        parser.add_argument("--password", default="")
    parser.add_argument("--column", required=True)
    parser.add_argument("--table", required=True)

    # first parse args with pywikibot, send remaining args to local handler
    return parser.parse_args(pwb.handle_args(args)) 
开发者ID:Vesihiisi,项目名称:COH-tools,代码行数:20,代码来源:create_distinct_lookup_table.py

示例12: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
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,代码行数:29,代码来源:add_google_images.py

示例13: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    """
    Main function. Grab a generator and pass it to the bot to work on
    """
    create = False
    for arg in pywikibot.handle_args(args):
        if arg=='-create':
            create = True

    if create:
        pywikibot.output(u'Not implemented yet!')
        #rkdArtistsCreatorBot = RKDArtistsCreatorBot()
        #generator = rkdArtistsCreatorBot.run()
        return
    else:
        pywikibot.output(u'Going to try to expand existing artists')

        query = u"""SELECT DISTINCT ?item {
        {
            ?item wdt:P3372 ?value .
            ?item wdt:P31 wd:Q5 . # Needs to be human
            MINUS { ?item wdt:P21 [] . # No gender
                    ?item wdt:P27 [] . # No country of citizenship
                    ?item wdt:P106 [] . # No occupation
                    ?item wdt:P569 [] . # No date of birth
                   } .
        } UNION {
          ?item wdt:P3372 [] .
          ?item p:P569 ?birthclaim .
          MINUS { ?item p:P570 [] } # No date of death
          ?birthclaim ps:P569 ?birth .
          FILTER(?birth < "+1900-00-15T00:00:00Z"^^xsd:dateTime)
        }
        }"""
        repo = pywikibot.Site().data_repository()
        generator = pagegenerators.PreloadingItemGenerator(pagegenerators.WikidataSPARQLPageGenerator(query, site=repo))

    aagArtistsImporterBot = AAGArtistsImporterBot(generator)
    aagArtistsImporterBot.run() 
开发者ID:multichill,项目名称:toollabs,代码行数:41,代码来源:aagartists_importer.py

示例14: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    artworkdir = u''
    for arg in pywikibot.handle_args(args):
        artworkdir = arg

    print artworkdir
    dictGen = getTateGenerator(artworkdir)

    #for painting in dictGen:
    #    print painting

    artDataBot = artdatabot.ArtDataBot(dictGen, create=True)
    artDataBot.run() 
开发者ID:multichill,项目名称:toollabs,代码行数:15,代码来源:tate_import.py

示例15: main

# 需要导入模块: import pywikibot [as 别名]
# 或者: from pywikibot import handle_args [as 别名]
def main(*args):
    csvlocation = u''
    for arg in pywikibot.handle_args(args):
        csvlocation = arg

    print csvlocation
    dictGen = getMETGenerator(csvlocation)

    for painting in dictGen:
        print painting

    #artDataBot = artdatabot.ArtDataBot(dictGen, create=False)
    #artDataBot.run() 
开发者ID:multichill,项目名称:toollabs,代码行数:15,代码来源:met_import.py


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