_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q227900 | remove_nones | train | def remove_nones(**kwargs):
"""Return diict copy with nones removed.
"""
return dict((k, v) for k, v in kwargs.iteritems() if v is not None) | python | {
"resource": ""
} |
q227901 | deep_update | train | def deep_update(dict1, dict2):
"""Perform a deep merge of `dict2` into `dict1`.
Note that `dict2` and any nested dicts are unchanged.
Supports `ModifyList` instances.
"""
def flatten(v):
if isinstance(v, ModifyList):
return v.apply([])
elif isinstance(v, dict):
... | python | {
"resource": ""
} |
q227902 | deep_del | train | def deep_del(data, fn):
"""Create dict copy with removed items.
Recursively remove items where fn(value) is True.
Returns:
dict: New dict with matching items removed.
"""
result = {}
for k, v in data.iteritems():
if not fn(v):
if isinstance(v, dict):
... | python | {
"resource": ""
} |
q227903 | get_dict_diff_str | train | def get_dict_diff_str(d1, d2, title):
"""Returns same as `get_dict_diff`, but as a readable string.
"""
added, removed, changed = get_dict_diff(d1, d2)
lines = [title]
if added:
lines.append("Added attributes: %s"
% ['.'.join(x) for x in added])
if removed:
... | python | {
"resource": ""
} |
q227904 | convert_dicts | train | def convert_dicts(d, to_class=AttrDictWrapper, from_class=dict):
"""Recursively convert dict and UserDict types.
Note that `d` is unchanged.
Args:
to_class (type): Dict-like type to convert values to, usually UserDict
subclass, or dict.
from_class (type): Dict-like type to conv... | python | {
"resource": ""
} |
q227905 | PackageRepositoryGlobalStats.package_loading | train | def package_loading(self):
"""Use this around code in your package repository that is loading a
package, for example from file or cache.
"""
t1 = time.time()
yield None
t2 = time.time()
self.package_load_time += t2 - t1 | python | {
"resource": ""
} |
q227906 | PackageRepository.is_empty | train | def is_empty(self):
"""Determine if the repository contains any packages.
Returns:
True if there are no packages, False if there are at least one.
"""
for family in self.iter_package_families():
for pkg in self.iter_packages(family):
return False
... | python | {
"resource": ""
} |
q227907 | PackageRepository.make_resource_handle | train | def make_resource_handle(self, resource_key, **variables):
"""Create a `ResourceHandle`
Nearly all `ResourceHandle` creation should go through here, because it
gives the various resource classes a chance to normalize / standardize
the resource handles, to improve caching / comparison / ... | python | {
"resource": ""
} |
q227908 | PackageRepositoryManager.get_repository | train | def get_repository(self, path):
"""Get a package repository.
Args:
path (str): Entry from the 'packages_path' config setting. This may
simply be a path (which is managed by the 'filesystem' package
repository plugin), or a string in the form "type@location",
... | python | {
"resource": ""
} |
q227909 | PackageRepositoryManager.are_same | train | def are_same(self, path_1, path_2):
"""Test that `path_1` and `path_2` refer to the same repository.
This is more reliable than testing that the strings match, since slightly
different strings might refer to the same repository (consider small
differences in a filesystem path for exampl... | python | {
"resource": ""
} |
q227910 | create_transport | train | def create_transport(host, connect_timeout, ssl=False):
"""Given a few parameters from the Connection constructor,
select and create a subclass of _AbstractTransport."""
if ssl:
return SSLTransport(host, connect_timeout, ssl)
else:
return TCPTransport(host, connect_timeout) | python | {
"resource": ""
} |
q227911 | RezPluginType.get_plugin_class | train | def get_plugin_class(self, plugin_name):
"""Returns the class registered under the given plugin name."""
try:
return self.plugin_classes[plugin_name]
except KeyError:
raise RezPluginError("Unrecognised %s plugin: '%s'"
% (self.pretty_type_... | python | {
"resource": ""
} |
q227912 | RezPluginType.get_plugin_module | train | def get_plugin_module(self, plugin_name):
"""Returns the module containing the plugin of the given name."""
try:
return self.plugin_modules[plugin_name]
except KeyError:
raise RezPluginError("Unrecognised %s plugin: '%s'"
% (self.pretty_ty... | python | {
"resource": ""
} |
q227913 | RezPluginType.config_schema | train | def config_schema(self):
"""Returns the merged configuration data schema for this plugin
type."""
from rez.config import _plugin_config_dict
d = _plugin_config_dict.get(self.type_name, {})
for name, plugin_class in self.plugin_classes.iteritems():
if hasattr(plugin_c... | python | {
"resource": ""
} |
q227914 | RezPluginManager.get_plugin_class | train | def get_plugin_class(self, plugin_type, plugin_name):
"""Return the class registered under the given plugin name."""
plugin = self._get_plugin_type(plugin_type)
return plugin.get_plugin_class(plugin_name) | python | {
"resource": ""
} |
q227915 | RezPluginManager.get_plugin_module | train | def get_plugin_module(self, plugin_type, plugin_name):
"""Return the module defining the class registered under the given
plugin name."""
plugin = self._get_plugin_type(plugin_type)
return plugin.get_plugin_module(plugin_name) | python | {
"resource": ""
} |
q227916 | RezPluginManager.create_instance | train | def create_instance(self, plugin_type, plugin_name, **instance_kwargs):
"""Create and return an instance of the given plugin."""
plugin_type = self._get_plugin_type(plugin_type)
return plugin_type.create_instance(plugin_name, **instance_kwargs) | python | {
"resource": ""
} |
q227917 | RezPluginManager.get_summary_string | train | def get_summary_string(self):
"""Get a formatted string summarising the plugins that were loaded."""
rows = [["PLUGIN TYPE", "NAME", "DESCRIPTION", "STATUS"],
["-----------", "----", "-----------", "------"]]
for plugin_type in sorted(self.get_plugin_types()):
type_na... | python | {
"resource": ""
} |
q227918 | Evaluator.get_fragment | train | def get_fragment(self, offset):
"""
Get the part of the source which is causing a problem.
"""
fragment_len = 10
s = '%r' % (self.source[offset:offset + fragment_len])
if offset + fragment_len < len(self.source):
s += '...'
return s | python | {
"resource": ""
} |
q227919 | Evaluator.evaluate | train | def evaluate(self, node, filename=None):
"""
Evaluate a source string or node, using ``filename`` when
displaying errors.
"""
if isinstance(node, string_types):
self.source = node
kwargs = {'mode': 'eval'}
if filename:
kwargs['f... | python | {
"resource": ""
} |
q227920 | recursive_repr | train | def recursive_repr(func):
"""Decorator to prevent infinite repr recursion."""
repr_running = set()
@wraps(func)
def wrapper(self):
"Return ellipsis on recursive re-entry to function."
key = id(self), get_ident()
if key in repr_running:
return '...'
repr_run... | python | {
"resource": ""
} |
q227921 | SortedList._reset | train | def _reset(self, load):
"""
Reset sorted list load.
The *load* specifies the load-factor of the list. The default load
factor of '1000' works well for lists from tens to tens of millions of
elements. Good practice is to use a value that is the cube root of the
list size... | python | {
"resource": ""
} |
q227922 | SortedList._build_index | train | def _build_index(self):
"""Build an index for indexing the sorted list.
Indexes are represented as binary trees in a dense array notation
similar to a binary heap.
For example, given a _lists representation storing integers:
[0]: 1 2 3
[1]: 4 5
[2]: 6 7 8 9
... | python | {
"resource": ""
} |
q227923 | SortedListWithKey.irange_key | train | def irange_key(self, min_key=None, max_key=None, inclusive=(True, True),
reverse=False):
"""
Create an iterator of values between `min_key` and `max_key`.
`inclusive` is a pair of booleans that indicates whether the min_key
and max_key ought to be included in the rang... | python | {
"resource": ""
} |
q227924 | view_graph | train | def view_graph(graph_str, parent=None, prune_to=None):
"""View a graph."""
from rezgui.dialogs.ImageViewerDialog import ImageViewerDialog
from rez.config import config
# check for already written tempfile
h = hash((graph_str, prune_to))
filepath = graph_file_lookup.get(h)
if filepath and no... | python | {
"resource": ""
} |
q227925 | PackageVersionsTable.select_version | train | def select_version(self, version_range):
"""Select the latest versioned package in the given range.
If there are no packages in the range, the selection is cleared.
"""
row = -1
version = None
for i, package in self.packages.iteritems():
if package.version in... | python | {
"resource": ""
} |
q227926 | SortedSet._fromset | train | def _fromset(cls, values, key=None):
"""Initialize sorted set from existing set."""
sorted_set = object.__new__(cls)
sorted_set._set = values # pylint: disable=protected-access
sorted_set.__init__(key=key)
return sorted_set | python | {
"resource": ""
} |
q227927 | setup_parser_common | train | def setup_parser_common(parser):
"""Parser setup common to both rez-build and rez-release."""
from rez.build_process_ import get_build_process_types
from rez.build_system import get_valid_build_systems
process_types = get_build_process_types()
parser.add_argument(
"--process", type=str, cho... | python | {
"resource": ""
} |
q227928 | scoped_format | train | def scoped_format(txt, **objects):
"""Format a string with respect to a set of objects' attributes.
Example:
>>> Class Foo(object):
>>> def __init__(self):
>>> self.name = "Dave"
>>> print scoped_format("hello {foo.name}", foo=Foo())
hello Dave
Args:
... | python | {
"resource": ""
} |
q227929 | RecursiveAttribute.to_dict | train | def to_dict(self):
"""Get an equivalent dict representation."""
d = {}
for k, v in self.__dict__["data"].iteritems():
if isinstance(v, RecursiveAttribute):
d[k] = v.to_dict()
else:
d[k] = v
return d | python | {
"resource": ""
} |
q227930 | Config.value | train | def value(self, key, type_=None):
"""Get the value of a setting.
If `type` is not provided, the key must be for a known setting,
present in `self.default_settings`. Conversely if `type` IS provided,
the key must be for an unknown setting.
"""
if type_ is None:
... | python | {
"resource": ""
} |
q227931 | Config.get_string_list | train | def get_string_list(self, key):
"""Get a list of strings."""
strings = []
size = self.beginReadArray(key)
for i in range(size):
self.setArrayIndex(i)
entry = str(self._value("entry"))
strings.append(entry)
self.endArray()
return strings | python | {
"resource": ""
} |
q227932 | Config.prepend_string_list | train | def prepend_string_list(self, key, value, max_length_key):
"""Prepend a fixed-length string list with a new string.
The oldest string will be removed from the list. If the string is
already in the list, it is shuffled to the top. Use this to implement
things like a 'most recent files' e... | python | {
"resource": ""
} |
q227933 | priority_queue.insert | train | def insert(self, item, priority):
"""
Insert item into the queue, with the given priority.
"""
heappush(self.heap, HeapItem(item, priority)) | python | {
"resource": ""
} |
q227934 | connected_components | train | def connected_components(graph):
"""
Connected components.
@type graph: graph, hypergraph
@param graph: Graph.
@rtype: dictionary
@return: Pairing that associates each node to its connected component.
"""
recursionlimit = getrecursionlimit()
setrecursionlimit(max(len(graph.nodes(... | python | {
"resource": ""
} |
q227935 | cut_edges | train | def cut_edges(graph):
"""
Return the cut-edges of the given graph.
A cut edge, or bridge, is an edge of a graph whose removal increases the number of connected
components in the graph.
@type graph: graph, hypergraph
@param graph: Graph.
@rtype: list
@return: List of cut-... | python | {
"resource": ""
} |
q227936 | _cut_hyperedges | train | def _cut_hyperedges(hypergraph):
"""
Return the cut-hyperedges of the given hypergraph.
@type hypergraph: hypergraph
@param hypergraph: Hypergraph
@rtype: list
@return: List of cut-nodes.
"""
edges_ = cut_nodes(hypergraph.graph)
edges = []
for each in edges_:
... | python | {
"resource": ""
} |
q227937 | cut_nodes | train | def cut_nodes(graph):
"""
Return the cut-nodes of the given graph.
A cut node, or articulation point, is a node of a graph whose removal increases the number of
connected components in the graph.
@type graph: graph, hypergraph
@param graph: Graph.
@rtype: list
@retur... | python | {
"resource": ""
} |
q227938 | _cut_hypernodes | train | def _cut_hypernodes(hypergraph):
"""
Return the cut-nodes of the given hypergraph.
@type hypergraph: hypergraph
@param hypergraph: Hypergraph
@rtype: list
@return: List of cut-nodes.
"""
nodes_ = cut_nodes(hypergraph.graph)
nodes = []
for each in nodes_:
... | python | {
"resource": ""
} |
q227939 | graph.del_edge | train | def del_edge(self, edge):
"""
Remove an edge from the graph.
@type edge: tuple
@param edge: Edge.
"""
u, v = edge
self.node_neighbors[u].remove(v)
self.del_edge_labeling((u, v))
if (u != v):
self.node_neighbors[v].remove(u)
... | python | {
"resource": ""
} |
q227940 | labeling.edge_weight | train | def edge_weight(self, edge):
"""
Get the weight of an edge.
@type edge: edge
@param edge: One edge.
@rtype: number
@return: Edge weight.
"""
return self.get_edge_properties( edge ).setdefault( self.WEIGHT_ATTRIBUTE_NAME, self.DEFAULT_WEIGHT ) | python | {
"resource": ""
} |
q227941 | labeling.set_edge_weight | train | def set_edge_weight(self, edge, wt):
"""
Set the weight of an edge.
@type edge: edge
@param edge: One edge.
@type wt: number
@param wt: Edge weight.
"""
self.set_edge_properties(edge, weight=wt )
if not self.DIRECTED:
self.set_edge_... | python | {
"resource": ""
} |
q227942 | labeling.edge_label | train | def edge_label(self, edge):
"""
Get the label of an edge.
@type edge: edge
@param edge: One edge.
@rtype: string
@return: Edge label
"""
return self.get_edge_properties( edge ).setdefault( self.LABEL_ATTRIBUTE_NAME, self.DEFAULT_LABEL ) | python | {
"resource": ""
} |
q227943 | labeling.set_edge_label | train | def set_edge_label(self, edge, label):
"""
Set the label of an edge.
@type edge: edge
@param edge: One edge.
@type label: string
@param label: Edge label.
"""
self.set_edge_properties(edge, label=label )
if not self.DIRECTED:
self.s... | python | {
"resource": ""
} |
q227944 | labeling.add_edge_attribute | train | def add_edge_attribute(self, edge, attr):
"""
Add attribute to the given edge.
@type edge: edge
@param edge: One edge.
@type attr: tuple
@param attr: Node attribute specified as a tuple in the form (attribute, value).
"""
self.edge_attr[edge] = self.ed... | python | {
"resource": ""
} |
q227945 | labeling.add_node_attribute | train | def add_node_attribute(self, node, attr):
"""
Add attribute to the given node.
@type node: node
@param node: Node identifier
@type attr: tuple
@param attr: Node attribute specified as a tuple in the form (attribute, value).
"""
self.node_attr[node] = s... | python | {
"resource": ""
} |
q227946 | Suite.activation_shell_code | train | def activation_shell_code(self, shell=None):
"""Get shell code that should be run to activate this suite."""
from rez.shells import create_shell
from rez.rex import RexExecutor
executor = RexExecutor(interpreter=create_shell(shell),
parent_variables=["PATH... | python | {
"resource": ""
} |
q227947 | Suite.context | train | def context(self, name):
"""Get a context.
Args:
name (str): Name to store the context under.
Returns:
`ResolvedContext` object.
"""
data = self._context(name)
context = data.get("context")
if context:
return context
... | python | {
"resource": ""
} |
q227948 | Suite.add_context | train | def add_context(self, name, context, prefix_char=None):
"""Add a context to the suite.
Args:
name (str): Name to store the context under.
context (ResolvedContext): Context to add.
"""
if name in self.contexts:
raise SuiteError("Context already in sui... | python | {
"resource": ""
} |
q227949 | Suite.find_contexts | train | def find_contexts(self, in_request=None, in_resolve=None):
"""Find contexts in the suite based on search criteria.
Args:
in_request (str): Match contexts that contain the given package in
their request.
in_resolve (str or `Requirement`): Match contexts that conta... | python | {
"resource": ""
} |
q227950 | Suite.remove_context | train | def remove_context(self, name):
"""Remove a context from the suite.
Args:
name (str): Name of the context to remove.
"""
self._context(name)
del self.contexts[name]
self._flush_tools() | python | {
"resource": ""
} |
q227951 | Suite.set_context_prefix | train | def set_context_prefix(self, name, prefix):
"""Set a context's prefix.
This will be applied to all wrappers for the tools in this context. For
example, a tool called 'foo' would appear as '<prefix>foo' in the
suite's bin path.
Args:
name (str): Name of the context t... | python | {
"resource": ""
} |
q227952 | Suite.set_context_suffix | train | def set_context_suffix(self, name, suffix):
"""Set a context's suffix.
This will be applied to all wrappers for the tools in this context. For
example, a tool called 'foo' would appear as 'foo<suffix>' in the
suite's bin path.
Args:
name (str): Name of the context t... | python | {
"resource": ""
} |
q227953 | Suite.bump_context | train | def bump_context(self, name):
"""Causes the context's tools to take priority over all others."""
data = self._context(name)
data["priority"] = self._next_priority
self._flush_tools() | python | {
"resource": ""
} |
q227954 | Suite.hide_tool | train | def hide_tool(self, context_name, tool_name):
"""Hide a tool so that it is not exposed in the suite.
Args:
context_name (str): Context containing the tool.
tool_name (str): Name of tool to hide.
"""
data = self._context(context_name)
hidden_tools = data["... | python | {
"resource": ""
} |
q227955 | Suite.unhide_tool | train | def unhide_tool(self, context_name, tool_name):
"""Unhide a tool so that it may be exposed in a suite.
Note that unhiding a tool doesn't guarantee it can be seen - a tool of
the same name from a different context may be overriding it.
Args:
context_name (str): Context conta... | python | {
"resource": ""
} |
q227956 | Suite.alias_tool | train | def alias_tool(self, context_name, tool_name, tool_alias):
"""Register an alias for a specific tool.
Note that a tool alias takes precedence over a context prefix/suffix.
Args:
context_name (str): Context containing the tool.
tool_name (str): Name of tool to alias.
... | python | {
"resource": ""
} |
q227957 | Suite.unalias_tool | train | def unalias_tool(self, context_name, tool_name):
"""Deregister an alias for a specific tool.
Args:
context_name (str): Context containing the tool.
tool_name (str): Name of tool to unalias.
"""
data = self._context(context_name)
aliases = data["tool_alias... | python | {
"resource": ""
} |
q227958 | Suite.get_tool_filepath | train | def get_tool_filepath(self, tool_alias):
"""Given a visible tool alias, return the full path to the executable.
Args:
tool_alias (str): Tool alias to search for.
Returns:
(str): Filepath of executable, or None if the tool is not in the
suite. May also re... | python | {
"resource": ""
} |
q227959 | Suite.get_tool_context | train | def get_tool_context(self, tool_alias):
"""Given a visible tool alias, return the name of the context it
belongs to.
Args:
tool_alias (str): Tool alias to search for.
Returns:
(str): Name of the context that exposes a visible instance of this
tool al... | python | {
"resource": ""
} |
q227960 | Suite.validate | train | def validate(self):
"""Validate the suite."""
for context_name in self.context_names:
context = self.context(context_name)
try:
context.validate()
except ResolvedContextError as e:
raise SuiteError("Error in context %r: %s"
... | python | {
"resource": ""
} |
q227961 | Suite.save | train | def save(self, path, verbose=False):
"""Save the suite to disk.
Args:
path (str): Path to save the suite to. If a suite is already saved
at `path`, then it will be overwritten. Otherwise, if `path`
exists, an error is raised.
"""
path = os.pat... | python | {
"resource": ""
} |
q227962 | Suite.print_info | train | def print_info(self, buf=sys.stdout, verbose=False):
"""Prints a message summarising the contents of the suite."""
_pr = Printer(buf)
if not self.contexts:
_pr("Suite is empty.")
return
context_names = sorted(self.contexts.iterkeys())
_pr("Suite contains... | python | {
"resource": ""
} |
q227963 | get_valid_build_systems | train | def get_valid_build_systems(working_dir, package=None):
"""Returns the build system classes that could build the source in given dir.
Args:
working_dir (str): Dir containing the package definition and potentially
build files.
package (`Package`): Package to be built. This may or may... | python | {
"resource": ""
} |
q227964 | create_build_system | train | def create_build_system(working_dir, buildsys_type=None, package=None, opts=None,
write_build_scripts=False, verbose=False,
build_args=[], child_build_args=[]):
"""Return a new build system that can build the source in working_dir."""
from rez.plugin_managers impo... | python | {
"resource": ""
} |
q227965 | BuildSystem.build | train | def build(self, context, variant, build_path, install_path, install=False,
build_type=BuildType.local):
"""Implement this method to perform the actual build.
Args:
context: A ResolvedContext object that the build process must be
executed within.
var... | python | {
"resource": ""
} |
q227966 | BuildSystem.get_standard_vars | train | def get_standard_vars(cls, context, variant, build_type, install,
build_path, install_path=None):
"""Returns a standard set of environment variables that can be set
for the build system to use
"""
from rez.config import config
package = variant.parent
... | python | {
"resource": ""
} |
q227967 | BuildSystem.set_standard_vars | train | def set_standard_vars(cls, executor, context, variant, build_type,
install, build_path, install_path=None):
"""Sets a standard set of environment variables for the build system to
use
"""
vars = cls.get_standard_vars(context=context,
... | python | {
"resource": ""
} |
q227968 | run_pip_command | train | def run_pip_command(command_args, pip_version=None, python_version=None):
"""Run a pip command.
Args:
command_args (list of str): Args to pip.
Returns:
`subprocess.Popen`: Pip process.
"""
pip_exe, context = find_pip(pip_version, python_version)
command = [pip_exe] + list(comma... | python | {
"resource": ""
} |
q227969 | find_pip | train | def find_pip(pip_version=None, python_version=None):
"""Find a pip exe using the given python version.
Returns:
2-tuple:
str: pip executable;
`ResolvedContext`: Context containing pip, or None if we fell back
to system pip.
"""
pip_exe = "pip"
try:
... | python | {
"resource": ""
} |
q227970 | create_context | train | def create_context(pip_version=None, python_version=None):
"""Create a context containing the specific pip and python.
Args:
pip_version (str or `Version`): Version of pip to use, or latest if None.
python_version (str or `Version`): Python version to use, or latest if
None.
Re... | python | {
"resource": ""
} |
q227971 | convert_old_variant_handle | train | def convert_old_variant_handle(handle_dict):
"""Convert a variant handle from serialize_version < 4.0."""
old_variables = handle_dict.get("variables", {})
variables = dict(repository_type="filesystem")
for old_key, key in variant_key_conversions.iteritems():
value = old_variables.get(old_key)
... | python | {
"resource": ""
} |
q227972 | convert_requirement | train | def convert_requirement(req):
"""
Converts a pkg_resources.Requirement object into a list of Rez package
request strings.
"""
pkg_name = convert_name(req.project_name)
if not req.specs:
return [pkg_name]
req_strs = []
for spec in req.specs:
op, ver = spec
ver = c... | python | {
"resource": ""
} |
q227973 | get_dist_dependencies | train | def get_dist_dependencies(name, recurse=True):
"""
Get the dependencies of the given, already installed distribution.
@param recurse If True, recursively find all dependencies.
@returns A set of package names.
@note The first entry in the list is always the top-level package itself.
"""
dist... | python | {
"resource": ""
} |
q227974 | common.add_graph | train | def add_graph(self, other):
"""
Add other graph to this graph.
@attention: Attributes and labels are not preserved.
@type other: graph
@param other: Graph
"""
self.add_nodes( n for n in other.nodes() if not n in self.nodes() )
f... | python | {
"resource": ""
} |
q227975 | common.add_spanning_tree | train | def add_spanning_tree(self, st):
"""
Add a spanning tree to the graph.
@type st: dictionary
@param st: Spanning tree.
"""
self.add_nodes(list(st.keys()))
for each in st:
if (st[each] is not None):
self.add_edge((st[each], each... | python | {
"resource": ""
} |
q227976 | common.complete | train | def complete(self):
"""
Make the graph a complete graph.
@attention: This will modify the current graph.
"""
for each in self.nodes():
for other in self.nodes():
if (each != other and not self.has_edge((each, other))):
self... | python | {
"resource": ""
} |
q227977 | common.inverse | train | def inverse(self):
"""
Return the inverse of the graph.
@rtype: graph
@return: Complement graph for the graph.
"""
inv = self.__class__()
inv.add_nodes(self.nodes())
inv.complete()
for each in self.edges():
if (inv.has_edge(ea... | python | {
"resource": ""
} |
q227978 | common.reverse | train | def reverse(self):
"""
Generate the reverse of a directed graph, returns an identical graph if not directed.
Attributes & weights are preserved.
@rtype: digraph
@return: The directed graph that should be reversed.
"""
assert self.DIRECTED, "Undirected gra... | python | {
"resource": ""
} |
q227979 | get_lock_request | train | def get_lock_request(name, version, patch_lock, weak=True):
"""Given a package and patch lock, return the equivalent request.
For example, for object 'foo-1.2.1' and lock type 'lock_3', the equivalent
request is '~foo-1.2'. This restricts updates to foo to patch-or-lower
version changes only.
For ... | python | {
"resource": ""
} |
q227980 | ResolvedContext.requested_packages | train | def requested_packages(self, include_implicit=False):
"""Get packages in the request.
Args:
include_implicit (bool): If True, implicit packages are appended
to the result.
Returns:
List of `PackageRequest` objects.
"""
if include_implicit... | python | {
"resource": ""
} |
q227981 | ResolvedContext.get_resolved_package | train | def get_resolved_package(self, name):
"""Returns a `Variant` object or None if the package is not in the
resolve.
"""
pkgs = [x for x in self._resolved_packages if x.name == name]
return pkgs[0] if pkgs else None | python | {
"resource": ""
} |
q227982 | ResolvedContext.get_patched_request | train | def get_patched_request(self, package_requests=None,
package_subtractions=None, strict=False, rank=0):
"""Get a 'patched' request.
A patched request is a copy of this context's request, but with some
changes applied. This can then be used to create a new, 'patched'
... | python | {
"resource": ""
} |
q227983 | ResolvedContext.write_to_buffer | train | def write_to_buffer(self, buf):
"""Save the context to a buffer."""
doc = self.to_dict()
if config.rxt_as_yaml:
content = dump_yaml(doc)
else:
content = json.dumps(doc, indent=4, separators=(",", ": "))
buf.write(content) | python | {
"resource": ""
} |
q227984 | ResolvedContext.get_current | train | def get_current(cls):
"""Get the context for the current env, if there is one.
Returns:
`ResolvedContext`: Current context, or None if not in a resolved env.
"""
filepath = os.getenv("REZ_RXT_FILE")
if not filepath or not os.path.exists(filepath):
return ... | python | {
"resource": ""
} |
q227985 | ResolvedContext.load | train | def load(cls, path):
"""Load a resolved context from file."""
with open(path) as f:
context = cls.read_from_buffer(f, path)
context.set_load_path(path)
return context | python | {
"resource": ""
} |
q227986 | ResolvedContext.read_from_buffer | train | def read_from_buffer(cls, buf, identifier_str=None):
"""Load the context from a buffer."""
try:
return cls._read_from_buffer(buf, identifier_str)
except Exception as e:
cls._load_error(e, identifier_str) | python | {
"resource": ""
} |
q227987 | ResolvedContext.get_resolve_diff | train | def get_resolve_diff(self, other):
"""Get the difference between the resolve in this context and another.
The difference is described from the point of view of the current context
- a newer package means that the package in `other` is newer than the
package in `self`.
Diffs can... | python | {
"resource": ""
} |
q227988 | ResolvedContext.print_resolve_diff | train | def print_resolve_diff(self, other, heading=None):
"""Print the difference between the resolve of two contexts.
Args:
other (`ResolvedContext`): Context to compare to.
heading: One of:
- None: Do not display a heading;
- True: Display the filename... | python | {
"resource": ""
} |
q227989 | ResolvedContext.get_dependency_graph | train | def get_dependency_graph(self):
"""Generate the dependency graph.
The dependency graph is a simpler subset of the resolve graph. It
contains package name nodes connected directly to their dependencies.
Weak references and conflict requests are not included in the graph.
The depe... | python | {
"resource": ""
} |
q227990 | ResolvedContext.validate | train | def validate(self):
"""Validate the context."""
try:
for pkg in self.resolved_packages:
pkg.validate_data()
except RezError as e:
raise ResolvedContextError("%s: %s" % (e.__class__.__name__, str(e))) | python | {
"resource": ""
} |
q227991 | ResolvedContext.get_environ | train | def get_environ(self, parent_environ=None):
"""Get the environ dict resulting from interpreting this context.
@param parent_environ Environment to interpret the context within,
defaults to os.environ if None.
@returns The environment dict generated by this context, when
... | python | {
"resource": ""
} |
q227992 | ResolvedContext.get_key | train | def get_key(self, key, request_only=False):
"""Get a data key value for each resolved package.
Args:
key (str): String key of property, eg 'tools'.
request_only (bool): If True, only return the key from resolved
packages that were also present in the request.
... | python | {
"resource": ""
} |
q227993 | ResolvedContext.get_conflicting_tools | train | def get_conflicting_tools(self, request_only=False):
"""Returns tools of the same name provided by more than one package.
Args:
request_only: If True, only return the key from resolved packages
that were also present in the request.
Returns:
Dict of {too... | python | {
"resource": ""
} |
q227994 | ResolvedContext.get_shell_code | train | def get_shell_code(self, shell=None, parent_environ=None, style=OutputStyle.file):
"""Get the shell code resulting from intepreting this context.
Args:
shell (str): Shell type, for eg 'bash'. If None, the current shell
type is used.
parent_environ (dict): Environ... | python | {
"resource": ""
} |
q227995 | ResolvedContext.get_actions | train | def get_actions(self, parent_environ=None):
"""Get the list of rex.Action objects resulting from interpreting this
context. This is provided mainly for testing purposes.
Args:
parent_environ Environment to interpret the context within,
defaults to os.environ if None.... | python | {
"resource": ""
} |
q227996 | ResolvedContext.apply | train | def apply(self, parent_environ=None):
"""Apply the context to the current python session.
Note that this updates os.environ and possibly sys.path, if
`parent_environ` is not provided.
Args:
parent_environ: Environment to interpret the context within,
default... | python | {
"resource": ""
} |
q227997 | ResolvedContext.which | train | def which(self, cmd, parent_environ=None, fallback=False):
"""Find a program in the resolved environment.
Args:
cmd: String name of the program to find.
parent_environ: Environment to interpret the context within,
defaults to os.environ if None.
fallb... | python | {
"resource": ""
} |
q227998 | ResolvedContext.execute_command | train | def execute_command(self, args, parent_environ=None, **subprocess_kwargs):
"""Run a command within a resolved context.
This applies the context to a python environ dict, then runs a
subprocess in that namespace. This is not a fully configured subshell -
shell-specific commands such as a... | python | {
"resource": ""
} |
q227999 | ResolvedContext.execute_rex_code | train | def execute_rex_code(self, code, filename=None, shell=None,
parent_environ=None, **Popen_args):
"""Run some rex code in the context.
Note:
This is just a convenience form of `execute_shell`.
Args:
code (str): Rex code to execute.
fil... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.