當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。