Remove use of positional decorator
The positional decorator results in poorly maintainable code in a misguided effort to emulate python3's key-word-arg only notation and functionality. This patch removes keysteonauth's dependance on the positional decorator. Change-Id: I20106345747860365cd0203ba1b33a2900e045b9
This commit is contained in:
parent
8757ad6719
commit
335a8cdf03
@ -16,8 +16,6 @@
|
||||
|
||||
import functools
|
||||
|
||||
from positional import positional
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
from keystoneauth1.access import service_catalog
|
||||
from keystoneauth1.access import service_providers
|
||||
@ -33,7 +31,6 @@ __all__ = ('AccessInfo',
|
||||
'create')
|
||||
|
||||
|
||||
@positional()
|
||||
def create(resp=None, body=None, auth_token=None):
|
||||
if resp and not body:
|
||||
body = resp.json()
|
||||
|
@ -19,7 +19,6 @@
|
||||
import abc
|
||||
import copy
|
||||
|
||||
from positional import positional
|
||||
import six
|
||||
|
||||
from keystoneauth1 import discover
|
||||
@ -133,7 +132,6 @@ class ServiceCatalog(object):
|
||||
interface = [interface]
|
||||
return [self.normalize_interface(i) for i in interface]
|
||||
|
||||
@positional()
|
||||
def get_endpoints_data(self, service_type=None, interface=None,
|
||||
region_name=None, service_name=None,
|
||||
service_id=None, endpoint_id=None):
|
||||
@ -222,7 +220,6 @@ class ServiceCatalog(object):
|
||||
|
||||
return ret
|
||||
|
||||
@positional()
|
||||
def get_endpoints(self, service_type=None, interface=None,
|
||||
region_name=None, service_name=None,
|
||||
service_id=None, endpoint_id=None):
|
||||
@ -246,7 +243,6 @@ class ServiceCatalog(object):
|
||||
endpoints[service_type] = self._denormalize_endpoints(data)
|
||||
return endpoints
|
||||
|
||||
@positional()
|
||||
def get_endpoint_data_list(self, service_type=None, interface='public',
|
||||
region_name=None, service_name=None,
|
||||
service_id=None, endpoint_id=None):
|
||||
@ -280,7 +276,6 @@ class ServiceCatalog(object):
|
||||
endpoint_id=endpoint_id)
|
||||
return [endpoint for data in endpoints.values() for endpoint in data]
|
||||
|
||||
@positional()
|
||||
def get_urls(self, service_type=None, interface='public',
|
||||
region_name=None, service_name=None,
|
||||
service_id=None, endpoint_id=None):
|
||||
@ -313,7 +308,6 @@ class ServiceCatalog(object):
|
||||
endpoint_id=endpoint_id)
|
||||
return tuple([endpoint.url for endpoint in endpoints])
|
||||
|
||||
@positional()
|
||||
def url_for(self, service_type=None, interface='public',
|
||||
region_name=None, service_name=None,
|
||||
service_id=None, endpoint_id=None):
|
||||
@ -343,7 +337,6 @@ class ServiceCatalog(object):
|
||||
service_id=service_id,
|
||||
endpoint_id=endpoint_id).url
|
||||
|
||||
@positional()
|
||||
def endpoint_data_for(self, service_type=None, interface='public',
|
||||
region_name=None, service_name=None,
|
||||
service_id=None, endpoint_id=None):
|
||||
|
@ -13,8 +13,6 @@
|
||||
import os
|
||||
import warnings
|
||||
|
||||
from positional import positional
|
||||
|
||||
from keystoneauth1 import session
|
||||
|
||||
|
||||
@ -87,7 +85,6 @@ class Adapter(object):
|
||||
client_name = None
|
||||
client_version = None
|
||||
|
||||
@positional()
|
||||
def __init__(self, session, service_type=None, service_name=None,
|
||||
interface=None, region_name=None, endpoint_override=None,
|
||||
version=None, auth=None, user_agent=None,
|
||||
|
@ -24,7 +24,6 @@ raw data specified in version discovery responses.
|
||||
import copy
|
||||
import re
|
||||
|
||||
from positional import positional
|
||||
import six
|
||||
from six.moves import urllib
|
||||
|
||||
@ -57,7 +56,6 @@ def _int_or_latest(val):
|
||||
return LATEST if val == 'latest' or val == LATEST else int(val)
|
||||
|
||||
|
||||
@positional()
|
||||
def get_version_data(session, url, authenticated=None):
|
||||
"""Retrieve raw version data from a url.
|
||||
|
||||
@ -395,7 +393,6 @@ class Discover(object):
|
||||
DEPRECATED_STATUSES = ('deprecated',)
|
||||
EXPERIMENTAL_STATUSES = ('experimental',)
|
||||
|
||||
@positional()
|
||||
def __init__(self, session, url, authenticated=None):
|
||||
self._url = url
|
||||
self._data = get_version_data(session, url,
|
||||
@ -441,7 +438,6 @@ class Discover(object):
|
||||
|
||||
return versions
|
||||
|
||||
@positional()
|
||||
def version_data(self, reverse=False, **kwargs):
|
||||
"""Get normalized version data.
|
||||
|
||||
@ -673,7 +669,6 @@ class EndpointData(object):
|
||||
possibilities.
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self,
|
||||
catalog_url=None,
|
||||
service_url=None,
|
||||
@ -739,7 +734,6 @@ class EndpointData(object):
|
||||
def url(self):
|
||||
return self.service_url or self.catalog_url
|
||||
|
||||
@positional(3)
|
||||
def get_current_versioned_data(self, session, allow=None, cache=None,
|
||||
project_id=None):
|
||||
"""Run version discovery on the current endpoint.
|
||||
@ -774,7 +768,6 @@ class EndpointData(object):
|
||||
discover_versions=True,
|
||||
min_version=min_version, max_version=max_version)
|
||||
|
||||
@positional(3)
|
||||
def get_versioned_data(self, session, allow=None, cache=None,
|
||||
allow_version_hack=True, project_id=None,
|
||||
discover_versions=True,
|
||||
@ -913,7 +906,6 @@ class EndpointData(object):
|
||||
self._saved_project_id)
|
||||
self.service_url = url
|
||||
|
||||
@positional(1)
|
||||
def _run_discovery(self, session, cache, min_version, max_version,
|
||||
project_id, allow_version_hack, discover_versions):
|
||||
tried = set()
|
||||
@ -1103,7 +1095,6 @@ class EndpointData(object):
|
||||
return _VERSION_HACKS.get_discover_hack(self.service_type, self.url)
|
||||
|
||||
|
||||
@positional()
|
||||
def get_discovery(session, url, cache=None, authenticated=False):
|
||||
"""Return the discovery object for a URL.
|
||||
|
||||
|
@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from positional import positional
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
|
||||
__all__ = ('DiscoveryList',
|
||||
@ -33,7 +31,6 @@ class DiscoveryBase(dict):
|
||||
:param DateTime updated: When the API was last updated.
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self, id, status=None, updated=None):
|
||||
super(DiscoveryBase, self).__init__()
|
||||
|
||||
@ -77,7 +74,6 @@ class DiscoveryBase(dict):
|
||||
def updated(self, value):
|
||||
self.updated_str = value.isoformat()
|
||||
|
||||
@positional()
|
||||
def add_link(self, href, rel='self', type=None):
|
||||
link = {'href': href, 'rel': rel}
|
||||
if type:
|
||||
@ -89,7 +85,6 @@ class DiscoveryBase(dict):
|
||||
def media_types(self):
|
||||
return self.setdefault('media-types', [])
|
||||
|
||||
@positional(1)
|
||||
def add_media_type(self, base, type):
|
||||
mt = {'base': base, 'type': type}
|
||||
self.media_types.append(mt)
|
||||
@ -126,7 +121,6 @@ class MicroversionDiscovery(DiscoveryBase):
|
||||
:param string max_version: The maximum supported microversion. (optional)
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self, href, id, min_version='', max_version='', **kwargs):
|
||||
super(MicroversionDiscovery, self).__init__(id, **kwargs)
|
||||
|
||||
@ -165,7 +159,6 @@ class NovaMicroversionDiscovery(DiscoveryBase):
|
||||
:param string version: The maximum microversion supported. (optional)
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self, href, id, min_version=None, version=None, **kwargs):
|
||||
super(NovaMicroversionDiscovery, self).__init__(id, **kwargs)
|
||||
|
||||
@ -210,7 +203,6 @@ class V2Discovery(DiscoveryBase):
|
||||
|
||||
_DESC_URL = 'https://developer.openstack.org/api-ref/identity/v2/'
|
||||
|
||||
@positional()
|
||||
def __init__(self, href, id=None, html=True, pdf=True, **kwargs):
|
||||
super(V2Discovery, self).__init__(id or 'v2.0', **kwargs)
|
||||
|
||||
@ -256,7 +248,6 @@ class V3Discovery(DiscoveryBase):
|
||||
:param bool xml: Add XML media-type elements to the structure.
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self, href, id=None, json=True, xml=True, **kwargs):
|
||||
super(V3Discovery, self).__init__(id or 'v3.0', **kwargs)
|
||||
|
||||
@ -307,7 +298,6 @@ class DiscoveryList(dict):
|
||||
|
||||
TEST_URL = 'http://keystone.host:5000/'
|
||||
|
||||
@positional(2)
|
||||
def __init__(self, href=None, v2=True, v3=True, v2_id=None, v3_id=None,
|
||||
v2_status=None, v2_updated=None, v2_html=True, v2_pdf=True,
|
||||
v3_status=None, v3_updated=None, v3_json=True, v3_xml=True):
|
||||
|
@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from positional import positional
|
||||
|
||||
from keystoneauth1.identity import base
|
||||
|
||||
|
||||
@ -32,7 +30,6 @@ class AccessInfoPlugin(base.BaseIdentityPlugin):
|
||||
if using the AUTH_INTERFACE with get_endpoint. (optional)
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self, auth_ref, auth_url=None):
|
||||
super(AccessInfoPlugin, self).__init__(auth_url=auth_url,
|
||||
reauthenticate=False)
|
||||
|
@ -16,7 +16,6 @@ import hashlib
|
||||
import json
|
||||
import threading
|
||||
|
||||
from positional import positional
|
||||
import six
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
@ -398,7 +397,6 @@ class BaseIdentityPlugin(plugin.BaseAuthPlugin):
|
||||
except exceptions.ServiceProviderNotFound:
|
||||
return None
|
||||
|
||||
@positional()
|
||||
def get_discovery(self, session, url, authenticated=None):
|
||||
"""Return the discovery object for a URL.
|
||||
|
||||
|
@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from positional import positional
|
||||
|
||||
from keystoneauth1 import discover
|
||||
from keystoneauth1.identity.generic import base
|
||||
from keystoneauth1.identity import v2
|
||||
@ -29,7 +27,6 @@ class Password(base.BaseGenericPlugin):
|
||||
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self, auth_url, username=None, user_id=None, password=None,
|
||||
user_domain_id=None, user_domain_name=None, **kwargs):
|
||||
super(Password, self).__init__(auth_url=auth_url, **kwargs)
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
import abc
|
||||
|
||||
from positional import positional
|
||||
import six
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
@ -35,7 +34,6 @@ class Auth(base.BaseIdentityPlugin):
|
||||
is going to expire. (optional) default True
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self, auth_url,
|
||||
trust_id=None,
|
||||
tenant_id=None,
|
||||
@ -111,7 +109,6 @@ class Password(Auth):
|
||||
:raises TypeError: if a user_id or username is not provided.
|
||||
"""
|
||||
|
||||
@positional(4)
|
||||
def __init__(self, auth_url, username=_NOT_PASSED, password=None,
|
||||
user_id=_NOT_PASSED, **kwargs):
|
||||
super(Password, self).__init__(auth_url, **kwargs)
|
||||
|
@ -13,7 +13,6 @@
|
||||
import abc
|
||||
import json
|
||||
|
||||
from positional import positional
|
||||
import six
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
@ -44,7 +43,6 @@ class BaseAuth(base.BaseIdentityPlugin):
|
||||
token. (optional) default True.
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self, auth_url,
|
||||
trust_id=None,
|
||||
domain_id=None,
|
||||
|
@ -13,7 +13,6 @@
|
||||
import abc
|
||||
import warnings
|
||||
|
||||
from positional import positional
|
||||
import six
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
@ -288,7 +287,6 @@ class OidcPassword(_OidcBase):
|
||||
|
||||
grant_type = "password"
|
||||
|
||||
@positional(4)
|
||||
def __init__(self, auth_url, identity_provider, protocol,
|
||||
client_id, client_secret,
|
||||
access_token_endpoint=None,
|
||||
@ -337,7 +335,6 @@ class OidcClientCredentials(_OidcBase):
|
||||
|
||||
grant_type = 'client_credentials'
|
||||
|
||||
@positional(4)
|
||||
def __init__(self, auth_url, identity_provider, protocol,
|
||||
client_id, client_secret,
|
||||
access_token_endpoint=None,
|
||||
@ -381,7 +378,6 @@ class OidcAuthorizationCode(_OidcBase):
|
||||
|
||||
grant_type = 'authorization_code'
|
||||
|
||||
@positional(4)
|
||||
def __init__(self, auth_url, identity_provider, protocol,
|
||||
client_id, client_secret,
|
||||
access_token_endpoint=None,
|
||||
@ -427,7 +423,6 @@ class OidcAuthorizationCode(_OidcBase):
|
||||
class OidcAccessToken(_OidcBase):
|
||||
"""Implementation for OpenID Connect access token reuse."""
|
||||
|
||||
@positional(5)
|
||||
def __init__(self, auth_url, identity_provider, protocol,
|
||||
access_token, **kwargs):
|
||||
"""The OpenID Connect plugin based on the Access Token.
|
||||
|
@ -13,8 +13,6 @@
|
||||
import argparse
|
||||
import os
|
||||
|
||||
from positional import positional
|
||||
|
||||
from keystoneauth1.loading import base
|
||||
|
||||
|
||||
@ -31,7 +29,6 @@ def _register_plugin_argparse_arguments(parser, plugin):
|
||||
dest='os_%s' % opt.dest)
|
||||
|
||||
|
||||
@positional()
|
||||
def register_argparse_arguments(parser, argv, default=None):
|
||||
"""Register CLI options needed to create a plugin.
|
||||
|
||||
|
@ -13,8 +13,6 @@
|
||||
import itertools
|
||||
import os
|
||||
|
||||
from positional import positional
|
||||
|
||||
from keystoneauth1.loading import _utils
|
||||
|
||||
|
||||
@ -62,7 +60,6 @@ class Opt(object):
|
||||
appropriate) set the string that should be used to prompt with.
|
||||
"""
|
||||
|
||||
@positional()
|
||||
def __init__(self,
|
||||
name,
|
||||
type=str,
|
||||
|
@ -13,8 +13,6 @@
|
||||
import argparse
|
||||
import os
|
||||
|
||||
from positional import positional
|
||||
|
||||
from keystoneauth1.loading import _utils
|
||||
from keystoneauth1.loading import base
|
||||
from keystoneauth1 import session
|
||||
@ -50,7 +48,6 @@ class Session(base.BaseLoader):
|
||||
def get_options(self):
|
||||
return []
|
||||
|
||||
@positional(1)
|
||||
def load_from_options(self,
|
||||
insecure=False,
|
||||
verify=None,
|
||||
|
@ -22,7 +22,6 @@ import sys
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from positional import positional
|
||||
import requests
|
||||
import six
|
||||
from six.moves import urllib
|
||||
@ -253,7 +252,6 @@ class Session(object):
|
||||
|
||||
_DEFAULT_REDIRECT_LIMIT = 30
|
||||
|
||||
@positional(2)
|
||||
def __init__(self, auth=None, session=None, original_ip=None, verify=True,
|
||||
cert=None, timeout=None, user_agent=None,
|
||||
redirect=_DEFAULT_REDIRECT_LIMIT, additional_headers=None,
|
||||
@ -326,7 +324,6 @@ class Session(object):
|
||||
return (header[0], '{SHA1}%s' % token_hash)
|
||||
return header
|
||||
|
||||
@positional()
|
||||
def _http_log_request(self, url, method=None, data=None,
|
||||
json=None, headers=None, query_params=None,
|
||||
logger=_logger):
|
||||
@ -374,7 +371,6 @@ class Session(object):
|
||||
|
||||
logger.debug(' '.join(string_parts))
|
||||
|
||||
@positional()
|
||||
def _http_log_response(self, response=None, json=None,
|
||||
status_code=None, headers=None, text=None,
|
||||
logger=_logger):
|
||||
@ -465,7 +461,6 @@ class Session(object):
|
||||
for h in header_names:
|
||||
headers.setdefault(h, microversion)
|
||||
|
||||
@positional()
|
||||
def request(self, url, method, json=None, original_ip=None,
|
||||
user_agent=None, redirect=None, authenticated=None,
|
||||
endpoint_filter=None, auth=None, requests_auth=None,
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
iso8601>=0.1.11 # MIT
|
||||
positional>=1.1.1 # Apache-2.0
|
||||
requests>=2.14.2 # Apache-2.0
|
||||
six>=1.9.0 # MIT
|
||||
stevedore>=1.20.0 # Apache-2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user