From 172c4de31d348fa42f074ccb2bbc858e6b63f91a Mon Sep 17 00:00:00 2001 From: Ngo Quoc Cuong Date: Wed, 3 May 2017 16:54:19 +0700 Subject: [PATCH] Trivial fix warnings in docstring Single quoted docstring Params and docstring are inconsistent Change-Id: Ie41bd2960280491f0a5fbd55c6a1aabb328099b8 --- swift/cli/recon.py | 4 ++-- swift/common/memcached.py | 12 ++++++------ swift/common/middleware/crypto/decrypter.py | 4 ++-- swift/common/middleware/ratelimit.py | 8 ++++---- swift/common/utils.py | 20 ++++++++++---------- swift/obj/diskfile.py | 4 ++-- swift/proxy/controllers/base.py | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/swift/cli/recon.py b/swift/cli/recon.py index 346bb30c00..5b65b95204 100644 --- a/swift/cli/recon.py +++ b/swift/cli/recon.py @@ -903,7 +903,7 @@ class SwiftRecon(object): print("=" * 79) def _get_ring_names(self, policy=None): - ''' + """ Retrieve name of ring files. If no policy is passed and the server type is object, @@ -912,7 +912,7 @@ class SwiftRecon(object): :param policy: name or index of storage policy, only applicable with server_type==object. :returns: list of ring names. - ''' + """ if self.server_type == 'object': ring_names = [p.ring_name for p in POLICIES if ( p.name == policy or not policy or ( diff --git a/swift/common/memcached.py b/swift/common/memcached.py index 5f47684c93..5b6145ba1c 100644 --- a/swift/common/memcached.py +++ b/swift/common/memcached.py @@ -239,10 +239,10 @@ class MemcacheRing(object): to memcache, or with pickle if configured to use pickle instead of JSON (to avoid cache poisoning) :param time: the time to live - :min_compress_len: minimum compress length, this parameter was added - to keep the signature compatible with - python-memcached interface. This implementation - ignores it. + :param min_compress_len: minimum compress length, this parameter was + added to keep the signature compatible with + python-memcached interface. This + implementation ignores it. """ key = md5hash(key) timeout = sanitize_timeout(time) @@ -430,8 +430,8 @@ class MemcacheRing(object): Gets multiple values from memcache for the given keys. :param keys: keys for values to be retrieved from memcache - :param servery_key: key to use in determining which server in the ring - is used + :param server_key: key to use in determining which server in the ring + is used :returns: list of values """ server_key = md5hash(server_key) diff --git a/swift/common/middleware/crypto/decrypter.py b/swift/common/middleware/crypto/decrypter.py index 4965122873..7479cf3882 100644 --- a/swift/common/middleware/crypto/decrypter.py +++ b/swift/common/middleware/crypto/decrypter.py @@ -233,7 +233,7 @@ class DecrypterObjContext(BaseDecrypterContext): :param resp: application response :param boundary: multipart boundary string - :param keys: a dict of decryption keys. + :param body_key: a dict of decryption keys. :param crypto_meta: crypto_meta for the response body :return: generator for decrypted response body """ @@ -262,7 +262,7 @@ class DecrypterObjContext(BaseDecrypterContext): Decrypts a response body. :param resp: application response - :param keys: a dict of decryption keys. + :param body_key: a dict of decryption keys. :param crypto_meta: crypto_meta for the response body :param offset: offset into object content at which response body starts :return: generator for decrypted response body diff --git a/swift/common/middleware/ratelimit.py b/swift/common/middleware/ratelimit.py index f688205c5d..8782e9e85b 100644 --- a/swift/common/middleware/ratelimit.py +++ b/swift/common/middleware/ratelimit.py @@ -183,14 +183,14 @@ class RateLimitMiddleware(object): return keys def _get_sleep_time(self, key, max_rate): - ''' + """ Returns the amount of time (a float in seconds) that the app should sleep. :param key: a memcache key :param max_rate: maximum rate allowed in requests per second :raises: MaxSleepTimeHitError if max sleep time is exceeded. - ''' + """ try: now_m = int(round(time.time() * self.clock_accuracy)) time_per_request_m = int(round(self.clock_accuracy / max_rate)) @@ -219,7 +219,7 @@ class RateLimitMiddleware(object): return 0 def handle_ratelimit(self, req, account_name, container_name, obj_name): - ''' + """ Performs rate limiting and account white/black listing. Sleeps if necessary. If self.memcache_client is not set, immediately returns None. @@ -227,7 +227,7 @@ class RateLimitMiddleware(object): :param account_name: account name from path :param container_name: container name from path :param obj_name: object name from path - ''' + """ if not self.memcache_client: return None diff --git a/swift/common/utils.py b/swift/common/utils.py index 2d962e634a..5c50e198f1 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -496,8 +496,8 @@ def get_policy_index(req_headers, res_headers): Returns the appropriate index of the storage policy for the request from a proxy server - :param req: dict of the request headers. - :param res: dict of the response headers. + :param req_headers: dict of the request headers. + :param res_headers: dict of the response headers. :returns: string index of storage policy, or None """ @@ -2574,7 +2574,7 @@ def remove_file(path): def audit_location_generator(devices, datadir, suffix='', mount_check=True, logger=None): - ''' + """ Given a devices path and a data directory, yield (path, device, partition) for all files in that directory @@ -2586,7 +2586,7 @@ def audit_location_generator(devices, datadir, suffix='', :param mount_check: Flag to check if a mount check should be performed on devices :param logger: a logger object - ''' + """ device_dir = listdir(devices) # randomize devices in case of process restart before sweep completed shuffle(device_dir) @@ -2636,7 +2636,7 @@ def audit_location_generator(devices, datadir, suffix='', def ratelimit_sleep(running_time, max_rate, incr_by=1, rate_buffer=5): - ''' + """ Will eventlet.sleep() for the appropriate time so that the max_rate is never exceeded. If max_rate is 0, will not ratelimit. The maximum recommended rate should not exceed (1000 * incr_by) a second @@ -2655,7 +2655,7 @@ def ratelimit_sleep(running_time, max_rate, incr_by=1, rate_buffer=5): A larger number will result in larger spikes in rate but better average accuracy. Must be > 0 to engage rate-limiting behavior. - ''' + """ if max_rate <= 0 or incr_by <= 0: return running_time @@ -2682,7 +2682,7 @@ def ratelimit_sleep(running_time, max_rate, incr_by=1, rate_buffer=5): class ContextPool(GreenPool): - "GreenPool subclassed to kill its coros when it gets gc'ed" + """GreenPool subclassed to kill its coros when it gets gc'ed""" def __enter__(self): return self @@ -2828,7 +2828,7 @@ class StreamingPile(GreenAsyncPile): class ModifiedParseResult(ParseResult): - "Parse results class for urlparse." + """Parse results class for urlparse.""" @property def hostname(self): @@ -2991,7 +2991,7 @@ def affinity_locality_predicate(write_affinity_str): If affinity_str is empty or all whitespace, then the resulting function will consider everything local - :param affinity_str: affinity config value, e.g. "r1z2" + :param write_affinity_str: affinity config value, e.g. "r1z2" or "r1, r2z1, r2z2" :returns: single-argument function, or None if affinity_str is empty :raises: ValueError if argument invalid @@ -3151,7 +3151,7 @@ def pairs(item_list): """ Returns an iterator of all pairs of elements from item_list. - :param items: items (no duplicates allowed) + :param item_list: items (no duplicates allowed) """ for i, item1 in enumerate(item_list): for item2 in item_list[(i + 1):]: diff --git a/swift/obj/diskfile.py b/swift/obj/diskfile.py index aa33b2f05d..18057a87b2 100644 --- a/swift/obj/diskfile.py +++ b/swift/obj/diskfile.py @@ -297,8 +297,8 @@ def consolidate_hashes(partition_dir): Take what's in hashes.pkl and hashes.invalid, combine them, write the result back to hashes.pkl, and clear out hashes.invalid. - :param suffix_dir: absolute path to partition dir containing hashes.pkl - and hashes.invalid + :param partition_dir: absolute path to partition dir containing hashes.pkl + and hashes.invalid :returns: a dict, the suffix hashes (if any), the key 'valid' will be False if hashes.pkl is corrupt, cannot be read or does not exist diff --git a/swift/proxy/controllers/base.py b/swift/proxy/controllers/base.py index feedce445f..bbdb4b4111 100644 --- a/swift/proxy/controllers/base.py +++ b/swift/proxy/controllers/base.py @@ -507,7 +507,7 @@ def set_object_info_cache(app, env, account, container, obj, resp): :param app: the application object :param account: the unquoted account name :param container: the unquoted container name - :param object: the unquoted object name + :param obj: the unquoted object name :param resp: a GET or HEAD response received from an object server, or None if info cache should be cleared :returns: the object info