本文整理汇总了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)
示例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 = {}