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


Python ParseContext.path方法代碼示例

本文整理匯總了Python中twitter.pants.base.parse_context.ParseContext.path方法的典型用法代碼示例。如果您正苦於以下問題:Python ParseContext.path方法的具體用法?Python ParseContext.path怎麽用?Python ParseContext.path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twitter.pants.base.parse_context.ParseContext的用法示例。


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

示例1: PythonEgg

# 需要導入模塊: from twitter.pants.base.parse_context import ParseContext [as 別名]
# 或者: from twitter.pants.base.parse_context.ParseContext import path [as 別名]
def PythonEgg(glob, name=None):
  """Refers to pre-built Python eggs in the file system. (To instead fetch
  eggs in a ``pip``/``easy_install`` way, use ``python_requirement``)

  E.g., ``egg(name='foo', glob='foo-0.1-py2.6.egg')`` would pick up the
  file ``foo-0.1-py2.6.egg`` from the ``BUILD`` file's directory; targets
  could depend on it by name ``foo``.

  :param string glob: File glob pattern.
  :param string name: Target name; by default uses the egg's project name.
  """
  # TODO(John Sirois): Rationalize with globs handling in ParseContext
  eggs = fsglob(ParseContext.path(glob))

  requirements = set()
  for egg in eggs:
    if os.path.isdir(egg):
      metadata = PathMetadata(egg, os.path.join(egg, 'EGG-INFO'))
    else:
      metadata = EggMetadata(zipimporter(egg))
    dist = Distribution.from_filename(egg, metadata=metadata)
    requirements.add(dist.as_requirement())

  if len(requirements) > 1:
    raise ValueError('Got multiple egg versions! => %s' % requirements)

  return PythonRequirement(str(requirements.pop()), name=name)
開發者ID:CodeWarltz,項目名稱:commons,代碼行數:29,代碼來源:python_egg.py

示例2: __init__

# 需要導入模塊: from twitter.pants.base.parse_context import ParseContext [as 別名]
# 或者: from twitter.pants.base.parse_context.ParseContext import path [as 別名]
  def __init__(self, base=None, mapper=None, relative_to=None):
    """
    :param mapper: Function that takes a path string and returns a path string. Takes a path in
      the source tree, returns a path to use in the resulting bundle. By default, an identity
      mapper.
    :param string relative_to: Set up a simple mapping from source path to bundle path.
      E.g., ``relative_to='common'`` removes that prefix from all files in the application bundle.
    """
    if mapper and relative_to:
      raise ValueError("Must specify exactly one of 'mapper' or 'relative_to'")

    if relative_to:
      base = base or ParseContext.path(relative_to)
      if not os.path.isdir(base):
        raise ValueError('Could not find a directory to bundle relative to at %s' % base)
      self.mapper = RelativeToMapper(base)
    else:
      self.mapper = mapper or RelativeToMapper(base or ParseContext.path())

    self.filemap = {}
開發者ID:testvidya11,項目名稱:commons,代碼行數:22,代碼來源:jvm_binary.py


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