本文整理汇总了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))
示例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()
示例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()
示例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()
示例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)
示例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()
示例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()
示例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()
示例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()
示例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()
示例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))
示例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>')
示例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()
示例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()
示例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()