From a8f60a8aa1c8cbbf0d1384131854a422705e7c78 Mon Sep 17 00:00:00 2001 From: wanghong Date: Mon, 12 Jan 2015 12:08:43 +0800 Subject: [PATCH] fix some small issues in catalog show I think there are three issues we should fix: 1. wrong indentation of 'continue' 2. currently, name is optional for service, but according to the currrent logic, if a service doesn't have name attribute we will select it anyway 3. we always loop all catalogs Change-Id: I9fce66677affa396b6a12afea76e87cab9215a58 --- openstackclient/identity/v2_0/catalog.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/openstackclient/identity/v2_0/catalog.py b/openstackclient/identity/v2_0/catalog.py index 1a96fdf60f..dfc99b47f3 100644 --- a/openstackclient/identity/v2_0/catalog.py +++ b/openstackclient/identity/v2_0/catalog.py @@ -83,17 +83,12 @@ class ShowCatalog(show.ShowOne): data = None for service in sc.get_data(): - if ( - 'name' in service and - service['name'] != parsed_args.service and - 'type' in service and - service['type'] != parsed_args.service - ): - continue - - data = service - data['endpoints'] = _format_endpoints(data['endpoints']) - if 'endpoints_links' in data: - data.pop('endpoints_links') + if (service.get('name') == parsed_args.service or + service.get('type') == parsed_args.service): + data = service + data['endpoints'] = _format_endpoints(data['endpoints']) + if 'endpoints_links' in data: + data.pop('endpoints_links') + break return zip(*sorted(six.iteritems(data)))