Skip to content

Commit 5697f1a

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 5697f1a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def delete_bucket(self, bucket_name):
379379
:type bucket_name: string
380380
:param bucket_name: The bucket name to delete.
381381
"""
382-
bucket_path = '/b/' + bucket_name
382+
bucket_path = Bucket.path_helper(bucket_name)
383383
self.api_request(method='DELETE', path=bucket_path)
384384

385385

0 commit comments

Comments
 (0)