Skip to content

Commit 43157db

Browse files
committed
Use constant for project key.
1 parent 411ac9a commit 43157db

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

gcloud/_helpers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,16 @@ def _default_service_project_id():
184184
:rtype: str or ``NoneType``
185185
:returns: Project-ID from ``gcloud info`` else ``None``
186186
"""
187+
PROJECT_KEY = 'project = '
187188
command = subprocess.Popen(['gcloud', 'config', 'list', 'project'],
188189
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
189190
shell=True)
190191
gcloud_project_conf = command.communicate()[0].decode('utf-8')
191192
gcloud_project_conf = gcloud_project_conf.split('\n')
192193

193194
for key in gcloud_project_conf:
194-
if key.startswith('project = '):
195-
return key[10:]
195+
if key.startswith(PROJECT_KEY):
196+
return key[len(PROJECT_KEY):]
196197

197198
return None
198199

0 commit comments

Comments
 (0)