Skip to content

Commit d846dd3

Browse files
committed
Inline path template patterns as locals.
Addresses: #1580 (comment)
1 parent 30ace60 commit d846dd3

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

gcloud/pubsub/_helpers.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,9 @@
1414

1515
"""Helper functions for shared behavior."""
1616

17-
import re
18-
1917
from gcloud._helpers import _name_from_project_path
2018

2119

22-
_TOPIC_PATH_TEMPLATE = re.compile(
23-
r'projects/(?P<project>\w+)/topics/(?P<name>\w+)')
24-
25-
2620
def topic_name_from_path(path, project):
2721
"""Validate a topic URI path and get the topic name.
2822
@@ -39,11 +33,8 @@ def topic_name_from_path(path, project):
3933
the project from the ``path`` does not agree with the
4034
``project`` passed in.
4135
"""
42-
return _name_from_project_path(path, project, _TOPIC_PATH_TEMPLATE)
43-
44-
45-
_SUBSCRIPTION_PATH_TEMPLATE = re.compile(
46-
r'projects/(?P<project>\w+)/subscriptions/(?P<name>\w+)')
36+
template = r'projects/(?P<project>\w+)/topics/(?P<name>\w+)'
37+
return _name_from_project_path(path, project, template)
4738

4839

4940
def subscription_name_from_path(path, project):
@@ -62,4 +53,5 @@ def subscription_name_from_path(path, project):
6253
the project from the ``path`` does not agree with the
6354
``project`` passed in.
6455
"""
65-
return _name_from_project_path(path, project, _SUBSCRIPTION_PATH_TEMPLATE)
56+
template = r'projects/(?P<project>\w+)/subscriptions/(?P<name>\w+)'
57+
return _name_from_project_path(path, project, template)

0 commit comments

Comments
 (0)