Skip to content

Commit 4fec0fb

Browse files
committed
Adding Bucket.path_helper static method for external use.
This covers callers which want a bucket path but don't want to create a full-flegded Bucket object. See #586 for context.
1 parent 41223d0 commit 4fec0fb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

gcloud/storage/bucket.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,25 @@ def connection(self):
128128
"""
129129
return self._connection
130130

131+
@staticmethod
132+
def path_helper(bucket_name):
133+
"""Relative URL path for a bucket.
134+
135+
:type bucket_name: string
136+
:param bucket_name: The bucket name in the path.
137+
138+
:rtype: string
139+
:returns: The relative URL path for ``bucket_name``.
140+
"""
141+
return '/b/' + bucket_name
142+
131143
@property
132144
def path(self):
133145
"""The URL path to this bucket."""
134146
if not self.name:
135147
raise ValueError('Cannot determine path without bucket name.')
136148

137-
return '/b/' + self.name
149+
return self.path_helper(self.name)
138150

139151
def get_blob(self, blob):
140152
"""Get a blob object by name.

gcloud/storage/connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from gcloud.exceptions import NotFound
2323
from gcloud.storage.bucket import Bucket
2424
from gcloud.storage.iterator import Iterator
25-
import six
2625

2726

2827
class Connection(_Base):
@@ -379,7 +378,7 @@ def delete_bucket(self, bucket_name):
379378
:type bucket_name: string
380379
:param bucket_name: The bucket name to delete.
381380
"""
382-
bucket_path = '/b/' + bucket_name
381+
bucket_path = Bucket.path_helper(bucket_name)
383382
self.api_request(method='DELETE', path=bucket_path)
384383

385384

0 commit comments

Comments
 (0)