diff options
author | Peter Portante <peter.portante@redhat.com> | 2012-10-22 13:59:31 -0400 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2012-10-30 09:46:02 -0700 |
commit | 5c272f4d1c4ae67a3cf5a6af17518c82f520c1de (patch) | |
tree | 72aad852f80b96b33661a4b3053cce6b3d0dc8ed /swift | |
parent | 232adb88512274863c9f5ad51569695af80bd6c0 (diff) |
Minor refactorings to mark an internal routine
Just a couple of changes to mark a routine as internal to this module (leading
underscore, helps understand what is part of the utils API and what is not),
and use of the positional argument for memcache for consistency and reduction
in line count (doing this ahead of another refactoring to keep changes
concise).
Change-Id: I71581ad6ac4c383b1de787b767be568fc0a87eef
Signed-off-by: Peter Portante <peter.portante@redhat.com>
Reviewed-on: http://review.gluster.org/4138
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Mohammed Junaid <junaid@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'swift')
-rw-r--r-- | swift/1.4.8/plugins/utils.py | 9 | ||||
-rw-r--r-- | swift/1.4.8/test/unit/plugins/test_utils.py | 8 |
2 files changed, 8 insertions, 9 deletions
diff --git a/swift/1.4.8/plugins/utils.py b/swift/1.4.8/plugins/utils.py index a25cbc3b8..1e666d709 100644 --- a/swift/1.4.8/plugins/utils.py +++ b/swift/1.4.8/plugins/utils.py @@ -481,7 +481,7 @@ def get_container_details(cont_path, memcache=None): """ if memcache: object_list, object_count, bytes_used = get_container_details_from_memcache(cont_path, cont_path, - memcache=memcache) + memcache) else: object_list, object_count, bytes_used = get_container_details_from_fs(cont_path, cont_path) @@ -524,7 +524,7 @@ def get_account_details(acc_path, memcache=None): else: return get_account_details_from_fs(acc_path, memcache) -def get_etag(path): +def _get_etag(path): etag = md5() with open(path, 'rb') as fp: while True: @@ -553,7 +553,7 @@ def get_object_metadata(obj_path): X_CONTENT_TYPE: DIR_TYPE if is_dir else FILE_TYPE, X_OBJECT_TYPE: DIR if is_dir else FILE, X_CONTENT_LENGTH: 0 if is_dir else stats.st_size, - X_ETAG: md5().hexdigest() if is_dir else get_etag(obj_path), + X_ETAG: md5().hexdigest() if is_dir else _get_etag(obj_path), } return metadata @@ -573,8 +573,7 @@ def get_container_metadata(cont_path, memcache=None): objects = [] object_count = 0 bytes_used = 0 - objects, object_count, bytes_used = get_container_details(cont_path, - memcache=memcache) + objects, object_count, bytes_used = get_container_details(cont_path, memcache) metadata = {X_TYPE: CONTAINER, X_TIMESTAMP: normalize_timestamp(os.path.getctime(cont_path)), X_PUT_TIMESTAMP: normalize_timestamp(os.path.getmtime(cont_path)), diff --git a/swift/1.4.8/test/unit/plugins/test_utils.py b/swift/1.4.8/test/unit/plugins/test_utils.py index 70081a7d2..0731c7865 100644 --- a/swift/1.4.8/test/unit/plugins/test_utils.py +++ b/swift/1.4.8/test/unit/plugins/test_utils.py @@ -291,14 +291,14 @@ class TestUtils(unittest.TestCase): def test_get_etag_empty(self): tf = tempfile.NamedTemporaryFile() - hd = utils.get_etag(tf.name) + hd = utils._get_etag(tf.name) assert hd == hashlib.md5().hexdigest() def test_get_etag(self): tf = tempfile.NamedTemporaryFile() tf.file.write('123' * utils.CHUNK_SIZE) tf.file.flush() - hd = utils.get_etag(tf.name) + hd = utils._get_etag(tf.name) tf.file.seek(0) md5 = hashlib.md5() while True: @@ -335,7 +335,7 @@ class TestUtils(unittest.TestCase): assert md[utils.X_CONTENT_TYPE] == utils.FILE_TYPE assert md[utils.X_CONTENT_LENGTH] == os.path.getsize(tf.name) assert md[utils.X_TIMESTAMP] == normalize_timestamp(os.path.getctime(tf.name)) - assert md[utils.X_ETAG] == utils.get_etag(tf.name) + assert md[utils.X_ETAG] == utils._get_etag(tf.name) def test_get_object_metadata_dir(self): td = tempfile.mkdtemp() @@ -372,7 +372,7 @@ class TestUtils(unittest.TestCase): assert md[utils.X_CONTENT_TYPE] == utils.FILE_TYPE assert md[utils.X_CONTENT_LENGTH] == os.path.getsize(tf.name) assert md[utils.X_TIMESTAMP] == normalize_timestamp(os.path.getctime(tf.name)) - assert md[utils.X_ETAG] == utils.get_etag(tf.name) + assert md[utils.X_ETAG] == utils._get_etag(tf.name) def test_create_object_metadata_dir(self): td = tempfile.mkdtemp() |