Merge "Docstrings formatted according to pep257"

This commit is contained in:
Jenkins 2013-05-17 14:10:37 +00:00 committed by Gerrit Code Review
commit 99a28085b7
6 changed files with 83 additions and 81 deletions

View File

@ -39,7 +39,8 @@ class ContextBase(common_context.RequestContext):
def __init__(self, user_id, tenant_id, is_admin=None, read_deleted="no", def __init__(self, user_id, tenant_id, is_admin=None, read_deleted="no",
roles=None, timestamp=None, **kwargs): roles=None, timestamp=None, **kwargs):
""" """Object initialization.
:param read_deleted: 'no' indicates deleted records are hidden, 'yes' :param read_deleted: 'no' indicates deleted records are hidden, 'yes'
indicates deleted records are visible, 'only' indicates that indicates deleted records are visible, 'only' indicates that
*only* deleted records are visible. *only* deleted records are visible.

View File

@ -60,7 +60,8 @@ class Manager(periodic_task.PeriodicTasks):
class QuantumManager(object): class QuantumManager(object):
""" """Quantum's Manager class.
Quantum's Manager class is responsible for parsing a config file and Quantum's Manager class is responsible for parsing a config file and
instantiating the correct plugin that concretely implement instantiating the correct plugin that concretely implement
quantum_plugin_base class. quantum_plugin_base class.

View File

@ -32,7 +32,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def create_subnet(self, context, subnet): def create_subnet(self, context, subnet):
""" """Create a subnet.
Create a subnet, which represents a range of IP addresses Create a subnet, which represents a range of IP addresses
that can be allocated to devices that can be allocated to devices
: param context: quantum api request context : param context: quantum api request context
@ -44,8 +45,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def update_subnet(self, context, id, subnet): def update_subnet(self, context, id, subnet):
""" """Update values of a subnet.
Update values of a subnet.
: param context: quantum api request context : param context: quantum api request context
: param id: UUID representing the subnet to update. : param id: UUID representing the subnet to update.
: param subnet: dictionary with keys indicating fields to update. : param subnet: dictionary with keys indicating fields to update.
@ -57,8 +58,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def get_subnet(self, context, id, fields=None): def get_subnet(self, context, id, fields=None):
""" """Retrieve a subnet.
Retrieve a subnet.
: param context: quantum api request context : param context: quantum api request context
: param id: UUID representing the subnet to fetch. : param id: UUID representing the subnet to fetch.
: param fields: a list of strings that are valid keys in a : param fields: a list of strings that are valid keys in a
@ -71,8 +72,9 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def get_subnets(self, context, filters=None, fields=None, def get_subnets(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None, page_reverse=False): sorts=None, limit=None, marker=None, page_reverse=False):
""" """Retrieve a list of subnets.
Retrieve a list of subnets. The contents of the list depends on
The contents of the list depends on
the identity of the user making the request (as indicated by the the identity of the user making the request (as indicated by the
context) as well as any filters. context) as well as any filters.
: param context: quantum api request context : param context: quantum api request context
@ -91,8 +93,9 @@ class QuantumPluginBaseV2(object):
pass pass
def get_subnets_count(self, context, filters=None): def get_subnets_count(self, context, filters=None):
""" """Return the number of subnets.
Return the number of subnets. The result depends on the identity of
The result depends on the identity of
the user making the request (as indicated by the context) as well as the user making the request (as indicated by the context) as well as
any filters. any filters.
: param context: quantum api request context : param context: quantum api request context
@ -111,8 +114,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def delete_subnet(self, context, id): def delete_subnet(self, context, id):
""" """Delete a subnet.
Delete a subnet.
: param context: quantum api request context : param context: quantum api request context
: param id: UUID representing the subnet to delete. : param id: UUID representing the subnet to delete.
""" """
@ -120,7 +123,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def create_network(self, context, network): def create_network(self, context, network):
""" """Create a network.
Create a network, which represents an L2 network segment which Create a network, which represents an L2 network segment which
can have a set of subnets and ports associated with it. can have a set of subnets and ports associated with it.
: param context: quantum api request context : param context: quantum api request context
@ -132,8 +136,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def update_network(self, context, id, network): def update_network(self, context, id, network):
""" """Update values of a network.
Update values of a network.
: param context: quantum api request context : param context: quantum api request context
: param id: UUID representing the network to update. : param id: UUID representing the network to update.
: param network: dictionary with keys indicating fields to update. : param network: dictionary with keys indicating fields to update.
@ -145,8 +149,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def get_network(self, context, id, fields=None): def get_network(self, context, id, fields=None):
""" """Retrieve a network.
Retrieve a network.
: param context: quantum api request context : param context: quantum api request context
: param id: UUID representing the network to fetch. : param id: UUID representing the network to fetch.
: param fields: a list of strings that are valid keys in a : param fields: a list of strings that are valid keys in a
@ -159,8 +163,9 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def get_networks(self, context, filters=None, fields=None, def get_networks(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None, page_reverse=False): sorts=None, limit=None, marker=None, page_reverse=False):
""" """Retrieve a list of networks.
Retrieve a list of networks. The contents of the list depends on
The contents of the list depends on
the identity of the user making the request (as indicated by the the identity of the user making the request (as indicated by the
context) as well as any filters. context) as well as any filters.
: param context: quantum api request context : param context: quantum api request context
@ -179,8 +184,9 @@ class QuantumPluginBaseV2(object):
pass pass
def get_networks_count(self, context, filters=None): def get_networks_count(self, context, filters=None):
""" """Return the number of networks.
Return the number of networks. The result depends on the identity
The result depends on the identity
of the user making the request (as indicated by the context) as well of the user making the request (as indicated by the context) as well
as any filters. as any filters.
: param context: quantum api request context : param context: quantum api request context
@ -199,8 +205,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def delete_network(self, context, id): def delete_network(self, context, id):
""" """Delete a network.
Delete a network.
: param context: quantum api request context : param context: quantum api request context
: param id: UUID representing the network to delete. : param id: UUID representing the network to delete.
""" """
@ -208,7 +214,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def create_port(self, context, port): def create_port(self, context, port):
""" """Create a port.
Create a port, which is a connection point of a device (e.g., a VM Create a port, which is a connection point of a device (e.g., a VM
NIC) to attach to a L2 Quantum network. NIC) to attach to a L2 Quantum network.
: param context: quantum api request context : param context: quantum api request context
@ -220,8 +227,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def update_port(self, context, id, port): def update_port(self, context, id, port):
""" """Update values of a port.
Update values of a port.
: param context: quantum api request context : param context: quantum api request context
: param id: UUID representing the port to update. : param id: UUID representing the port to update.
: param port: dictionary with keys indicating fields to update. : param port: dictionary with keys indicating fields to update.
@ -233,8 +240,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def get_port(self, context, id, fields=None): def get_port(self, context, id, fields=None):
""" """Retrieve a port.
Retrieve a port.
: param context: quantum api request context : param context: quantum api request context
: param id: UUID representing the port to fetch. : param id: UUID representing the port to fetch.
: param fields: a list of strings that are valid keys in a : param fields: a list of strings that are valid keys in a
@ -247,10 +254,10 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def get_ports(self, context, filters=None, fields=None, def get_ports(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None, page_reverse=False): sorts=None, limit=None, marker=None, page_reverse=False):
""" """Retrieve a list of ports.
Retrieve a list of ports. The contents of the list depends on
the identity of the user making the request (as indicated by the The contents of the list depends on the identity of the user making
context) as well as any filters. the request (as indicated by the context) as well as any filters.
: param context: quantum api request context : param context: quantum api request context
: param filters: a dictionary with keys that are valid keys for : param filters: a dictionary with keys that are valid keys for
a port as listed in the RESOURCE_ATTRIBUTE_MAP object a port as listed in the RESOURCE_ATTRIBUTE_MAP object
@ -267,10 +274,10 @@ class QuantumPluginBaseV2(object):
pass pass
def get_ports_count(self, context, filters=None): def get_ports_count(self, context, filters=None):
""" """Return the number of ports.
Return the number of ports. The result depends on the identity of
the user making the request (as indicated by the context) as well as The result depends on the identity of the user making the request
any filters. (as indicated by the context) as well as any filters.
: param context: quantum api request context : param context: quantum api request context
: param filters: a dictionary with keys that are valid keys for : param filters: a dictionary with keys that are valid keys for
a network as listed in the RESOURCE_ATTRIBUTE_MAP object a network as listed in the RESOURCE_ATTRIBUTE_MAP object
@ -287,8 +294,8 @@ class QuantumPluginBaseV2(object):
@abstractmethod @abstractmethod
def delete_port(self, context, id): def delete_port(self, context, id):
""" """Delete a port.
Delete a port.
: param context: quantum api request context : param context: quantum api request context
: param id: UUID representing the port to delete. : param id: UUID representing the port to delete.
""" """

View File

@ -54,14 +54,16 @@ cfg.CONF.register_opts(quota_opts, 'QUOTAS')
class ConfDriver(object): class ConfDriver(object):
""" """Configuration driver.
Driver to perform necessary checks to enforce quotas and obtain Driver to perform necessary checks to enforce quotas and obtain
quota information. The default driver utilizes the default values quota information. The default driver utilizes the default values
in quantum.conf. in quantum.conf.
""" """
def _get_quotas(self, context, resources, keys): def _get_quotas(self, context, resources, keys):
""" """Get quotas.
A helper method which retrieves the quotas for the specific A helper method which retrieves the quotas for the specific
resources identified by keys, and which apply to the current resources identified by keys, and which apply to the current
context. context.
@ -150,8 +152,7 @@ class BaseResource(object):
"""Describe a single resource for quota checking.""" """Describe a single resource for quota checking."""
def __init__(self, name, flag): def __init__(self, name, flag):
""" """Initializes a resource.
Initializes a Resource.
:param name: The name of the resource, i.e., "instances". :param name: The name of the resource, i.e., "instances".
:param flag: The name of the flag or configuration option :param flag: The name of the flag or configuration option
@ -169,8 +170,7 @@ class BaseResource(object):
class CountableResource(BaseResource): class CountableResource(BaseResource):
"""Describe a resource where the counts are determined by a function. """Describe a resource where the counts are determined by a function."""
"""
def __init__(self, name, count, flag=None): def __init__(self, name, count, flag=None):
"""Initializes a CountableResource. """Initializes a CountableResource.

View File

@ -31,10 +31,7 @@ class NoFilterMatched(Exception):
class FilterMatchNotExecutable(Exception): class FilterMatchNotExecutable(Exception):
""" """Raised when a filter matched but no executable was found."""
This exception is raised when a filter matched but no executable was
found.
"""
def __init__(self, match=None, **kwargs): def __init__(self, match=None, **kwargs):
self.match = match self.match = match
@ -122,7 +119,8 @@ def load_filters(filters_path):
def match_filter(filter_list, userargs, exec_dirs=[]): def match_filter(filter_list, userargs, exec_dirs=[]):
""" """Return first matched filter from command filters.
Checks user command and arguments through command filters and Checks user command and arguments through command filters and
returns the first matching filter. returns the first matching filter.
Raises NoFilterMatched if no filter matched. Raises NoFilterMatched if no filter matched.

View File

@ -202,11 +202,11 @@ class Server(object):
class Middleware(object): class Middleware(object):
""" """Base WSGI middleware wrapper.
Base WSGI middleware wrapper. These classes require an application to be
initialized that will be called next. By default the middleware will These classes require an application to be initialized that will be called
simply call its wrapped app, or you can override __call__ to customize its next. By default the middleware will simply call its wrapped app, or you
behavior. can override __call__ to customize its behavior.
""" """
@classmethod @classmethod
@ -240,8 +240,7 @@ class Middleware(object):
self.application = application self.application = application
def process_request(self, req): def process_request(self, req):
""" """Called on each request.
Called on each request.
If this returns None, the next application down the stack will be If this returns None, the next application down the stack will be
executed. If it returns a response then that response will be returned executed. If it returns a response then that response will be returned
@ -342,7 +341,8 @@ class JSONDictSerializer(DictSerializer):
class XMLDictSerializer(DictSerializer): class XMLDictSerializer(DictSerializer):
def __init__(self, metadata=None, xmlns=None): def __init__(self, metadata=None, xmlns=None):
""" """Object initialization.
:param metadata: information needed to deserialize xml into :param metadata: information needed to deserialize xml into
a dictionary. a dictionary.
:param xmlns: XML namespace to include with serialized xml :param xmlns: XML namespace to include with serialized xml
@ -356,7 +356,8 @@ class XMLDictSerializer(DictSerializer):
self.xmlns = xmlns self.xmlns = xmlns
def default(self, data): def default(self, data):
""" """Return data as XML string.
:param data: expect data to contain a single key as XML root, or :param data: expect data to contain a single key as XML root, or
contain another '*_links' key as atom links. Other contain another '*_links' key as atom links. Other
case will use 'VIRTUAL_ROOT_KEY' as XML root. case will use 'VIRTUAL_ROOT_KEY' as XML root.
@ -571,7 +572,8 @@ class ProtectedXMLParser(etree.XMLParser):
class XMLDeserializer(TextDeserializer): class XMLDeserializer(TextDeserializer):
def __init__(self, metadata=None): def __init__(self, metadata=None):
""" """Object initialization.
:param metadata: information needed to deserialize xml into :param metadata: information needed to deserialize xml into
a dictionary. a dictionary.
""" """
@ -865,7 +867,8 @@ class Application(object):
class Debug(Middleware): class Debug(Middleware):
""" """Middleware for debugging.
Helper class that can be inserted into any WSGI application chain Helper class that can be inserted into any WSGI application chain
to get information about the request and response. to get information about the request and response.
""" """
@ -889,10 +892,7 @@ class Debug(Middleware):
@staticmethod @staticmethod
def print_generator(app_iter): def print_generator(app_iter):
""" """Print contents of a wrapper string iterator when iterated."""
Iterator that prints the contents of a wrapper string iterator
when iterated.
"""
print ("*" * 40) + " BODY" print ("*" * 40) + " BODY"
for part in app_iter: for part in app_iter:
sys.stdout.write(part) sys.stdout.write(part)
@ -902,20 +902,15 @@ class Debug(Middleware):
class Router(object): class Router(object):
""" """WSGI middleware that maps incoming requests to WSGI apps."""
WSGI middleware that maps incoming requests to WSGI apps.
"""
@classmethod @classmethod
def factory(cls, global_config, **local_config): def factory(cls, global_config, **local_config):
""" """Return an instance of the WSGI Router class."""
Returns an instance of the WSGI Router class
"""
return cls() return cls()
def __init__(self, mapper): def __init__(self, mapper):
""" """Create a router for the given routes.Mapper.
Create a router for the given routes.Mapper.
Each route in `mapper` must specify a 'controller', which is a Each route in `mapper` must specify a 'controller', which is a
WSGI app to call. You'll probably want to specify an 'action' as WSGI app to call. You'll probably want to specify an 'action' as
@ -943,8 +938,8 @@ class Router(object):
@webob.dec.wsgify @webob.dec.wsgify
def __call__(self, req): def __call__(self, req):
""" """Route the incoming request to a controller based on self.map.
Route the incoming request to a controller based on self.map.
If no match, return a 404. If no match, return a 404.
""" """
return self._router return self._router
@ -952,9 +947,10 @@ class Router(object):
@staticmethod @staticmethod
@webob.dec.wsgify @webob.dec.wsgify
def _dispatch(req): def _dispatch(req):
""" """Dispatch a Request.
Called by self._router after matching the incoming request to a route Called by self._router after matching the incoming request to a route
and putting the information into req.environ. Either returns 404 and putting the information into req.environ. Either returns 404
or the routed WSGI app's response. or the routed WSGI app's response.
""" """
match = req.environ['wsgiorg.routing_args'][1] match = req.environ['wsgiorg.routing_args'][1]
@ -979,7 +975,8 @@ class Resource(Application):
def __init__(self, controller, fault_body_function, def __init__(self, controller, fault_body_function,
deserializer=None, serializer=None): deserializer=None, serializer=None):
""" """Object initialization.
:param controller: object that implement methods created by routes lib :param controller: object that implement methods created by routes lib
:param deserializer: object that can serialize the output of a :param deserializer: object that can serialize the output of a
controller into a webob response controller into a webob response
@ -1118,9 +1115,7 @@ class Controller(object):
@webob.dec.wsgify(RequestClass=Request) @webob.dec.wsgify(RequestClass=Request)
def __call__(self, req): def __call__(self, req):
""" """Call the method specified in req.environ by RoutesMiddleware."""
Call the method specified in req.environ by RoutesMiddleware.
"""
arg_dict = req.environ['wsgiorg.routing_args'][1] arg_dict = req.environ['wsgiorg.routing_args'][1]
action = arg_dict['action'] action = arg_dict['action']
method = getattr(self, action) method = getattr(self, action)