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:
Morgan Fainberg 2017-08-07 16:36:41 -07:00
parent 8757ad6719
commit 335a8cdf03
16 changed files with 0 additions and 65 deletions

View File

@ -16,8 +16,6 @@
import functools import functools
from positional import positional
from keystoneauth1 import _utils as utils from keystoneauth1 import _utils as utils
from keystoneauth1.access import service_catalog from keystoneauth1.access import service_catalog
from keystoneauth1.access import service_providers from keystoneauth1.access import service_providers
@ -33,7 +31,6 @@ __all__ = ('AccessInfo',
'create') 'create')
@positional()
def create(resp=None, body=None, auth_token=None): def create(resp=None, body=None, auth_token=None):
if resp and not body: if resp and not body:
body = resp.json() body = resp.json()

View File

@ -19,7 +19,6 @@
import abc import abc
import copy import copy
from positional import positional
import six import six
from keystoneauth1 import discover from keystoneauth1 import discover
@ -133,7 +132,6 @@ class ServiceCatalog(object):
interface = [interface] interface = [interface]
return [self.normalize_interface(i) for i in interface] return [self.normalize_interface(i) for i in interface]
@positional()
def get_endpoints_data(self, service_type=None, interface=None, def get_endpoints_data(self, service_type=None, interface=None,
region_name=None, service_name=None, region_name=None, service_name=None,
service_id=None, endpoint_id=None): service_id=None, endpoint_id=None):
@ -222,7 +220,6 @@ class ServiceCatalog(object):
return ret return ret
@positional()
def get_endpoints(self, service_type=None, interface=None, def get_endpoints(self, service_type=None, interface=None,
region_name=None, service_name=None, region_name=None, service_name=None,
service_id=None, endpoint_id=None): service_id=None, endpoint_id=None):
@ -246,7 +243,6 @@ class ServiceCatalog(object):
endpoints[service_type] = self._denormalize_endpoints(data) endpoints[service_type] = self._denormalize_endpoints(data)
return endpoints return endpoints
@positional()
def get_endpoint_data_list(self, service_type=None, interface='public', def get_endpoint_data_list(self, service_type=None, interface='public',
region_name=None, service_name=None, region_name=None, service_name=None,
service_id=None, endpoint_id=None): service_id=None, endpoint_id=None):
@ -280,7 +276,6 @@ class ServiceCatalog(object):
endpoint_id=endpoint_id) endpoint_id=endpoint_id)
return [endpoint for data in endpoints.values() for endpoint in data] return [endpoint for data in endpoints.values() for endpoint in data]
@positional()
def get_urls(self, service_type=None, interface='public', def get_urls(self, service_type=None, interface='public',
region_name=None, service_name=None, region_name=None, service_name=None,
service_id=None, endpoint_id=None): service_id=None, endpoint_id=None):
@ -313,7 +308,6 @@ class ServiceCatalog(object):
endpoint_id=endpoint_id) endpoint_id=endpoint_id)
return tuple([endpoint.url for endpoint in endpoints]) return tuple([endpoint.url for endpoint in endpoints])
@positional()
def url_for(self, service_type=None, interface='public', def url_for(self, service_type=None, interface='public',
region_name=None, service_name=None, region_name=None, service_name=None,
service_id=None, endpoint_id=None): service_id=None, endpoint_id=None):
@ -343,7 +337,6 @@ class ServiceCatalog(object):
service_id=service_id, service_id=service_id,
endpoint_id=endpoint_id).url endpoint_id=endpoint_id).url
@positional()
def endpoint_data_for(self, service_type=None, interface='public', def endpoint_data_for(self, service_type=None, interface='public',
region_name=None, service_name=None, region_name=None, service_name=None,
service_id=None, endpoint_id=None): service_id=None, endpoint_id=None):

View File

@ -13,8 +13,6 @@
import os import os
import warnings import warnings
from positional import positional
from keystoneauth1 import session from keystoneauth1 import session
@ -87,7 +85,6 @@ class Adapter(object):
client_name = None client_name = None
client_version = None client_version = None
@positional()
def __init__(self, session, service_type=None, service_name=None, def __init__(self, session, service_type=None, service_name=None,
interface=None, region_name=None, endpoint_override=None, interface=None, region_name=None, endpoint_override=None,
version=None, auth=None, user_agent=None, version=None, auth=None, user_agent=None,

View File

@ -24,7 +24,6 @@ raw data specified in version discovery responses.
import copy import copy
import re import re
from positional import positional
import six import six
from six.moves import urllib 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) return LATEST if val == 'latest' or val == LATEST else int(val)
@positional()
def get_version_data(session, url, authenticated=None): def get_version_data(session, url, authenticated=None):
"""Retrieve raw version data from a url. """Retrieve raw version data from a url.
@ -395,7 +393,6 @@ class Discover(object):
DEPRECATED_STATUSES = ('deprecated',) DEPRECATED_STATUSES = ('deprecated',)
EXPERIMENTAL_STATUSES = ('experimental',) EXPERIMENTAL_STATUSES = ('experimental',)
@positional()
def __init__(self, session, url, authenticated=None): def __init__(self, session, url, authenticated=None):
self._url = url self._url = url
self._data = get_version_data(session, url, self._data = get_version_data(session, url,
@ -441,7 +438,6 @@ class Discover(object):
return versions return versions
@positional()
def version_data(self, reverse=False, **kwargs): def version_data(self, reverse=False, **kwargs):
"""Get normalized version data. """Get normalized version data.
@ -673,7 +669,6 @@ class EndpointData(object):
possibilities. possibilities.
""" """
@positional()
def __init__(self, def __init__(self,
catalog_url=None, catalog_url=None,
service_url=None, service_url=None,
@ -739,7 +734,6 @@ class EndpointData(object):
def url(self): def url(self):
return self.service_url or self.catalog_url return self.service_url or self.catalog_url
@positional(3)
def get_current_versioned_data(self, session, allow=None, cache=None, def get_current_versioned_data(self, session, allow=None, cache=None,
project_id=None): project_id=None):
"""Run version discovery on the current endpoint. """Run version discovery on the current endpoint.
@ -774,7 +768,6 @@ class EndpointData(object):
discover_versions=True, discover_versions=True,
min_version=min_version, max_version=max_version) min_version=min_version, max_version=max_version)
@positional(3)
def get_versioned_data(self, session, allow=None, cache=None, def get_versioned_data(self, session, allow=None, cache=None,
allow_version_hack=True, project_id=None, allow_version_hack=True, project_id=None,
discover_versions=True, discover_versions=True,
@ -913,7 +906,6 @@ class EndpointData(object):
self._saved_project_id) self._saved_project_id)
self.service_url = url self.service_url = url
@positional(1)
def _run_discovery(self, session, cache, min_version, max_version, def _run_discovery(self, session, cache, min_version, max_version,
project_id, allow_version_hack, discover_versions): project_id, allow_version_hack, discover_versions):
tried = set() tried = set()
@ -1103,7 +1095,6 @@ class EndpointData(object):
return _VERSION_HACKS.get_discover_hack(self.service_type, self.url) return _VERSION_HACKS.get_discover_hack(self.service_type, self.url)
@positional()
def get_discovery(session, url, cache=None, authenticated=False): def get_discovery(session, url, cache=None, authenticated=False):
"""Return the discovery object for a URL. """Return the discovery object for a URL.

View File

@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from positional import positional
from keystoneauth1 import _utils as utils from keystoneauth1 import _utils as utils
__all__ = ('DiscoveryList', __all__ = ('DiscoveryList',
@ -33,7 +31,6 @@ class DiscoveryBase(dict):
:param DateTime updated: When the API was last updated. :param DateTime updated: When the API was last updated.
""" """
@positional()
def __init__(self, id, status=None, updated=None): def __init__(self, id, status=None, updated=None):
super(DiscoveryBase, self).__init__() super(DiscoveryBase, self).__init__()
@ -77,7 +74,6 @@ class DiscoveryBase(dict):
def updated(self, value): def updated(self, value):
self.updated_str = value.isoformat() self.updated_str = value.isoformat()
@positional()
def add_link(self, href, rel='self', type=None): def add_link(self, href, rel='self', type=None):
link = {'href': href, 'rel': rel} link = {'href': href, 'rel': rel}
if type: if type:
@ -89,7 +85,6 @@ class DiscoveryBase(dict):
def media_types(self): def media_types(self):
return self.setdefault('media-types', []) return self.setdefault('media-types', [])
@positional(1)
def add_media_type(self, base, type): def add_media_type(self, base, type):
mt = {'base': base, 'type': type} mt = {'base': base, 'type': type}
self.media_types.append(mt) self.media_types.append(mt)
@ -126,7 +121,6 @@ class MicroversionDiscovery(DiscoveryBase):
:param string max_version: The maximum supported microversion. (optional) :param string max_version: The maximum supported microversion. (optional)
""" """
@positional()
def __init__(self, href, id, min_version='', max_version='', **kwargs): def __init__(self, href, id, min_version='', max_version='', **kwargs):
super(MicroversionDiscovery, self).__init__(id, **kwargs) super(MicroversionDiscovery, self).__init__(id, **kwargs)
@ -165,7 +159,6 @@ class NovaMicroversionDiscovery(DiscoveryBase):
:param string version: The maximum microversion supported. (optional) :param string version: The maximum microversion supported. (optional)
""" """
@positional()
def __init__(self, href, id, min_version=None, version=None, **kwargs): def __init__(self, href, id, min_version=None, version=None, **kwargs):
super(NovaMicroversionDiscovery, self).__init__(id, **kwargs) super(NovaMicroversionDiscovery, self).__init__(id, **kwargs)
@ -210,7 +203,6 @@ class V2Discovery(DiscoveryBase):
_DESC_URL = 'https://developer.openstack.org/api-ref/identity/v2/' _DESC_URL = 'https://developer.openstack.org/api-ref/identity/v2/'
@positional()
def __init__(self, href, id=None, html=True, pdf=True, **kwargs): def __init__(self, href, id=None, html=True, pdf=True, **kwargs):
super(V2Discovery, self).__init__(id or 'v2.0', **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. :param bool xml: Add XML media-type elements to the structure.
""" """
@positional()
def __init__(self, href, id=None, json=True, xml=True, **kwargs): def __init__(self, href, id=None, json=True, xml=True, **kwargs):
super(V3Discovery, self).__init__(id or 'v3.0', **kwargs) super(V3Discovery, self).__init__(id or 'v3.0', **kwargs)
@ -307,7 +298,6 @@ class DiscoveryList(dict):
TEST_URL = 'http://keystone.host:5000/' TEST_URL = 'http://keystone.host:5000/'
@positional(2)
def __init__(self, href=None, v2=True, v3=True, v2_id=None, v3_id=None, 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, v2_status=None, v2_updated=None, v2_html=True, v2_pdf=True,
v3_status=None, v3_updated=None, v3_json=True, v3_xml=True): v3_status=None, v3_updated=None, v3_json=True, v3_xml=True):

View File

@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from positional import positional
from keystoneauth1.identity import base from keystoneauth1.identity import base
@ -32,7 +30,6 @@ class AccessInfoPlugin(base.BaseIdentityPlugin):
if using the AUTH_INTERFACE with get_endpoint. (optional) if using the AUTH_INTERFACE with get_endpoint. (optional)
""" """
@positional()
def __init__(self, auth_ref, auth_url=None): def __init__(self, auth_ref, auth_url=None):
super(AccessInfoPlugin, self).__init__(auth_url=auth_url, super(AccessInfoPlugin, self).__init__(auth_url=auth_url,
reauthenticate=False) reauthenticate=False)

View File

@ -16,7 +16,6 @@ import hashlib
import json import json
import threading import threading
from positional import positional
import six import six
from keystoneauth1 import _utils as utils from keystoneauth1 import _utils as utils
@ -398,7 +397,6 @@ class BaseIdentityPlugin(plugin.BaseAuthPlugin):
except exceptions.ServiceProviderNotFound: except exceptions.ServiceProviderNotFound:
return None return None
@positional()
def get_discovery(self, session, url, authenticated=None): def get_discovery(self, session, url, authenticated=None):
"""Return the discovery object for a URL. """Return the discovery object for a URL.

View File

@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from positional import positional
from keystoneauth1 import discover from keystoneauth1 import discover
from keystoneauth1.identity.generic import base from keystoneauth1.identity.generic import base
from keystoneauth1.identity import v2 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, def __init__(self, auth_url, username=None, user_id=None, password=None,
user_domain_id=None, user_domain_name=None, **kwargs): user_domain_id=None, user_domain_name=None, **kwargs):
super(Password, self).__init__(auth_url=auth_url, **kwargs) super(Password, self).__init__(auth_url=auth_url, **kwargs)

View File

@ -12,7 +12,6 @@
import abc import abc
from positional import positional
import six import six
from keystoneauth1 import _utils as utils from keystoneauth1 import _utils as utils
@ -35,7 +34,6 @@ class Auth(base.BaseIdentityPlugin):
is going to expire. (optional) default True is going to expire. (optional) default True
""" """
@positional()
def __init__(self, auth_url, def __init__(self, auth_url,
trust_id=None, trust_id=None,
tenant_id=None, tenant_id=None,
@ -111,7 +109,6 @@ class Password(Auth):
:raises TypeError: if a user_id or username is not provided. :raises TypeError: if a user_id or username is not provided.
""" """
@positional(4)
def __init__(self, auth_url, username=_NOT_PASSED, password=None, def __init__(self, auth_url, username=_NOT_PASSED, password=None,
user_id=_NOT_PASSED, **kwargs): user_id=_NOT_PASSED, **kwargs):
super(Password, self).__init__(auth_url, **kwargs) super(Password, self).__init__(auth_url, **kwargs)

View File

@ -13,7 +13,6 @@
import abc import abc
import json import json
from positional import positional
import six import six
from keystoneauth1 import _utils as utils from keystoneauth1 import _utils as utils
@ -44,7 +43,6 @@ class BaseAuth(base.BaseIdentityPlugin):
token. (optional) default True. token. (optional) default True.
""" """
@positional()
def __init__(self, auth_url, def __init__(self, auth_url,
trust_id=None, trust_id=None,
domain_id=None, domain_id=None,

View File

@ -13,7 +13,6 @@
import abc import abc
import warnings import warnings
from positional import positional
import six import six
from keystoneauth1 import _utils as utils from keystoneauth1 import _utils as utils
@ -288,7 +287,6 @@ class OidcPassword(_OidcBase):
grant_type = "password" grant_type = "password"
@positional(4)
def __init__(self, auth_url, identity_provider, protocol, def __init__(self, auth_url, identity_provider, protocol,
client_id, client_secret, client_id, client_secret,
access_token_endpoint=None, access_token_endpoint=None,
@ -337,7 +335,6 @@ class OidcClientCredentials(_OidcBase):
grant_type = 'client_credentials' grant_type = 'client_credentials'
@positional(4)
def __init__(self, auth_url, identity_provider, protocol, def __init__(self, auth_url, identity_provider, protocol,
client_id, client_secret, client_id, client_secret,
access_token_endpoint=None, access_token_endpoint=None,
@ -381,7 +378,6 @@ class OidcAuthorizationCode(_OidcBase):
grant_type = 'authorization_code' grant_type = 'authorization_code'
@positional(4)
def __init__(self, auth_url, identity_provider, protocol, def __init__(self, auth_url, identity_provider, protocol,
client_id, client_secret, client_id, client_secret,
access_token_endpoint=None, access_token_endpoint=None,
@ -427,7 +423,6 @@ class OidcAuthorizationCode(_OidcBase):
class OidcAccessToken(_OidcBase): class OidcAccessToken(_OidcBase):
"""Implementation for OpenID Connect access token reuse.""" """Implementation for OpenID Connect access token reuse."""
@positional(5)
def __init__(self, auth_url, identity_provider, protocol, def __init__(self, auth_url, identity_provider, protocol,
access_token, **kwargs): access_token, **kwargs):
"""The OpenID Connect plugin based on the Access Token. """The OpenID Connect plugin based on the Access Token.

View File

@ -13,8 +13,6 @@
import argparse import argparse
import os import os
from positional import positional
from keystoneauth1.loading import base from keystoneauth1.loading import base
@ -31,7 +29,6 @@ def _register_plugin_argparse_arguments(parser, plugin):
dest='os_%s' % opt.dest) dest='os_%s' % opt.dest)
@positional()
def register_argparse_arguments(parser, argv, default=None): def register_argparse_arguments(parser, argv, default=None):
"""Register CLI options needed to create a plugin. """Register CLI options needed to create a plugin.

View File

@ -13,8 +13,6 @@
import itertools import itertools
import os import os
from positional import positional
from keystoneauth1.loading import _utils from keystoneauth1.loading import _utils
@ -62,7 +60,6 @@ class Opt(object):
appropriate) set the string that should be used to prompt with. appropriate) set the string that should be used to prompt with.
""" """
@positional()
def __init__(self, def __init__(self,
name, name,
type=str, type=str,

View File

@ -13,8 +13,6 @@
import argparse import argparse
import os import os
from positional import positional
from keystoneauth1.loading import _utils from keystoneauth1.loading import _utils
from keystoneauth1.loading import base from keystoneauth1.loading import base
from keystoneauth1 import session from keystoneauth1 import session
@ -50,7 +48,6 @@ class Session(base.BaseLoader):
def get_options(self): def get_options(self):
return [] return []
@positional(1)
def load_from_options(self, def load_from_options(self,
insecure=False, insecure=False,
verify=None, verify=None,

View File

@ -22,7 +22,6 @@ import sys
import time import time
import uuid import uuid
from positional import positional
import requests import requests
import six import six
from six.moves import urllib from six.moves import urllib
@ -253,7 +252,6 @@ class Session(object):
_DEFAULT_REDIRECT_LIMIT = 30 _DEFAULT_REDIRECT_LIMIT = 30
@positional(2)
def __init__(self, auth=None, session=None, original_ip=None, verify=True, def __init__(self, auth=None, session=None, original_ip=None, verify=True,
cert=None, timeout=None, user_agent=None, cert=None, timeout=None, user_agent=None,
redirect=_DEFAULT_REDIRECT_LIMIT, additional_headers=None, redirect=_DEFAULT_REDIRECT_LIMIT, additional_headers=None,
@ -326,7 +324,6 @@ class Session(object):
return (header[0], '{SHA1}%s' % token_hash) return (header[0], '{SHA1}%s' % token_hash)
return header return header
@positional()
def _http_log_request(self, url, method=None, data=None, def _http_log_request(self, url, method=None, data=None,
json=None, headers=None, query_params=None, json=None, headers=None, query_params=None,
logger=_logger): logger=_logger):
@ -374,7 +371,6 @@ class Session(object):
logger.debug(' '.join(string_parts)) logger.debug(' '.join(string_parts))
@positional()
def _http_log_response(self, response=None, json=None, def _http_log_response(self, response=None, json=None,
status_code=None, headers=None, text=None, status_code=None, headers=None, text=None,
logger=_logger): logger=_logger):
@ -465,7 +461,6 @@ class Session(object):
for h in header_names: for h in header_names:
headers.setdefault(h, microversion) headers.setdefault(h, microversion)
@positional()
def request(self, url, method, json=None, original_ip=None, def request(self, url, method, json=None, original_ip=None,
user_agent=None, redirect=None, authenticated=None, user_agent=None, redirect=None, authenticated=None,
endpoint_filter=None, auth=None, requests_auth=None, endpoint_filter=None, auth=None, requests_auth=None,

View File

@ -13,7 +13,6 @@
pbr!=2.1.0,>=2.0.0 # Apache-2.0 pbr!=2.1.0,>=2.0.0 # Apache-2.0
iso8601>=0.1.11 # MIT iso8601>=0.1.11 # MIT
positional>=1.1.1 # Apache-2.0
requests>=2.14.2 # Apache-2.0 requests>=2.14.2 # Apache-2.0
six>=1.9.0 # MIT six>=1.9.0 # MIT
stevedore>=1.20.0 # Apache-2.0 stevedore>=1.20.0 # Apache-2.0