Fix pep H402 and H401 errors

This is an effort to get the pep ignores to be closer to nova.

Change-Id: I451df579bbead00a8ff2c301c1a84e7c0a896002
This commit is contained in:
Angus Salkeld
2013-05-20 12:52:58 +10:00
parent b324ccc37b
commit ae142c0ffe
9 changed files with 36 additions and 45 deletions

View File

@@ -29,9 +29,8 @@ except NameError:
def getid(obj): def getid(obj):
""" """Abstracts the common pattern of allowing both an object or an
Abstracts the common pattern of allowing both an object or an object's ID object's ID (UUID) as a parameter when dealing with relationships.
(UUID) as a parameter when dealing with relationships.
""" """
try: try:
return obj.id return obj.id
@@ -40,9 +39,8 @@ def getid(obj):
class Manager(object): class Manager(object):
""" """Managers interact with a particular type of API
Managers interact with a particular type of API (servers, flavors, images, (samples, meters, alarms, etc.) and provide CRUD operations for them.
etc.) and provide CRUD operations for them.
""" """
resource_class = None resource_class = None
@@ -78,8 +76,7 @@ class Manager(object):
class Resource(object): class Resource(object):
""" """A resource represents a particular instance of an object (tenant, user,
A resource represents a particular instance of an object (tenant, user,
etc). This is pretty much just a bag for attributes. etc). This is pretty much just a bag for attributes.
:param manager: Manager object :param manager: Manager object

View File

@@ -124,7 +124,7 @@ class HTTPClient(object):
return '%s/%s' % (base_url.rstrip('/'), url.lstrip('/')) return '%s/%s' % (base_url.rstrip('/'), url.lstrip('/'))
def _http_request(self, url, method, **kwargs): def _http_request(self, url, method, **kwargs):
""" Send an http request with the specified characteristics. """Send an http request with the specified characteristics.
Wrapper around httplib.HTTP(S)Connection.request to handle tasks such Wrapper around httplib.HTTP(S)Connection.request to handle tasks such
as setting headers and error handling. as setting headers and error handling.
@@ -224,8 +224,7 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
self.insecure = insecure self.insecure = insecure
def connect(self): def connect(self):
""" """Connect to a host on a given (SSL) port.
Connect to a host on a given (SSL) port.
If ca_file is pointing somewhere, use it to check Server Certificate. If ca_file is pointing somewhere, use it to check Server Certificate.
Redefined/copied and extended from httplib.py:1105 (Python 2.6.x). Redefined/copied and extended from httplib.py:1105 (Python 2.6.x).
@@ -253,7 +252,7 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
@staticmethod @staticmethod
def get_system_ca_file(): def get_system_ca_file():
""""Return path to system default CA file""" """Return path to system default CA file."""
# Standard CA file locations for Debian/Ubuntu, RedHat/Fedora, # Standard CA file locations for Debian/Ubuntu, RedHat/Fedora,
# Suse, FreeBSD/OpenBSD # Suse, FreeBSD/OpenBSD
ca_path = ['/etc/ssl/certs/ca-certificates.crt', ca_path = ['/etc/ssl/certs/ca-certificates.crt',

View File

@@ -23,7 +23,7 @@ class BaseException(Exception):
class CommandError(BaseException): class CommandError(BaseException):
"""Invalid usage of CLI""" """Invalid usage of CLI."""
class InvalidEndpoint(BaseException): class InvalidEndpoint(BaseException):
@@ -35,11 +35,11 @@ class CommunicationError(BaseException):
class ClientException(Exception): class ClientException(Exception):
"""DEPRECATED""" """DEPRECATED."""
class HTTPException(ClientException): class HTTPException(ClientException):
"""Base exception for all HTTP-derived exceptions""" """Base exception for all HTTP-derived exceptions."""
code = 'N/A' code = 'N/A'
def __init__(self, details=None): def __init__(self, details=None):
@@ -60,7 +60,7 @@ class HTTPMultipleChoices(HTTPException):
class BadRequest(HTTPException): class BadRequest(HTTPException):
"""DEPRECATED""" """DEPRECATED."""
code = 400 code = 400
@@ -69,7 +69,7 @@ class HTTPBadRequest(BadRequest):
class Unauthorized(HTTPException): class Unauthorized(HTTPException):
"""DEPRECATED""" """DEPRECATED."""
code = 401 code = 401
@@ -78,7 +78,7 @@ class HTTPUnauthorized(Unauthorized):
class Forbidden(HTTPException): class Forbidden(HTTPException):
"""DEPRECATED""" """DEPRECATED."""
code = 403 code = 403
@@ -87,7 +87,7 @@ class HTTPForbidden(Forbidden):
class NotFound(HTTPException): class NotFound(HTTPException):
"""DEPRECATED""" """DEPRECATED."""
code = 404 code = 404
@@ -100,7 +100,7 @@ class HTTPMethodNotAllowed(HTTPException):
class Conflict(HTTPException): class Conflict(HTTPException):
"""DEPRECATED""" """DEPRECATED."""
code = 409 code = 409
@@ -109,7 +109,7 @@ class HTTPConflict(Conflict):
class OverLimit(HTTPException): class OverLimit(HTTPException):
"""DEPRECATED""" """DEPRECATED."""
code = 413 code = 413
@@ -130,7 +130,7 @@ class HTTPBadGateway(HTTPException):
class ServiceUnavailable(HTTPException): class ServiceUnavailable(HTTPException):
"""DEPRECATED""" """DEPRECATED."""
code = 503 code = 503
@@ -154,10 +154,10 @@ def from_response(response):
class NoTokenLookupException(Exception): class NoTokenLookupException(Exception):
"""DEPRECATED""" """DEPRECATED."""
pass pass
class EndpointNotFound(Exception): class EndpointNotFound(Exception):
"""DEPRECATED""" """DEPRECATED."""
pass pass

View File

@@ -313,9 +313,7 @@ class CeilometerShell(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 getattr(args, 'command', None): if getattr(args, 'command', None):
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

@@ -28,7 +28,7 @@ class Client(http.HTTPClient):
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" Initialize a new client for the Ceilometer v1 API. """ """Initialize a new client for the Ceilometer v1 API."""
super(Client, self).__init__(*args, **kwargs) super(Client, self).__init__(*args, **kwargs)
self.meters = meters.MeterManager(self) self.meters = meters.MeterManager(self)
self.samples = meters.SampleManager(self) self.samples = meters.SampleManager(self)

View File

@@ -36,7 +36,7 @@ import ceilometerclient.exc as exc
help='ISO date in UTC which limits events by ' help='ISO date in UTC which limits events by '
'timestamp <= this value') 'timestamp <= this value')
def do_sample_list(cc, args): def do_sample_list(cc, args):
'''List the samples for this meters''' '''List the samples for this meters.'''
fields = {'counter_name': args.counter_name, fields = {'counter_name': args.counter_name,
'resource_id': args.resource_id, 'resource_id': args.resource_id,
'user_id': args.user_id, 'user_id': args.user_id,
@@ -84,7 +84,7 @@ def do_meter_list(cc, args={}):
@utils.arg('-s', '--source', metavar='<SOURCE>', @utils.arg('-s', '--source', metavar='<SOURCE>',
help='ID of the resource to show projects for.') help='ID of the resource to show projects for.')
def do_user_list(cc, args={}): def do_user_list(cc, args={}):
'''List the users''' '''List the users.'''
kwargs = {'source': args.source} kwargs = {'source': args.source}
users = cc.users.list(**kwargs) users = cc.users.list(**kwargs)
field_labels = ['User ID'] field_labels = ['User ID']
@@ -108,7 +108,7 @@ def do_user_list(cc, args={}):
help='ISO date in UTC which limits resouces by ' help='ISO date in UTC which limits resouces by '
'last update time <= this value') 'last update time <= this value')
def do_resource_list(cc, args={}): def do_resource_list(cc, args={}):
'''List the resources''' '''List the resources.'''
kwargs = {'source': args.source, kwargs = {'source': args.source,
'user_id': args.user_id, 'user_id': args.user_id,
'project_id': args.project_id, 'project_id': args.project_id,
@@ -126,7 +126,7 @@ def do_resource_list(cc, args={}):
@utils.arg('-s', '--source', metavar='<SOURCE>', @utils.arg('-s', '--source', metavar='<SOURCE>',
help='ID of the resource to show projects for.') help='ID of the resource to show projects for.')
def do_project_list(cc, args={}): def do_project_list(cc, args={}):
'''List the projects''' '''List the projects.'''
kwargs = {'source': args.source} kwargs = {'source': args.source}
projects = cc.projects.list(**kwargs) projects = cc.projects.list(**kwargs)

View File

@@ -32,7 +32,7 @@ class Client(http.HTTPClient):
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" Initialize a new client for the Ceilometer v1 API. """ """Initialize a new client for the Ceilometer v1 API."""
super(Client, self).__init__(*args, **kwargs) super(Client, self).__init__(*args, **kwargs)
self.meters = meters.MeterManager(self) self.meters = meters.MeterManager(self)
self.samples = samples.SampleManager(self) self.samples = samples.SampleManager(self)

View File

@@ -16,9 +16,7 @@ import urllib
def build_url(path, q): def build_url(path, q):
''' '''This converts from a list of dict's to what the rest api needs so from:
This converts from a list of dict's to what the rest api needs
so from:
"[{field=this,op=le,value=34},{field=that,op=eq,value=foo}]" "[{field=this,op=le,value=34},{field=that,op=eq,value=foo}]"
to: to:
"?q.field=this&q.op=le&q.value=34& "?q.field=this&q.op=le&q.value=34&
@@ -39,8 +37,7 @@ def build_url(path, q):
def cli_to_array(cli_query): def cli_to_array(cli_query):
''' '''This converts from the cli list of queries to what is required
This converts from the cli list of queries to what is required
by the python api. by the python api.
so from: so from:
"this<=34;that=foo" "this<=34;that=foo"

View File

@@ -26,7 +26,7 @@ import ceilometerclient.exc as exc
@utils.arg('-m', '--meter', metavar='<NAME>', @utils.arg('-m', '--meter', metavar='<NAME>',
help='Name of meter to show samples for.') help='Name of meter to show samples for.')
def do_statistics(cc, args): def do_statistics(cc, args):
'''List the statistics for this meters''' '''List the statistics for this meters.'''
fields = {'meter_name': args.meter, fields = {'meter_name': args.meter,
'q': options.cli_to_array(args.query)} 'q': options.cli_to_array(args.query)}
if args.meter is None: if args.meter is None:
@@ -50,7 +50,7 @@ def do_statistics(cc, args):
@utils.arg('-m', '--meter', metavar='<NAME>', @utils.arg('-m', '--meter', metavar='<NAME>',
help='Name of meter to show samples for.') help='Name of meter to show samples for.')
def do_sample_list(cc, args): def do_sample_list(cc, args):
'''List the samples for this meters''' '''List the samples for this meters.'''
fields = {'meter_name': args.meter, fields = {'meter_name': args.meter,
'q': options.cli_to_array(args.query)} 'q': options.cli_to_array(args.query)}
if args.meter is None: if args.meter is None:
@@ -71,7 +71,7 @@ def do_sample_list(cc, args):
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
help='key[op]value; list.') help='key[op]value; list.')
def do_meter_list(cc, args={}): def do_meter_list(cc, args={}):
'''List the user's meters''' '''List the user's meters.'''
meters = cc.meters.list(q=options.cli_to_array(args.query)) meters = cc.meters.list(q=options.cli_to_array(args.query))
field_labels = ['Name', 'Type', 'Unit', 'Resource ID', 'User ID', field_labels = ['Name', 'Type', 'Unit', 'Resource ID', 'User ID',
'Project ID'] 'Project ID']
@@ -84,7 +84,7 @@ def do_meter_list(cc, args={}):
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
help='key[op]value; list.') help='key[op]value; list.')
def do_alarm_list(cc, args={}): def do_alarm_list(cc, args={}):
'''List the user's alarms''' '''List the user's alarms.'''
alarms = cc.alarms.list(q=options.cli_to_array(args.query)) alarms = cc.alarms.list(q=options.cli_to_array(args.query))
# omit action initially to keep output width sane # omit action initially to keep output width sane
# (can switch over to vertical formatting when available from CLIFF) # (can switch over to vertical formatting when available from CLIFF)
@@ -101,7 +101,7 @@ def do_alarm_list(cc, args={}):
@utils.arg('-a', '--alarm_id', metavar='<ALARM_ID>', @utils.arg('-a', '--alarm_id', metavar='<ALARM_ID>',
help='ID of the alarm to show.') help='ID of the alarm to show.')
def do_alarm_show(cc, args={}): def do_alarm_show(cc, args={}):
'''Show an alarm''' '''Show an alarm.'''
if args.alarm_id is None: if args.alarm_id is None:
raise exc.CommandError('Alarm ID not provided (-a <alarm id>)') raise exc.CommandError('Alarm ID not provided (-a <alarm id>)')
try: try:
@@ -120,7 +120,7 @@ def do_alarm_show(cc, args={}):
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
help='key[op]value; list.') help='key[op]value; list.')
def do_resource_list(cc, args={}): def do_resource_list(cc, args={}):
'''List the resources''' '''List the resources.'''
resources = cc.resources.list(q=options.cli_to_array(args.query)) resources = cc.resources.list(q=options.cli_to_array(args.query))
field_labels = ['Resource ID', 'Source', 'User ID', 'Project ID'] field_labels = ['Resource ID', 'Source', 'User ID', 'Project ID']
@@ -132,7 +132,7 @@ def do_resource_list(cc, args={}):
@utils.arg('-r', '--resource_id', metavar='<RESOURCE_ID>', @utils.arg('-r', '--resource_id', metavar='<RESOURCE_ID>',
help='ID of the resource to show.') help='ID of the resource to show.')
def do_resource_show(cc, args={}): def do_resource_show(cc, args={}):
'''Show the resource''' '''Show the resource.'''
if args.resource_id is None: if args.resource_id is None:
raise exc.CommandError('Resource id not provided (-r <resource id>)') raise exc.CommandError('Resource id not provided (-r <resource id>)')
try: try: