api.py 806 Bytes
Newer Older
1 2 3 4 5 6 7
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from recipe_engine import recipe_api

class PresubmitApi(recipe_api.RecipeApi):
8 9 10 11
  @property
  def presubmit_support_path(self):
    return self.package_repo_resource('presubmit_support.py')

12 13
  def __call__(self, *args, **kwargs):
    """Return a presubmit step."""
14

15
    name = kwargs.pop('name', 'presubmit')
16

17 18 19 20
    env = self.m.step.get_from_context('env', {})
    env.setdefault('PATH', '%(PATH)s')
    env['PATH'] = self.m.path.pathsep.join([
        env['PATH'], str(self._module.PACKAGE_REPO_ROOT)])
21

22 23 24
    with self.m.step.context({'env': env}):
      return self.m.python(
          name, self.presubmit_support_path, list(args), **kwargs)