Enable H40* rules in pep/flake

First part of pep/flake fixies, that enables H40* group of rules.

Change-Id: Ia85b49645b3bf634e99877855e6b31a404331b7f
Related-Bug: #1333290
This commit is contained in:
Valeriy Ponomaryov 2014-06-23 10:52:24 -04:00
parent c6b3c90c53
commit b87c55d5fc
19 changed files with 121 additions and 131 deletions

View File

@ -37,9 +37,10 @@ except NameError:
def getid(obj): def getid(obj):
""" """Searches for id in provided object.
Abstracts the common pattern of allowing both an object or an object's ID
as a parameter when dealing with relationships. Abstracts the common pattern of allowing both an object or an
object's ID as a parameter when dealing with relationships.
""" """
try: try:
return obj.id return obj.id
@ -48,8 +49,9 @@ def getid(obj):
class Manager(utils.HookableMixin): class Manager(utils.HookableMixin):
""" """Manager for CRUD operations.
Managers interact with a particular type of API (servers, flavors, images,
Managers interact with a particular type of API (shares, snapshots,
etc.) and provide CRUD operations for them. etc.) and provide CRUD operations for them.
""" """
resource_class = None resource_class = None
@ -83,7 +85,8 @@ class Manager(utils.HookableMixin):
@contextlib.contextmanager @contextlib.contextmanager
def completion_cache(self, cache_type, obj_class, mode): def completion_cache(self, cache_type, obj_class, mode):
""" """Bash autocompletion items storage.
The completion cache store items that can be used for bash The completion cache store items that can be used for bash
autocompletion, like UUIDs or human-friendly IDs. autocompletion, like UUIDs or human-friendly IDs.
@ -170,12 +173,9 @@ class Manager(utils.HookableMixin):
class ManagerWithFind(Manager): class ManagerWithFind(Manager):
""" """Like a `Manager`, but with additional `find()`/`findall()` methods."""
Like a `Manager`, but with additional `find()`/`findall()` methods.
"""
def find(self, **kwargs): def find(self, **kwargs):
""" """Find a single item with attributes matching ``**kwargs``.
Find a single item with attributes matching ``**kwargs``.
This isn't very efficient: it loads the entire list then filters on This isn't very efficient: it loads the entire list then filters on
the Python side. the Python side.
@ -191,8 +191,7 @@ class ManagerWithFind(Manager):
return matches[0] return matches[0]
def findall(self, **kwargs): def findall(self, **kwargs):
""" """Find all items with attributes matching ``**kwargs``.
Find all items with attributes matching ``**kwargs``.
This isn't very efficient: it loads the entire list then filters on This isn't very efficient: it loads the entire list then filters on
the Python side. the Python side.
@ -215,9 +214,10 @@ class ManagerWithFind(Manager):
class Resource(object): class Resource(object):
""" """Resource as instance of an object.
A resource represents a particular instance of an object (server, flavor,
etc). This is pretty much just a bag for attributes. A resource represents a particular instance of an object (share,
snapshot, etc). This is pretty much just a bag for attributes.
:param manager: Manager object :param manager: Manager object
:param info: dictionary representing resource attributes :param info: dictionary representing resource attributes

View File

@ -202,8 +202,10 @@ class HTTPClient(object):
def _extract_service_catalog(self, url, resp, body, extract_token=True): def _extract_service_catalog(self, url, resp, body, extract_token=True):
"""See what the auth service told us and process the response. """See what the auth service told us and process the response.
We may get redirected to another site, fail or actually get We may get redirected to another site, fail or actually get
back a service catalog with a token and our endpoints.""" back a service catalog with a token and our endpoints.
"""
if resp.status_code == 200: # content must always present if resp.status_code == 200: # content must always present
try: try:

View File

@ -5,8 +5,11 @@ Exception definitions.
class UnsupportedVersion(Exception): class UnsupportedVersion(Exception):
"""Indicates that the user is trying to use an unsupported """Usage of unsupported API version.
version of the API"""
Indicates that the user is trying to use an unsupported version
of the API.
"""
pass pass
@ -23,8 +26,11 @@ class NoUniqueMatch(Exception):
class NoTokenLookupException(Exception): class NoTokenLookupException(Exception):
"""This form of authentication does not support looking up """No support for looking up endpoints.
endpoints from an existing token."""
This form of authentication does not support looking up
endpoints from an existing token.
"""
pass pass
@ -43,9 +49,7 @@ class AmbiguousEndpoints(Exception):
class ClientException(Exception): class ClientException(Exception):
""" """The base exception class for all exceptions this library raises."""
The base exception class for all exceptions this library raises.
"""
def __init__(self, code, message=None, details=None, request_id=None): def __init__(self, code, message=None, details=None, request_id=None):
self.code = code self.code = code
self.message = message or self.__class__.message self.message = message or self.__class__.message
@ -61,41 +65,36 @@ class ClientException(Exception):
class BadRequest(ClientException): class BadRequest(ClientException):
""" """HTTP 400 - Bad request: you sent some malformed data."""
HTTP 400 - Bad request: you sent some malformed data.
"""
http_status = 400 http_status = 400
message = "Bad request" message = "Bad request"
class Unauthorized(ClientException): class Unauthorized(ClientException):
""" """HTTP 401 - Unauthorized: bad credentials."""
HTTP 401 - Unauthorized: bad credentials.
"""
http_status = 401 http_status = 401
message = "Unauthorized" message = "Unauthorized"
class Forbidden(ClientException): class Forbidden(ClientException):
""" """HTTP 403.
HTTP 403 - Forbidden: your credentials don't give you access to this
resource. Forbidden: your credentials don't give you access to this resource.
""" """
http_status = 403 http_status = 403
message = "Forbidden" message = "Forbidden"
class NotFound(ClientException): class NotFound(ClientException):
""" """HTTP 404 - Not found."""
HTTP 404 - Not found
"""
http_status = 404 http_status = 404
message = "Not found" message = "Not found"
class OverLimit(ClientException): class OverLimit(ClientException):
""" """HTTP 413.
HTTP 413 - Over limit: you're over the API limits for this time period.
Over limit: you're over the API limits for this time period.
""" """
http_status = 413 http_status = 413
message = "Over limit" message = "Over limit"
@ -103,8 +102,9 @@ class OverLimit(ClientException):
# NotImplemented is a python keyword. # NotImplemented is a python keyword.
class HTTPNotImplemented(ClientException): class HTTPNotImplemented(ClientException):
""" """HTTP 501.
HTTP 501 - Not Implemented: the server does not support this operation.
Not Implemented: the server does not support this operation.
""" """
http_status = 501 http_status = 501
message = "Not Implemented" message = "Not Implemented"
@ -122,9 +122,10 @@ _code_map = dict((c.http_status, c) for c in [BadRequest, Unauthorized,
def from_response(response, body): def from_response(response, body):
""" """Parse response and return Exception based on it.
Return an instance of an ClientException or subclass
based on an requests response. Return an instance of an ClientException or subclass based
on an requests response.
Usage:: Usage::

View File

@ -34,9 +34,12 @@ class ServiceCatalog(object):
def url_for(self, attr=None, filter_value=None, def url_for(self, attr=None, filter_value=None,
service_type=None, endpoint_type='publicURL', service_type=None, endpoint_type='publicURL',
service_name=None, share_service_name=None): service_name=None, share_service_name=None):
"""Fetch the public URL from the Compute service for """Returns url for specified endpoint type.
a particular endpoint attribute. If none given, return
the first. See tests for sample service catalog.""" Fetch the public URL from the Compute service for
a particular endpoint attribute.
If none given, return the first. See tests for sample service catalog.
"""
matching_endpoints = [] matching_endpoints = []
if 'endpoints' in self.catalog: if 'endpoints' in self.catalog:
# We have a bastardized service catalog. Treat it special. :/ # We have a bastardized service catalog. Treat it special. :/

View File

@ -432,9 +432,7 @@ class OpenStackManilaShell(object):
@utils.arg('command', metavar='<subcommand>', nargs='?', @utils.arg('command', metavar='<subcommand>', nargs='?',
help='Display help for <subcommand>') help='Display help for <subcommand>')
def do_help(self, args): def do_help(self, args):
""" """Display help about this program or one of its subcommands."""
Display help about this program or one of its subcommands.
"""
if args.command: if args.command:
if args.command in self.subcommands: if args.command in self.subcommands:
self.subcommands[args.command].print_help() self.subcommands[args.command].print_help()

View File

@ -17,9 +17,10 @@ def arg(*args, **kwargs):
def env(*vars, **kwargs): def env(*vars, **kwargs):
""" """Returns value of env var if exist.
returns the first environment variable set
if none are non-empty, defaults to '' or keyword arg default Returns the first environment variable set if none are non-empty,
defaults to '' or keyword arg default.
""" """
for v in vars: for v in vars:
value = os.environ.get(v, None) value = os.environ.get(v, None)
@ -78,8 +79,8 @@ def get_resource_manager_extra_kwargs(f, args, allow_conflicts=False):
def unauthenticated(f): def unauthenticated(f):
""" """Adds 'unauthenticated' attribute to decorated function.
Adds 'unauthenticated' attribute to decorated function.
Usage: Usage:
@unauthenticated @unauthenticated
def mymethod(f): def mymethod(f):
@ -90,17 +91,18 @@ def unauthenticated(f):
def isunauthenticated(f): def isunauthenticated(f):
""" """Verifies whether function requires authentication or not.
Checks to see if the function is marked as not requiring authentication Checks to see if the function is marked as not requiring authentication
with the @unauthenticated decorator. Returns True if decorator is with the @unauthenticated decorator.
set to True, False otherwise. Returns True if decorator is set to True, False otherwise.
""" """
return getattr(f, 'unauthenticated', False) return getattr(f, 'unauthenticated', False)
def service_type(stype): def service_type(stype):
""" """Adds 'service_type' attribute to decorated function.
Adds 'service_type' attribute to decorated function.
Usage: Usage:
@service_type('share') @service_type('share')
def mymethod(f): def mymethod(f):
@ -113,9 +115,7 @@ def service_type(stype):
def get_service_type(f): def get_service_type(f):
""" """Retrieves service type from function."""
Retrieves service type from function
"""
return getattr(f, 'service_type', None) return getattr(f, 'service_type', None)
@ -250,10 +250,7 @@ def import_class(import_str):
def make_metadata_dict(metadata): def make_metadata_dict(metadata):
""" """Converts cli key=value data to python dict as {'key': 'value'}."""
Converts given metadata in form of list of 'key=value' strings into
{'key': 'value'} dictionary
"""
metadata_dict = {} metadata_dict = {}
for item in metadata: for item in metadata:
try: try:

View File

@ -39,9 +39,7 @@ class ListExtManager(base.Manager):
@utils.service_type('share') @utils.service_type('share')
def do_list_extensions(client, _args): def do_list_extensions(client, _args):
""" """List all the os-api extensions that are available."""
List all the os-api extensions that are available.
"""
extensions = client.list_extensions.show_all() extensions = client.list_extensions.show_all()
fields = ["Name", "Summary", "Alias", "Updated"] fields = ["Name", "Summary", "Alias", "Updated"]
utils.print_list(extensions, fields) utils.print_list(extensions, fields)

View File

@ -4,7 +4,7 @@ from manilaclient import base
class Limits(base.Resource): class Limits(base.Resource):
"""A collection of RateLimit and AbsoluteLimit objects""" """A collection of RateLimit and AbsoluteLimit objects."""
def __repr__(self): def __repr__(self):
return "<Limits>" return "<Limits>"
@ -26,7 +26,7 @@ class Limits(base.Resource):
class RateLimit(object): class RateLimit(object):
"""Data model that represents a flattened view of a single rate limit""" """Data model that represents a flattened view of a single rate limit."""
def __init__(self, verb, uri, regex, value, remain, def __init__(self, verb, uri, regex, value, remain,
unit, next_available): unit, next_available):
@ -52,7 +52,7 @@ class RateLimit(object):
class AbsoluteLimit(object): class AbsoluteLimit(object):
"""Data model that represents a single absolute limit""" """Data model that represents a single absolute limit."""
def __init__(self, name, value): def __init__(self, name, value):
self.name = name self.name = name
@ -66,7 +66,7 @@ class AbsoluteLimit(object):
class LimitsManager(base.Manager): class LimitsManager(base.Manager):
"""Manager object used to interact with limits resource""" """Manager object used to interact with limits resource."""
resource_class = Limits resource_class = Limits

View File

@ -20,7 +20,7 @@ class QuotaClassSet(base.Resource):
@property @property
def id(self): def id(self):
"""Needed by base.Resource to self-refresh and be indexed""" """Needed by base.Resource to self-refresh and be indexed."""
return self.class_name return self.class_name
def update(self, *args, **kwargs): def update(self, *args, **kwargs):

View File

@ -20,7 +20,7 @@ class QuotaSet(base.Resource):
@property @property
def id(self): def id(self):
"""Needed by base.Resource to self-refresh and be indexed""" """Needed by base.Resource to self-refresh and be indexed."""
return self.tenant_id return self.tenant_id
def update(self, *args, **kwargs): def update(self, *args, **kwargs):

View File

@ -24,13 +24,14 @@ RESOURCES_NAME = 'security_services'
class SecurityService(base.Resource): class SecurityService(base.Resource):
"""Security service for Manila shares """ """Security service for Manila shares."""
def __repr__(self): def __repr__(self):
return "<SecurityService: %s>" % self.id return "<SecurityService: %s>" % self.id
class SecurityServiceManager(base.Manager): class SecurityServiceManager(base.Manager):
"""Manage :class:`SecurityService` resources.""" """Manage :class:`SecurityService` resources."""
resource_class = SecurityService resource_class = SecurityService
def create(self, type, dns_ip=None, server=None, domain=None, sid=None, def create(self, type, dns_ip=None, server=None, domain=None, sid=None,

View File

@ -24,7 +24,7 @@ RESOURCES_NAME = 'share_networks'
class ShareNetwork(base.Resource): class ShareNetwork(base.Resource):
"""Network info for Manila shares """ """Network info for Manila shares."""
def __repr__(self): def __repr__(self):
return "<ShareNetwork: %s>" % self.id return "<ShareNetwork: %s>" % self.id

View File

@ -220,16 +220,14 @@ class ShareManager(base.ManagerWithFind):
return [] return []
def get_metadata(self, share): def get_metadata(self, share):
""" """Get a shares metadata.
Get a shares metadata.
:param share: The :class:`Share`. :param share: The :class:`Share`.
""" """
return self._get("/shares/%s/metadata" % base.getid(share), "metadata") return self._get("/shares/%s/metadata" % base.getid(share), "metadata")
def set_metadata(self, share, metadata): def set_metadata(self, share, metadata):
""" """Update/Set a shares metadata.
Update/Set a shares metadata.
:param share: The :class:`Share`. :param share: The :class:`Share`.
:param metadata: A list of keys to be set. :param metadata: A list of keys to be set.
@ -239,8 +237,7 @@ class ShareManager(base.ManagerWithFind):
body, "metadata") body, "metadata")
def delete_metadata(self, share, keys): def delete_metadata(self, share, keys):
""" """Delete specified keys from volumes metadata.
Delete specified keys from volumes metadata.
:param share: The :class:`Share`. :param share: The :class:`Share`.
:param keys: A list of keys to be removed. :param keys: A list of keys to be removed.

View File

@ -101,14 +101,14 @@ def _extract_metadata(args):
def do_endpoints(cs, args): def do_endpoints(cs, args):
"""Discover endpoints that get returned from the authenticate services""" """Discover endpoints that get returned from the authenticate services."""
catalog = cs.client.service_catalog.catalog catalog = cs.client.service_catalog.catalog
for e in catalog['access']['serviceCatalog']: for e in catalog['access']['serviceCatalog']:
utils.print_dict(e['endpoints'][0], e['name']) utils.print_dict(e['endpoints'][0], e['name'])
def do_credentials(cs, args): def do_credentials(cs, args):
"""Show user credentials returned from auth""" """Show user credentials returned from auth."""
catalog = cs.client.service_catalog.catalog catalog = cs.client.service_catalog.catalog
utils.print_dict(catalog['access']['user'], "User Credentials") utils.print_dict(catalog['access']['user'], "User Credentials")
utils.print_dict(catalog['access']['token'], "Token") utils.print_dict(catalog['access']['token'], "Token")
@ -731,7 +731,7 @@ def do_reset_state(cs, args):
default=None, default=None,
help="Share network description.") help="Share network description.")
def do_share_network_create(cs, args): def do_share_network_create(cs, args):
"""Create description for network used by the tenant""" """Create description for network used by the tenant."""
values = {'neutron_net_id': args.neutron_net_id, values = {'neutron_net_id': args.neutron_net_id,
'neutron_subnet_id': args.neutron_subnet_id, 'neutron_subnet_id': args.neutron_subnet_id,
'name': args.name, 'name': args.name,
@ -767,7 +767,7 @@ def do_share_network_create(cs, args):
default=None, default=None,
help="Share network description.") help="Share network description.")
def do_share_network_update(cs, args): def do_share_network_update(cs, args):
"""Update share network data""" """Update share network data."""
values = {'neutron_net_id': args.neutron_net_id, values = {'neutron_net_id': args.neutron_net_id,
'neutron_subnet_id': args.neutron_subnet_id, 'neutron_subnet_id': args.neutron_subnet_id,
'name': args.name, 'name': args.name,
@ -783,7 +783,7 @@ def do_share_network_update(cs, args):
metavar='<share-network>', metavar='<share-network>',
help='Name or ID of the share network to show.') help='Name or ID of the share network to show.')
def do_share_network_show(cs, args): def do_share_network_show(cs, args):
"""Get a description for network used by the tenant""" """Get a description for network used by the tenant."""
share_network = _find_share_network(cs, args.share_network) share_network = _find_share_network(cs, args.share_network)
info = share_network._info.copy() info = share_network._info.copy()
utils.print_dict(info) utils.print_dict(info)
@ -804,7 +804,7 @@ def do_share_network_show(cs, args):
default=None, default=None,
help='Filter results by status') help='Filter results by status')
def do_share_network_list(cs, args): def do_share_network_list(cs, args):
"""Get a list of network info""" """Get a list of network info."""
all_tenants = int(os.environ.get("ALL_TENANTS", args.all_tenants)) all_tenants = int(os.environ.get("ALL_TENANTS", args.all_tenants))
search_opts = { search_opts = {
'all_tenants': all_tenants, 'all_tenants': all_tenants,
@ -824,7 +824,7 @@ def do_share_network_list(cs, args):
metavar='<security-service>', metavar='<security-service>',
help='Security service to associate with.') help='Security service to associate with.')
def do_share_network_security_service_add(cs, args): def do_share_network_security_service_add(cs, args):
"""Associate security service with share network""" """Associate security service with share network."""
share_network = _find_share_network(cs, args.share_network) share_network = _find_share_network(cs, args.share_network)
cs.share_networks.add_security_service(share_network, cs.share_networks.add_security_service(share_network,
args.security_service) args.security_service)
@ -839,7 +839,7 @@ def do_share_network_security_service_add(cs, args):
metavar='<security-service>', metavar='<security-service>',
help='Security service to dissociate.') help='Security service to dissociate.')
def do_share_network_security_service_remove(cs, args): def do_share_network_security_service_remove(cs, args):
"""Dissociate security service from share network""" """Dissociate security service from share network."""
share_network = _find_share_network(cs, args.share_network) share_network = _find_share_network(cs, args.share_network)
cs.share_networks.remove_security_service(share_network, cs.share_networks.remove_security_service(share_network,
args.security_service) args.security_service)
@ -850,7 +850,7 @@ def do_share_network_security_service_remove(cs, args):
metavar='<share-network>', metavar='<share-network>',
help='Share network name or ID.') help='Share network name or ID.')
def do_share_network_security_service_list(cs, args): def do_share_network_security_service_list(cs, args):
"""Get a list of security services associated with a given share network""" """Get list of security services associated with a given share network."""
share_network = _find_share_network(cs, args.share_network) share_network = _find_share_network(cs, args.share_network)
search_opts = { search_opts = {
'share_network_id': share_network.id, 'share_network_id': share_network.id,
@ -865,7 +865,7 @@ def do_share_network_security_service_list(cs, args):
metavar='<share-network>', metavar='<share-network>',
help='Name or ID of share network to be deleted.') help='Name or ID of share network to be deleted.')
def do_share_network_delete(cs, args): def do_share_network_delete(cs, args):
"""Delete share network""" """Delete share network."""
_find_share_network(cs, args.share_network).delete() _find_share_network(cs, args.share_network).delete()
@ -909,7 +909,7 @@ def do_share_network_delete(cs, args):
default=None, default=None,
help="security service description") help="security service description")
def do_security_service_create(cs, args): def do_security_service_create(cs, args):
"""Create security service used by tenant""" """Create security service used by tenant."""
values = {'dns_ip': args.dns_ip, values = {'dns_ip': args.dns_ip,
'server': args.server, 'server': args.server,
'domain': args.domain, 'domain': args.domain,
@ -962,7 +962,7 @@ def do_security_service_create(cs, args):
default=None, default=None,
help="security service description") help="security service description")
def do_security_service_update(cs, args): def do_security_service_update(cs, args):
"""Update security service""" """Update security service."""
values = {'dns_ip': args.dns_ip, values = {'dns_ip': args.dns_ip,
'server': args.server, 'server': args.server,
'domain': args.domain, 'domain': args.domain,
@ -981,7 +981,7 @@ def do_security_service_update(cs, args):
metavar='<security-service>', metavar='<security-service>',
help='Security service to show.') help='Security service to show.')
def do_security_service_show(cs, args): def do_security_service_show(cs, args):
"""Show security service""" """Show security service."""
security_service = cs.security_services.get(args.security_service) security_service = cs.security_services.get(args.security_service)
info = security_service._info.copy() info = security_service._info.copy()
utils.print_dict(info) utils.print_dict(info)
@ -1002,7 +1002,7 @@ def do_security_service_show(cs, args):
default=None, default=None,
help='Filter results by status') help='Filter results by status')
def do_security_service_list(cs, args): def do_security_service_list(cs, args):
"""Get a list of security services""" """Get a list of security services."""
all_tenants = int(os.environ.get("ALL_TENANTS", args.all_tenants)) all_tenants = int(os.environ.get("ALL_TENANTS", args.all_tenants))
search_opts = { search_opts = {
'all_tenants': all_tenants, 'all_tenants': all_tenants,
@ -1018,7 +1018,7 @@ def do_security_service_list(cs, args):
metavar='<security-service>', metavar='<security-service>',
help='Security service to delete.') help='Security service to delete.')
def do_security_service_delete(cs, args): def do_security_service_delete(cs, args):
"""Delete security service""" """Delete security service."""
cs.security_services.delete(args.security_service) cs.security_services.delete(args.security_service)

View File

@ -22,15 +22,13 @@ from manilaclient import base
class VolumeType(base.Resource): class VolumeType(base.Resource):
""" """A Volume Type is the type of volume to be created."""
A Volume Type is the type of volume to be created
"""
def __repr__(self): def __repr__(self):
return "<VolumeType: %s>" % self.name return "<VolumeType: %s>" % self.name
def get_keys(self): def get_keys(self):
""" """Get extra specs from a volume type.
Get extra specs from a volume type.
:param vol_type: The :class:`VolumeType` to get extra specs from :param vol_type: The :class:`VolumeType` to get extra specs from
""" """
@ -40,8 +38,7 @@ class VolumeType(base.Resource):
return body["extra_specs"] return body["extra_specs"]
def set_keys(self, metadata): def set_keys(self, metadata):
""" """Set extra specs on a volume type.
Set extra specs on a volume type.
:param type : The :class:`VolumeType` to set extra spec on :param type : The :class:`VolumeType` to set extra spec on
:param metadata: A dict of key/value pairs to be set :param metadata: A dict of key/value pairs to be set
@ -54,8 +51,7 @@ class VolumeType(base.Resource):
return_raw=True) return_raw=True)
def unset_keys(self, keys): def unset_keys(self, keys):
""" """Unset extra specs on a volume type.
Unset extra specs on a volume type.
:param type_id: The :class:`VolumeType` to unset extra spec on :param type_id: The :class:`VolumeType` to unset extra spec on
:param keys: A list of keys to be unset :param keys: A list of keys to be unset
@ -74,22 +70,19 @@ class VolumeType(base.Resource):
class VolumeTypeManager(base.ManagerWithFind): class VolumeTypeManager(base.ManagerWithFind):
""" """Manage :class:`VolumeType` resources."""
Manage :class:`VolumeType` resources.
"""
resource_class = VolumeType resource_class = VolumeType
def list(self, search_opts=None): def list(self, search_opts=None):
""" """Get a list of all volume types.
Get a list of all volume types.
:rtype: list of :class:`VolumeType`. :rtype: list of :class:`VolumeType`.
""" """
return self._list("/types", "volume_types") return self._list("/types", "volume_types")
def get(self, volume_type): def get(self, volume_type):
""" """Get a specific volume type.
Get a specific volume type.
:param volume_type: The ID of the :class:`VolumeType` to get. :param volume_type: The ID of the :class:`VolumeType` to get.
:rtype: :class:`VolumeType` :rtype: :class:`VolumeType`
@ -97,16 +90,14 @@ class VolumeTypeManager(base.ManagerWithFind):
return self._get("/types/%s" % base.getid(volume_type), "volume_type") return self._get("/types/%s" % base.getid(volume_type), "volume_type")
def delete(self, volume_type): def delete(self, volume_type):
""" """Delete a specific volume_type.
Delete a specific volume_type.
:param volume_type: The name or ID of the :class:`VolumeType` to get. :param volume_type: The name or ID of the :class:`VolumeType` to get.
""" """
self._delete("/types/%s" % base.getid(volume_type)) self._delete("/types/%s" % base.getid(volume_type))
def create(self, name): def create(self, name):
""" """Create a volume type.
Create a volume type.
:param name: Descriptive name of the volume type :param name: Descriptive name of the volume type
:rtype: :class:`VolumeType` :rtype: :class:`VolumeType`

View File

@ -21,9 +21,7 @@ def assert_has_keys(dict, required=[], optional=[]):
class FakeClient(object): class FakeClient(object):
def assert_called(self, method, url, body=None, pos=-1, **kwargs): def assert_called(self, method, url, body=None, pos=-1, **kwargs):
""" """Assert than an API method was just called."""
Assert than an API method was just called.
"""
expected = (method, url) expected = (method, url)
called = self.client.callstack[pos][0:2] called = self.client.callstack[pos][0:2]
@ -37,9 +35,7 @@ class FakeClient(object):
assert self.client.callstack[pos][2] == body assert self.client.callstack[pos][2] == body
def assert_called_anytime(self, method, url, body=None): def assert_called_anytime(self, method, url, body=None):
""" """Assert than an API method was called anytime in the test."""
Assert than an API method was called anytime in the test.
"""
expected = (method, url) expected = (method, url)
assert self.client.callstack, ("Expected %s %s but no calls " assert self.client.callstack, ("Expected %s %s but no calls "

View File

@ -23,8 +23,11 @@ class TestCase(testtools.TestCase):
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 """
Class used to wrap requests.Response and provide some
convenience to initialize with a dict.
"""
def __init__(self, data): def __init__(self, data):
self._text = None self._text = None

View File

@ -46,7 +46,8 @@ def check_python_version():
def run_command_with_code(cmd, redirect_output=True, check_exit_code=True): def run_command_with_code(cmd, redirect_output=True, check_exit_code=True):
""" """Runs a command in an out-of-process shell.
Runs a command in an out-of-process shell, returning the Runs a command in an out-of-process shell, returning the
output of that command. Working directory is ROOT. output of that command. Working directory is ROOT.
""" """
@ -91,7 +92,8 @@ class Distro(object):
"""Any distribution-specific post-processing gets done here. """Any distribution-specific post-processing gets done here.
In particular, this is useful for applying patches to code inside In particular, this is useful for applying patches to code inside
the venv.""" the venv.
"""
pass pass
@ -121,7 +123,8 @@ class Debian(Distro):
class Fedora(Distro): class Fedora(Distro):
"""This covers all Fedora-based distributions. """This covers all Fedora-based distributions.
Includes: Fedora, RHEL, CentOS, Scientific Linux""" Includes: Fedora, RHEL, CentOS, Scientific Linux.
"""
def check_pkg(self, pkg): def check_pkg(self, pkg):
return run_command_with_code(['rpm', '-q', pkg], return run_command_with_code(['rpm', '-q', pkg],
@ -223,7 +226,7 @@ def print_help():
def parse_args(): def parse_args():
"""Parse command-line arguments""" """Parse command-line arguments."""
parser = optparse.OptionParser() parser = optparse.OptionParser()
parser.add_option("-n", "--no-site-packages", dest="no_site_packages", parser.add_option("-n", "--no-site-packages", dest="no_site_packages",
default=False, action="store_true", default=False, action="store_true",

View File

@ -28,6 +28,6 @@ commands = python setup.py testr --coverage --testr-args='{posargs}'
downloadcache = ~/cache/pip downloadcache = ~/cache/pip
[flake8] [flake8]
ignore = E12,H102,H23,H30,H40,H501,F811,F821 ignore = E12,H102,H23,H30,H501,F811,F821
builtins = _ builtins = _
exclude = .venv,.tox,dist,doc,openstack,*egg exclude = .venv,.tox,dist,doc,openstack,*egg