当前位置: 首页>>代码示例>>Python>>正文


Python InternalTarget.check_cycles方法代码示例

本文整理汇总了Python中twitter.pants.targets.InternalTarget.check_cycles方法的典型用法代码示例。如果您正苦于以下问题:Python InternalTarget.check_cycles方法的具体用法?Python InternalTarget.check_cycles怎么用?Python InternalTarget.check_cycles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twitter.pants.targets.InternalTarget的用法示例。


在下文中一共展示了InternalTarget.check_cycles方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import check_cycles [as 别名]
  def run(self, lock):
    with self.check_errors("Target contains a dependency cycle") as error:
      for target in self.targets:
        try:
          InternalTarget.check_cycles(target)
        except InternalTarget.CycleException as e:
          error(target.id)

    timer = None
    if self.options.time:
      class Timer(object):
        def now(self):
          return time.time()
        def log(self, message):
          print(message)
      timer = Timer()

    logger = None
    if self.options.log or self.options.log_level:
      from twitter.common.log import init
      from twitter.common.log.options import LogOptions
      LogOptions.set_stderr_log_level((self.options.log_level or 'info').upper())
      logdir = self.options.logdir or self.config.get('goals', 'logdir', default=None)
      if logdir:
        safe_mkdir(logdir)
        LogOptions.set_log_dir(logdir)
        init('goals')
      else:
        init()
      logger = log

    if self.options.recursive_directory:
      log.warn('--all-recursive is deprecated, use a target spec with the form [dir]:: instead')
      for dir in self.options.recursive_directory:
        self.add_target_recursive(dir)

    if self.options.target_directory:
      log.warn('--all is deprecated, use a target spec with the form [dir]: instead')
      for dir in self.options.target_directory:
        self.add_target_directory(dir)

    context = Context(self.config, self.options, self.targets, lock=lock, log=logger)

    unknown = []
    for phase in self.phases:
      if not phase.goals():
        unknown.append(phase)

    if unknown:
        print('Unknown goal(s): %s' % ' '.join(phase.name for phase in unknown))
        print('')
        return Phase.execute(context, 'goals')

    if logger:
      logger.debug('Operating on targets: %s', self.targets)

    return Phase.attempt(context, self.phases, timer=timer)
开发者ID:soheilhy,项目名称:commons,代码行数:59,代码来源:goal.py

示例2: run

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import check_cycles [as 别名]
    def run(self, lock):
        with self.check_errors("Target contains a dependency cycle") as error:
            with self.timer.timing("parse:check_cycles"):
                for target in self.targets:
                    try:
                        InternalTarget.check_cycles(target)
                    except InternalTarget.CycleException as e:
                        error(target.id)

        logger = None
        if self.options.log or self.options.log_level:
            from twitter.common.log import init
            from twitter.common.log.options import LogOptions

            LogOptions.set_stderr_log_level((self.options.log_level or "info").upper())
            logdir = self.options.logdir or self.config.get("goals", "logdir", default=None)
            if logdir:
                safe_mkdir(logdir)
                LogOptions.set_log_dir(logdir)
                init("goals")
            else:
                init()
            logger = log

        if self.options.recursive_directory:
            log.warn("--all-recursive is deprecated, use a target spec with the form [dir]:: instead")
            for dir in self.options.recursive_directory:
                self.add_target_recursive(dir)

        if self.options.target_directory:
            log.warn("--all is deprecated, use a target spec with the form [dir]: instead")
            for dir in self.options.target_directory:
                self.add_target_directory(dir)

        context = Context(self.config, self.options, self.targets, lock=lock, log=logger)

        unknown = []
        for phase in self.phases:
            if not phase.goals():
                unknown.append(phase)

        if unknown:
            print("Unknown goal(s): %s" % " ".join(phase.name for phase in unknown))
            print("")
            return Phase.execute(context, "goals")

        if logger:
            logger.debug("Operating on targets: %s", self.targets)

        ret = Phase.attempt(context, self.phases, timer=self.timer if self.options.time else None)
        if self.options.time:
            print("Timing report")
            print("=============")
            self.timer.print_timings()
        return ret
开发者ID:nsanch,项目名称:commons,代码行数:57,代码来源:goal.py

示例3: testDetectCycleDirect

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import check_cycles [as 别名]
    def testDetectCycleDirect(self):
        a = MockTarget("a")

        # no cycles yet
        InternalTarget.check_cycles(a)
        a.internal_dependencies = [a]
        try:
            InternalTarget.check_cycles(a)
            self.fail("Expected a cycle to be detected")
        except InternalTarget.CycleException:
            # expected
            pass
开发者ID:nsanch,项目名称:commons,代码行数:14,代码来源:test-internal.py

示例4: testDetectIndirect

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import check_cycles [as 别名]
    def testDetectIndirect(self):
        c = MockTarget("c")
        b = MockTarget("b", c)
        a = MockTarget("a", c, b)

        # no cycles yet
        InternalTarget.check_cycles(a)

        c.internal_dependencies = [a]
        try:
            InternalTarget.check_cycles(a)
            self.fail("Expected a cycle to be detected")
        except InternalTarget.CycleException:
            # expected
            pass
开发者ID:nsanch,项目名称:commons,代码行数:17,代码来源:test-internal.py

示例5: __init__

# 需要导入模块: from twitter.pants.targets import InternalTarget [as 别名]
# 或者: from twitter.pants.targets.InternalTarget import check_cycles [as 别名]
  def __init__(self, root_dir, parser, argv):
    Command.__init__(self, root_dir, parser, argv)

    if not self.args:
      self.error("A spec argument is required")

    try:
      specs_end = self.args.index('--')
      if len(self.args) > specs_end:
        self.build_args = self.args.__getslice__(specs_end + 1, len(self.args) + 1)
      else:
        self.build_args = []
    except ValueError:
      specs_end = 1
      self.build_args = self.args[1:] if len(self.args) > 1 else []

    self.targets = OrderedSet()
    for spec in self.args.__getslice__(0, specs_end):
      try:
        address = Address.parse(root_dir, spec)
      except:
        self.error("Problem parsing spec %s: %s" % (spec, traceback.format_exc()))

      try:
        target = Target.get(address)
      except:
        self.error("Problem parsing BUILD target %s: %s" % (address, traceback.format_exc()))

      try:
        InternalTarget.check_cycles(target)
      except CycleException as e:
        self.error("Target contains an internal dependency cycle: %s" % e)

      if not target:
        self.error("Target %s does not exist" % address)
      if not target.address.is_meta:
        target.address.is_meta = self.options.is_meta or address.is_meta
      self.targets.add(target)

    self.is_ide = self.options.is_ide
    self.ide_transitivity = self.options.ide_transitivity
开发者ID:DikangGu,项目名称:commons,代码行数:43,代码来源:build.py


注:本文中的twitter.pants.targets.InternalTarget.check_cycles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。