當前位置: 首頁>>代碼示例>>Python>>正文


Python base.BuildFile類代碼示例

本文整理匯總了Python中twitter.pants.base.BuildFile的典型用法代碼示例。如果您正苦於以下問題:Python BuildFile類的具體用法?Python BuildFile怎麽用?Python BuildFile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了BuildFile類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_target_recursive

 def add_target_recursive(self, *specs):
   with self.check_errors('There was a problem scanning the '
                          'following directories for targets:') as error:
     for spec in specs:
       dir = self.get_dir(spec)
       for buildfile in BuildFile.scan_buildfiles(self.root_dir, dir):
         self.add_targets(error, dir, buildfile)
開發者ID:soheilhy,項目名稱:commons,代碼行數:7,代碼來源:goal.py

示例2: execute

 def execute(self):
   for buildfile in BuildFile.scan_buildfiles(self.root_dir):
     for address in Target.get_all_addresses(buildfile):
       target = Target.get(address)
       if hasattr(target, 'sources') and target.sources is not None:
         for sourcefile in target.sources:
           print sourcefile, address
開發者ID:DikangGu,項目名稱:commons,代碼行數:7,代碼來源:filemap.py

示例3: _addresses

 def _addresses(self):
     if self.context.target_roots:
         for target in self.context.target_roots:
             yield target.address
     else:
         for buildfile in BuildFile.scan_buildfiles(self._root_dir):
             for address in Target.get_all_addresses(buildfile):
                 yield address
開發者ID:pkwarren,項目名稱:commons,代碼行數:8,代碼來源:listtargets.py

示例4: scan_addresses

  def scan_addresses(root_dir, base_path = None):
    """Parses all targets available in BUILD files under base_path and returns their addresses.  If no
    base_path is specified, root_dir is assumed to be the base_path"""

    addresses = OrderedSet()
    for buildfile in BuildFile.scan_buildfiles(root_dir, base_path):
      addresses.update(Target.get_all_addresses(buildfile))
    return addresses
開發者ID:DikangGu,項目名稱:commons,代碼行數:8,代碼來源:__init__.py

示例5: _find_targets

 def _find_targets(self):
   if len(self.context.target_roots) > 0:
     for target in self.context.target_roots:
       yield target
   else:
     for buildfile in BuildFile.scan_buildfiles(get_buildroot()):
       target_addresses = Target.get_all_addresses(buildfile)
       for target_address in target_addresses:
         yield Target.get(target_address)
開發者ID:CodeWarltz,項目名稱:commons,代碼行數:9,代碼來源:filemap.py

示例6: execute

  def execute(self):
    def add_targets(dir, buildfile):
      try:
        self.targets.extend(Target.get(addr) for addr in Target.get_all_addresses(buildfile))
      except (TypeError, ImportError):
        error(dir, include_traceback=True)
      except (IOError, SyntaxError):
        error(dir)

    if self.options.recursive_directory:
      with self.check_errors('There was a problem scanning the '
                             'following directories for targets:') as error:
        for dir in self.options.recursive_directory:
          for buildfile in BuildFile.scan_buildfiles(self.root_dir, dir):
            add_targets(dir, buildfile)

    if self.options.target_directory:
      with self.check_errors("There was a problem loading targets "
                             "from the following directory's BUILD files") as error:
        for dir in self.options.target_directory:
          add_targets(dir, BuildFile(self.root_dir, dir))

    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.config.get('goals', 'logdir')
      if logdir:
        safe_mkdir(logdir)
        LogOptions.set_log_dir(logdir)
      init('goals')
      logger = log

    context = Context(self.config, self.options, self.targets, 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')

    return Phase.attempt(context, self.phases, timer=timer)
開發者ID:adamsxu,項目名稱:commons,代碼行數:56,代碼來源:goal.py

示例7: execute

 def execute(self, expanded_target_addresses):
   buildroot = get_buildroot()
   if len(self.context.target_roots) > 0:
     for target in self.context.target_roots:
       self._execute_target(target, buildroot)
   else:
     for buildfile in BuildFile.scan_buildfiles(buildroot):
       target_addresses = Target.get_all_addresses(buildfile)
       for target_address in target_addresses:
         target = Target.get(target_address)
         self._execute_target(target, buildroot)
開發者ID:alfss,項目名稱:commons,代碼行數:11,代碼來源:filemap.py

示例8: _parse_buildfiles

 def _parse_buildfiles(self):
   buildfiles = OrderedSet()
   for spec in self.args:
     try:
       if self.options.is_directory_list:
         for buildfile in BuildFile.scan_buildfiles(self.root_dir, spec):
           buildfiles.add(buildfile)
       else:
         buildfiles.add(Address.parse(self.root_dir, spec).buildfile)
     except:
       self.error("Problem parsing spec %s: %s" % (spec, traceback.format_exc()))
   return buildfiles
開發者ID:DikangGu,項目名稱:commons,代碼行數:12,代碼來源:list.py

示例9: _parse_addresses

 def _parse_addresses(self, spec):
   if spec.endswith('::'):
     dir = self._get_dir(spec[:-len('::')])
     for buildfile in BuildFile.scan_buildfiles(self._root_dir, os.path.join(self._root_dir, dir)):
       for address in Target.get_all_addresses(buildfile):
         yield address
   elif spec.endswith(':'):
     dir = self._get_dir(spec[:-len(':')])
     for address in Target.get_all_addresses(BuildFile(self._root_dir, dir)):
       yield address
   else:
     yield Address.parse(self._root_dir, spec)
開發者ID:patricklaw,項目名稱:twitter-commons,代碼行數:12,代碼來源:goal.py

示例10: __init__

  def __init__(self, context):
    ConsoleTask.__init__(self, context)

    self._print_uptodate = context.options.check_deps_print_uptodate
    self.repos = context.config.getdict('jar-publish', 'repos')
    self._artifacts_to_targets = {}
    all_addresses = (address for buildfile in BuildFile.scan_buildfiles(get_buildroot())
                     for address in Target.get_all_addresses(buildfile))
    for address in all_addresses:
      target = Target.get(address)
      if target.is_exported:
        provided_jar, _, _ = target.get_artifact_info()
        artifact = (provided_jar.org, provided_jar.name)
        if not artifact in self._artifacts_to_targets:
          self._artifacts_to_targets[artifact] = target
開發者ID:CodeWarltz,項目名稱:commons,代碼行數:15,代碼來源:check_published_deps.py

示例11: __init__

  def __init__(self, root_dir, parser, argv):
    Command.__init__(self, root_dir, parser, argv)

    self.buildfiles = self._parse_buildfiles() if self.args else BuildFile.scan_buildfiles(root_dir)
開發者ID:DikangGu,項目名稱:commons,代碼行數:4,代碼來源:list.py

示例12: _addresses

 def _addresses(self):
   if self.context.target_roots:
     return (target.address for target in self.context.target_roots)
   else:
     return (address for buildfile in BuildFile.scan_buildfiles(self._root_dir)
                     for address in Target.get_all_addresses(buildfile))
開發者ID:BabyDuncan,項目名稱:commons,代碼行數:6,代碼來源:listtargets.py


注:本文中的twitter.pants.base.BuildFile類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。