Skip to content

Commit 7d80f9e

Browse files
committed
Blacken openstack.common
Black used with the '-l 79 -S' flags. A future change will ignore this commit in git-blame history by adding a 'git-blame-ignore-revs' file. Change-Id: Ifcb3c798666d74d596b8ecb3d6d507f782de7ba5 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
1 parent 7ca4388 commit 7d80f9e

29 files changed

Lines changed: 777 additions & 566 deletions

openstackclient/common/availability_zone.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828

2929
def _xform_common_availability_zone(az, zone_info):
3030
if hasattr(az, 'zoneState'):
31-
zone_info['zone_status'] = ('available' if az.zoneState['available']
32-
else 'not available')
31+
zone_info['zone_status'] = (
32+
'available' if az.zoneState['available'] else 'not available'
33+
)
3334
if hasattr(az, 'zoneName'):
3435
zone_info['zone_name'] = az.zoneName
3536

@@ -56,7 +57,8 @@ def _xform_compute_availability_zone(az, include_extra):
5657
info['service_status'] = '%s %s %s' % (
5758
'enabled' if state['active'] else 'disabled',
5859
':-)' if state['available'] else 'XXX',
59-
state['updated_at'])
60+
state['updated_at'],
61+
)
6062
result.append(info)
6163
else:
6264
zone_info['host_name'] = ''
@@ -141,8 +143,10 @@ def _get_volume_availability_zones(self, parsed_args):
141143
except Exception as e:
142144
LOG.debug('Volume availability zone exception: %s', e)
143145
if parsed_args.volume:
144-
message = _("Availability zones list not supported by "
145-
"Block Storage API")
146+
message = _(
147+
"Availability zones list not supported by "
148+
"Block Storage API"
149+
)
146150
LOG.warning(message)
147151

148152
result = []
@@ -154,13 +158,15 @@ def _get_network_availability_zones(self, parsed_args):
154158
network_client = self.app.client_manager.network
155159
try:
156160
# Verify that the extension exists.
157-
network_client.find_extension('Availability Zone',
158-
ignore_missing=False)
161+
network_client.find_extension(
162+
'Availability Zone', ignore_missing=False
163+
)
159164
except Exception as e:
160165
LOG.debug('Network availability zone exception: ', e)
161166
if parsed_args.network:
162-
message = _("Availability zones list not supported by "
163-
"Network API")
167+
message = _(
168+
"Availability zones list not supported by " "Network API"
169+
)
164170
LOG.warning(message)
165171
return []
166172

@@ -170,17 +176,24 @@ def _get_network_availability_zones(self, parsed_args):
170176
return result
171177

172178
def take_action(self, parsed_args):
173-
174179
if parsed_args.long:
175-
columns = ('Zone Name', 'Zone Status', 'Zone Resource',
176-
'Host Name', 'Service Name', 'Service Status')
180+
columns = (
181+
'Zone Name',
182+
'Zone Status',
183+
'Zone Resource',
184+
'Host Name',
185+
'Service Name',
186+
'Service Status',
187+
)
177188
else:
178189
columns = ('Zone Name', 'Zone Status')
179190

180191
# Show everything by default.
181-
show_all = (not parsed_args.compute and
182-
not parsed_args.volume and
183-
not parsed_args.network)
192+
show_all = (
193+
not parsed_args.compute
194+
and not parsed_args.volume
195+
and not parsed_args.network
196+
)
184197

185198
result = []
186199
if parsed_args.compute or show_all:
@@ -190,7 +203,7 @@ def take_action(self, parsed_args):
190203
if parsed_args.network or show_all:
191204
result += self._get_network_availability_zones(parsed_args)
192205

193-
return (columns,
194-
(utils.get_dict_properties(
195-
s, columns
196-
) for s in result))
206+
return (
207+
columns,
208+
(utils.get_dict_properties(s, columns) for s in result),
209+
)

openstackclient/common/clientmanager.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,20 @@ def setup_auth(self):
7777
# CloudConfig.__init__() and we'll die if it was not
7878
# passed.
7979
if (
80-
self._auth_required and
81-
self._cli_options._openstack_config is not None
80+
self._auth_required
81+
and self._cli_options._openstack_config is not None
8282
):
83-
self._cli_options._openstack_config._pw_callback = \
83+
self._cli_options._openstack_config._pw_callback = (
8484
shell.prompt_for_password
85+
)
8586
try:
8687
# We might already get auth from SDK caching
8788
if not self._cli_options._auth:
88-
self._cli_options._auth = \
89+
self._cli_options._auth = (
8990
self._cli_options._openstack_config.load_auth_plugin(
9091
self._cli_options.config,
9192
)
93+
)
9294
except TypeError as e:
9395
self._fallback_load_auth_plugin(e)
9496

@@ -101,14 +103,14 @@ def _fallback_load_auth_plugin(self, e):
101103
# We know it looks ugly, but it's necessary.
102104
if self._cli_options.config['auth']['token'] == 'x':
103105
# restore original auth_type
104-
self._cli_options.config['auth_type'] = \
105-
self._original_auth_type
106+
self._cli_options.config['auth_type'] = self._original_auth_type
106107
del self._cli_options.config['auth']['token']
107108
del self._cli_options.config['auth']['endpoint']
108-
self._cli_options._auth = \
109+
self._cli_options._auth = (
109110
self._cli_options._openstack_config.load_auth_plugin(
110111
self._cli_options.config,
111112
)
113+
)
112114
else:
113115
raise e
114116

@@ -132,8 +134,10 @@ def is_volume_endpoint_enabled(self, volume_client):
132134
# name so we need to figure out which version to look
133135
# for when calling is_service_available()
134136
volume_version = volume_client.api_version.ver_major
135-
if self.is_service_available(
136-
"volumev%s" % volume_version) is not False:
137+
if (
138+
self.is_service_available("volumev%s" % volume_version)
139+
is not False
140+
):
137141
return True
138142
elif self.is_service_available('volume') is not False:
139143
return True
@@ -143,6 +147,7 @@ def is_volume_endpoint_enabled(self, volume_client):
143147

144148
# Plugin Support
145149

150+
146151
def get_plugin_modules(group):
147152
"""Find plugin entry points"""
148153
mod_list = []
@@ -165,7 +170,8 @@ def get_plugin_modules(group):
165170
module = importlib.import_module(module_name)
166171
except Exception as err:
167172
sys.stderr.write(
168-
"WARNING: Failed to import plugin %s: %s.\n" % (ep.name, err))
173+
"WARNING: Failed to import plugin %s: %s.\n" % (ep.name, err)
174+
)
169175
continue
170176

171177
mod_list.append(module)
@@ -198,6 +204,8 @@ def build_plugin_option_parser(parser):
198204
'openstack.cli.base',
199205
)
200206
# Append list of external plugin modules
201-
PLUGIN_MODULES.extend(get_plugin_modules(
202-
'openstack.cli.extension',
203-
))
207+
PLUGIN_MODULES.extend(
208+
get_plugin_modules(
209+
'openstack.cli.extension',
210+
)
211+
)

openstackclient/common/configuration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def take_action(self, parsed_args):
5353
if getattr(self.app.client_manager, "auth_plugin_name", None):
5454
auth_plg_name = self.app.client_manager.auth_plugin_name
5555
secret_opts = [
56-
o.dest for o in base.get_plugin_options(auth_plg_name)
56+
o.dest
57+
for o in base.get_plugin_options(auth_plg_name)
5758
if o.secret
5859
]
5960

openstackclient/common/extension.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ def get_parser(self, prog_name):
6565

6666
def take_action(self, parsed_args):
6767
if parsed_args.long:
68-
columns = ('Name', 'Alias', 'Description',
69-
'Namespace', 'Updated', 'Links')
68+
columns = (
69+
'Name',
70+
'Alias',
71+
'Description',
72+
'Namespace',
73+
'Updated',
74+
'Links',
75+
)
7076
else:
7177
columns = ('Name', 'Alias', 'Description')
7278

@@ -75,10 +81,12 @@ def take_action(self, parsed_args):
7581
# by default we want to show everything, unless the
7682
# user specifies one or more of the APIs to show
7783
# for now, only identity and compute are supported.
78-
show_all = (not parsed_args.identity and
79-
not parsed_args.compute and
80-
not parsed_args.volume and
81-
not parsed_args.network)
84+
show_all = (
85+
not parsed_args.identity
86+
and not parsed_args.compute
87+
and not parsed_args.volume
88+
and not parsed_args.network
89+
)
8290

8391
if parsed_args.identity or show_all:
8492
identity_client = self.app.client_manager.identity
@@ -101,24 +109,27 @@ def take_action(self, parsed_args):
101109
try:
102110
data += volume_client.list_extensions.show_all()
103111
except Exception:
104-
message = _("Extensions list not supported by "
105-
"Block Storage API")
112+
message = _(
113+
"Extensions list not supported by " "Block Storage API"
114+
)
106115
LOG.warning(message)
107116

108117
if parsed_args.network or show_all:
109118
network_client = self.app.client_manager.network
110119
try:
111120
data += network_client.extensions()
112121
except Exception:
113-
message = _("Failed to retrieve extensions list "
114-
"from Network API")
122+
message = _(
123+
"Failed to retrieve extensions list " "from Network API"
124+
)
115125
LOG.warning(message)
116126

117127
extension_tuples = (
118128
utils.get_item_properties(
119129
s,
120130
columns,
121-
) for s in data
131+
)
132+
for s in data
122133
)
123134

124135
return (columns, extension_tuples)
@@ -132,9 +143,11 @@ def get_parser(self, prog_name):
132143
parser.add_argument(
133144
'extension',
134145
metavar='<extension>',
135-
help=_('Extension to display. '
136-
'Currently, only network extensions are supported. '
137-
'(Name or Alias)'),
146+
help=_(
147+
'Extension to display. '
148+
'Currently, only network extensions are supported. '
149+
'(Name or Alias)'
150+
),
138151
)
139152
return parser
140153

openstackclient/common/limits.py

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,41 +54,49 @@ def get_parser(self, prog_name):
5454
parser.add_argument(
5555
'--project',
5656
metavar='<project>',
57-
help=_('Show limits for a specific project (name or ID)'
58-
' [only valid with --absolute]'),
57+
help=_(
58+
'Show limits for a specific project (name or ID)'
59+
' [only valid with --absolute]'
60+
),
5961
)
6062
parser.add_argument(
6163
'--domain',
6264
metavar='<domain>',
63-
help=_('Domain the project belongs to (name or ID)'
64-
' [only valid with --absolute]'),
65+
help=_(
66+
'Domain the project belongs to (name or ID)'
67+
' [only valid with --absolute]'
68+
),
6569
)
6670
return parser
6771

6872
def take_action(self, parsed_args):
69-
7073
compute_client = self.app.client_manager.compute
7174
volume_client = self.app.client_manager.volume
7275

7376
project_id = None
7477
if parsed_args.project is not None:
7578
identity_client = self.app.client_manager.identity
7679
if parsed_args.domain is not None:
77-
domain = identity_common.find_domain(identity_client,
78-
parsed_args.domain)
79-
project_id = utils.find_resource(identity_client.projects,
80-
parsed_args.project,
81-
domain_id=domain.id).id
80+
domain = identity_common.find_domain(
81+
identity_client, parsed_args.domain
82+
)
83+
project_id = utils.find_resource(
84+
identity_client.projects,
85+
parsed_args.project,
86+
domain_id=domain.id,
87+
).id
8288
else:
83-
project_id = utils.find_resource(identity_client.projects,
84-
parsed_args.project).id
89+
project_id = utils.find_resource(
90+
identity_client.projects, parsed_args.project
91+
).id
8592

8693
compute_limits = None
8794
volume_limits = None
8895

8996
if self.app.client_manager.is_compute_endpoint_enabled():
90-
compute_limits = compute_client.limits.get(parsed_args.is_reserved,
91-
tenant_id=project_id)
97+
compute_limits = compute_client.limits.get(
98+
parsed_args.is_reserved, tenant_id=project_id
99+
)
92100

93101
if self.app.client_manager.is_volume_endpoint_enabled(volume_client):
94102
volume_limits = volume_client.limits.get()
@@ -100,17 +108,33 @@ def take_action(self, parsed_args):
100108
if volume_limits:
101109
data.append(volume_limits.absolute)
102110
columns = ["Name", "Value"]
103-
return (columns, (utils.get_item_properties(s, columns)
104-
for s in itertools.chain(*data)))
111+
return (
112+
columns,
113+
(
114+
utils.get_item_properties(s, columns)
115+
for s in itertools.chain(*data)
116+
),
117+
)
105118

106119
elif parsed_args.is_rate:
107120
if compute_limits:
108121
data.append(compute_limits.rate)
109122
if volume_limits:
110123
data.append(volume_limits.rate)
111-
columns = ["Verb", "URI", "Value", "Remain", "Unit",
112-
"Next Available"]
113-
return (columns, (utils.get_item_properties(s, columns)
114-
for s in itertools.chain(*data)))
124+
columns = [
125+
"Verb",
126+
"URI",
127+
"Value",
128+
"Remain",
129+
"Unit",
130+
"Next Available",
131+
]
132+
return (
133+
columns,
134+
(
135+
utils.get_item_properties(s, columns)
136+
for s in itertools.chain(*data)
137+
),
138+
)
115139
else:
116140
return {}, {}

0 commit comments

Comments
 (0)