From ddaa1189f75627f516926b5363398fe7e24fe992 Mon Sep 17 00:00:00 2001 From: Kyle Ellrott Date: Wed, 23 Dec 2015 11:30:18 -0800 Subject: [PATCH 1/3] Adding uuid support to directory_hash_id --- lib/galaxy/util/directory_hash.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/util/directory_hash.py b/lib/galaxy/util/directory_hash.py index 094b0cdf3e4..1bf306db3de 100644 --- a/lib/galaxy/util/directory_hash.py +++ b/lib/galaxy/util/directory_hash.py @@ -1,4 +1,5 @@ +from galaxy.util import is_uuid def directory_hash_id( id ): """ @@ -9,15 +10,21 @@ def directory_hash_id( id ): ['090'] >>> directory_hash_id("777777777") ['000', '777', '777'] + >>> directory_hash_id("135ee48a-4f51-470c-ae2f-ce8bd78799e6") + ['1','3','5'] """ s = str( id ) l = len( s ) # Shortcut -- ids 0-999 go under ../000/ if l < 4: return [ "000" ] - # Pad with zeros until a multiple of three - padded = ( ( 3 - len( s ) % 3 ) * "0" ) + s - # Drop the last three digits -- 1000 files per directory - padded = padded[:-3] - # Break into chunks of three - return [ padded[ i * 3 : (i + 1 ) * 3 ] for i in range( len( padded ) // 3 ) ] + if not is_uuid(s): + # Pad with zeros until a multiple of three + padded = ( ( 3 - len( s ) % 3 ) * "0" ) + s + # Drop the last three digits -- 1000 files per directory + padded = padded[:-3] + # Break into chunks of three + return [ padded[ i * 3 : (i + 1 ) * 3 ] for i in range( len( padded ) // 3 ) ] + else: + #assume it is a UUID + return list(iter(s[0:3])) From 8f34f2a6104ff595d411bfc5e77b488f2c86dfd9 Mon Sep 17 00:00:00 2001 From: Kyle Ellrott Date: Wed, 23 Dec 2015 12:30:20 -0800 Subject: [PATCH 2/3] Fixing issues for PR unit testing and linting --- lib/galaxy/util/directory_hash.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/util/directory_hash.py b/lib/galaxy/util/directory_hash.py index 1bf306db3de..8bfd1babce1 100644 --- a/lib/galaxy/util/directory_hash.py +++ b/lib/galaxy/util/directory_hash.py @@ -11,7 +11,7 @@ def directory_hash_id( id ): >>> directory_hash_id("777777777") ['000', '777', '777'] >>> directory_hash_id("135ee48a-4f51-470c-ae2f-ce8bd78799e6") - ['1','3','5'] + ['1', '3', '5'] """ s = str( id ) l = len( s ) @@ -26,5 +26,5 @@ def directory_hash_id( id ): # Break into chunks of three return [ padded[ i * 3 : (i + 1 ) * 3 ] for i in range( len( padded ) // 3 ) ] else: - #assume it is a UUID + # assume it is a UUID return list(iter(s[0:3])) From 4840a3d8b1caae9666eeebf95d4aeaebaee8260b Mon Sep 17 00:00:00 2001 From: Kyle Ellrott Date: Wed, 23 Dec 2015 16:45:04 -0800 Subject: [PATCH 3/3] Fixing lint problem --- lib/galaxy/util/directory_hash.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/galaxy/util/directory_hash.py b/lib/galaxy/util/directory_hash.py index 8bfd1babce1..303da7535bd 100644 --- a/lib/galaxy/util/directory_hash.py +++ b/lib/galaxy/util/directory_hash.py @@ -1,6 +1,7 @@ from galaxy.util import is_uuid + def directory_hash_id( id ): """