_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q27400
PackageManager.add_package
train
def add_package( self, package, node_paths=None, type_option=PackageInstallationTypeOption.PROD, version_option=None): """Returns a command that when executed will add a node package to current node module. :param package: string. A valid npm/yarn package description. The accepted forms ...
python
{ "resource": "" }
q27401
PackageManager.run_cli
train
def run_cli(self, cli, args=None, node_paths=None): """Returns a command that when executed will run an installed cli via package manager.""" cli_args = [cli] if args:
python
{ "resource": "" }
q27402
BuildFile.get_build_files_family
train
def get_build_files_family(project_tree, dir_relpath, build_ignore_patterns=None): """Returns all the BUILD files on a path""" build_files = set() for build in sorted(project_tree.glob1(dir_relpath, '{prefix}*'.format(prefix=BuildFile._BUILD_FILE_PREFIX))): if BuildFile._is_buildfile_name(build)
python
{ "resource": "" }
q27403
BuildFile.code
train
def code(self): """Returns the code object for this BUILD file."""
python
{ "resource": "" }
q27404
Parser.walk
train
def walk(self, callback): """Invoke callback on this parser and its descendants, in depth-first order.""" callback(self)
python
{ "resource": "" }
q27405
Parser._create_flag_value_map
train
def _create_flag_value_map(self, flags): """Returns a map of flag -> list of values, based on the given flag strings. None signals no value given (e.g., -x, --foo). The value is a list because the user may specify the same flag multiple times, and that's sometimes OK (e.g., when appending to list-value...
python
{ "resource": "" }
q27406
Parser.parse_args
train
def parse_args(self, flags, namespace): """Set values for this parser's options on the namespace object.""" flag_value_map = self._create_flag_value_map(flags) mutex_map = defaultdict(list) for args, kwargs in self._unnormalized_option_registrations_iter(): self._validate(args, kwargs) dest...
python
{ "resource": "" }
q27407
Parser.option_registrations_iter
train
def option_registrations_iter(self): """Returns an iterator over the normalized registration arguments of each option in this parser. Useful for generating help and other documentation. Each yielded item is an (args, kwargs) pair, as passed to register(), except that kwargs will be normalized in the f...
python
{ "resource": "" }
q27408
Parser._unnormalized_option_registrations_iter
train
def _unnormalized_option_registrations_iter(self): """Returns an iterator over the raw registration arguments of each option in this parser. Each yielded item is an (args, kwargs) pair, exactly as passed to register(), except for substituting list and dict types with list_option/dict_option. Note that...
python
{ "resource": "" }
q27409
Parser._recursive_option_registration_args
train
def _recursive_option_registration_args(self): """Yield args, kwargs pairs for just our recursive options. Includes all the options we inherit recursively from our ancestors. """ if self._parent_parser: for args, kwargs in self._parent_parser._recursive_option_registration_args(): yield a...
python
{ "resource": "" }
q27410
Parser.register
train
def register(self, *args, **kwargs): """Register an option.""" if self._frozen: raise FrozenRegistration(self.scope, args[0]) # Prevent further registration in enclosing scopes. ancestor = self._parent_parser while ancestor: ancestor._freeze() ancestor = ancestor._parent_parser ...
python
{ "resource": "" }
q27411
Parser._validate
train
def _validate(self, args, kwargs): """Validate option registration arguments.""" def error(exception_type, arg_name=None, **msg_kwargs): if arg_name is None: arg_name = args[0] if args else '<unknown>' raise exception_type(self.scope, arg_name, **msg_kwargs) if not args: error(NoO...
python
{ "resource": "" }
q27412
Parser.parse_dest
train
def parse_dest(*args, **kwargs): """Select the dest name for an option registration. If an explicit `dest` is specified, returns that and otherwise derives a default from the
python
{ "resource": "" }
q27413
BuildLocalPythonDistributions._create_dist
train
def _create_dist(self, dist_tgt, dist_target_dir, setup_requires_pex, snapshot_fingerprint, is_platform_specific): """Create a .whl file for the specified python_distribution target.""" self._copy_sources(dist_tgt, di...
python
{ "resource": "" }
q27414
BuildLocalPythonDistributions._inject_synthetic_dist_requirements
train
def _inject_synthetic_dist_requirements(self, dist, req_lib_addr): """Inject a synthetic requirements library that references a local wheel. :param dist: Path of the locally built wheel to reference. :param req_lib_addr: :class: `Address` to give to the synthetic target. :return: a :class: `PythonRequ...
python
{ "resource": "" }
q27415
BuildLocalPythonDistributions._get_whl_from_dir
train
def _get_whl_from_dir(cls, install_dir): """Return the absolute path of the whl in a setup.py install directory.""" dist_dir = cls._get_dist_dir(install_dir) dists = glob.glob(os.path.join(dist_dir, '*.whl')) if len(dists) == 0: raise cls.BuildLocalPythonDistributionsError( 'No distributio...
python
{ "resource": "" }
q27416
JUnitRun._spawn
train
def _spawn(self, distribution, executor=None, *args, **kwargs): """Returns a processhandler to a process executing java. :param Executor executor: the java subprocess executor to use. If not specified, construct using the distribution.
python
{ "resource": "" }
q27417
JUnitRun.execute_java_for_coverage
train
def execute_java_for_coverage(self, targets, *args, **kwargs): """Execute java for targets directly and don't use the test mixin. This execution won't be wrapped with timeouts and other test mixin code common across test targets. Used for coverage instrumentation.
python
{ "resource": "" }
q27418
JUnitRun._parse
train
def _parse(self, test_spec_str): """Parses a test specification string into an object that can yield corresponding tests. Tests can be specified in one of four forms: * [classname] * [classname]#[methodname] * [fully qualified classname]#[methodname] * [fully qualified classname]#[methodname] ...
python
{ "resource": "" }
q27419
JvmToolMixin.register_jvm_tool
train
def register_jvm_tool(cls, register, key, classpath_spec=None, main=None, custom_rules=None, fingerprint=True, classpath=None, h...
python
{ "resource": "" }
q27420
target_types_from_build_file_aliases
train
def target_types_from_build_file_aliases(aliases): """Given BuildFileAliases, return the concrete target types constructed for each alias.""" target_types = dict(aliases.target_types) for alias,
python
{ "resource": "" }
q27421
transitive_hydrated_targets
train
def transitive_hydrated_targets(build_file_addresses): """Given BuildFileAddresses, kicks off recursion on expansion of TransitiveHydratedTargets. The TransitiveHydratedTarget struct represents a structure-shared graph, which we walk and flatten here. The engine memoizes the computation of TransitiveHydratedTarg...
python
{ "resource": "" }
q27422
hydrated_targets
train
def hydrated_targets(build_file_addresses): """Requests HydratedTarget instances for BuildFileAddresses."""
python
{ "resource": "" }
q27423
hydrate_target
train
def hydrate_target(hydrated_struct): target_adaptor = hydrated_struct.value """Construct a HydratedTarget from a TargetAdaptor and hydrated versions of its adapted fields.""" # Hydrate the fields of the adaptor and re-construct it. hydrated_fields = yield [Get(HydratedField, HydrateableField, fa) ...
python
{ "resource": "" }
q27424
hydrate_sources
train
def hydrate_sources(sources_field, glob_match_error_behavior): """Given a SourcesField, request a Snapshot for its path_globs and create an EagerFilesetWithSpec. """ # TODO(#5864): merge the target's selection of --glob-expansion-failure (which doesn't exist yet) # with the global default! path_globs = source...
python
{ "resource": "" }
q27425
hydrate_bundles
train
def hydrate_bundles(bundles_field, glob_match_error_behavior): """Given a BundlesField, request Snapshots for each of its filesets and create BundleAdaptors.""" path_globs_with_match_errors = [ pg.copy(glob_match_error_behavior=glob_match_error_behavior) for pg in bundles_field.path_globs_list ] snapsho...
python
{ "resource": "" }
q27426
create_legacy_graph_tasks
train
def create_legacy_graph_tasks(): """Create tasks to recursively parse the legacy graph.""" return [ transitive_hydrated_targets,
python
{ "resource": "" }
q27427
LegacyBuildGraph._index
train
def _index(self, hydrated_targets): """Index from the given roots into the storage provided by the base class. This is an additive operation: any existing connections involving these nodes are preserved. """ all_addresses = set() new_targets = list() # Index the ProductGraph. for hydrated_...
python
{ "resource": "" }
q27428
LegacyBuildGraph._index_target
train
def _index_target(self, target_adaptor): """Instantiate the given TargetAdaptor, index it in the graph, and return a Target.""" # Instantiate the target. address = target_adaptor.address target = self._instantiate_target(target_adaptor) self._target_by_address[address] = target for dependency i...
python
{ "resource": "" }
q27429
LegacyBuildGraph._instantiate_target
train
def _instantiate_target(self, target_adaptor): """Given a TargetAdaptor struct previously parsed from a BUILD file, instantiate a Target.""" target_cls = self._target_types[target_adaptor.type_alias] try: # Pop dependencies, which were already consumed during construction. kwargs = target_adapto...
python
{ "resource": "" }
q27430
LegacyBuildGraph._instantiate_app
train
def _instantiate_app(self, target_cls, kwargs): """For App targets, convert BundleAdaptor to BundleProps.""" parse_context = ParseContext(kwargs['address'].spec_path, dict()) bundleprops_factory = Bundle(parse_context) kwargs['bundles'] = [
python
{ "resource": "" }
q27431
LegacyBuildGraph._instantiate_remote_sources
train
def _instantiate_remote_sources(self, kwargs): """For RemoteSources target, convert "dest" field to its real target type.""" kwargs['dest']
python
{ "resource": "" }
q27432
LegacyBuildGraph._inject_addresses
train
def _inject_addresses(self, subjects): """Injects targets into the graph for each of the given `Address` objects, and then yields them. TODO: See #5606 about undoing the split between `_inject_addresses` and `_inject_specs`. """ logger.debug('Injecting addresses to %s: %s', self, subjects)
python
{ "resource": "" }
q27433
LegacyBuildGraph._inject_specs
train
def _inject_specs(self, specs): """Injects targets into the graph for the given `Specs` object. Yields the resulting addresses. """ if not specs: return logger.debug('Injecting specs to
python
{ "resource": "" }
q27434
_DependentGraph.from_iterable
train
def from_iterable(cls, target_types, address_mapper, adaptor_iter): """Create a new DependentGraph from an iterable of TargetAdaptor subclasses.""" inst = cls(target_types, address_mapper) all_valid_addresses = set() for target_adaptor in adaptor_iter:
python
{ "resource": "" }
q27435
_DependentGraph._validate
train
def _validate(self, all_valid_addresses): """Validate that all of the dependencies in the graph exist in the given addresses set.""" for dependency, dependents in iteritems(self._dependent_address_map): if dependency not in all_valid_addresses: raise AddressLookupError( 'Dependent grap...
python
{ "resource": "" }
q27436
_DependentGraph._inject_target
train
def _inject_target(self, target_adaptor): """Inject a target, respecting all sources of dependencies.""" target_cls = self._target_types[target_adaptor.type_alias] declared_deps = target_adaptor.dependencies implicit_deps = (Address.parse(s, relative_to=target_adaptor...
python
{ "resource": "" }
q27437
_DependentGraph.dependents_of_addresses
train
def dependents_of_addresses(self, addresses): """Given an iterable of addresses, yield all of those addresses dependents.""" seen = OrderedSet(addresses) for address in addresses:
python
{ "resource": "" }
q27438
_DependentGraph.transitive_dependents_of_addresses
train
def transitive_dependents_of_addresses(self, addresses): """Given an iterable of addresses, yield all of those addresses dependents, transitively.""" closure = set() result = [] to_visit = deque(addresses) while to_visit: address = to_visit.popleft() if address in closure: conti...
python
{ "resource": "" }
q27439
_legacy_symbol_table
train
def _legacy_symbol_table(build_file_aliases): """Construct a SymbolTable for the given BuildFileAliases. :param build_file_aliases: BuildFileAliases to register. :type build_file_aliases: :class:`pants.build_graph.build_file_aliases.BuildFileAliases` :returns: A SymbolTable. """ table = { alias: _make...
python
{ "resource": "" }
q27440
_make_target_adaptor
train
def _make_target_adaptor(base_class, target_type): """Look up the default source globs for the type, and apply them to parsing through the engine.""" if not target_type.supports_default_sources() or target_type.default_sources_globs is None: return base_class globs = _tuplify(target_type.default_sources_glob...
python
{ "resource": "" }
q27441
LegacyGraphSession.warm_product_graph
train
def warm_product_graph(self, target_roots): """Warm the scheduler's `ProductGraph` with `TransitiveHydratedTargets` products. This method raises only fatal errors, and does not consider failed roots in the execution graph: in the v1 codepath, failed
python
{ "resource": "" }
q27442
LegacyGraphSession.create_build_graph
train
def create_build_graph(self, target_roots, build_root=None): """Construct and return a `BuildGraph` given a set of input specs. :param TargetRoots target_roots: The targets root of the request. :param string build_root: The build root. :returns: A tuple of (BuildGraph, AddressMapper). """ logge...
python
{ "resource": "" }
q27443
FSEventService.register_all_files_handler
train
def register_all_files_handler(self, callback, name='all_files'): """Registers a subscription for all files under a given watch path. :param func callback: the callback to execute on each filesystem event :param str name: the subscription name as used by watchman """ self.register_handler( ...
python
{ "resource": "" }
q27444
FSEventService.register_handler
train
def register_handler(self, name, metadata, callback): """Register subscriptions and their event handlers. :param str name: the subscription name as used by watchman :param dict metadata: a dictionary of metadata to be serialized and passed to the watchman subscribe command. t...
python
{ "resource": "" }
q27445
default_subsystem_for_plugin
train
def default_subsystem_for_plugin(plugin_type): """Create a singleton PluginSubsystemBase subclass for the given plugin type. The singleton enforcement is useful in cases where dependent Tasks are installed multiple times, to avoid creating duplicate types which would have option scope collisions. :param plugi...
python
{ "resource": "" }
q27446
CacheFactory.get_read_cache
train
def get_read_cache(self): """Returns the read cache for this setup, creating it if necessary. Returns None if no read cache is configured. """ if self._options.read_from and not self._read_cache: cache_spec = self._resolve(self._sanitize_cache_spec(self._options.read_from)) if
python
{ "resource": "" }
q27447
CacheFactory.get_write_cache
train
def get_write_cache(self): """Returns the write cache for this setup, creating it if necessary. Returns None if no write cache is configured. """ if self._options.write_to and not self._write_cache: cache_spec = self._resolve(self._sanitize_cache_spec(self._options.write_to)) if
python
{ "resource": "" }
q27448
CacheFactory._resolve
train
def _resolve(self, spec): """Attempt resolving cache URIs when a remote spec is provided. """ if not spec.remote: return spec try: resolved_urls = self._resolver.resolve(spec.remote) if resolved_urls: # keep the bar separated list of URLs convention return CacheSpec(local=...
python
{ "resource": "" }
q27449
CacheFactory.get_available_urls
train
def get_available_urls(self, urls): """Return reachable urls sorted by their ping times.""" baseurl_to_urls = {self._baseurl(url): url for url in urls} pingtimes = self._pinger.pings(list(baseurl_to_urls.keys())) # List of pairs (host, time in ms). self._log.debug('Artifact cache server ping times: {}'...
python
{ "resource": "" }
q27450
CacheFactory._do_create_artifact_cache
train
def _do_create_artifact_cache(self, spec, action): """Returns an artifact cache for the specified spec. spec can be: - a path to a file-based cache root. - a URL of a RESTful cache root. - a bar-separated list of URLs, where we'll pick the one with the best ping times. - A list or tuple...
python
{ "resource": "" }
q27451
PluginResolver.resolve
train
def resolve(self, working_set=None): """Resolves any configured plugins and adds them to the global working set. :param working_set: The working set to add the resolved plugins to instead of the global working set (for testing).
python
{ "resource": "" }
q27452
validate_deprecation_semver
train
def validate_deprecation_semver(version_string, version_description): """Validates that version_string is a valid semver. If so, returns that semver. Raises an error otherwise. :param str version_string: A pantsbuild.pants version which affects some deprecated entity. :param str version_description: A string...
python
{ "resource": "" }
q27453
_get_frame_info
train
def _get_frame_info(stacklevel, context=1): """Get a Traceback for the given `stacklevel`. For example: `stacklevel=0` means this function's frame (_get_frame_info()). `stacklevel=1` means the calling function's frame. See https://docs.python.org/2/library/inspect.html#inspect.getouterframes for more
python
{ "resource": "" }
q27454
warn_or_error
train
def warn_or_error(removal_version, deprecated_entity_description, hint=None, deprecation_start_version=None, stacklevel=3, frame_info=None, context=1, ensure_stderr=False): """Check the removal_version against the current pants version. Issues a warning if the removal version is...
python
{ "resource": "" }
q27455
deprecated_conditional
train
def deprecated_conditional(predicate, removal_version, entity_description, hint_message=None, stacklevel=4): """Marks a certain configuration as deprecated. The predicate is used to determine if that configu...
python
{ "resource": "" }
q27456
deprecated
train
def deprecated(removal_version, hint_message=None, subject=None, ensure_stderr=False): """Marks a function or method as deprecated. A removal version must be supplied and it must be greater than the current 'pantsbuild.pants' version. When choosing a removal version there is a natural tension between the code...
python
{ "resource": "" }
q27457
HelpInfoExtracter.compute_default
train
def compute_default(kwargs): """Compute the default value to display in help for an option registered with these kwargs.""" ranked_default = kwargs.get('default') typ = kwargs.get('type', str) default = ranked_default.value if ranked_default else None if default is None: return 'None' if...
python
{ "resource": "" }
q27458
HelpInfoExtracter.compute_metavar
train
def compute_metavar(kwargs): """Compute the metavar to display in help for an option registered with these kwargs.""" metavar = kwargs.get('metavar') if not metavar: typ = kwargs.get('type', str) if typ == list: typ = kwargs.get('member_type', str) if typ == dict:
python
{ "resource": "" }
q27459
GlobalOptionsRegistrar.register_options
train
def register_options(cls, register): """Register options not tied to any particular task or subsystem.""" # The bootstrap options need to be registered on the post-bootstrap Options instance, so it # won't choke on them on the command line, and also so we can access their values as regular # global-scop...
python
{ "resource": "" }
q27460
GlobalOptionsRegistrar.validate_instance
train
def validate_instance(cls, opts): """Validates an instance of global options for cases that are not prohibited via registration. For example: mutually exclusive options may be registered by passing a `mutually_exclusive_group`, but when multiple flags must be specified together, it can be necessary to spec...
python
{ "resource": "" }
q27461
assert_single_element
train
def assert_single_element(iterable): """Get the single element of `iterable`, or raise an error. :raise: :class:`StopIteration` if there is no element. :raise: :class:`ValueError` if there is more than one element. """ it = iter(iterable) first_item
python
{ "resource": "" }
q27462
Checkstyle._constraints_are_whitelisted
train
def _constraints_are_whitelisted(self, constraint_tuple): """ Detect whether a tuple of compatibility constraints matches constraints imposed by the merged list of the global constraints from PythonSetup
python
{ "resource": "" }
q27463
Checkstyle.execute
train
def execute(self): """"Run Checkstyle on all found non-synthetic source files.""" python_tgts = self.context.targets( lambda tgt: isinstance(tgt, (PythonTarget)) ) if not python_tgts: return 0 interpreter_cache = PythonInterpreterCache.global_instance() with self.invalidated(self.get...
python
{ "resource": "" }
q27464
AddressMap.parse
train
def parse(cls, filepath, filecontent, parser): """Parses a source for addressable Serializable objects. No matter the parser used, the parsed and mapped addressable objects are all 'thin'; ie: any objects they point to in other namespaces or even in the same namespace but from a seperate source are lef...
python
{ "resource": "" }
q27465
AddressFamily.create
train
def create(cls, spec_path, address_maps): """Creates an address family from the given set of address maps. :param spec_path: The directory prefix shared by all address_maps. :param address_maps: The family of maps that form this namespace. :type address_maps: :class:`collections.Iterable` of :class:`Ad...
python
{ "resource": "" }
q27466
AddressFamily.addressables
train
def addressables(self): """Return a mapping from BuildFileAddress to thin addressable objects in this namespace. :rtype: dict from :class:`pants.build_graph.address.BuildFileAddress` to thin
python
{ "resource": "" }
q27467
UnpackJarsFingerprintStrategy.compute_fingerprint
train
def compute_fingerprint(self, target): """UnpackedJars targets need to be re-unpacked if any of its configuration changes or any of the jars they import have changed. """ if isinstance(target, UnpackedJars):
python
{ "resource": "" }
q27468
DeferredSourcesMapper.process_remote_sources
train
def process_remote_sources(self): """Create synthetic targets with populated sources from remote_sources targets.""" unpacked_sources = self.context.products.get_data(UnpackedArchives) remote_sources_targets = self.context.targets(predicate=lambda t: isinstance(t, RemoteSources)) if not remote_sources_t...
python
{ "resource": "" }
q27469
per_instance
train
def per_instance(*args, **kwargs): """A memoized key factory that works like `equal_args` except that the first parameter's identity is used when forming the key. This is a useful key factory when you want to enforce memoization happens per-instance for an instance method in a
python
{ "resource": "" }
q27470
memoized
train
def memoized(func=None, key_factory=equal_args, cache_factory=dict): """Memoizes the results of a function call. By default, exactly one result is memoized for each unique combination of function arguments. Note that memoization is not thread-safe and the default result cache will grow without bound; so care ...
python
{ "resource": "" }
q27471
memoized_method
train
def memoized_method(func=None, key_factory=per_instance, **kwargs): """A convenience wrapper for memoizing instance methods. Typically you'd expect a memoized instance method to hold a cached value per class instance; however, for classes that implement a custom `__hash__`/`__eq__` that can hash separate instanc...
python
{ "resource": "" }
q27472
memoized_property
train
def memoized_property(func=None, key_factory=per_instance, **kwargs): """A convenience wrapper for memoizing properties. Applied like so: >>> class Foo(object): ... @memoized_property ... def name(self): ... pass Is equivalent to: >>> class Foo(object): ... @property ... @memoized_me...
python
{ "resource": "" }
q27473
OptionsFingerprinter.combined_options_fingerprint_for_scope
train
def combined_options_fingerprint_for_scope(cls, scope, options, build_graph=None, **kwargs): """Given options and a scope, compute a combined fingerprint for the scope. :param string scope: The scope to fingerprint. :param Options options: The `Options` object t...
python
{ "resource": "" }
q27474
OptionsFingerprinter.fingerprint
train
def fingerprint(self, option_type, option_val): """Returns a hash of the given option_val based on the option_type. :API: public Returns None if option_val is None. """ if option_val is None: return None # Wrapping all other values in a list here allows us to easily handle single-valued...
python
{ "resource": "" }
q27475
OptionsFingerprinter._fingerprint_target_specs
train
def _fingerprint_target_specs(self, specs): """Returns a fingerprint of the targets resolved from given target specs.""" assert self._build_graph is not None, ( 'cannot fingerprint specs `{}` without a `BuildGraph`'.format(specs) ) hasher = sha1() for spec in sorted(specs): for target in...
python
{ "resource": "" }
q27476
OptionsFingerprinter._assert_in_buildroot
train
def _assert_in_buildroot(self, filepath): """Raises an error if the given filepath isn't in the buildroot. Returns the normalized, absolute form of the path. """ filepath = os.path.normpath(filepath) root = get_buildroot() if not os.path.abspath(filepath) == filepath: # If not absolute, a...
python
{ "resource": "" }
q27477
OptionsFingerprinter._fingerprint_dirs
train
def _fingerprint_dirs(self, dirpaths, topdown=True, onerror=None, followlinks=False): """Returns a fingerprint of the given file directories and all their sub contents. This assumes that the file directories are of reasonable size to cause memory or performance issues. """ # Note that we don't sort...
python
{ "resource": "" }
q27478
OptionsFingerprinter._fingerprint_files
train
def _fingerprint_files(self, filepaths): """Returns a fingerprint of the given filepaths and their contents. This assumes the files are small enough to be read into memory. """ hasher = sha1() # Note that we
python
{ "resource": "" }
q27479
OptionsFingerprinter._fingerprint_dict_with_files
train
def _fingerprint_dict_with_files(self, option_val): """Returns a fingerprint of the given dictionary containing file paths. Any value which is a file path which exists on disk will be fingerprinted by that file's contents rather than by its path. This assumes the files are small enough to be read into...
python
{ "resource": "" }
q27480
OptionsFingerprinter._expand_possible_file_value
train
def _expand_possible_file_value(self, value): """If the value is a file, returns its contents. Otherwise return the original value.""" if
python
{ "resource": "" }
q27481
bootstrap_c_source
train
def bootstrap_c_source(scheduler_bindings_path, output_dir, module_name=NATIVE_ENGINE_MODULE): """Bootstrap an external CFFI C source file.""" safe_mkdir(output_dir) with temporary_dir() as tempdir: temp_output_prefix = os.path.join(tempdir, module_name) real_output_prefix = os.path.join(output_dir, mod...
python
{ "resource": "" }
q27482
_replace_file
train
def _replace_file(path, content): """Writes a file if it doesn't already exist with the same content. This is useful because cargo uses timestamps to decide whether to compile things."""
python
{ "resource": "" }
q27483
_extern_decl
train
def _extern_decl(return_type, arg_types): """A decorator for methods corresponding to extern functions. All types should be strings. The _FFISpecification class is able to automatically convert these into method declarations for cffi. """ def wrapper(func):
python
{ "resource": "" }
q27484
_FFISpecification.format_cffi_externs
train
def format_cffi_externs(cls): """Generate stubs for the cffi bindings from @_extern_decl methods.""" extern_decls = [ f.extern_signature.pretty_print() for _, f in
python
{ "resource": "" }
q27485
_FFISpecification.extern_get_type_for
train
def extern_get_type_for(self, context_handle, val): """Return a representation of the object's type.""" c = self._ffi.from_handle(context_handle)
python
{ "resource": "" }
q27486
_FFISpecification.extern_identify
train
def extern_identify(self, context_handle, val): """Return a representation of the object's identity, including a hash and TypeId. `extern_get_type_for()` also returns a TypeId, but doesn't hash the object -- this allows that
python
{ "resource": "" }
q27487
_FFISpecification.extern_clone_val
train
def extern_clone_val(self, context_handle, val): """Clone the given Handle."""
python
{ "resource": "" }
q27488
_FFISpecification.extern_drop_handles
train
def extern_drop_handles(self, context_handle, handles_ptr, handles_len): """Drop the given Handles.""" c = self._ffi.from_handle(context_handle)
python
{ "resource": "" }
q27489
_FFISpecification.extern_store_tuple
train
def extern_store_tuple(self, context_handle, vals_ptr, vals_len): """Given storage and an array of Handles, return a new
python
{ "resource": "" }
q27490
_FFISpecification.extern_store_set
train
def extern_store_set(self, context_handle, vals_ptr, vals_len): """Given storage and an array of Handles, return a new Handle
python
{ "resource": "" }
q27491
_FFISpecification.extern_store_dict
train
def extern_store_dict(self, context_handle, vals_ptr, vals_len): """Given storage and an array of Handles, return a new Handle to represent the dict. Array of handles alternates keys and values (i.e. key0, value0, key1, value1, ...). It is assumed that an even number of values were passed. """ c =...
python
{ "resource": "" }
q27492
_FFISpecification.extern_store_bytes
train
def extern_store_bytes(self, context_handle, bytes_ptr, bytes_len): """Given a context and raw bytes, return a new Handle to represent the content."""
python
{ "resource": "" }
q27493
_FFISpecification.extern_store_utf8
train
def extern_store_utf8(self, context_handle, utf8_ptr, utf8_len): """Given a context and UTF8 bytes, return a new Handle to represent the content."""
python
{ "resource": "" }
q27494
_FFISpecification.extern_store_i64
train
def extern_store_i64(self, context_handle, i64): """Given a context and int32_t, return a new Handle to represent the int32_t."""
python
{ "resource": "" }
q27495
_FFISpecification.extern_store_f64
train
def extern_store_f64(self, context_handle, f64): """Given a context and double, return a new Handle to represent the double."""
python
{ "resource": "" }
q27496
_FFISpecification.extern_store_bool
train
def extern_store_bool(self, context_handle, b): """Given a context and _Bool, return a new Handle to represent the _Bool."""
python
{ "resource": "" }
q27497
_FFISpecification.extern_project_ignoring_type
train
def extern_project_ignoring_type(self, context_handle, val, field_str_ptr, field_str_len): """Given a Handle for `obj`, and a field name, project the field as a new Handle.""" c = self._ffi.from_handle(context_handle) obj = c.from_value(val[0])
python
{ "resource": "" }
q27498
_FFISpecification.extern_project_multi
train
def extern_project_multi(self, context_handle, val, field_str_ptr, field_str_len): """Given a Key for `obj`, and a field name, project the field as a list of Keys.""" c = self._ffi.from_handle(context_handle) obj = c.from_value(val[0])
python
{ "resource": "" }
q27499
_FFISpecification.extern_create_exception
train
def extern_create_exception(self, context_handle, msg_ptr, msg_len): """Given a utf8 message string, create an Exception object.""" c
python
{ "resource": "" }