From de686fc83f9d09024344d27934861c8486e94c0c Mon Sep 17 00:00:00 2001 From: Luke Faraone Date: Fri, 6 Dec 2013 17:33:09 -0500 Subject: [PATCH] api: Specify a default client of ZulipPython/version (imported from commit 366d0e81a67f6a993fb0e9539d51e593c7863299) --- zulip/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zulip/__init__.py b/zulip/__init__.py index 3b13c3d..24b7fdf 100644 --- a/zulip/__init__.py +++ b/zulip/__init__.py @@ -45,6 +45,9 @@ requests_json_is_function = callable(requests.Response.json) API_VERSTRING = "v1/" +def _default_client(): + return "ZulipPython/" + __version__ + def generate_option_group(parser): group = optparse.OptionGroup(parser, 'API configuration') group.add_option('--site', @@ -63,7 +66,7 @@ def generate_option_group(parser): help='Provide detailed output.') group.add_option('--client', action='store', - default="API: Python", + default=_default_client(), help=optparse.SUPPRESS_HELP) return group @@ -75,7 +78,9 @@ def init_from_options(options): class Client(object): def __init__(self, email=None, api_key=None, config_file=None, verbose=False, retry_on_errors=True, - site=None, client="API: Python"): + site=None, client=None): + if client is None: + client = _default_client() if None in (api_key, email): if config_file is None: config_file = os.path.join(os.environ["HOME"], ".zuliprc")