trivial: Prepare for pyupgrade pre-commit hook
This change is entirely automated save for the update of some mocks from 'io.open' to '__builtins__.open'). We are keeping this change separate from addition of the actual hook so that we can ignore the commit later. Change-Id: I0a9d8736632084473b57b57b693322447d7be519 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -21,7 +21,7 @@ import simplejson as json
|
||||
from openstackclient.i18n import _
|
||||
|
||||
|
||||
class KeystoneSession(object):
|
||||
class KeystoneSession:
|
||||
"""Wrapper for the Keystone Session
|
||||
|
||||
Restore some requests.session.Session compatibility;
|
||||
@@ -40,7 +40,7 @@ class KeystoneSession(object):
|
||||
requests on this API.
|
||||
"""
|
||||
|
||||
super(KeystoneSession, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
# a requests.Session-style interface
|
||||
self.session = session
|
||||
@@ -95,7 +95,7 @@ class BaseAPI(KeystoneSession):
|
||||
requests on this API.
|
||||
"""
|
||||
|
||||
super(BaseAPI, self).__init__(session=session, endpoint=endpoint)
|
||||
super().__init__(session=session, endpoint=endpoint)
|
||||
|
||||
self.service_type = service_type
|
||||
|
||||
@@ -303,7 +303,7 @@ class BaseAPI(KeystoneSession):
|
||||
"""
|
||||
|
||||
try:
|
||||
ret = self._request('GET', "/%s/%s" % (path, value)).json()
|
||||
ret = self._request('GET', f"/{path}/{value}").json()
|
||||
except ks_exceptions.NotFound:
|
||||
kwargs = {attr: value}
|
||||
try:
|
||||
|
||||
@@ -30,7 +30,7 @@ class APIv2(api.BaseAPI):
|
||||
"""Compute v2 API"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(APIv2, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
# Overrides
|
||||
|
||||
@@ -76,7 +76,7 @@ class APIv2(api.BaseAPI):
|
||||
"""
|
||||
|
||||
try:
|
||||
ret = self._request('GET', "/%s/%s" % (path, value)).json()
|
||||
ret = self._request('GET', f"/{path}/{value}").json()
|
||||
if isinstance(ret, dict):
|
||||
# strip off the enclosing dict
|
||||
key = list(ret.keys())[0]
|
||||
@@ -136,7 +136,7 @@ class APIv2(api.BaseAPI):
|
||||
|
||||
return self._request(
|
||||
"POST",
|
||||
"/%s/%s/action" % (url, server['id']),
|
||||
"/{}/{}/action".format(url, server['id']),
|
||||
json={'addFloatingIp': body},
|
||||
)
|
||||
|
||||
@@ -180,7 +180,7 @@ class APIv2(api.BaseAPI):
|
||||
url = "/os-floating-ips"
|
||||
|
||||
if floating_ip_id is not None:
|
||||
return self.delete('/%s/%s' % (url, floating_ip_id))
|
||||
return self.delete(f'/{url}/{floating_ip_id}')
|
||||
|
||||
return None
|
||||
|
||||
@@ -248,7 +248,7 @@ class APIv2(api.BaseAPI):
|
||||
|
||||
return self._request(
|
||||
"POST",
|
||||
"/%s/%s/action" % (url, server['id']),
|
||||
"/{}/{}/action".format(url, server['id']),
|
||||
json={'removeFloatingIp': body},
|
||||
)
|
||||
|
||||
@@ -316,7 +316,7 @@ class APIv2(api.BaseAPI):
|
||||
else:
|
||||
return self._request(
|
||||
"PUT",
|
||||
"/%s/%s" % (url, host),
|
||||
f"/{url}/{host}",
|
||||
json=params,
|
||||
).json()
|
||||
|
||||
@@ -398,7 +398,7 @@ class APIv2(api.BaseAPI):
|
||||
value=network,
|
||||
)['id']
|
||||
if network is not None:
|
||||
return self.delete('/%s/%s' % (url, network))
|
||||
return self.delete(f'/{url}/{network}')
|
||||
|
||||
return None
|
||||
|
||||
@@ -487,7 +487,7 @@ class APIv2(api.BaseAPI):
|
||||
value=security_group,
|
||||
)['id']
|
||||
if security_group is not None:
|
||||
return self.delete('/%s/%s' % (url, security_group))
|
||||
return self.delete(f'/{url}/{security_group}')
|
||||
|
||||
return None
|
||||
|
||||
@@ -535,7 +535,7 @@ class APIv2(api.BaseAPI):
|
||||
|
||||
params = {}
|
||||
if search_opts is not None:
|
||||
params = dict((k, v) for (k, v) in search_opts.items() if v)
|
||||
params = {k: v for (k, v) in search_opts.items() if v}
|
||||
if limit:
|
||||
params['limit'] = limit
|
||||
if marker:
|
||||
@@ -549,7 +549,7 @@ class APIv2(api.BaseAPI):
|
||||
security_group=None,
|
||||
# name=None,
|
||||
# description=None,
|
||||
**params
|
||||
**params,
|
||||
):
|
||||
"""Update a security group
|
||||
|
||||
@@ -579,7 +579,7 @@ class APIv2(api.BaseAPI):
|
||||
security_group[k] = v
|
||||
return self._request(
|
||||
"PUT",
|
||||
"/%s/%s" % (url, security_group['id']),
|
||||
"/{}/{}".format(url, security_group['id']),
|
||||
json={'security_group': security_group},
|
||||
).json()['security_group']
|
||||
return None
|
||||
@@ -648,6 +648,6 @@ class APIv2(api.BaseAPI):
|
||||
|
||||
url = "/os-security-group-rules"
|
||||
if security_group_rule_id is not None:
|
||||
return self.delete('/%s/%s' % (url, security_group_rule_id))
|
||||
return self.delete(f'/{url}/{security_group_rule_id}')
|
||||
|
||||
return None
|
||||
|
||||
@@ -22,7 +22,7 @@ class APIv1(api.BaseAPI):
|
||||
_endpoint_suffix = '/v1'
|
||||
|
||||
def __init__(self, endpoint=None, **kwargs):
|
||||
super(APIv1, self).__init__(endpoint=endpoint, **kwargs)
|
||||
super().__init__(endpoint=endpoint, **kwargs)
|
||||
|
||||
self.endpoint = self.endpoint.rstrip('/')
|
||||
self._munge_url()
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
"""Object Store v1 API Library"""
|
||||
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
@@ -33,7 +32,7 @@ class APIv1(api.BaseAPI):
|
||||
"""Object Store v1 API"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(APIv1, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def container_create(
|
||||
self, container=None, public=False, storage_policy=None
|
||||
@@ -257,11 +256,11 @@ class APIv1(api.BaseAPI):
|
||||
# object's name in the container.
|
||||
object_name_str = name if name else object
|
||||
|
||||
full_url = "%s/%s" % (
|
||||
full_url = "{}/{}".format(
|
||||
urllib.parse.quote(container),
|
||||
urllib.parse.quote(object_name_str),
|
||||
)
|
||||
with io.open(object, 'rb') as f:
|
||||
with open(object, 'rb') as f:
|
||||
response = self.create(
|
||||
full_url,
|
||||
method='PUT',
|
||||
|
||||
Reference in New Issue
Block a user