Skip to content

Commit aed521d

Browse files
committed
Blacken openstackclient.identity
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: I2eeade1ce6653be8e9179ecc40105182c5ff5f16 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
1 parent 6475dc5 commit aed521d

100 files changed

Lines changed: 4901 additions & 4011 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

openstackclient/identity/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,15 @@
4343
def make_client(instance):
4444
"""Returns an identity service client."""
4545
identity_client = utils.get_client_class(
46-
API_NAME,
47-
instance._api_version[API_NAME],
48-
API_VERSIONS)
46+
API_NAME, instance._api_version[API_NAME], API_VERSIONS
47+
)
4948
LOG.debug('Instantiating identity client: %s', identity_client)
5049

5150
# Remember interface only if interface is set
5251
kwargs = utils.build_kwargs_dict('interface', instance.interface)
5352

5453
client = identity_client(
55-
session=instance.session,
56-
region_name=instance.region_name,
57-
**kwargs
54+
session=instance.session, region_name=instance.region_name, **kwargs
5855
)
5956

6057
return client
@@ -66,8 +63,11 @@ def build_option_parser(parser):
6663
'--os-identity-api-version',
6764
metavar='<identity-api-version>',
6865
default=utils.env('OS_IDENTITY_API_VERSION'),
69-
help=_('Identity API version, default=%s '
70-
'(Env: OS_IDENTITY_API_VERSION)') % DEFAULT_API_VERSION,
66+
help=_(
67+
'Identity API version, default=%s '
68+
'(Env: OS_IDENTITY_API_VERSION)'
69+
)
70+
% DEFAULT_API_VERSION,
7171
)
7272
return parser
7373

openstackclient/identity/common.py

Lines changed: 72 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def find_service_in_list(service_list, service_id):
3333
if service.id == service_id:
3434
return service
3535
raise exceptions.CommandError(
36-
"No service with a type, name or ID of '%s' exists." % service_id)
36+
"No service with a type, name or ID of '%s' exists." % service_id
37+
)
3738

3839

3940
def find_service(identity_client, name_type_or_id):
@@ -52,8 +53,10 @@ def find_service(identity_client, name_type_or_id):
5253
except identity_exc.NotFound:
5354
pass
5455
except identity_exc.NoUniqueMatch:
55-
msg = _("Multiple service matches found for '%s', "
56-
"use an ID to be more specific.")
56+
msg = _(
57+
"Multiple service matches found for '%s', "
58+
"use an ID to be more specific."
59+
)
5760
raise exceptions.CommandError(msg % name_type_or_id)
5861

5962
try:
@@ -63,8 +66,10 @@ def find_service(identity_client, name_type_or_id):
6366
msg = _("No service with a type, name or ID of '%s' exists.")
6467
raise exceptions.CommandError(msg % name_type_or_id)
6568
except identity_exc.NoUniqueMatch:
66-
msg = _("Multiple service matches found for '%s', "
67-
"use an ID to be more specific.")
69+
msg = _(
70+
"Multiple service matches found for '%s', "
71+
"use an ID to be more specific."
72+
)
6873
raise exceptions.CommandError(msg % name_type_or_id)
6974

7075

@@ -141,42 +146,56 @@ def _get_domain_id_if_requested(identity_client, domain_name_or_id):
141146

142147

143148
def find_domain(identity_client, name_or_id):
144-
return _find_identity_resource(identity_client.domains, name_or_id,
145-
domains.Domain)
149+
return _find_identity_resource(
150+
identity_client.domains, name_or_id, domains.Domain
151+
)
146152

147153

148154
def find_group(identity_client, name_or_id, domain_name_or_id=None):
149155
domain_id = _get_domain_id_if_requested(identity_client, domain_name_or_id)
150156
if not domain_id:
151-
return _find_identity_resource(identity_client.groups, name_or_id,
152-
groups.Group)
157+
return _find_identity_resource(
158+
identity_client.groups, name_or_id, groups.Group
159+
)
153160
else:
154-
return _find_identity_resource(identity_client.groups, name_or_id,
155-
groups.Group, domain_id=domain_id)
161+
return _find_identity_resource(
162+
identity_client.groups,
163+
name_or_id,
164+
groups.Group,
165+
domain_id=domain_id,
166+
)
156167

157168

158169
def find_project(identity_client, name_or_id, domain_name_or_id=None):
159170
domain_id = _get_domain_id_if_requested(identity_client, domain_name_or_id)
160171
if not domain_id:
161-
return _find_identity_resource(identity_client.projects, name_or_id,
162-
projects.Project)
172+
return _find_identity_resource(
173+
identity_client.projects, name_or_id, projects.Project
174+
)
163175
else:
164-
return _find_identity_resource(identity_client.projects, name_or_id,
165-
projects.Project, domain_id=domain_id)
176+
return _find_identity_resource(
177+
identity_client.projects,
178+
name_or_id,
179+
projects.Project,
180+
domain_id=domain_id,
181+
)
166182

167183

168184
def find_user(identity_client, name_or_id, domain_name_or_id=None):
169185
domain_id = _get_domain_id_if_requested(identity_client, domain_name_or_id)
170186
if not domain_id:
171-
return _find_identity_resource(identity_client.users, name_or_id,
172-
users.User)
187+
return _find_identity_resource(
188+
identity_client.users, name_or_id, users.User
189+
)
173190
else:
174-
return _find_identity_resource(identity_client.users, name_or_id,
175-
users.User, domain_id=domain_id)
191+
return _find_identity_resource(
192+
identity_client.users, name_or_id, users.User, domain_id=domain_id
193+
)
176194

177195

178-
def _find_identity_resource(identity_client_manager, name_or_id,
179-
resource_type, **kwargs):
196+
def _find_identity_resource(
197+
identity_client_manager, name_or_id, resource_type, **kwargs
198+
):
180199
"""Find a specific identity resource.
181200
182201
Using keystoneclient's manager, attempt to find a specific resource by its
@@ -203,8 +222,9 @@ def _find_identity_resource(identity_client_manager, name_or_id,
203222
"""
204223

205224
try:
206-
identity_resource = utils.find_resource(identity_client_manager,
207-
name_or_id, **kwargs)
225+
identity_resource = utils.find_resource(
226+
identity_client_manager, name_or_id, **kwargs
227+
)
208228
if identity_resource is not None:
209229
return identity_resource
210230
except (exceptions.Forbidden, identity_exc.Forbidden):
@@ -226,39 +246,49 @@ def add_user_domain_option_to_parser(parser):
226246
parser.add_argument(
227247
'--user-domain',
228248
metavar='<user-domain>',
229-
help=_('Domain the user belongs to (name or ID). '
230-
'This can be used in case collisions between user names '
231-
'exist.'),
249+
help=_(
250+
'Domain the user belongs to (name or ID). '
251+
'This can be used in case collisions between user names '
252+
'exist.'
253+
),
232254
)
233255

234256

235257
def add_group_domain_option_to_parser(parser):
236258
parser.add_argument(
237259
'--group-domain',
238260
metavar='<group-domain>',
239-
help=_('Domain the group belongs to (name or ID). '
240-
'This can be used in case collisions between group names '
241-
'exist.'),
261+
help=_(
262+
'Domain the group belongs to (name or ID). '
263+
'This can be used in case collisions between group names '
264+
'exist.'
265+
),
242266
)
243267

244268

245269
def add_project_domain_option_to_parser(parser, enhance_help=lambda _h: _h):
246270
parser.add_argument(
247271
'--project-domain',
248272
metavar='<project-domain>',
249-
help=enhance_help(_('Domain the project belongs to (name or ID). This '
250-
'can be used in case collisions between project '
251-
'names exist.')),
273+
help=enhance_help(
274+
_(
275+
'Domain the project belongs to (name or ID). This '
276+
'can be used in case collisions between project '
277+
'names exist.'
278+
)
279+
),
252280
)
253281

254282

255283
def add_role_domain_option_to_parser(parser):
256284
parser.add_argument(
257285
'--role-domain',
258286
metavar='<role-domain>',
259-
help=_('Domain the role belongs to (name or ID). '
260-
'This must be specified when the name of a domain specific '
261-
'role is used.'),
287+
help=_(
288+
'Domain the role belongs to (name or ID). '
289+
'This must be specified when the name of a domain specific '
290+
'role is used.'
291+
),
262292
)
263293

264294

@@ -267,8 +297,9 @@ def add_inherited_option_to_parser(parser):
267297
'--inherited',
268298
action='store_true',
269299
default=False,
270-
help=_('Specifies if the role grant is inheritable to the sub '
271-
'projects'),
300+
help=_(
301+
'Specifies if the role grant is inheritable to the sub ' 'projects'
302+
),
272303
)
273304

274305

@@ -277,8 +308,10 @@ def add_resource_option_to_parser(parser):
277308
enable_group.add_argument(
278309
'--immutable',
279310
action='store_true',
280-
help=_('Make resource immutable. An immutable project may not '
281-
'be deleted or modified except to remove the immutable flag'),
311+
help=_(
312+
'Make resource immutable. An immutable project may not '
313+
'be deleted or modified except to remove the immutable flag'
314+
),
282315
)
283316
enable_group.add_argument(
284317
'--no-immutable',

openstackclient/identity/v2_0/catalog.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class ListCatalog(command.Lister):
4747
_description = _("List services in the service catalog")
4848

4949
def take_action(self, parsed_args):
50-
5150
# Trigger auth if it has not happened yet
5251
auth_ref = self.app.client_manager.auth_ref
5352
if not auth_ref:
@@ -57,13 +56,19 @@ def take_action(self, parsed_args):
5756

5857
data = auth_ref.service_catalog.catalog
5958
columns = ('Name', 'Type', 'Endpoints')
60-
return (columns,
61-
(utils.get_dict_properties(
62-
s, columns,
59+
return (
60+
columns,
61+
(
62+
utils.get_dict_properties(
63+
s,
64+
columns,
6365
formatters={
6466
'Endpoints': EndpointsColumn,
6567
},
66-
) for s in data))
68+
)
69+
for s in data
70+
),
71+
)
6772

6873

6974
class ShowCatalog(command.ShowOne):
@@ -79,7 +84,6 @@ def get_parser(self, prog_name):
7984
return parser
8085

8186
def take_action(self, parsed_args):
82-
8387
# Trigger auth if it has not happened yet
8488
auth_ref = self.app.client_manager.auth_ref
8589
if not auth_ref:
@@ -89,8 +93,10 @@ def take_action(self, parsed_args):
8993

9094
data = None
9195
for service in auth_ref.service_catalog.catalog:
92-
if (service.get('name') == parsed_args.service or
93-
service.get('type') == parsed_args.service):
96+
if (
97+
service.get('name') == parsed_args.service
98+
or service.get('type') == parsed_args.service
99+
):
94100
data = service.copy()
95101
data['endpoints'] = EndpointsColumn(data['endpoints'])
96102
if 'endpoints_links' in data:

openstackclient/identity/v2_0/ec2creds.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ def take_action(self, parsed_args):
7777
info.update(creds._info)
7878

7979
if 'tenant_id' in info:
80-
info.update(
81-
{'project_id': info.pop('tenant_id')}
82-
)
80+
info.update({'project_id': info.pop('tenant_id')})
8381

8482
return zip(*sorted(info.items()))
8583

@@ -120,14 +118,19 @@ def take_action(self, parsed_args):
120118
identity_client.ec2.delete(user, access_key)
121119
except Exception as e:
122120
result += 1
123-
LOG.error(_("Failed to delete EC2 credentials with "
124-
"access key '%(access_key)s': %(e)s"),
125-
{'access_key': access_key, 'e': e})
121+
LOG.error(
122+
_(
123+
"Failed to delete EC2 credentials with "
124+
"access key '%(access_key)s': %(e)s"
125+
),
126+
{'access_key': access_key, 'e': e},
127+
)
126128

127129
if result > 0:
128130
total = len(parsed_args.access_keys)
129-
msg = (_("%(result)s of %(total)s EC2 keys failed "
130-
"to delete.") % {'result': result, 'total': total})
131+
msg = _(
132+
"%(result)s of %(total)s EC2 keys failed " "to delete."
133+
) % {'result': result, 'total': total}
131134
raise exceptions.CommandError(msg)
132135

133136

@@ -159,11 +162,17 @@ def take_action(self, parsed_args):
159162
column_headers = ('Access', 'Secret', 'Project ID', 'User ID')
160163
data = identity_client.ec2.list(user)
161164

162-
return (column_headers,
163-
(utils.get_item_properties(
164-
s, columns,
165+
return (
166+
column_headers,
167+
(
168+
utils.get_item_properties(
169+
s,
170+
columns,
165171
formatters={},
166-
) for s in data))
172+
)
173+
for s in data
174+
),
175+
)
167176

168177

169178
class ShowEC2Creds(command.ShowOne):
@@ -201,8 +210,6 @@ def take_action(self, parsed_args):
201210
info.update(creds._info)
202211

203212
if 'tenant_id' in info:
204-
info.update(
205-
{'project_id': info.pop('tenant_id')}
206-
)
213+
info.update({'project_id': info.pop('tenant_id')})
207214

208215
return zip(*sorted(info.items()))

0 commit comments

Comments
 (0)