1414
1515"""Helper functions for shared behavior."""
1616
17- import re
18-
1917from 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-
2620def 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
4940def 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