[pyKoL-users] SF.net SVN: pykol: [23] bots/icypeak.py
Brought to you by:
scelis
From: <mi...@us...> - 2007-06-03 22:20:07
|
Revision: 23 http://pykol.svn.sourceforge.net/pykol/?rev=23&view=rev Author: misza13 Date: 2007-06-03 15:20:04 -0700 (Sun, 03 Jun 2007) Log Message: ----------- Added option parser Modified Paths: -------------- bots/icypeak.py Modified: bots/icypeak.py =================================================================== --- bots/icypeak.py 2007-06-03 22:19:28 UTC (rev 22) +++ bots/icypeak.py 2007-06-03 22:20:04 UTC (rev 23) @@ -6,19 +6,18 @@ # import sys +sys.path.append('.') -sys.path.append('.') +from optparse import OptionParser + from kolsite import KoLSite from campground import Campground from adventure import AutoAdventurer -def main(): - if len(sys.argv) < 2: - print 'Please specify a config file!' - return +def main(options,args): config = {} - execfile(sys.argv[1]) + execfile(options.conf) if not config.has_key('nick') or not config.has_key('password'): print 'Nick or password not specified in config!' return @@ -27,8 +26,21 @@ Site.doLogin(config['nick'],config['password']) AutoAdv = AutoAdventurer(Site) - AutoAdv.adventure('110') + for i in range(options.num): + print 'Adventure %d of %d...' % (i+1,options.num) + AutoAdv.adventure('110') + if __name__ == '__main__': - main() + parser = OptionParser() + parser.add_option('-c', '--conf', dest='conf', + help='use FILE as configuration', metavar='FILE') + parser.add_option('-n', '--num', dest='num', type='int', default=1, + help='adventure NUM times', metavar='NUM') + options, args = parser.parse_args() + + if options.conf: + main(options,args) + else: + parser.print_help() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |