Chromium Code Reviews| Index: projects.py |
| diff --git a/projects.py b/projects.py |
| index d304dadcf846d2c42763abf2f43987ef08b55eae..d088c623351eb946e5627a65151d598c05d263fd 100644 |
| --- a/projects.py |
| +++ b/projects.py |
| @@ -39,6 +39,7 @@ if os.path.isdir(INTERNAL_DIR): |
| import gyp_committers # pylint: disable=F0401 |
| import nacl_committers # pylint: disable=F0401 |
| import skia_committers # pylint: disable=F0401 |
| + import projects_internal # pylint: disable=F0401 |
| else: |
| print >> sys.stderr, ( |
| 'Failed to find commit-queue-internal; will fail to start!') |
| @@ -46,7 +47,7 @@ else: |
| gyp_committers = None |
| nacl_committers = None |
| skia_committers = None |
| - |
| + projects_internal = None |
| # It's tricky here because 'chrome' is remapped to 'svn' on src.chromium.org but |
| # the other repositories keep their repository name. So don't list it here. |
| @@ -757,14 +758,45 @@ def _internal_simple(path, project_bases, user, root_dir, rietveld_obj): |
| verifiers) |
| +def _get_supported_projects(): |
| + """Return project names and corresponding functions in a dict. |
| + |
| + Projects functions start with '_gen_' and are searched for in the present |
| + file and in commit-queue-internal/projects_internal.py. |
| + """ |
| + projects = {} |
| + for name in dir(sys.modules[__name__]): |
| + if name.startswith('_gen_'): |
| + projects[name[5:]] = getattr(sys.modules[__name__], name) |
| + |
| + if projects_internal: |
| + for name in dir(sys.modules['projects_internal']): |
| + if name.startswith('_gen_'): |
| + if name[5:] in projects: |
| + raise errors.ConfigurationError( |
| + 'public project function %s overriden by private one' |
|
Paweł Hajdan Jr.
2014/01/27 18:23:17
nit: Let's indent +4 instead of +2 here and line b
|
| + % name) |
| + projects[name[5:]] = getattr(sys.modules['projects_internal'], name) |
| + |
| + return projects |
| + |
| + |
| def supported_projects(): |
| """List the projects that can be managed by the commit queue.""" |
| - return sorted( |
| - x[5:] for x in dir(sys.modules[__name__]) if x.startswith('_gen_')) |
| + return sorted(_get_supported_projects().keys()) |
| def load_project(project, user, root_dir, rietveld_obj, no_try): |
| - """Loads the specified project.""" |
| + """Loads the specified project. |
| + |
| + Args: |
| + project (string): project name (suffix of _gen_* functions above) |
| + user (string): email address identifying the commit bot. |
| + root_dir (string): working directory (were credentials are stored e.g. .gaia) |
| + rietveld_obj (rietveld.Rietveld): object for communicating with Rietveld. |
| + no_try (boolean): is True, means "do not send try jobs" |
| + """ |
| assert os.path.isabs(root_dir) |
| - return getattr(sys.modules[__name__], '_gen_' + project)( |
| - user, root_dir, rietveld_obj, no_try) |
| + return _get_supported_projects()[project]( |
| + user, root_dir, rietveld_obj, no_try) |
| + |