api: Disambiguate the names of Zulip options

(imported from commit 67525764cc2f2a26081640063e2d78852f6229ca)
This commit is contained in:
Zev Benjamin 2014-02-21 14:11:29 -05:00
parent 314f03a5bb
commit 4db2dab645
3 changed files with 14 additions and 14 deletions

View file

@ -47,7 +47,7 @@ parser.add_option_group(zulip.generate_option_group(parser))
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if not (options.user and options.calendar): if not (options.zulip_email and options.calendar):
parser.error('You must specify --user and --calendar') parser.error('You must specify --user and --calendar')
try: try:

View file

@ -126,9 +126,9 @@ except ConfigParser.NoOptionError:
user_id = options.twitter_id user_id = options.twitter_id
client = zulip.Client( client = zulip.Client(
email=options.email, email=options.zulip_email,
api_key=options.api_key, api_key=options.zulip_api_key,
site=options.site, site=options.zulip_site,
client="ZulipTwitter/" + VERSION, client="ZulipTwitter/" + VERSION,
verbose=True) verbose=True)

View file

@ -51,18 +51,18 @@ def _default_client():
def generate_option_group(parser, prefix=''): def generate_option_group(parser, prefix=''):
group = optparse.OptionGroup(parser, 'Zulip API configuration') group = optparse.OptionGroup(parser, 'Zulip API configuration')
group.add_option('--%ssite' % (prefix,), group.add_option('--%ssite' % (prefix,),
dest="site", dest="zulip_site",
help="Zulip Enterprise server URI (if using Zulip Enterprise)", help="Zulip Enterprise server URI (if using Zulip Enterprise)",
default=None) default=None)
group.add_option('--%sapi-key' % (prefix,), group.add_option('--%sapi-key' % (prefix,),
dest="api_key", dest="zulip_api_key",
action='store') action='store')
group.add_option('--%suser' % (prefix,), group.add_option('--%suser' % (prefix,),
dest='email', dest='zulip_email',
help='Email address of the calling bot or user.') help='Email address of the calling bot or user.')
group.add_option('--%sconfig-file' % (prefix,), group.add_option('--%sconfig-file' % (prefix,),
action='store', action='store',
dest="config_file", dest="zulip_config_file",
help='Location of an ini file containing the\nabove information. (default ~/.zuliprc)') help='Location of an ini file containing the\nabove information. (default ~/.zuliprc)')
group.add_option('-v', '--verbose', group.add_option('-v', '--verbose',
action='store_true', action='store_true',
@ -70,18 +70,18 @@ def generate_option_group(parser, prefix=''):
group.add_option('--%sclient' % (prefix,), group.add_option('--%sclient' % (prefix,),
action='store', action='store',
default=None, default=None,
dest="client", dest="zulip_client",
help=optparse.SUPPRESS_HELP) help=optparse.SUPPRESS_HELP)
return group return group
def init_from_options(options, client=None): def init_from_options(options, client=None):
if options.client is not None: if options.zulip_client is not None:
client = options.client client = options.zulip_client
elif client is None: elif client is None:
client = _default_client() client = _default_client()
return Client(email=options.email, api_key=options.api_key, return Client(email=options.zulip_email, api_key=options.zulip_api_key,
config_file=options.config_file, verbose=options.verbose, config_file=options.zulip_config_file, verbose=options.verbose,
site=options.site, client=client) site=options.zulip_site, client=client)
class Client(object): class Client(object):
def __init__(self, email=None, api_key=None, config_file=None, def __init__(self, email=None, api_key=None, config_file=None,