本文整理汇总了Python中twitter.pants.base.Target类的典型用法代码示例。如果您正苦于以下问题:Python Target类的具体用法?Python Target怎么用?Python Target使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Target类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_target
def configure_target(target):
if target not in analyzed:
analyzed.add(target)
self.has_scala = self.has_scala or is_scala(target)
if isinstance(target, JavaLibrary) or isinstance(target, ScalaLibrary):
# TODO(John Sirois): this does not handle test resources, make test resources 1st class
# in ant build and punch this through to pants model
resources = set()
if target.resources:
resources.update(target.resources)
if target.binary_resources:
resources.update(target.binary_resources)
if resources:
self.resource_extensions.update(Project.extract_resource_extensions(resources))
configure_source_sets(ExportableJvmLibrary.RESOURCES_BASE_DIR, resources, is_test = False)
if target.sources:
test = is_test(target)
self.has_tests = self.has_tests or test
configure_source_sets(target.target_base, target.sources, is_test = test)
siblings = Target.get_all_addresses(target.address.buildfile)
return filter(accept_target, [ Target.get(a) for a in siblings if a != target.address ])
示例2: test_sibling_references
def test_sibling_references(self):
with temporary_dir() as root_dir:
buildfile = create_buildfile(root_dir, 'a', name='BUILD',
content=dedent("""
dependencies(name='util',
dependencies=[
jar(org='com.twitter', name='util', rev='0.0.1')
]
)
""").strip()
)
sibling = create_buildfile(root_dir, 'a', name='BUILD.sibling',
content=dedent("""
dependencies(name='util-ex',
dependencies=[
pants(':util'),
jar(org='com.twitter', name='util-ex', rev='0.0.1')
]
)
""").strip()
)
ParseContext(buildfile).parse()
utilex = Target.get(Address.parse(root_dir, 'a:util-ex', is_relative=False))
utilex_deps = set(utilex.resolve())
util = Target.get(Address.parse(root_dir, 'a:util', is_relative=False))
util_deps = set(util.resolve())
self.assertEquals(util_deps, util_deps.intersection(utilex_deps))
示例3: __init__
def __init__(self, name, dependencies, is_meta):
Target.__init__(self, name, is_meta)
self._injected_deps = []
self.processed_dependencies = resolve(dependencies)
self.add_label('internal')
self.dependency_addresses = OrderedSet()
self.dependencies = OrderedSet()
self.internal_dependencies = OrderedSet()
self.jar_dependencies = OrderedSet()
# TODO(John Sirois): if meta targets were truly built outside parse contexts - we could instead
# just use the more general check: if parsing: delay(doit) else: doit()
# Fix how target _ids are built / addresses to not require a BUILD file - ie: support anonymous,
# non-addressable targets - which is what meta-targets really are once created.
if is_meta:
# Meta targets are built outside any parse context - so update dependencies immediately
self.update_dependencies(self.processed_dependencies)
else:
# Defer dependency resolution after parsing the current BUILD file to allow for forward
# references
self._post_construct(self.update_dependencies, self.processed_dependencies)
self._post_construct(self.inject_dependencies)
示例4: __init__
def __init__(self, name, sources=None):
Target.__init__(self, name)
self.add_labels('sources')
self.target_base = SourceRoot.find(self)
self.sources = None
self._sources = sources or []
示例5: __init__
def __init__(self, requirement, dynamic=False, repository=None, name=None, version_filter=None):
self._requirement = Requirement.parse(requirement)
self._name = name or self._requirement.project_name
self._dynamic = dynamic
self._repository = repository
self._version_filter = version_filter or (lambda: True)
Target.__init__(self, self._name, False)
示例6: 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
示例7: __init__
def __init__(self, name, sources=None, exclusives=None):
Target.__init__(self, name, exclusives=exclusives)
self.add_labels("sources")
self.target_base = SourceRoot.find(self)
self.sources = None
self._sources = sources or []
示例8: add_targets
def add_targets(self, error, 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)
示例9: __init__
def __init__(self, name, dependencies, is_meta):
Target.__init__(self, name, is_meta)
self.resolved_dependencies = OrderedSet()
self.internal_dependencies = OrderedSet()
self.jar_dependencies = OrderedSet()
self.update_dependencies(dependencies)
示例10: _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)
示例11: __init__
def __init__(self, name, url_builder, exclusives=None):
"""
:param string name: The name of this target, which combined with this
build file defines the target :class:`twitter.pants.base.address.Address`.
:param url_builder: Function that accepts a page target and an optional wiki config dict.
:returns: A tuple of (alias, fully qualified url).
"""
Target.__init__(self, name, exclusives=exclusives)
self.url_builder = url_builder
示例12: __init__
def __init__(self, name, username=None, password=None):
"""
:name The name of these credentials
:username Either a constant username value or else a callable that can fetch one
:password Either a constant password value or else a callable that can fetch one
"""
Target.__init__(self, name, False)
self._username = username if callable(username) else lambda: username
self._password = password if callable(password) else lambda: password
示例13: __init__
def __init__(self, name, dependencies):
"""name: The name of this module target, addressable via pants via the portion of the spec
following the colon
dependencies: one or more JarDependencies this JarLibrary bundles or Pants pointing to other
JarLibraries or JavaTargets"""
assert len(dependencies) > 0, "At least one dependency must be specified"
Target.__init__(self, name, False)
self.dependencies = dependencies
示例14: __init__
def __init__(self, name, url, push_db, exclusives=None):
"""name: an identifier for the repo
url: the url used to access the repo and retrieve artifacts or artifact metadata
push_db: the data file associated with this repo that records artifact push history"""
Target.__init__(self, name, exclusives=exclusives)
self.name = name
self.url = url
self.push_db = push_db
示例15: 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)