From b72141979f8766f411d2fea8fe8856b157bc9b91 Mon Sep 17 00:00:00 2001 From: Yatin Kumbhare Date: Mon, 14 Dec 2015 17:04:34 +0530 Subject: [PATCH] Fixed inconsistencies in docstrings Fixed :returns:, and few one-line comments as per the docstring guide lines. http://docs.openstack.org/developer/hacking/#docstrings Change-Id: I36ecf4faf5b49e070c13eb6324841ebcf442524f --- swift/common/constraints.py | 12 ++++++------ swift/common/internal_client.py | 29 ++++++++++++----------------- swift/common/manager.py | 2 +- swift/common/utils.py | 7 +++---- swift/common/wsgi.py | 4 ++-- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/swift/common/constraints.py b/swift/common/constraints.py index 451e7458bf..985eefe019 100644 --- a/swift/common/constraints.py +++ b/swift/common/constraints.py @@ -174,12 +174,12 @@ def check_object_creation(req, object_name): :param req: HTTP request object :param object_name: name of object to be created - :returns HTTPRequestEntityTooLarge: the object is too large - :returns HTTPLengthRequired: missing content-length header and not - a chunked request - :returns HTTPBadRequest: missing or bad content-type header, or - bad metadata - :returns HTTPNotImplemented: unsupported transfer-encoding header value + :returns: HTTPRequestEntityTooLarge -- the object is too large + :returns: HTTPLengthRequired -- missing content-length header and not + a chunked request + :returns: HTTPBadRequest -- missing or bad content-type header, or + bad metadata + :returns: HTTPNotImplemented -- unsupported transfer-encoding header value """ try: ml = req.message_length() diff --git a/swift/common/internal_client.py b/swift/common/internal_client.py index 7dceda8427..7d08a69d27 100644 --- a/swift/common/internal_client.py +++ b/swift/common/internal_client.py @@ -152,8 +152,7 @@ class InternalClient(object): def make_request( self, method, path, headers, acceptable_statuses, body_file=None): - """ - Makes a request to Swift with retries. + """Makes a request to Swift with retries. :param method: HTTP method of request. :param path: Path of request. @@ -162,7 +161,7 @@ class InternalClient(object): :param body_file: Body file to be passed along with request, defaults to None. - :returns : Response object on success. + :returns: Response object on success. :raises UnexpectedResponse: Exception raised when make_request() fails to get a response with an acceptable status @@ -212,8 +211,8 @@ class InternalClient(object): defaults to (2,). :param headers: extra headers to send - :returns : A dict of metadata with metadata_prefix stripped from keys. - Keys will be lowercase. + :returns: A dict of metadata with metadata_prefix stripped from keys. + Keys will be lowercase. :raises UnexpectedResponse: Exception raised when requests fail to get a response with an acceptable status @@ -366,8 +365,7 @@ class InternalClient(object): def get_account_metadata( self, account, metadata_prefix='', acceptable_statuses=(2,)): - """ - Gets account metadata. + """Gets account metadata. :param account: Account on which to get the metadata. :param metadata_prefix: Used to filter values from the headers @@ -376,7 +374,7 @@ class InternalClient(object): :param acceptable_statuses: List of status for valid responses, defaults to (2,). - :returns : Returns dict of account metadata. Keys will be lowercase. + :returns: Returns dict of account metadata. Keys will be lowercase. :raises UnexpectedResponse: Exception raised when requests fail to get a response with an acceptable status @@ -417,8 +415,7 @@ class InternalClient(object): # container methods def container_exists(self, account, container): - """ - Checks to see if a container exists. + """Checks to see if a container exists. :param account: The container's account. :param container: Container to check. @@ -428,7 +425,7 @@ class InternalClient(object): :raises Exception: Exception is raised when code fails in an unexpected way. - :returns : True if container exists, false otherwise. + :returns: True if container exists, false otherwise. """ path = self.make_path(account, container) @@ -478,8 +475,7 @@ class InternalClient(object): def get_container_metadata( self, account, container, metadata_prefix='', acceptable_statuses=(2,)): - """ - Gets container metadata. + """Gets container metadata. :param account: The container's account. :param container: Container to get metadata on. @@ -489,7 +485,7 @@ class InternalClient(object): :param acceptable_statuses: List of status for valid responses, defaults to (2,). - :returns : Returns dict of container metadata. Keys will be lowercase. + :returns: Returns dict of container metadata. Keys will be lowercase. :raises UnexpectedResponse: Exception raised when requests fail to get a response with an acceptable status @@ -579,8 +575,7 @@ class InternalClient(object): def get_object_metadata( self, account, container, obj, metadata_prefix='', acceptable_statuses=(2,), headers=None): - """ - Gets object metadata. + """Gets object metadata. :param account: The object's account. :param container: The object's container. @@ -592,7 +587,7 @@ class InternalClient(object): defaults to (2,). :param headers: extra headers to send with request - :returns : Dict of object metadata. + :returns: Dict of object metadata. :raises UnexpectedResponse: Exception raised when requests fail to get a response with an acceptable status diff --git a/swift/common/manager.py b/swift/common/manager.py index 03eb0479e9..d4e010caec 100644 --- a/swift/common/manager.py +++ b/swift/common/manager.py @@ -608,7 +608,7 @@ class Server(object): :param wait: boolean, if true capture stdout with a pipe :param daemon: boolean, if false ask server to log to console - :returns : the pid of the spawned process + :returns: the pid of the spawned process """ args = [self.cmd, conf_file] if once: diff --git a/swift/common/utils.py b/swift/common/utils.py index d6cc5d7afb..ceb8fd7816 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -1629,15 +1629,14 @@ def capture_stdio(logger, **kwargs): def parse_options(parser=None, once=False, test_args=None): - """ - Parse standard swift server/daemon options with optparse.OptionParser. + """Parse standard swift server/daemon options with optparse.OptionParser. :param parser: OptionParser to use. If not sent one will be created. :param once: Boolean indicating the "once" option is available :param test_args: Override sys.argv; used in testing - :returns : Tuple of (config, options); config is an absolute path to the - config file, options is the parser options as a dictionary. + :returns: Tuple of (config, options); config is an absolute path to the + config file, options is the parser options as a dictionary. :raises SystemExit: First arg (CONFIG) is required, file must exist """ diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py index 97e704228a..725c826b0b 100644 --- a/swift/common/wsgi.py +++ b/swift/common/wsgi.py @@ -168,8 +168,8 @@ def get_socket(conf): :param conf: Configuration dict to read settings from - :returns : a socket object as returned from socket.listen or - ssl.wrap_socket if conf specifies cert_file + :returns: a socket object as returned from socket.listen or + ssl.wrap_socket if conf specifies cert_file """ try: bind_port = int(conf['bind_port'])