_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q27800 | LinkerWrapperMixin.for_compiler | train | def for_compiler(self, compiler, platform):
"""Return a Linker object which is intended to be compatible with the given `compiler`."""
return (self.linker
# TODO(#6143): describe why the compiler needs to be first on the PATH!
| python | {
"resource": ""
} |
q27801 | ImportOrder.is_module_on_std_lib_path | train | def is_module_on_std_lib_path(cls, module):
"""
Sometimes .py files are symlinked to the real python files, such as the case of virtual
env. However the .pyc files are created under the virtual env directory rather than
the path in cls.STANDARD_LIB_PATH. Hence this function checks for both.
:param ... | python | {
"resource": ""
} |
q27802 | ImportOrder.iter_import_chunks | train | def iter_import_chunks(self):
"""Iterate over space-separated import chunks in a file."""
chunk = []
last_line = None
for leaf in self.python_file.tree.body:
if isinstance(leaf, (ast.Import, ast.ImportFrom)):
# we've seen previous imports but this import is not in | python | {
"resource": ""
} |
q27803 | ThriftDefaults.compiler | train | def compiler(self, target):
"""Returns the thrift compiler to use for the given target.
:param target: The target to extract the thrift compiler from.
:type target: :class:`pants.backend.codegen.thrift.java.java_thrift_library.JavaThriftLibrary`
:returns: The thrift | python | {
"resource": ""
} |
q27804 | ThriftDefaults.language | train | def language(self, target):
"""Returns the target language to generate thrift stubs for.
:param target: The target to extract the target language from.
:type target: :class:`pants.backend.codegen.thrift.java.java_thrift_library.JavaThriftLibrary`
:returns: The target | python | {
"resource": ""
} |
q27805 | ThriftDefaults.namespace_map | train | def namespace_map(self, target):
"""Returns the namespace_map used for Thrift generation.
:param target: The target to extract the namespace_map from.
:type target: :class:`pants.backend.codegen.targets.java_thrift_library.JavaThriftLibrary`
:returns: The namespaces to | python | {
"resource": ""
} |
q27806 | ThriftDefaults.compiler_args | train | def compiler_args(self, target):
"""Returns the compiler_args used for Thrift generation.
:param target: The target to extract the compiler args from.
:type target: :class:`pants.backend.codegen.targets.java_thrift_library.JavaThriftLibrary`
:returns: Extra arguments for | python | {
"resource": ""
} |
q27807 | ThriftDefaults.default_java_namespace | train | def default_java_namespace(self, target):
"""Returns the default_java_namespace used for Thrift generation.
:param target: The target to extract the default_java_namespace from.
:type target: :class:`pants.backend.codegen.targets.java_thrift_library.JavaThriftLibrary`
:returns: The default Java | python | {
"resource": ""
} |
q27808 | UnpackRemoteSourcesBase._calculate_unpack_filter | train | def _calculate_unpack_filter(cls, includes=None, excludes=None, spec=None):
"""Take regex patterns and return a filter function.
:param list includes: List of include patterns to pass to _file_filter.
:param list excludes: List of exclude patterns to pass to _file_filter.
"""
include_patterns = cls... | python | {
"resource": ""
} |
q27809 | ScroogeGen._resolve_deps | train | def _resolve_deps(self, depmap):
"""Given a map of gen-key=>target specs, resolves the target specs into references."""
deps = defaultdict(lambda: OrderedSet())
for category, depspecs in depmap.items():
dependencies = deps[category]
for depspec in depspecs:
dep_address = Address.parse(de... | python | {
"resource": ""
} |
q27810 | TargetRootsCalculator.parse_specs | train | def parse_specs(cls, target_specs, build_root=None, exclude_patterns=None, tags=None):
"""Parse string specs into unique `Spec` objects.
:param iterable target_specs: An iterable of string specs.
:param string build_root: The path to the build root.
:returns: A `Specs` object.
"""
build_root = ... | python | {
"resource": ""
} |
q27811 | ResolveRequirementsTaskBase.resolve_requirements | train | def resolve_requirements(self, interpreter, req_libs):
"""Requirements resolution for PEX files.
:param interpreter: Resolve against this :class:`PythonInterpreter`.
:param req_libs: A list of :class:`PythonRequirementLibrary` targets to resolve.
:returns: a PEX containing target requirements and any s... | python | {
"resource": ""
} |
q27812 | ResolveRequirementsTaskBase.resolve_requirement_strings | train | def resolve_requirement_strings(self, interpreter, requirement_strings):
"""Resolve a list of pip-style requirement strings."""
requirement_strings = sorted(requirement_strings)
if len(requirement_strings) == 0:
req_strings_id = 'no_requirements'
elif len(requirement_strings) == 1:
req_strin... | python | {
"resource": ""
} |
q27813 | ResolveRequirementsTaskBase.merged_pex | train | def merged_pex(cls, path, pex_info, interpreter, pexes, interpeter_constraints=None):
"""Yields a pex builder at path with the given pexes already merged.
:rtype: :class:`pex.pex_builder.PEXBuilder`
"""
pex_paths = [pex.path() for pex in pexes if pex]
if pex_paths:
pex_info = pex_info.copy()
... | python | {
"resource": ""
} |
q27814 | ResolveRequirementsTaskBase.merge_pexes | train | def merge_pexes(cls, path, pex_info, interpreter, pexes, interpeter_constraints=None):
"""Generates a merged pex at path."""
| python | {
"resource": ""
} |
q27815 | PythonSetup.artifact_cache_dir | train | def artifact_cache_dir(self):
"""Note that this is unrelated to the general pants | python | {
"resource": ""
} |
q27816 | PythonSetup.compatibility_or_constraints | train | def compatibility_or_constraints(self, target):
"""
Return either the compatibility of the given target, or the interpreter constraints.
If interpreter constraints are supplied by the CLI flag, return those only.
"""
| python | {
"resource": ""
} |
q27817 | PythonSetup.get_pex_python_paths | train | def get_pex_python_paths():
"""Returns a list of paths to Python interpreters as defined in a pexrc file.
These are provided by a PEX_PYTHON_PATH in either of '/etc/pexrc', '~/.pexrc'.
PEX_PYTHON_PATH defines a colon-separated list of paths to interpreters
| python | {
"resource": ""
} |
q27818 | PythonSetup.get_pyenv_paths | train | def get_pyenv_paths(pyenv_root_func=None):
"""Returns a list of paths to Python interpreters managed by pyenv.
:param pyenv_root_func: A no-arg function that returns the pyenv root. Defaults to
running `pyenv root`, but can be overridden for testing.
"""
pyenv_root_func = py... | python | {
"resource": ""
} |
q27819 | BasicAuth.authenticate | train | def authenticate(self, provider, creds=None, cookies=None):
"""Authenticate against the specified provider.
:param str provider: Authorize against this provider.
:param pants.auth.basic_auth.BasicAuthCreds creds: The creds to use.
If unspecified, assumes that creds are set in the netrc file.
:par... | python | {
"resource": ""
} |
q27820 | ProjectTree.glob1 | train | def glob1(self, dir_relpath, glob):
"""Returns a list of paths in path that match glob and are not ignored."""
if self.isignored(dir_relpath, directory=True):
return []
matched_files = self._glob1_raw(dir_relpath, glob)
| python | {
"resource": ""
} |
q27821 | ProjectTree.scandir | train | def scandir(self, relpath):
"""Return paths relative to the root, which are in the given directory and not ignored."""
if self.isignored(relpath, directory=True):
| python | {
"resource": ""
} |
q27822 | ProjectTree.isdir | train | def isdir(self, relpath):
"""Returns True if path is a directory and is not ignored."""
if self._isdir_raw(relpath):
| python | {
"resource": ""
} |
q27823 | ProjectTree.isfile | train | def isfile(self, relpath):
"""Returns True if path is a file and is not ignored."""
if self.isignored(relpath):
| python | {
"resource": ""
} |
q27824 | ProjectTree.exists | train | def exists(self, relpath):
"""Returns True if path exists and is not ignored."""
| python | {
"resource": ""
} |
q27825 | ProjectTree.content | train | def content(self, file_relpath):
"""Returns the content for file at path. Raises exception if path is ignored.
Raises exception if path is ignored.
"""
| python | {
"resource": ""
} |
q27826 | ProjectTree.relative_readlink | train | def relative_readlink(self, relpath):
"""Execute `readlink` for the given path, which may result in a relative path.
Raises exception | python | {
"resource": ""
} |
q27827 | ProjectTree.walk | train | def walk(self, relpath, topdown=True):
"""Walk the file tree rooted at `path`.
Works like os.walk but returned root value is relative path.
Ignored paths will not be returned.
"""
for root, dirs, files in self._walk_raw(relpath, topdown):
matched_dirs = self.ignore.match_files([os.path.join(r... | python | {
"resource": ""
} |
q27828 | ProjectTree.isignored | train | def isignored(self, relpath, directory=False):
"""Returns True if path matches pants ignore pattern."""
relpath = self._relpath_no_dot(relpath)
if directory:
| python | {
"resource": ""
} |
q27829 | ProjectTree._filter_ignored | train | def _filter_ignored(self, entries, selector=None):
"""Given an opaque entry list, filter any ignored entries.
:param entries: A list or generator that produces entries to filter.
:param selector: A function that computes a path for an entry relative to the root of the
ProjectTree, or None to use iden... | python | {
"resource": ""
} |
q27830 | ProjectTree._append_slash_if_dir_path | train | def _append_slash_if_dir_path(self, relpath):
"""For a dir path return a path that has | python | {
"resource": ""
} |
q27831 | ImportRemoteSourcesMixin.compute_dependency_specs | train | def compute_dependency_specs(cls, kwargs=None, payload=None):
"""Tack imported_target_specs onto the traversable_specs generator for this target."""
for spec in | python | {
"resource": ""
} |
q27832 | BaseLocalArtifactCache._tmpfile | train | def _tmpfile(self, cache_key, use):
"""Allocate tempfile on same device as cache with a suffix chosen to prevent collisions""" | python | {
"resource": ""
} |
q27833 | BaseLocalArtifactCache.insert_paths | train | def insert_paths(self, cache_key, paths):
"""Gather paths into artifact, store it, and yield the path to stored artifact | python | {
"resource": ""
} |
q27834 | BaseLocalArtifactCache.store_and_use_artifact | train | def store_and_use_artifact(self, cache_key, src, results_dir=None):
"""Store and then extract the artifact from the given `src` iterator for the given cache_key.
:param cache_key: Cache key for the artifact.
:param src: Iterator over binary data to store for the artifact.
:param str results_dir: The pa... | python | {
"resource": ""
} |
q27835 | LocalArtifactCache.prune | train | def prune(self, root):
"""Prune stale cache files
If the option --cache-target-max-entry is greater than zero, then prune will remove all but n
old cache files for each target/task.
:param str root: The path under which cacheable artifacts will be cleaned
| python | {
"resource": ""
} |
q27836 | hash_all | train | def hash_all(strs, digest=None):
"""Returns a hash of the concatenation of all the strings in strs.
If a hashlib message digest is not supplied a new sha1 message digest is used.
"""
digest = digest or hashlib.sha1()
| python | {
"resource": ""
} |
q27837 | hash_file | train | def hash_file(path, digest=None):
"""Hashes the contents of the file at the given path and returns the hash digest in hex form.
If a hashlib message digest is not supplied a new | python | {
"resource": ""
} |
q27838 | json_hash | train | def json_hash(obj, digest=None, encoder=None):
"""Hashes `obj` by dumping to JSON.
:param obj: An object that can be rendered to json using the given `encoder`.
:param digest: An optional `hashlib` compatible message digest. Defaults to `hashlib.sha1`.
:param encoder: An optional custom json encoder.
:type e... | python | {
"resource": ""
} |
q27839 | Sharder.is_in_shard | train | def is_in_shard(self, s):
"""Returns True iff the string s is in this shard.
:param string s: The string to check.
"""
| python | {
"resource": ""
} |
q27840 | ClasspathUtil.classpath | train | def classpath(cls, targets, classpath_products, confs=('default',)):
"""Return the classpath as a list of paths covering all the passed targets.
:param targets: Targets to build an aggregated classpath for.
:param ClasspathProducts classpath_products: Product | python | {
"resource": ""
} |
q27841 | ClasspathUtil.internal_classpath | train | def internal_classpath(cls, targets, classpath_products, confs=('default',)):
"""Return the list of internal classpath entries for a classpath covering all `targets`.
Any classpath entries contributed by external dependencies will be omitted.
:param targets: Targets to build an aggregated classpath for.
... | python | {
"resource": ""
} |
q27842 | ClasspathUtil.classpath_by_targets | train | def classpath_by_targets(cls, targets, classpath_products, confs=('default',)):
"""Return classpath entries grouped by their targets for the given `targets`.
:param targets: The targets to lookup classpath products for.
:param ClasspathProducts classpath_products: Product containing classpath elements.
... | python | {
"resource": ""
} |
q27843 | PailgunService._setup_pailgun | train | def _setup_pailgun(self):
"""Sets up a PailgunServer instance."""
# Constructs and returns a runnable PantsRunner.
def runner_factory(sock, arguments, environment):
return self._runner_class.create(
sock,
arguments,
environment,
self.services,
self._scheduler_se... | python | {
"resource": ""
} |
q27844 | HtmlReporter._emit | train | def _emit(self, s):
"""Append content to the main report file."""
if os.path.exists(self._html_dir): # Make sure we're not immediately after a | python | {
"resource": ""
} |
q27845 | HtmlReporter._overwrite | train | def _overwrite(self, filename, func, force=False):
"""Overwrite a file with the specified contents.
Write times are tracked, too-frequent overwrites are skipped, for performance reasons.
:param filename: The path under the html dir to write to.
:param func: A no-arg function that returns the contents ... | python | {
"resource": ""
} |
q27846 | HtmlReporter._htmlify_text | train | def _htmlify_text(self, s):
"""Make text HTML-friendly."""
colored = self._handle_ansi_color_codes(html.escape(s))
| python | {
"resource": ""
} |
q27847 | HtmlReporter._handle_ansi_color_codes | train | def _handle_ansi_color_codes(self, s):
"""Replace ansi escape sequences with spans of appropriately named css classes."""
parts = HtmlReporter._ANSI_COLOR_CODE_RE.split(s)
ret = []
span_depth = 0
# Note that len(parts) is always odd: text, code, text, code, ..., text.
for i in range(0, len(parts... | python | {
"resource": ""
} |
q27848 | LocalPantsRunner.create | train | def create(cls, exiter, args, env, target_roots=None, daemon_graph_session=None,
options_bootstrapper=None):
"""Creates a new LocalPantsRunner instance by parsing options.
:param Exiter exiter: The Exiter instance to use for this run.
:param list args: The arguments (e.g. sys.argv) for this ru... | python | {
"resource": ""
} |
q27849 | LocalPantsRunner._maybe_handle_help | train | def _maybe_handle_help(self):
"""Handle requests for `help` information."""
if self._options.help_request: | python | {
"resource": ""
} |
q27850 | LocalPantsRunner._compute_final_exit_code | train | def _compute_final_exit_code(*codes):
"""Returns the exit code with higher abs value in case of negative values."""
max_code = None
for code in codes:
| python | {
"resource": ""
} |
q27851 | GoTask.import_oracle | train | def import_oracle(self):
"""Return an import oracle that can help look up and categorize imports.
| python | {
"resource": ""
} |
q27852 | ImportOracle.go_stdlib | train | def go_stdlib(self):
"""Return the set of all Go standard library import paths.
:rtype: frozenset of string
"""
| python | {
"resource": ""
} |
q27853 | ImportOracle.list_imports | train | def list_imports(self, pkg, gopath=None):
"""Return a listing of the dependencies of the given package.
:param string pkg: The package whose files to list all dependencies of.
:param string gopath: An optional $GOPATH which points to a Go workspace containing `pkg`.
:returns: The import listing for `pk... | python | {
"resource": ""
} |
q27854 | linkify | train | def linkify(buildroot, s, memoized_urls):
"""Augment text by heuristically finding URL and file references and turning them into links.
:param string buildroot: The base directory of the project.
:param string s: The text to insert links into.
:param dict memoized_urls: A cache of text to links so repeated sub... | python | {
"resource": ""
} |
q27855 | assert_list | train | def assert_list(obj, expected_type=string_types, can_be_none=True, default=(), key_arg=None,
allowable=(list, Fileset, OrderedSet, set, tuple), raise_type=ValueError):
"""
This function is used to ensure that parameters set by users in BUILD files are of acceptable types.
:API: public
:param obj ... | python | {
"resource": ""
} |
q27856 | AggregatedTimings.add_timing | train | def add_timing(self, label, secs, is_tool=False):
"""Aggregate timings by label.
secs - a double, so fractional seconds are allowed.
is_tool - whether this label represents a tool invocation.
"""
self._timings_by_path[label] += secs
if is_tool:
self._tool_labels.add(label)
# Check exi... | python | {
"resource": ""
} |
q27857 | AggregatedTimings.get_all | train | def get_all(self):
"""Returns all the timings, sorted in decreasing order.
Each value is a dict: { path: <path>, timing: <timing in seconds> }
"""
return [{'label': x[0], 'timing': x[1], 'is_tool': | python | {
"resource": ""
} |
q27858 | JvmDependencyAnalyzer.files_for_target | train | def files_for_target(self, target):
"""Yields a sequence of abs path of source, class or jar files provided by the target.
The runtime classpath for a target must already have been finalized for a target in order
to compute its provided files.
"""
def gen():
# Compute src -> target.
if ... | python | {
"resource": ""
} |
q27859 | JvmDependencyAnalyzer.targets_by_file | train | def targets_by_file(self, targets):
"""Returns a map from abs path of source, class or jar file to an OrderedSet of targets.
The value is usually a singleton, because a source or class file belongs to a single target.
However a single jar may be provided (transitively or intransitively) by multiple JarLibr... | python | {
"resource": ""
} |
q27860 | JvmDependencyAnalyzer.targets_for_class | train | def targets_for_class(self, target, classname):
"""Search which targets from `target`'s transitive dependencies contain `classname`."""
targets_with_class = set()
for target in target.closure():
for one_class | python | {
"resource": ""
} |
q27861 | JvmDependencyAnalyzer._target_classes | train | def _target_classes(self, target):
"""Set of target's provided classes.
Call at the target level is to memoize efficiently.
"""
target_classes = set()
contents = ClasspathUtil.classpath_contents((target,), self.runtime_classpath)
for f in contents:
| python | {
"resource": ""
} |
q27862 | JvmDependencyAnalyzer._jar_classfiles | train | def _jar_classfiles(self, jar_file):
"""Returns an iterator over the classfiles inside | python | {
"resource": ""
} |
q27863 | JvmDependencyAnalyzer.bootstrap_jar_classfiles | train | def bootstrap_jar_classfiles(self):
"""Returns a set of classfiles from the JVM bootstrap jars."""
bootstrap_jar_classfiles = set()
for jar_file in self._find_all_bootstrap_jars():
for cls | python | {
"resource": ""
} |
q27864 | JvmDependencyAnalyzer.compute_transitive_deps_by_target | train | def compute_transitive_deps_by_target(self, targets):
"""Map from target to all the targets it depends on, transitively."""
# Sort from least to most dependent.
sorted_targets = reversed(sort_targets(targets))
transitive_deps_by_target = defaultdict(set)
# Iterate in dep order, to accumulate the tra... | python | {
"resource": ""
} |
q27865 | JvmDependencyAnalyzer.resolve_aliases | train | def resolve_aliases(self, target, scope=None):
"""Resolve aliases in the direct dependencies of the target.
:param target: The direct dependencies of this target are included.
:param scope: When specified, only deps with this scope are included. This is more
than a filter, because it prunes the subgr... | python | {
"resource": ""
} |
q27866 | IvyTaskMixin.ivy_classpath | train | def ivy_classpath(self, targets, silent=True, workunit_name=None):
"""Create the classpath for the passed targets.
:API: public
:param targets: A collection of targets to resolve a classpath for.
:type targets: collection.Iterable
| python | {
"resource": ""
} |
q27867 | IvyTaskMixin._ivy_resolve | train | def _ivy_resolve(self,
targets,
executor=None,
silent=False,
workunit_name=None,
confs=None,
extra_args=None,
invalidate_dependents=False,
pinned_artifacts=None):
"... | python | {
"resource": ""
} |
q27868 | PythonExecutionTaskBase.create_pex | train | def create_pex(self, pex_info=None):
"""Returns a wrapped pex that "merges" the other pexes via PEX_PATH."""
relevant_targets = self.context.targets(
lambda tgt: isinstance(tgt, (
PythonDistribution, PythonRequirementLibrary, PythonTarget, Files)))
with self.invalidated(relevant_targets) as in... | python | {
"resource": ""
} |
q27869 | get_pants_cachedir | train | def get_pants_cachedir():
"""Return the pants global cache directory."""
# Follow the unix XDB base spec: http://standards.freedesktop.org/basedir-spec/latest/index.html.
cache_home = os.environ.get('XDG_CACHE_HOME')
if not | python | {
"resource": ""
} |
q27870 | get_pants_configdir | train | def get_pants_configdir():
"""Return the pants global config directory."""
# Follow the unix XDB base spec: http://standards.freedesktop.org/basedir-spec/latest/index.html.
config_home = os.environ.get('XDG_CONFIG_HOME')
if not | python | {
"resource": ""
} |
q27871 | get_scm | train | def get_scm():
"""Returns the pants Scm if any.
:API: public
"""
# TODO(John Sirois): Extract a module/class to carry the bootstrap logic.
global _SCM
if not _SCM:
from pants.scm.git import Git
# We know about git, so attempt an auto-configure
worktree = Git.detect_worktree()
if worktree an... | python | {
"resource": ""
} |
q27872 | set_scm | train | def set_scm(scm):
"""Sets the pants Scm."""
if scm is not None:
if not isinstance(scm, Scm):
raise ValueError('The | python | {
"resource": ""
} |
q27873 | NativeCompile.get_sources_headers_for_target | train | def get_sources_headers_for_target(self, target):
"""Return a list of file arguments to provide to the compiler.
NB: result list will contain both header and source files!
:raises: :class:`NativeCompile.NativeCompileError` if there is an error processing the sources.
"""
# Get source paths relativ... | python | {
"resource": ""
} |
q27874 | NativeCompile._make_compile_argv | train | def _make_compile_argv(self, compile_request):
"""Return a list of arguments to use to compile sources. Subclasses can override and append."""
sources_minus_headers = list(self._iter_sources_minus_headers(compile_request))
if len(sources_minus_headers) == 0:
raise self._HeaderOnlyLibrary()
compi... | python | {
"resource": ""
} |
q27875 | NativeCompile._compile | train | def _compile(self, compile_request):
"""Perform the process of compilation, writing object files to the request's 'output_dir'.
NB: This method must arrange the output files so that `collect_cached_objects()` can collect all
of the results (or vice versa)!
"""
try:
argv = self._make_compile_... | python | {
"resource": ""
} |
q27876 | NativeCompile.collect_cached_objects | train | def collect_cached_objects(self, versioned_target):
"""Scan `versioned_target`'s results directory and return the output files from that directory.
:return: :class:`ObjectFiles`
"""
| python | {
"resource": ""
} |
q27877 | all_enclosing_scopes | train | def all_enclosing_scopes(scope, allow_global=True):
"""Utility function to return all scopes up to the global scope enclosing a
given scope."""
_validate_full_scope(scope)
# TODO: validate scopes here and/or in `enclosing_scope()` instead of | python | {
"resource": ""
} |
q27878 | ExportTask._resolve_jars_info | train | def _resolve_jars_info(self, targets, classpath_products):
"""Consults ivy_jar_products to export the external libraries.
:return: mapping of jar_id -> { 'default' : <jar_file>,
'sources' : <jar_file>,
'javadoc' : <jar_file>,
... | python | {
"resource": ""
} |
q27879 | ExportTask._get_pants_target_alias | train | def _get_pants_target_alias(self, pants_target_type):
"""Returns the pants target alias for the given target"""
if pants_target_type in self.target_aliases_map:
return | python | {
"resource": ""
} |
q27880 | DependencyContext.all_dependencies | train | def all_dependencies(self, target):
"""All transitive dependencies of the context's target."""
for dep in | python | {
"resource": ""
} |
q27881 | DependencyContext.defaulted_property | train | def defaulted_property(self, target, option_name):
"""Computes a language property setting for the given JvmTarget.
:param selector A function that takes a target or platform and returns the boolean value of the
property for that target or platform, or None if that target or platform does
... | python | {
"resource": ""
} |
q27882 | Zinc.dist | train | def dist(self):
"""Return the `Distribution` selected for Zinc based on execution strategy.
:rtype: pants.java.distribution.distribution.Distribution
"""
underlying_dist = self.underlying_dist
if self._execution_strategy != NailgunTaskBase.HERMETIC:
# symlink .pants.d/.jdk -> /some/java/home/... | python | {
"resource": ""
} |
q27883 | Zinc._compiler_bridge_cache_dir | train | def _compiler_bridge_cache_dir(self):
"""A directory where we can store compiled copies of the `compiler-bridge`.
The compiler-bridge is specific to each scala version.
Currently we compile the `compiler-bridge` only once, while bootstrapping.
Then, we store it in the working directory under .pants.d/z... | python | {
"resource": ""
} |
q27884 | Zinc.compile_compiler_bridge | train | def compile_compiler_bridge(self, context):
"""Compile the compiler bridge to be used by zinc, using our scala bootstrapper.
It will compile and cache the jar, and materialize it if not already there.
:param context: The context of the task trying to compile the bridge.
This is mostly n... | python | {
"resource": ""
} |
q27885 | Zinc._compiler_plugins_cp_entries | train | def _compiler_plugins_cp_entries(self):
"""Any additional global compiletime classpath entries for compiler plugins."""
java_options_src = Java.global_instance()
scala_options_src = ScalaPlatform.global_instance()
def cp(instance, toolname):
scope = instance.options_scope
return instance.to... | python | {
"resource": ""
} |
q27886 | Zinc.compile_classpath | train | def compile_classpath(self, classpath_product_key, target, extra_cp_entries=None):
"""Compute the compile classpath for the given target."""
classpath_entries = list(
entry.path
for entry in self.compile_classpath_entries(classpath_product_key, target, extra_cp_entries)
)
# Verify that a... | python | {
"resource": ""
} |
q27887 | GlobalSubsystems.get | train | def get(cls):
"""Subsystems used outside of any task."""
return {
SourceRootConfig,
Reporting,
Reproducer,
| python | {
"resource": ""
} |
q27888 | MustacheRenderer._get_template_text_from_package | train | def _get_template_text_from_package(self, template_name):
"""Load the named template embedded in our package."""
if self._package_name is None:
raise self.MustacheError('No package specified for template loading.')
path = os.path.join('templates', template_name + '.mustache')
template_text = pkgu... | python | {
"resource": ""
} |
q27889 | union | train | def union(cls):
"""A class decorator which other classes can specify that they can resolve to with `UnionRule`.
Annotating a class with @union allows other classes to use a UnionRule() instance to indicate that
they can be resolved to this base union class. This class will never be instantiated, and should
hav... | python | {
"resource": ""
} |
q27890 | _RuleVisitor._maybe_end_of_stmt_list | train | def _maybe_end_of_stmt_list(attr_value):
"""If `attr_value` is a non-empty iterable, return its final element."""
if (attr_value is not None) and isinstance(attr_value, Iterable):
| python | {
"resource": ""
} |
q27891 | NailgunTaskBase.create_java_executor | train | def create_java_executor(self, dist=None):
"""Create java executor that uses this task's ng daemon, if allowed.
Call only in execute() or later. TODO: Enforce this.
"""
dist = dist or self.dist
if self.execution_strategy == self.NAILGUN:
classpath = os.pathsep.join(self.tool_classpath('nailgu... | python | {
"resource": ""
} |
q27892 | NailgunTaskBase.runjava | train | def runjava(self, classpath, main, jvm_options=None, args=None, workunit_name=None,
workunit_labels=None, workunit_log_config=None, dist=None):
"""Runs the java main using the given classpath and args.
If --execution-strategy=subprocess is specified then the java main is run in a freshly spawned
... | python | {
"resource": ""
} |
q27893 | safe_filename | train | def safe_filename(name, extension=None, digest=None, max_length=_MAX_FILENAME_LENGTH):
"""Creates filename from name and extension ensuring that the final length is within the
max_length constraint.
By default the length is capped to work on most filesystems and the fallback to achieve
shortening is a sha1 has... | python | {
"resource": ""
} |
q27894 | expand_path | train | def expand_path(path):
"""Returns ``path`` as an absolute path with ~user and env | python | {
"resource": ""
} |
q27895 | RemotePantsRunner._run_pants_with_retry | train | def _run_pants_with_retry(self, pantsd_handle, retries=3):
"""Runs pants remotely with retry and recovery for nascent executions.
:param PantsDaemon.Handle pantsd_handle: A Handle for the daemon to connect to.
"""
attempt = 1
while 1:
logger.debug(
'connecting to pantsd on port {} (at... | python | {
"resource": ""
} |
q27896 | IvySubsystem.http_proxy | train | def http_proxy(self):
"""Set ivy to use an http proxy.
Expects a string of the form http://<host>:<port>
"""
if os.getenv('HTTP_PROXY'):
return os.getenv('HTTP_PROXY')
| python | {
"resource": ""
} |
q27897 | IvySubsystem.https_proxy | train | def https_proxy(self):
"""Set ivy to use an https proxy.
Expects a string of the form http://<host>:<port>
"""
if os.getenv('HTTPS_PROXY'):
return os.getenv('HTTPS_PROXY')
| python | {
"resource": ""
} |
q27898 | GoImportMetaTagReader.get_imported_repo | train | def get_imported_repo(self, import_path):
"""Looks for a go-import meta tag for the provided import_path.
Returns an ImportedRepo instance with the information in the meta tag,
or None if no go-import meta tag is found.
"""
try:
session = requests.session()
# TODO: Support https with (o... | python | {
"resource": ""
} |
q27899 | MutableBuildGraph._target_addressable_to_target | train | def _target_addressable_to_target(self, address, addressable):
"""Realizes a TargetAddressable into a Target at `address`.
:param TargetAddressable addressable:
:param Address address:
"""
try:
# TODO(John Sirois): Today - in practice, Addressable is unusable. BuildGraph assumes
# addr... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.