Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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.dirname(self.script_path) # pragma: no cover | |
| 125 | |
| 126 def __repr__(self): | |
| 127 return 'RECIPE[%s].resources' % self.recipe_name | |
|
nodir
2016/11/18 22:42:25
shouldn't this be RECIPE_RESOURCES[%s] ?
what is R
iannucci
2016/11/19 00:00:57
Discussed offline, don't see a better alternative
| |
| 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 Loading... | |
| 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 + ")" |
| OLD | NEW |