Fix H4xx docstring issues
Completes blueprint openstack-hacking-compliant Change-Id: Ib286972b65e0e3282db483718421f7f28e8c6cd1
This commit is contained in:
@@ -32,8 +32,10 @@ class TestDataContainer(object):
|
|||||||
|
|
||||||
|
|
||||||
class TestResponse(requests.Response):
|
class TestResponse(requests.Response):
|
||||||
""" Class used to wrap requests.Response and provide some
|
"""Class used to wrap requests.Response.
|
||||||
convenience to initialize with a dict """
|
|
||||||
|
It also provides some convenience to initialize with a dict.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
self._text = None
|
self._text = None
|
||||||
|
@@ -185,7 +185,8 @@ class User(models.AnonymousUser):
|
|||||||
return "<%s: %s>" % (self.__class__.__name__, self.username)
|
return "<%s: %s>" % (self.__class__.__name__, self.username)
|
||||||
|
|
||||||
def is_token_expired(self):
|
def is_token_expired(self):
|
||||||
"""
|
"""Determine if the token is expired.
|
||||||
|
|
||||||
Returns ``True`` if the token is expired, ``False`` if not, and
|
Returns ``True`` if the token is expired, ``False`` if not, and
|
||||||
``None`` if there is no token set.
|
``None`` if there is no token set.
|
||||||
"""
|
"""
|
||||||
@@ -199,8 +200,9 @@ class User(models.AnonymousUser):
|
|||||||
utils.check_token_expiration(self.token))
|
utils.check_token_expiration(self.token))
|
||||||
|
|
||||||
def is_anonymous(self):
|
def is_anonymous(self):
|
||||||
"""
|
"""Return if the user is not authenticated.
|
||||||
Returns ``True`` if the user is not authenticated,``False`` otherwise.
|
|
||||||
|
Returns ``True`` if not authenticated,``False`` otherwise.
|
||||||
"""
|
"""
|
||||||
return not self.is_authenticated()
|
return not self.is_authenticated()
|
||||||
|
|
||||||
@@ -210,9 +212,9 @@ class User(models.AnonymousUser):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_superuser(self):
|
def is_superuser(self):
|
||||||
"""
|
"""Evaluates whether this user has admin privileges.
|
||||||
Evaluates whether this user has admin privileges. Returns
|
|
||||||
``True`` or ``False``.
|
Returns ``True`` or ``False``.
|
||||||
"""
|
"""
|
||||||
return 'admin' in [role['name'].lower() for role in self.roles]
|
return 'admin' in [role['name'].lower() for role in self.roles]
|
||||||
|
|
||||||
@@ -243,9 +245,9 @@ class User(models.AnonymousUser):
|
|||||||
self._authorized_tenants = tenant_list
|
self._authorized_tenants = tenant_list
|
||||||
|
|
||||||
def default_services_region(self):
|
def default_services_region(self):
|
||||||
"""
|
"""Returns the first endpoint region for first non-identity service.
|
||||||
Returns the first endpoint region for first non-identity service
|
|
||||||
in the service catalog
|
Extracted from the service catalog.
|
||||||
"""
|
"""
|
||||||
if self.service_catalog:
|
if self.service_catalog:
|
||||||
for service in self.service_catalog:
|
for service in self.service_catalog:
|
||||||
@@ -265,9 +267,7 @@ class User(models.AnonymousUser):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def available_services_regions(self):
|
def available_services_regions(self):
|
||||||
"""
|
"""Returns list of unique region name values in service catalog."""
|
||||||
Returns list of unique region name values found in service catalog
|
|
||||||
"""
|
|
||||||
regions = []
|
regions = []
|
||||||
if self.service_catalog:
|
if self.service_catalog:
|
||||||
for service in self.service_catalog:
|
for service in self.service_catalog:
|
||||||
@@ -289,10 +289,10 @@ class User(models.AnonymousUser):
|
|||||||
# Check for OR'd permission rules, check that user has one of the
|
# Check for OR'd permission rules, check that user has one of the
|
||||||
# required permission.
|
# required permission.
|
||||||
def has_a_matching_perm(self, perm_list, obj=None):
|
def has_a_matching_perm(self, perm_list, obj=None):
|
||||||
"""
|
"""Returns True if the user has one of the specified permissions.
|
||||||
Returns True if the user has one of the specified permissions. If
|
|
||||||
object is passed, it checks if the user has any of the required perms
|
If object is passed, it checks if the user has any of the required
|
||||||
for this object.
|
perms for this object.
|
||||||
"""
|
"""
|
||||||
# If there are no permissions to check, just return true
|
# If there are no permissions to check, just return true
|
||||||
if not perm_list:
|
if not perm_list:
|
||||||
@@ -316,8 +316,8 @@ class User(models.AnonymousUser):
|
|||||||
# ('openstack.roles.admin', ('openstack.roles.L3-support',
|
# ('openstack.roles.admin', ('openstack.roles.L3-support',
|
||||||
# 'openstack.roles.L2-support'),)
|
# 'openstack.roles.L2-support'),)
|
||||||
def has_perms(self, perm_list, obj=None):
|
def has_perms(self, perm_list, obj=None):
|
||||||
"""
|
"""Returns True if the user has all of the specified permissions.
|
||||||
Returns True if the user has all of the specified permissions.
|
|
||||||
Tuples in the list will possess the required permissions if
|
Tuples in the list will possess the required permissions if
|
||||||
the user has a permissions matching one of the elements of
|
the user has a permissions matching one of the elements of
|
||||||
that tuple
|
that tuple
|
||||||
|
@@ -80,10 +80,9 @@ def check_token_expiration(token):
|
|||||||
# Added in Django 1.4.3, 1.5b2
|
# Added in Django 1.4.3, 1.5b2
|
||||||
# Vendored here for compatibility with old Django versions.
|
# Vendored here for compatibility with old Django versions.
|
||||||
def is_safe_url(url, host=None):
|
def is_safe_url(url, host=None):
|
||||||
"""
|
"""Return ``True`` if the url is a safe redirection.
|
||||||
Return ``True`` if the url is a safe redirection (i.e. it doesn't point to
|
|
||||||
a different host).
|
|
||||||
|
|
||||||
|
The safe redirection means that it doesn't point to a different host.
|
||||||
Always returns ``False`` on an empty url.
|
Always returns ``False`` on an empty url.
|
||||||
"""
|
"""
|
||||||
if not url:
|
if not url:
|
||||||
|
@@ -188,9 +188,10 @@ def switch(request, tenant_id, redirect_field_name=auth.REDIRECT_FIELD_NAME):
|
|||||||
@login_required
|
@login_required
|
||||||
def switch_region(request, region_name,
|
def switch_region(request, region_name,
|
||||||
redirect_field_name=auth.REDIRECT_FIELD_NAME):
|
redirect_field_name=auth.REDIRECT_FIELD_NAME):
|
||||||
"""
|
"""Switches the user's region for all services except Identity service.
|
||||||
Switches the non-identity services region that is being managed
|
|
||||||
for the scoped project.
|
The region will be switched if the given region is one of the regions
|
||||||
|
available for the scoped project. Otherwise the region is not switched.
|
||||||
"""
|
"""
|
||||||
if region_name in request.user.available_services_regions:
|
if region_name in request.user.available_services_regions:
|
||||||
request.session['services_region'] = region_name
|
request.session['services_region'] = region_name
|
||||||
|
3
tox.ini
3
tox.ini
@@ -41,9 +41,8 @@ downloadcache = ~/cache/pip
|
|||||||
[flake8]
|
[flake8]
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py
|
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py
|
||||||
# H4xx docstrings
|
|
||||||
# H803 git commit title should not end with period (disabled on purpose, see bug #1236621)
|
# H803 git commit title should not end with period (disabled on purpose, see bug #1236621)
|
||||||
ignore = H4,H803
|
ignore = H803
|
||||||
|
|
||||||
[hacking]
|
[hacking]
|
||||||
import_exceptions = django.conf.settings,
|
import_exceptions = django.conf.settings,
|
||||||
|
Reference in New Issue
Block a user