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

Side by Side Diff: recipe_engine/config_types.py

Issue 2512253002: Add name, package_repo_resource and resource support to recipe scripts. (Closed)
Patch Set: Fix bug, add additional test Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | recipe_engine/doc.py » ('j') | recipe_engine/loader.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The LUCI Authors. All rights reserved. 1 # Copyright 2013 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 import abc 5 import abc
6 import os 6 import os
7 import re 7 import re
8 8
9 from collections import namedtuple 9 from collections import namedtuple
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 def __repr__(self): 110 def __repr__(self):
111 prefix = '%s.' % RECIPE_MODULE_PREFIX 111 prefix = '%s.' % RECIPE_MODULE_PREFIX
112 assert self.module.__name__.startswith(prefix) 112 assert self.module.__name__.startswith(prefix)
113 name = self.module.__name__[len(prefix):] 113 name = self.module.__name__[len(prefix):]
114 # We change python's module delimiter . to ::, since . is already used 114 # We change python's module delimiter . to ::, since . is already used
115 # by expect tests. 115 # by expect tests.
116 return 'RECIPE_MODULE[%s]' % re.sub('\.', '::', name) 116 return 'RECIPE_MODULE[%s]' % re.sub('\.', '::', name)
117 117
118 118
119 class RecipeScriptBasePath(
120 BasePath, namedtuple('RecipeScriptBasePath', 'recipe_name script_path')):
121 def resolve(self, test_enabled):
122 if test_enabled:
123 return repr(self)
124 return os.path.splitext(self.script_path)[0]+".resources" # pragma: no cover
iannucci 2016/11/19 00:15:32 this was a bug
125
126 def __repr__(self):
127 return 'RECIPE[%s].resources' % self.recipe_name
128
129
119 class PackageRepoBasePath( 130 class PackageRepoBasePath(
120 BasePath, namedtuple('PackageRepoBasePath', 'package')): 131 BasePath, namedtuple('PackageRepoBasePath', 'package')):
121 def resolve(self, test_enabled): 132 def resolve(self, test_enabled):
122 if test_enabled: 133 if test_enabled:
123 return repr(self) 134 return repr(self)
124 return self.package.repo_root # pragma: no cover 135 return self.package.repo_root # pragma: no cover
125 136
126 def __repr__(self): 137 def __repr__(self):
127 return 'RECIPE_PACKAGE_REPO[%s]' % self.package.name 138 return 'RECIPE_PACKAGE_REPO[%s]' % self.package.name
128 139
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if len(self.pieces) >= len(child.pieces): 191 if len(self.pieces) >= len(child.pieces):
181 return False 192 return False
182 return child.pieces[:len(self.pieces)] == self.pieces 193 return child.pieces[:len(self.pieces)] == self.pieces
183 194
184 def __repr__(self): 195 def __repr__(self):
185 s = "Path(%r" % self.base 196 s = "Path(%r" % self.base
186 if self.pieces: 197 if self.pieces:
187 s += ", %s" % ",".join(repr(x) for x in self.pieces) 198 s += ", %s" % ",".join(repr(x) for x in self.pieces)
188 199
189 return s + ")" 200 return s + ")"
OLDNEW
« no previous file with comments | « no previous file | recipe_engine/doc.py » ('j') | recipe_engine/loader.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698