_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q28000
TargetAdaptor.field_adaptors
train
def field_adaptors(self): """Returns a tuple of Fields for captured fields which need additional treatment.""" with exception_logging(logger, 'Exception in `field_adaptors` property'): conjunction_globs = self.get_sources() if conjunction_globs is None: return tuple() sources = conju...
python
{ "resource": "" }
q28001
BaseGlobs.from_sources_field
train
def from_sources_field(sources, spec_path): """Return a BaseGlobs for the given sources field. `sources` may be None, a list/tuple/set, a string or a BaseGlobs instance. """ if sources is None: return Files(spec_path=spec_path) elif isinstance(sources, BaseGlobs): return sources eli...
python
{ "resource": "" }
q28002
BaseGlobs.filespecs
train
def filespecs(self): """Return a filespecs dict representing both globs and excludes.""" filespecs = {'globs': self._file_globs} exclude_filespecs = self._exclude_filespecs
python
{ "resource": "" }
q28003
BaseGlobs.to_path_globs
train
def to_path_globs(self, relpath, conjunction): """Return a PathGlobs representing the included and excluded Files for these patterns.""" return PathGlobs( include=tuple(os.path.join(relpath, glob) for glob in self._file_globs),
python
{ "resource": "" }
q28004
ConsolidateClasspath._consolidate_classpath
train
def _consolidate_classpath(self, targets, classpath_products): """Convert loose directories in classpath_products into jars. """ # TODO: find a way to not process classpath entries for valid VTs. # NB: It is very expensive to call to get entries for each target one at a time. # For performance reasons ...
python
{ "resource": "" }
q28005
_convert
train
def _convert(val, acceptable_types): """Ensure that val is one of the acceptable types, converting it if needed. :param val: The value we're parsing (either a string or one of the acceptable types). :param acceptable_types: A tuple of expected types for val. :returns: The parsed value. :raises :class:`pants....
python
{ "resource": "" }
q28006
ListValueComponent.create
train
def create(cls, value): """Interpret value as either a list or something to extend another list with. Note that we accept tuple literals, but the internal value is always a list. :param value: The value to convert. Can be an instance of ListValueComponent, a list, a tuple, a string repr...
python
{ "resource": "" }
q28007
DictValueComponent.create
train
def create(cls, value): """Interpret value as either a dict or something to extend another dict with. :param value: The value to convert. Can be an instance of DictValueComponent, a dict, or a string representation (possibly prefixed by +) of a dict. :rtype: `DictValueComponent` """ ...
python
{ "resource": "" }
q28008
TemplateData.extend
train
def extend(self, **kwargs): """Returns a new instance with this instance's data overlayed by the key-value args."""
python
{ "resource": "" }
q28009
Scm.github
train
def github(cls, user, repo): """Creates an `Scm` for a github repo. :param string user: The github user or organization name the repo is hosted under. :param string repo: The repository name. :returns: An `Scm` representing the github
python
{ "resource": "" }
q28010
Scm.tagged
train
def tagged(self, tag): """Creates a new `Scm` identical to this `Scm` but with the given `tag`."""
python
{ "resource": "" }
q28011
Cookies.update
train
def update(self, cookies): """Add specified cookies to our cookie jar, and persists it. :param cookies: Any iterable that yields http.cookiejar.Cookie instances, such as a CookieJar. """ cookie_jar = self.get_cookie_jar()
python
{ "resource": "" }
q28012
Cookies.get_cookie_jar
train
def get_cookie_jar(self): """Returns our cookie jar.""" cookie_file = self._get_cookie_file() cookie_jar = LWPCookieJar(cookie_file) if os.path.exists(cookie_file): cookie_jar.load() else: safe_mkdir_for(cookie_file) # Save an empty cookie jar so we can change the
python
{ "resource": "" }
q28013
Cookies._lock
train
def _lock(self): """An identity-keyed inter-process lock around the cookie file."""
python
{ "resource": "" }
q28014
GoTargetGenerator.generate
train
def generate(self, local_go_targets): """Automatically generates a Go target graph for the given local go targets. :param iter local_go_targets: The target roots to fill in a target graph for. :raises: :class:`GoTargetGenerator.GenerationError` if any missing targets cannot be generated. """ visite...
python
{ "resource": "" }
q28015
GoBuildgen.generate_targets
train
def generate_targets(self, local_go_targets=None): """Generate Go targets in memory to form a complete Go graph. :param local_go_targets: The local Go targets to fill in a complete target graph for. If `None`, then all local Go targets under the Go source root are used. :type ...
python
{ "resource": "" }
q28016
SingleAddress.address_target_pairs_from_address_families
train
def address_target_pairs_from_address_families(self, address_families): """Return the pair for the single target matching the single AddressFamily, or error. :raises: :class:`SingleAddress._SingleAddressResolutionError` if no targets could be found for a :class:`SingleAddress` instance. :retur...
python
{ "resource": "" }
q28017
Bootstrapper.ivy
train
def ivy(self, bootstrap_workunit_factory=None): """Returns an ivy instance bootstrapped by this bootstrapper. :param bootstrap_workunit_factory: the optional workunit to bootstrap under. :raises: Bootstrapper.Error if ivy
python
{ "resource": "" }
q28018
Bootstrapper._get_classpath
train
def _get_classpath(self, workunit_factory): """Returns the bootstrapped ivy classpath as a list of jar paths. :raises: Bootstrapper.Error if the classpath could not be bootstrapped """ if not
python
{ "resource": "" }
q28019
Target.maybe_readable_combine_ids
train
def maybe_readable_combine_ids(cls, ids): """Generates combined id for a set of ids, but if the set is a single id, just use that. :API: public """
python
{ "resource": "" }
q28020
Target.closure_for_targets
train
def closure_for_targets(cls, target_roots, exclude_scopes=None, include_scopes=None, bfs=None, postorder=None, respect_intransitive=False): """Computes the closure of the given targets respecting the given input scopes. :API: public :param list target_roots: The list of Targets t...
python
{ "resource": "" }
q28021
Target.mark_invalidation_hash_dirty
train
def mark_invalidation_hash_dirty(self): """Invalidates memoized fingerprints for this target, including those in payloads. Exposed for testing. :API: public """ self._cached_fingerprint_map = {} self._cached_all_transitive_fingerprint_map = {} self._cached_direct_transitive_fingerprint_map...
python
{ "resource": "" }
q28022
Target.has_sources
train
def has_sources(self, extension=None): """Return `True` if this target owns sources; optionally of the given `extension`. :API: public :param string extension: Optional suffix of filenames to test for.
python
{ "resource": "" }
q28023
Target.derived_from_chain
train
def derived_from_chain(self): """Returns all targets that this target was derived from. If this target was not derived from another, returns an empty sequence. :API: public
python
{ "resource": "" }
q28024
Target.walk
train
def walk(self, work, predicate=None): """Walk of this target's dependency graph, DFS preorder traversal, visiting each node exactly once. If a predicate is supplied it will be used to test each target before handing the target to work and descending. Work can return targets in which case these will be ...
python
{ "resource": "" }
q28025
Target.create_sources_field
train
def create_sources_field(self, sources, sources_rel_path, key_arg=None): """Factory method to create a SourcesField appropriate for the type of the sources object. Note that this method is called before the call to Target.__init__ so don't expect fields to be populated! :API: public :return: a pa...
python
{ "resource": "" }
q28026
SourceRootFactory.create
train
def create(self, relpath, langs, category): """Return a source root at the given `relpath` for the given `langs` and `category`. :returns: :class:`SourceRoot`. """
python
{ "resource": "" }
q28027
SourceRoots.add_source_root
train
def add_source_root(self, path, langs=tuple(), category=SourceRootCategories.UNKNOWN): """Add the specified fixed source root, which must be relative to the buildroot. Useful in a limited set of circumstances, e.g., when unpacking sources from a jar with unknown
python
{ "resource": "" }
q28028
SourceRoots.find_by_path
train
def find_by_path(self, path): """Find the source root for the given path, or None. :param path: Find the source root for this path, relative to the buildroot. :return: A SourceRoot instance, or None if the path is not located under a source root and `unmatched==fail`. """ matched = sel...
python
{ "resource": "" }
q28029
SourceRoots.all_roots
train
def all_roots(self): """Return all known source roots. Returns a generator over (source root, list of langs, category) triples. Note: Requires a directory walk to match actual directories against patterns. However we don't descend into source roots, once found, so this should be fast in practice. ...
python
{ "resource": "" }
q28030
SourceRootConfig.create_trie
train
def create_trie(self): """Create a trie of source root patterns from options. :returns: :class:`SourceRootTrie` """ trie = SourceRootTrie(self.source_root_factory) options = self.get_options() for category in SourceRootCategories.ALL:
python
{ "resource": "" }
q28031
SourceRootTrie.add_pattern
train
def add_pattern(self, pattern, category=SourceRootCategories.UNKNOWN): """Add a pattern to the
python
{ "resource": "" }
q28032
SourceRootTrie.add_fixed
train
def add_fixed(self, path, langs, category=SourceRootCategories.UNKNOWN): """Add a fixed source root to the trie.""" if '*' in path: raise self.InvalidPath(path, 'fixed path cannot contain the * character')
python
{ "resource": "" }
q28033
SourceRootTrie.fixed
train
def fixed(self): """Returns a list of just the fixed source roots in the trie."""
python
{ "resource": "" }
q28034
SourceRootTrie.find
train
def find(self, path): """Find the source root for the given path.""" keys = ['^'] + path.split(os.path.sep) for i in range(len(keys)): # See if we have a match at position i. We have such a match if following the path # segments into the trie, from the root, leads us to a terminal. node =...
python
{ "resource": "" }
q28035
BinaryToolBase.version
train
def version(self, context=None): """Returns the version of the specified binary tool. If replaces_scope and replaces_name are defined, then the caller must pass in a context, otherwise no context should be passed. # TODO: Once we're migrated, get rid of the context arg. :API: public """ i...
python
{ "resource": "" }
q28036
Reporting.initialize
train
def initialize(self, run_tracker, all_options, start_time=None): """Initialize with the given RunTracker. TODO: See `RunTracker.start`. """ run_id, run_uuid = run_tracker.initialize(all_options) run_dir = os.path.join(self.get_options().reports_dir, run_id) html_dir = os.path.join(run_dir, 'h...
python
{ "resource": "" }
q28037
Reporting.update_reporting
train
def update_reporting(self, global_options, is_quiet, run_tracker): """Updates reporting config once we've parsed cmd-line flags.""" # Get any output silently buffered in the old console reporter, and remove it. removed_reporter = run_tracker.report.remove_reporter('capturing') buffered_out = self._cons...
python
{ "resource": "" }
q28038
Pinger.ping
train
def ping(self, url): """Time a single roundtrip to the url. :param url to ping. :returns: the fastest ping time for a given netloc and number of tries. or Pinger.UNREACHABLE if ping times out.
python
{ "resource": "" }
q28039
BestUrlSelector.select_best_url
train
def select_best_url(self): """Select `best` url. Since urls are pre-sorted w.r.t. their ping times, we simply return the first element from the list. And we always return the same url unless we observe greater than max allowed number of consecutive failures. In this case, we would return the next `best...
python
{ "resource": "" }
q28040
ExceptionSink.reset_log_location
train
def reset_log_location(cls, new_log_location): """Re-acquire file handles to error logs based in the new location. Class state: - Overwrites `cls._log_dir`, `cls._pid_specific_error_fileobj`, and `cls._shared_error_fileobj`. OS state: - May create a new directory. - Overwrites signal hand...
python
{ "resource": "" }
q28041
ExceptionSink.exceptions_log_path
train
def exceptions_log_path(cls, for_pid=None, in_dir=None): """Get the path to either the shared or pid-specific fatal errors log file.""" if for_pid is None: intermediate_filename_component = '' else: assert(isinstance(for_pid, IntegerForPid))
python
{ "resource": "" }
q28042
ExceptionSink.log_exception
train
def log_exception(cls, msg): """Try to log an error message to this process's error log and the shared error log. NB: Doesn't raise (logs an error instead). """ pid = os.getpid() fatal_error_log_entry = cls._format_exception_message(msg, pid) # We care more about this log than the shared log, ...
python
{ "resource": "" }
q28043
ExceptionSink.trapped_signals
train
def trapped_signals(cls, new_signal_handler): """A contextmanager which temporarily overrides signal handling.""" try:
python
{ "resource": "" }
q28044
ExceptionSink._log_unhandled_exception_and_exit
train
def _log_unhandled_exception_and_exit(cls, exc_class=None, exc=None, tb=None, add_newline=False): """A sys.excepthook implementation which logs the error and exits with failure.""" exc_class = exc_class or sys.exc_info()[0] exc = exc or sys.exc_info()[1] tb = tb or sys.exc_info()[2] # This exceptio...
python
{ "resource": "" }
q28045
ExceptionSink._handle_signal_gracefully
train
def _handle_signal_gracefully(cls, signum, signame, traceback_lines): """Signal handler for non-fatal signals which raises or logs an error and exits with failure.""" # Extract the stack, and format an entry to be written to the exception log. formatted_traceback = cls._format_traceback(traceback_lines=trac...
python
{ "resource": "" }
q28046
DaemonExiter.exit
train
def exit(self, result=0, msg=None, *args, **kwargs): """Exit the runtime.""" if self._finalizer: try: self._finalizer() except Exception as e: try: NailgunProtocol.send_stderr( self._socket, '\nUnexpected exception in finalizer: {!r}\n'.format(e) ...
python
{ "resource": "" }
q28047
DaemonPantsRunner._tty_stdio
train
def _tty_stdio(cls, env): """Handles stdio redirection in the case of all stdio descriptors being the same tty.""" # If all stdio is a tty, there's only one logical I/O device (the tty device). This happens to # be addressable as a file in OSX and Linux, so we take advantage of that and directly open the ...
python
{ "resource": "" }
q28048
DaemonPantsRunner.nailgunned_stdio
train
def nailgunned_stdio(cls, sock, env, handle_stdin=True): """Redirects stdio to the connected socket speaking the nailgun protocol.""" # Determine output tty capabilities from the environment. stdin_isatty, stdout_isatty, stderr_isatty = NailgunProtocol.isatty_from_env(env)
python
{ "resource": "" }
q28049
DaemonPantsRunner._raise_deferred_exc
train
def _raise_deferred_exc(self): """Raises deferred exceptions from the daemon's synchronous path in the post-fork client.""" if self._deferred_exception: try: exc_type, exc_value, exc_traceback = self._deferred_exception raise_with_traceback(exc_value, exc_traceback)
python
{ "resource": "" }
q28050
NpmResolver._scoped_package_name
train
def _scoped_package_name(node_task, package_name, node_scope): """Apply a node_scope to the package name. Overrides any existing package_name if already in a scope :return: A package_name with prepended with a node scope via '@' """ if not node_scope: return package_name scoped_package...
python
{ "resource": "" }
q28051
JvmCompile.compile
train
def compile(self, ctx, args, dependency_classpath, upstream_analysis, settings, compiler_option_sets, zinc_file_manager, javac_plugin_map, scalac_plugin_map): """Invoke the compiler. Subclasses must implement. Must raise TaskError on compile failure. :param CompileContext ctx: ...
python
{ "resource": "" }
q28052
JvmCompile.do_compile
train
def do_compile(self, invalidation_check, compile_contexts, classpath_product): """Executes compilations for the invalid targets contained in a single chunk.""" invalid_targets = [vt.target for vt in invalidation_check.invalid_vts] valid_targets = [vt.target for vt in invalidation_check.all_vts if vt.valid]...
python
{ "resource": "" }
q28053
JvmCompile._compile_vts
train
def _compile_vts(self, vts, ctx, upstream_analysis, dependency_classpath, progress_message, settings, compiler_option_sets, zinc_file_manager, counter): """Compiles sources for the given vts into the given output dir. :param vts: VersionedTargetSet with one entry for the target. :param c...
python
{ "resource": "" }
q28054
JvmCompile._get_plugin_map
train
def _get_plugin_map(self, compiler, options_src, target): """Returns a map of plugin to args, for the given compiler. Only plugins that must actually be activated will be present as keys in the map. Plugins with no arguments will have an empty list as a value. Active plugins and their args will be gat...
python
{ "resource": "" }
q28055
JvmCompile._find_logs
train
def _find_logs(self, compile_workunit): """Finds all logs under the given workunit.""" for idx, workunit in enumerate(compile_workunit.children): for output_name, outpath in workunit.output_paths().items():
python
{ "resource": "" }
q28056
JvmCompile._upstream_analysis
train
def _upstream_analysis(self, compile_contexts, classpath_entries): """Returns tuples of classes_dir->analysis_file for the closure of the target.""" # Reorganize the compile_contexts by class directory. compile_contexts_by_directory = {} for compile_context in compile_contexts.values(): compile_co...
python
{ "resource": "" }
q28057
JvmCompile.should_compile_incrementally
train
def should_compile_incrementally(self, vts, ctx): """Check to see if the compile should try to re-use the existing analysis. Returns true if we should try to compile the target incrementally. """
python
{ "resource": "" }
q28058
JvmCompile._create_context_jar
train
def _create_context_jar(self, compile_context): """Jar up the compile_context to its output jar location. TODO(stuhood): In the medium term, we hope to add compiler support for this step, which would allow the jars to be used as compile _inputs_ as well. Currently using jar'd compile outputs as compile...
python
{ "resource": "" }
q28059
JvmCompile._extra_compile_time_classpath
train
def _extra_compile_time_classpath(self): """Compute any extra compile-time-only classpath elements.""" def extra_compile_classpath_iter(): for conf in self._confs:
python
{ "resource": "" }
q28060
JvmCompile._plugin_targets
train
def _plugin_targets(self, compiler): """Returns a map from plugin name to the targets that build that plugin.""" if compiler == 'javac': plugin_cls = JavacPlugin elif compiler ==
python
{ "resource": "" }
q28061
CppCompile.execute
train
def execute(self): """Compile all sources in a given target to object files.""" def is_cc(source): _, ext = os.path.splitext(source) return ext in self.get_options().cc_extensions targets = self.context.targets(self.is_cpp) # Compile source files to objects. with self.invalidated(targ...
python
{ "resource": "" }
q28062
CppCompile._compile
train
def _compile(self, target, results_dir, source): """Compile given source to an object file.""" obj = self._objpath(target, results_dir, source) safe_mkdir_for(obj) abs_source = os.path.join(get_buildroot(), source) # TODO: include dir should include dependent work dir when headers are copied there...
python
{ "resource": "" }
q28063
PantsHandler.do_GET
train
def do_GET(self): """GET method implementation for BaseHTTPRequestHandler.""" if not self._client_allowed(): return try: (_, _, path, query, _) = urlsplit(self.path) params = parse_qs(query) # Give each handler a chance to respond. for prefix, handler in self._GET_handlers:
python
{ "resource": "" }
q28064
PantsHandler._handle_runs
train
def _handle_runs(self, relpath, params): """Show a listing of all pants runs since the last clean-all.""" runs_by_day = self._partition_runs_by_day() args = self._default_template_args('run_list.html') args['runs_by_day'] = runs_by_day
python
{ "resource": "" }
q28065
PantsHandler._handle_run
train
def _handle_run(self, relpath, params): """Show the report for a single pants run.""" args = self._default_template_args('run.html') run_id = relpath run_info = self._get_run_info_dict(run_id) if run_info is None: args['no_such_run'] = relpath if run_id == 'latest': args['is_late...
python
{ "resource": "" }
q28066
PantsHandler._handle_browse
train
def _handle_browse(self, relpath, params): """Handle requests to browse the filesystem under the build root.""" abspath = os.path.normpath(os.path.join(self._root, relpath))
python
{ "resource": "" }
q28067
PantsHandler._handle_content
train
def _handle_content(self, relpath, params): """Render file content for pretty display.""" abspath = os.path.normpath(os.path.join(self._root, relpath)) if os.path.isfile(abspath): with open(abspath, 'rb') as infile: content = infile.read() else: content = 'No file found at {}'.format...
python
{ "resource": "" }
q28068
PantsHandler._handle_poll
train
def _handle_poll(self, relpath, params): """Handle poll requests for raw file contents.""" request = json.loads(params.get('q')[0]) ret = {} # request is a polling request for multiple files. For each file: # - id is some identifier assigned by the client, used to differentiate the results. # ...
python
{ "resource": "" }
q28069
PantsHandler._partition_runs_by_day
train
def _partition_runs_by_day(self): """Split the runs by day, so we can display them grouped that way.""" run_infos = self._get_all_run_infos() for x in run_infos: ts = float(x['timestamp']) x['time_of_day_text'] = datetime.fromtimestamp(ts).strftime('%H:%M:%S') def date_text(dt): delta...
python
{ "resource": "" }
q28070
PantsHandler._get_run_info_dict
train
def _get_run_info_dict(self, run_id): """Get the RunInfo for a run, as a dict.""" run_info_path = os.path.join(self._settings.info_dir, run_id, 'info') if os.path.exists(run_info_path): # We copy the RunInfo
python
{ "resource": "" }
q28071
PantsHandler._get_all_run_infos
train
def _get_all_run_infos(self): """Find the RunInfos for all runs since the last clean-all.""" info_dir = self._settings.info_dir if not os.path.isdir(info_dir): return [] paths = [os.path.join(info_dir, x) for x in os.listdir(info_dir)] # We copy the RunInfo as a dict, so we can add stuff to i...
python
{ "resource": "" }
q28072
PantsHandler._serve_dir
train
def _serve_dir(self, abspath, params): """Show a directory listing.""" relpath = os.path.relpath(abspath, self._root) breadcrumbs = self._create_breadcrumbs(relpath) entries = [{'link_path': os.path.join(relpath, e), 'name': e} for e in os.listdir(abspath)] args = self._default_template_args('dir.ht...
python
{ "resource": "" }
q28073
PantsHandler._serve_file
train
def _serve_file(self, abspath, params): """Show a file. The actual content of the file is rendered by _handle_content. """ relpath = os.path.relpath(abspath, self._root) breadcrumbs = self._create_breadcrumbs(relpath) link_path = urlunparse(['', '', relpath, '', urlencode(params), '']) args...
python
{ "resource": "" }
q28074
PantsHandler._send_content
train
def _send_content(self, content, content_type, code=200): """Send content to client.""" assert isinstance(content, bytes)
python
{ "resource": "" }
q28075
PantsHandler._client_allowed
train
def _client_allowed(self): """Check if client is allowed to connect to this server.""" client_ip = self._client_address[0] if not client_ip in self._settings.allowed_clients and \ not 'ALL' in self._settings.allowed_clients:
python
{ "resource": "" }
q28076
PantsHandler._maybe_handle
train
def _maybe_handle(self, prefix, handler, path, params, data=None): """Apply the handler if the prefix matches.""" if path.startswith(prefix): relpath = path[len(prefix):] if data:
python
{ "resource": "" }
q28077
PantsHandler._create_breadcrumbs
train
def _create_breadcrumbs(self, relpath): """Create filesystem browsing breadcrumb navigation. That is, make each path segment into a clickable element that takes you to that dir. """ if relpath == '.': breadcrumbs = []
python
{ "resource": "" }
q28078
PantsHandler._default_template_args
train
def _default_template_args(self, content_template): """Initialize template args.""" def include(text, args): template_name = pystache.render(text, args) return self._renderer.render_name(template_name, args) # Our base template calls
python
{ "resource": "" }
q28079
ArgSplitter._consume_flags
train
def _consume_flags(self): """Read flags until we encounter the first token that isn't a flag.""" flags = [] while self._at_flag(): flag = self._unconsumed_args.pop()
python
{ "resource": "" }
q28080
ArgSplitter._descope_flag
train
def _descope_flag(self, flag, default_scope): """If the flag is prefixed by its scope, in the old style, extract the scope. Otherwise assume it belongs to default_scope. returns a pair (scope, flag). """ for scope_prefix, scope_info in self._known_scoping_prefixes: for flag_prefix in ['--', ...
python
{ "resource": "" }
q28081
Git.detect_worktree
train
def detect_worktree(cls, binary='git', subdir=None): """Detect the git working tree above cwd and return it; else, return None. :param string binary: The path to the git binary to use, 'git' by default. :param string subdir: The path to start searching for a git repo. :returns: path to the directory wh...
python
{ "resource": "" }
q28082
Git.clone
train
def clone(cls, repo_url, dest, binary='git'): """Clone the repo at repo_url into dest. :param string binary: The path to the git binary to use, 'git' by default. :returns: an instance of this class representing the cloned repo. :rtype: Git
python
{ "resource": "" }
q28083
Git._invoke
train
def _invoke(cls, cmd): """Invoke the given command, and return a tuple of process and raw binary output. stderr flows to wherever its currently mapped for the parent process - generally to the terminal where the user can see the error. :param list cmd: The command in the form of a list of strings ...
python
{ "resource": "" }
q28084
Git._get_upstream
train
def _get_upstream(self): """Return the remote and remote merge branch for the current branch""" if not self._remote or not self._branch: branch = self.branch_name if not branch: raise Scm.LocalException('Failed to determine local branch') def get_local_config(key):
python
{ "resource": "" }
q28085
GitRepositoryReader.listdir
train
def listdir(self, relpath): """Like os.listdir, but reads from the git repository. :returns: a list of relative filenames """ path = self._realpath(relpath) if not path.endswith('/'): raise self.NotADirException(self.rev, relpath)
python
{ "resource": "" }
q28086
GitRepositoryReader.open
train
def open(self, relpath): """Read a file out of the repository at a certain revision. This is complicated because, unlike vanilla git cat-file, this follows symlinks in the repo. If a symlink points outside repo, the file is read from the filesystem; that's because presumably whoever put that symlink t...
python
{ "resource": "" }
q28087
GitRepositoryReader._realpath
train
def _realpath(self, relpath): """Follow symlinks to find the real path to a file or directory in the repo. :returns: if the expanded path points to a file, the relative path to that file; if a directory, the relative path + '/'; if a symlink outside the repo, a path starting with / ...
python
{ "resource": "" }
q28088
GitRepositoryReader._read_tree
train
def _read_tree(self, path): """Given a revision and path, parse the tree data out of git cat-file output. :returns: a dict from filename -> [list of Symlink, Dir, and File objects] """ path = self._fixup_dot_relative(path) tree = self._trees.get(path) if tree: return tree tree = {} ...
python
{ "resource": "" }
q28089
BundleMixin.register_options
train
def register_options(cls, register): """Register options common to all bundle tasks.""" super(BundleMixin, cls).register_options(register) register('--archive', choices=list(archive.TYPE_NAMES), fingerprint=True, help='Create an archive of this type from the bundle. '
python
{ "resource": "" }
q28090
BundleMixin.resolved_option
train
def resolved_option(options, target, key): """Get value for option "key". Resolution precedence is CLI option > target option > pants.ini option. :param options: Options returned by `task.get_option()` :param target: Target :param key: Key to get using the resolution precedence """ option_...
python
{ "resource": "" }
q28091
BundleMixin.symlink_bundles
train
def symlink_bundles(self, app, bundle_dir): """For each bundle in the given app, symlinks relevant matched paths. Validates that at least one path was matched by a bundle. """ for bundle_counter, bundle in enumerate(app.bundles): count = 0 for path, relpath in bundle.filemap.items(): ...
python
{ "resource": "" }
q28092
BundleMixin.publish_results
train
def publish_results(self, dist_dir, use_basename_prefix, vt, bundle_dir, archivepath, id, archive_ext): """Publish a copy of the bundle and archive from the results dir in dist.""" # TODO (from mateor) move distdir management somewhere more general purpose. name = vt.target.basename if use_basename_prefix e...
python
{ "resource": "" }
q28093
NodeResolve.prepare
train
def prepare(cls, options, round_manager): """Allow each resolver to declare additional product requirements.""" super(NodeResolve, cls).prepare(options, round_manager)
python
{ "resource": "" }
q28094
NodeResolve._topological_sort
train
def _topological_sort(self, targets): """Topologically order a list of targets""" target_set = set(targets)
python
{ "resource": "" }
q28095
safe_kill
train
def safe_kill(pid, signum): """Kill a process with the specified signal, catching nonfatal errors.""" assert(isinstance(pid, IntegerForPid)) assert(isinstance(signum, int)) try: os.kill(pid, signum)
python
{ "resource": "" }
q28096
IvyResolveResult.all_linked_artifacts_exist
train
def all_linked_artifacts_exist(self): """All of the artifact paths for this resolve point to existing files.""" if not
python
{ "resource": "" }
q28097
IvyResolveResult.resolved_jars_for_each_target
train
def resolved_jars_for_each_target(self, conf, targets): """Yields the resolved jars for each passed JarLibrary. If there is no report for the requested conf, yields nothing. :param conf: The ivy conf to load jars for. :param targets: The collection of JarLibrary targets to find resolved jars for. ...
python
{ "resource": "" }
q28098
IvyInfo.traverse_dependency_graph
train
def traverse_dependency_graph(self, ref, collector, memo=None): """Traverses module graph, starting with ref, collecting values for each ref into the sets created by the collector function. :param ref an IvyModuleRef to start traversing the ivy dependency graph :param collector a function that takes a ...
python
{ "resource": "" }
q28099
IvyInfo.get_resolved_jars_for_coordinates
train
def get_resolved_jars_for_coordinates(self, coordinates, memo=None): """Collects jars for the passed coordinates. Because artifacts are only fetched for the "winning" version of a module, the artifacts will not always represent the version originally declared by the library. This method is transitive ...
python
{ "resource": "" }