Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Unified Diff: recipe_engine/config_types.py

Issue 1925653002: recipe engine: require all path bases to be classes (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipe_modules/path/api.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/config_types.py
diff --git a/recipe_engine/config_types.py b/recipe_engine/config_types.py
index 6b9891eab3adc4d9bb5a226b87e10423bfe0f41c..2afac8eeab3c56c3e7ac245e0ddcd72f5d2c633e 100644
--- a/recipe_engine/config_types.py
+++ b/recipe_engine/config_types.py
@@ -80,17 +80,6 @@ class BasePath(object):
class NamedBasePath(BasePath, namedtuple('NamedBasePath', 'name')):
- # Restrict basenames to '[ALL_CAPS]'. This will help catch
- # errors if someone attempts to provide an actual string path '/some/example'
- # as the 'base'.
- BASE_RE = re.compile(r'\[([A-Z][A-Z_]*)\]')
-
- @staticmethod
- def parse(base):
- base_match = NamedBasePath.BASE_RE.match(base)
- assert base_match, 'Base should be [ALL_CAPS], got %r' % base
- return NamedBasePath(base_match.group(1).lower())
-
def resolve(self, api, test_enabled):
if self.name in api.c.dynamic_paths:
return api.c.dynamic_paths[self.name]
@@ -154,17 +143,12 @@ class Path(RecipeConfigType):
by the 'platform' module), to a suffix for the path.
"""
super(Path, self).__init__()
+ assert isinstance(base, BasePath), base
assert all(isinstance(x, basestring) for x in pieces), pieces
assert not any(x in ('..', '.', '/', '\\') for x in pieces)
- self.pieces = pieces
-
- if isinstance(base, BasePath):
- self.base = base
- elif isinstance(base, basestring):
- self.base = NamedBasePath.parse(base)
- else:
- raise ValueError('%s is not a valid base path' % (base,))
+ self.base = base
+ self.pieces = pieces
self.platform_ext = kwargs.get('platform_ext', {})
def __eq__(self, other):
« no previous file with comments | « no previous file | recipe_modules/path/api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698