zulip_bot_output.py: Rename options to args.
This commit is contained in:
parent
c5ab72a50a
commit
2aa6201d47
|
@ -51,9 +51,9 @@ def parse_args():
|
|||
action='store_true',
|
||||
help='Install dependencies for the bot.')
|
||||
|
||||
options = parser.parse_args()
|
||||
args = parser.parse_args()
|
||||
|
||||
if not options.name and not options.path_to_bot:
|
||||
if not args.name and not args.path_to_bot:
|
||||
error_message = """
|
||||
You must either specify the name of an existing bot or
|
||||
specify a path to the file (--path-to-bot) that contains
|
||||
|
@ -64,33 +64,33 @@ the bot handler class.
|
|||
# checks if both of these are in sync, otherwise we'll
|
||||
# have to be bias towards one and the user may get incorrect
|
||||
# result.
|
||||
elif not name_and_path_match(options.name, options.path_to_bot):
|
||||
elif not name_and_path_match(args.name, args.path_to_bot):
|
||||
error_message = """
|
||||
Please make sure that the given name of the bot and the
|
||||
given path to the bot are same and valid.
|
||||
"""
|
||||
parser.error(error_message)
|
||||
|
||||
return options
|
||||
return args
|
||||
|
||||
def main():
|
||||
# type: () -> None
|
||||
options = parse_args()
|
||||
bot_name = options.name
|
||||
if options.path_to_bot:
|
||||
if options.provision:
|
||||
bot_dir = os.path.dirname(os.path.abspath(options.path_to_bot))
|
||||
provision_bot(bot_dir, options.force)
|
||||
lib_module = import_module_from_source(options.path_to_bot, name=bot_name)
|
||||
elif options.name:
|
||||
if options.provision:
|
||||
args = parse_args()
|
||||
bot_name = args.name
|
||||
if args.path_to_bot:
|
||||
if args.provision:
|
||||
bot_dir = os.path.dirname(os.path.abspath(args.path_to_bot))
|
||||
provision_bot(bot_dir, args.force)
|
||||
lib_module = import_module_from_source(args.path_to_bot, name=bot_name)
|
||||
elif args.name:
|
||||
if args.provision:
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
bots_parent_dir = os.path.join(current_dir, "bots")
|
||||
bot_dir = os.path.join(bots_parent_dir, options.name)
|
||||
provision_bot(bot_dir, options.force)
|
||||
bot_dir = os.path.join(bots_parent_dir, args.name)
|
||||
provision_bot(bot_dir, args.force)
|
||||
lib_module = import_module('zulip_bots.bots.{bot}.{bot}'.format(bot=bot_name))
|
||||
|
||||
message = {'content': options.message, 'sender_email': 'foo_sender@zulip.com'}
|
||||
message = {'content': args.message, 'sender_email': 'foo_sender@zulip.com'}
|
||||
message_handler = lib_module.handler_class()
|
||||
|
||||
with patch('zulip_bots.lib.ExternalBotHandler') as mock_bot_handler:
|
||||
|
@ -120,7 +120,7 @@ def main():
|
|||
bot_handler=mock_bot_handler,
|
||||
state_handler=StateHandler()
|
||||
)
|
||||
print("On sending ", options.name, " bot the following message:\n\"", options.message, "\"")
|
||||
print("On sending ", args.name, " bot the following message:\n\"", args.message, "\"")
|
||||
|
||||
# send_reply and send_message have slightly arguments; the
|
||||
# following takes that into account.
|
||||
|
|
Loading…
Reference in a new issue