_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q227700 | ActionManager.get_public_methods | train | def get_public_methods(self):
"""
return a list of methods on this class which should be exposed in the rex
API.
"""
return self.get_action_methods() + [
('getenv', self.getenv),
('expandvars', self.expandvars),
('defined', self.defined),
... | python | {
"resource": ""
} |
q227701 | Python.apply_environ | train | def apply_environ(self):
"""Apply changes to target environ.
"""
if self.manager is None:
raise RezSystemError("You must call 'set_manager' on a Python rex "
"interpreter before using it.")
self.target_environ.update(self.manager.environ) | python | {
"resource": ""
} |
q227702 | EscapedString.formatted | train | def formatted(self, func):
"""Return the string with non-literal parts formatted.
Args:
func (callable): Callable that translates a string into a
formatted string.
Returns:
`EscapedString` object.
"""
other = EscapedString.__new__(Escaped... | python | {
"resource": ""
} |
q227703 | RexExecutor.execute_code | train | def execute_code(self, code, filename=None, isolate=False):
"""Execute code within the execution context.
Args:
code (str or SourceCode): Rex code to execute.
filename (str): Filename to report if there are syntax errors.
isolate (bool): If True, do not affect `self.... | python | {
"resource": ""
} |
q227704 | RexExecutor.execute_function | train | def execute_function(self, func, *nargs, **kwargs):
"""
Execute a function object within the execution context.
@returns The result of the function call.
"""
# makes a copy of the func
import types
fn = types.FunctionType(func.func_code,
... | python | {
"resource": ""
} |
q227705 | RexExecutor.get_output | train | def get_output(self, style=OutputStyle.file):
"""Returns the result of all previous calls to execute_code."""
return self.manager.get_output(style=style) | python | {
"resource": ""
} |
q227706 | find.configure | train | def configure(self, graph, spanning_tree):
"""
Configure the filter.
@type graph: graph
@param graph: Graph.
@type spanning_tree: dictionary
@param spanning_tree: Spanning tree.
"""
self.graph = graph
self.spanning_tree = spanni... | python | {
"resource": ""
} |
q227707 | PackageFilterBase.iter_packages | train | def iter_packages(self, name, range_=None, paths=None):
"""Same as iter_packages in packages.py, but also applies this filter.
Args:
name (str): Name of the package, eg 'maya'.
range_ (VersionRange or str): If provided, limits the versions returned
to those in `r... | python | {
"resource": ""
} |
q227708 | PackageFilter.copy | train | def copy(self):
"""Return a shallow copy of the filter.
Adding rules to the copy will not alter the source.
"""
other = PackageFilter.__new__(PackageFilter)
other._excludes = self._excludes.copy()
other._includes = self._includes.copy()
return other | python | {
"resource": ""
} |
q227709 | PackageFilter.cost | train | def cost(self):
"""Get the approximate cost of this filter.
Cost is the total cost of the exclusion rules in this filter. The cost
of family-specific filters is divided by 10.
Returns:
float: The approximate cost of the filter.
"""
total = 0.0
for fa... | python | {
"resource": ""
} |
q227710 | PackageFilterList.add_filter | train | def add_filter(self, package_filter):
"""Add a filter to the list.
Args:
package_filter (`PackageFilter`): Filter to add.
"""
filters = self.filters + [package_filter]
self.filters = sorted(filters, key=lambda x: x.cost) | python | {
"resource": ""
} |
q227711 | PackageFilterList.copy | train | def copy(self):
"""Return a copy of the filter list.
Adding rules to the copy will not alter the source.
"""
other = PackageFilterList.__new__(PackageFilterList)
other.filters = [x.copy() for x in self.filters]
return other | python | {
"resource": ""
} |
q227712 | Rule.parse_rule | train | def parse_rule(cls, txt):
"""Parse a rule from a string.
See rezconfig.package_filter for an overview of valid strings.
Args:
txt (str): String to parse.
Returns:
`Rule` instance.
"""
types = {"glob": GlobRule,
"regex": RegexRul... | python | {
"resource": ""
} |
q227713 | AMQPReader.read_bit | train | def read_bit(self):
"""Read a single boolean value."""
if not self.bitcount:
self.bits = ord(self.input.read(1))
self.bitcount = 8
result = (self.bits & 1) == 1
self.bits >>= 1
self.bitcount -= 1
return result | python | {
"resource": ""
} |
q227714 | AMQPReader.read_long | train | def read_long(self):
"""Read an unsigned 32-bit integer"""
self.bitcount = self.bits = 0
return unpack('>I', self.input.read(4))[0] | python | {
"resource": ""
} |
q227715 | AMQPReader.read_longlong | train | def read_longlong(self):
"""Read an unsigned 64-bit integer"""
self.bitcount = self.bits = 0
return unpack('>Q', self.input.read(8))[0] | python | {
"resource": ""
} |
q227716 | AMQPReader.read_float | train | def read_float(self):
"""Read float value."""
self.bitcount = self.bits = 0
return unpack('>d', self.input.read(8))[0] | python | {
"resource": ""
} |
q227717 | AMQPReader.read_shortstr | train | def read_shortstr(self):
"""Read a short string that's stored in up to 255 bytes.
The encoding isn't specified in the AMQP spec, so
assume it's utf-8
"""
self.bitcount = self.bits = 0
slen = unpack('B', self.input.read(1))[0]
return self.input.read(slen).decode(... | python | {
"resource": ""
} |
q227718 | GenericContent._load_properties | train | def _load_properties(self, raw_bytes):
"""Given the raw bytes containing the property-flags and property-list
from a content-frame-header, parse and insert into a dictionary
stored in this object as an attribute named 'properties'."""
r = AMQPReader(raw_bytes)
#
# Read 1... | python | {
"resource": ""
} |
q227719 | create_executable_script | train | def create_executable_script(filepath, body, program=None):
"""Create an executable script.
Args:
filepath (str): File to create.
body (str or callable): Contents of the script. If a callable, its code
is used as the script body.
program (str): Name of program to launch the ... | python | {
"resource": ""
} |
q227720 | create_forwarding_script | train | def create_forwarding_script(filepath, module, func_name, *nargs, **kwargs):
"""Create a 'forwarding' script.
A forwarding script is one that executes some arbitrary Rez function. This
is used internally by Rez to dynamically create a script that uses Rez,
even though the parent environment may not be ... | python | {
"resource": ""
} |
q227721 | dedup | train | def dedup(seq):
"""Remove duplicates from a list while keeping order."""
seen = set()
for item in seq:
if item not in seen:
seen.add(item)
yield item | python | {
"resource": ""
} |
q227722 | find_last_sublist | train | def find_last_sublist(list_, sublist):
"""Given a list, find the last occurance of a sublist within it.
Returns:
Index where the sublist starts, or None if there is no match.
"""
for i in reversed(range(len(list_) - len(sublist) + 1)):
if list_[i] == sublist[0] and list_[i:i + len(subli... | python | {
"resource": ""
} |
q227723 | PackageHelp.open | train | def open(self, section_index=0):
"""Launch a help section."""
uri = self._sections[section_index][1]
if len(uri.split()) == 1:
self._open_url(uri)
else:
if self._verbose:
print "running command: %s" % uri
p = popen(uri, shell=True)
... | python | {
"resource": ""
} |
q227724 | PackageHelp.print_info | train | def print_info(self, buf=None):
"""Print help sections."""
buf = buf or sys.stdout
print >> buf, "Sections:"
for i, section in enumerate(self._sections):
print >> buf, " %s:\t%s (%s)" % (i + 1, section[0], section[1]) | python | {
"resource": ""
} |
q227725 | Client.set_servers | train | def set_servers(self, servers):
"""
Set the pool of servers used by this client.
@param servers: an array of servers.
Servers can be passed in two forms:
1. Strings of the form C{"host:port"}, which implies a default weight of 1.
2. Tuples of the form C{("host:po... | python | {
"resource": ""
} |
q227726 | Client.get_stats | train | def get_stats(self, stat_args = None):
'''Get statistics from each of the servers.
@param stat_args: Additional arguments to pass to the memcache
"stats" command.
@return: A list of tuples ( server_identifier, stats_dictionary ).
The dictionary contains a number of name... | python | {
"resource": ""
} |
q227727 | Client.delete_multi | train | def delete_multi(self, keys, time=0, key_prefix=''):
'''
Delete multiple keys in the memcache doing just one query.
>>> notset_keys = mc.set_multi({'key1' : 'val1', 'key2' : 'val2'})
>>> mc.get_multi(['key1', 'key2']) == {'key1' : 'val1', 'key2' : 'val2'}
1
>>> mc.delete... | python | {
"resource": ""
} |
q227728 | Client.delete | train | def delete(self, key, time=0):
'''Deletes a key from the memcache.
@return: Nonzero on success.
@param time: number of seconds any subsequent set / update commands
should fail. Defaults to None for no delay.
@rtype: int
'''
if self.do_check_key:
self.... | python | {
"resource": ""
} |
q227729 | Client.add | train | def add(self, key, val, time = 0, min_compress_len = 0):
'''
Add new key with value.
Like L{set}, but only stores in memcache if the key doesn't already exist.
@return: Nonzero on success.
@rtype: int
'''
return self._set("add", key, val, time, min_compress_len) | python | {
"resource": ""
} |
q227730 | Client.append | train | def append(self, key, val, time=0, min_compress_len=0):
'''Append the value to the end of the existing key's value.
Only stores in memcache if key already exists.
Also see L{prepend}.
@return: Nonzero on success.
@rtype: int
'''
return self._set("append", key, v... | python | {
"resource": ""
} |
q227731 | Client.prepend | train | def prepend(self, key, val, time=0, min_compress_len=0):
'''Prepend the value to the beginning of the existing key's value.
Only stores in memcache if key already exists.
Also see L{append}.
@return: Nonzero on success.
@rtype: int
'''
return self._set("prepend"... | python | {
"resource": ""
} |
q227732 | Client.replace | train | def replace(self, key, val, time=0, min_compress_len=0):
'''Replace existing key with value.
Like L{set}, but only stores in memcache if the key already exists.
The opposite of L{add}.
@return: Nonzero on success.
@rtype: int
'''
return self._set("replace", key,... | python | {
"resource": ""
} |
q227733 | Client.set | train | def set(self, key, val, time=0, min_compress_len=0):
'''Unconditionally sets a key to a given value in the memcache.
The C{key} can optionally be an tuple, with the first element
being the server hash value and the second being the key.
If you want to avoid making this module calculate ... | python | {
"resource": ""
} |
q227734 | Client.set_multi | train | def set_multi(self, mapping, time=0, key_prefix='', min_compress_len=0):
'''
Sets multiple keys in the memcache doing just one query.
>>> notset_keys = mc.set_multi({'key1' : 'val1', 'key2' : 'val2'})
>>> mc.get_multi(['key1', 'key2']) == {'key1' : 'val1', 'key2' : 'val2'}
1
... | python | {
"resource": ""
} |
q227735 | Client.get_multi | train | def get_multi(self, keys, key_prefix=''):
'''
Retrieves multiple keys from the memcache doing just one query.
>>> success = mc.set("foo", "bar")
>>> success = mc.set("baz", 42)
>>> mc.get_multi(["foo", "baz", "foobar"]) == {"foo": "bar", "baz": 42}
1
>>> mc.set_m... | python | {
"resource": ""
} |
q227736 | _Host.readline | train | def readline(self, raise_exception=False):
"""Read a line and return it. If "raise_exception" is set,
raise _ConnectionDeadError if the read fails, otherwise return
an empty string.
"""
buf = self.buffer
if self.socket:
recv = self.socket.recv
else:
... | python | {
"resource": ""
} |
q227737 | MemoryPackageRepository.create_repository | train | def create_repository(cls, repository_data):
"""Create a standalone, in-memory repository.
Using this function bypasses the `package_repository_manager` singleton.
This is usually desired however, since in-memory repositories are for
temporarily storing programmatically created packages... | python | {
"resource": ""
} |
q227738 | LegacyMetadata.read_file | train | def read_file(self, fileob):
"""Read the metadata values from a file object."""
msg = message_from_file(fileob)
self._fields['Metadata-Version'] = msg['metadata-version']
# When reading, get all the fields we can
for field in _ALL_FIELDS:
if field not in msg:
... | python | {
"resource": ""
} |
q227739 | LegacyMetadata.check | train | def check(self, strict=False):
"""Check if the metadata is compliant. If strict is True then raise if
no Name or Version are provided"""
self.set_metadata_version()
# XXX should check the versions (if the file was loaded)
missing, warnings = [], []
for attr in ('Name', ... | python | {
"resource": ""
} |
q227740 | create_pane | train | def create_pane(widgets, horizontal, parent_widget=None, compact=False,
compact_spacing=2):
"""Create a widget containing an aligned set of widgets.
Args:
widgets (list of `QWidget`).
horizontal (bool).
align (str): One of:
- 'left', 'right' (horizontal);
... | python | {
"resource": ""
} |
q227741 | get_icon | train | def get_icon(name, as_qicon=False):
"""Returns a `QPixmap` containing the given image, or a QIcon if `as_qicon`
is True"""
filename = name + ".png"
icon = icons.get(filename)
if not icon:
path = os.path.dirname(__file__)
path = os.path.join(path, "icons")
filepath = os.path.j... | python | {
"resource": ""
} |
q227742 | interp_color | train | def interp_color(a, b, f):
"""Interpolate between two colors.
Returns:
`QColor` object.
"""
a_ = (a.redF(), a.greenF(), a.blueF())
b_ = (b.redF(), b.greenF(), b.blueF())
a_ = [x * (1 - f) for x in a_]
b_ = [x * f for x in b_]
c = [x + y for x, y in zip(a_, b_)]
return QtGui.... | python | {
"resource": ""
} |
q227743 | create_toolbutton | train | def create_toolbutton(entries, parent=None):
"""Create a toolbutton.
Args:
entries: List of (label, slot) tuples.
Returns:
`QtGui.QToolBar`.
"""
btn = QtGui.QToolButton(parent)
menu = QtGui.QMenu()
actions = []
for label, slot in entries:
action = add_menu_acti... | python | {
"resource": ""
} |
q227744 | SimpleScrapingLocator.get_page | train | def get_page(self, url):
"""
Get the HTML for an URL, possibly from an in-memory cache.
XXX TODO Note: this cache is never actually cleared. It's assumed that
the data won't get stale over the lifetime of a locator instance (not
necessarily true for the default_locator).
... | python | {
"resource": ""
} |
q227745 | get_reverse_dependency_tree | train | def get_reverse_dependency_tree(package_name, depth=None, paths=None,
build_requires=False,
private_build_requires=False):
"""Find packages that depend on the given package.
This is a reverse dependency lookup. A tree is constructed, showing what
... | python | {
"resource": ""
} |
q227746 | get_plugins | train | def get_plugins(package_name, paths=None):
"""Find packages that are plugins of the given package.
Args:
package_name (str): Name of the package.
paths (list of str): Paths to search for packages, defaults to
`config.packages_path`.
Returns:
list of str: The packages th... | python | {
"resource": ""
} |
q227747 | ResourceSearcher.search | train | def search(self, resources_request=None):
"""Search for resources.
Args:
resources_request (str): Resource to search, glob-style patterns
are supported. If None, returns all matching resource types.
Returns:
2-tuple:
- str: resource type (fam... | python | {
"resource": ""
} |
q227748 | ResourceSearchResultFormatter.print_search_results | train | def print_search_results(self, search_results, buf=sys.stdout):
"""Print formatted search results.
Args:
search_results (list of `ResourceSearchResult`): Search to format.
"""
formatted_lines = self.format_search_results(search_results)
pr = Printer(buf)
for... | python | {
"resource": ""
} |
q227749 | ResourceSearchResultFormatter.format_search_results | train | def format_search_results(self, search_results):
"""Format search results.
Args:
search_results (list of `ResourceSearchResult`): Search to format.
Returns:
List of 2-tuple: Text and color to print in.
"""
formatted_lines = []
for search_result ... | python | {
"resource": ""
} |
q227750 | read | train | def read(string):
"""
Read a graph from a string in Dot language and return it. Nodes and edges specified in the
input will be added to the current graph.
@type string: string
@param string: Input string in Dot format specifying a graph.
@rtype: graph
@return: Graph
"""
... | python | {
"resource": ""
} |
q227751 | read_hypergraph | train | def read_hypergraph(string):
"""
Read a hypergraph from a string in dot format. Nodes and edges specified in the input will be
added to the current hypergraph.
@type string: string
@param string: Input string in dot format specifying a graph.
@rtype: hypergraph
@return: Hypergrap... | python | {
"resource": ""
} |
q227752 | graph_from_dot_file | train | def graph_from_dot_file(path):
"""Load graph as defined by a DOT file.
The file is assumed to be in DOT format. It will
be loaded, parsed and a Dot class will be returned,
representing the graph.
"""
fd = file(path, 'rb')
data = fd.read()
fd.close()
return graph_from_... | python | {
"resource": ""
} |
q227753 | __find_executables | train | def __find_executables(path):
"""Used by find_graphviz
path - single directory as a string
If any of the executables are found, it will return a dictionary
containing the program names as keys and their paths as values.
Otherwise returns None
"""
success = False
progs... | python | {
"resource": ""
} |
q227754 | Edge.to_string | train | def to_string(self):
"""Returns a string representation of the edge in dot language.
"""
src = self.parse_node_ref( self.get_source() )
dst = self.parse_node_ref( self.get_destination() )
if isinstance(src, frozendict):
edge = [ Subgraph(obj_dict=src).to_str... | python | {
"resource": ""
} |
q227755 | Graph.get_node | train | def get_node(self, name):
"""Retrieve a node from the graph.
Given a node's name the corresponding Node
instance will be returned.
If one or more nodes exist with that name a list of
Node instances is returned.
An empty list is returned otherwise.
... | python | {
"resource": ""
} |
q227756 | Graph.add_edge | train | def add_edge(self, graph_edge):
"""Adds an edge object to the graph.
It takes a edge object as its only argument and returns
None.
"""
if not isinstance(graph_edge, Edge):
raise TypeError('add_edge() received a non edge class object: ' + str(graph_edge))
... | python | {
"resource": ""
} |
q227757 | Graph.add_subgraph | train | def add_subgraph(self, sgraph):
"""Adds an subgraph object to the graph.
It takes a subgraph object as its only argument and returns
None.
"""
if not isinstance(sgraph, Subgraph) and not isinstance(sgraph, Cluster):
raise TypeError('add_subgraph() received a... | python | {
"resource": ""
} |
q227758 | Graph.to_string | train | def to_string(self):
"""Returns a string representation of the graph in dot language.
It will return the graph and all its subelements in string from.
"""
graph = list()
if self.obj_dict.get('strict', None) is not None:
if ... | python | {
"resource": ""
} |
q227759 | Dot.create | train | def create(self, prog=None, format='ps'):
"""Creates and returns a Postscript representation of the graph.
create will write the graph to a temporary dot file and process
it with the program given by 'prog' (which defaults to 'twopi'),
reading the Postscript output and returning it as a... | python | {
"resource": ""
} |
q227760 | dump_yaml | train | def dump_yaml(data, Dumper=_Dumper, default_flow_style=False):
"""Returns data as yaml-formatted string."""
content = yaml.dump(data,
default_flow_style=default_flow_style,
Dumper=Dumper)
return content.strip() | python | {
"resource": ""
} |
q227761 | load_yaml | train | def load_yaml(filepath):
"""Convenience function for loading yaml-encoded data from disk."""
with open(filepath) as f:
txt = f.read()
return yaml.load(txt) | python | {
"resource": ""
} |
q227762 | memcached_client | train | def memcached_client(servers=config.memcached_uri, debug=config.debug_memcache):
"""Get a shared memcached instance.
This function shares the same memcached instance across nested invocations.
This is done so that memcached connections can be kept to a minimum, but at
the same time unnecessary extra re... | python | {
"resource": ""
} |
q227763 | pool_memcached_connections | train | def pool_memcached_connections(func):
"""Function decorator to pool memcached connections.
Use this to wrap functions that might make multiple calls to memcached. This
will cause a single memcached client to be shared for all connections.
"""
if isgeneratorfunction(func):
def wrapper(*nargs... | python | {
"resource": ""
} |
q227764 | memcached | train | def memcached(servers, key=None, from_cache=None, to_cache=None, time=0,
min_compress_len=0, debug=False):
"""memcached memoization function decorator.
The wrapped function is expected to return a value that is stored to a
memcached server, first translated by `to_cache` if provided. In the e... | python | {
"resource": ""
} |
q227765 | Client.client | train | def client(self):
"""Get the native memcache client.
Returns:
`memcache.Client` instance.
"""
if self._client is None:
self._client = Client_(self.servers)
return self._client | python | {
"resource": ""
} |
q227766 | Client.flush | train | def flush(self, hard=False):
"""Drop existing entries from the cache.
Args:
hard (bool): If True, all current entries are flushed from the
server(s), which affects all users. If False, only the local
process is affected.
"""
if not self.server... | python | {
"resource": ""
} |
q227767 | depth_first_search | train | def depth_first_search(graph, root=None, filter=null()):
"""
Depth-first search.
@type graph: graph, digraph
@param graph: Graph.
@type root: node
@param root: Optional root node (will explore only root's connected component)
@rtype: tuple
@return: A tupple containing a diction... | python | {
"resource": ""
} |
q227768 | breadth_first_search | train | def breadth_first_search(graph, root=None, filter=null()):
"""
Breadth-first search.
@type graph: graph, digraph
@param graph: Graph.
@type root: node
@param root: Optional root node (will explore only root's connected component)
@rtype: tuple
@return: A tuple containing a dictiona... | python | {
"resource": ""
} |
q227769 | PackageResource.normalize_variables | train | def normalize_variables(cls, variables):
"""Make sure version is treated consistently
"""
# if the version is False, empty string, etc, throw it out
if variables.get('version', True) in ('', False, '_NO_VERSION', None):
del variables['version']
return super(PackageRes... | python | {
"resource": ""
} |
q227770 | shlex.push_source | train | def push_source(self, newstream, newfile=None):
"Push an input source onto the lexer's input source stack."
if isinstance(newstream, basestring):
newstream = StringIO(newstream)
self.filestack.appendleft((self.infile, self.instream, self.lineno))
self.infile = newfile
... | python | {
"resource": ""
} |
q227771 | shlex.error_leader | train | def error_leader(self, infile=None, lineno=None):
"Emit a C-compiler-like, Emacs-friendly error-message leader."
if infile is None:
infile = self.infile
if lineno is None:
lineno = self.lineno
return "\"%s\", line %d: " % (infile, lineno) | python | {
"resource": ""
} |
q227772 | System.rez_bin_path | train | def rez_bin_path(self):
"""Get path containing rez binaries, or None if no binaries are
available, or Rez is not a production install.
"""
binpath = None
if sys.argv and sys.argv[0]:
executable = sys.argv[0]
path = which("rezolve", env={"PATH":os.path.dirn... | python | {
"resource": ""
} |
q227773 | System.get_summary_string | train | def get_summary_string(self):
"""Get a string summarising the state of Rez as a whole.
Returns:
String.
"""
from rez.plugin_managers import plugin_manager
txt = "Rez %s" % __version__
txt += "\n\n%s" % plugin_manager.get_summary_string()
return txt | python | {
"resource": ""
} |
q227774 | System.clear_caches | train | def clear_caches(self, hard=False):
"""Clear all caches in Rez.
Rez caches package contents and iteration during a python session. Thus
newly released packages, and changes to existing packages, may not be
picked up. You need to clear the cache for these changes to become
visibl... | python | {
"resource": ""
} |
q227775 | Resolver.solve | train | def solve(self):
"""Perform the solve.
"""
with log_duration(self._print, "memcache get (resolve) took %s"):
solver_dict = self._get_cached_solve()
if solver_dict:
self.from_cache = True
self._set_result(solver_dict)
else:
self.fro... | python | {
"resource": ""
} |
q227776 | Resolver._set_cached_solve | train | def _set_cached_solve(self, solver_dict):
"""Store a solve to memcached.
If there is NOT a resolve timestamp:
- store the solve to a non-timestamped entry.
If there IS a resolve timestamp (let us call this T):
- if NO newer package in the solve has been released since T... | python | {
"resource": ""
} |
q227777 | Resolver._memcache_key | train | def _memcache_key(self, timestamped=False):
"""Makes a key suitable as a memcache entry."""
request = tuple(map(str, self.package_requests))
repo_ids = []
for path in self.package_paths:
repo = package_repository_manager.get_repository(path)
repo_ids.append(repo.u... | python | {
"resource": ""
} |
q227778 | create_shell | train | def create_shell(shell=None, **kwargs):
"""Returns a Shell of the given type, or the current shell type if shell
is None."""
if not shell:
shell = config.default_shell
if not shell:
from rez.system import system
shell = system.shell
from rez.plugin_managers impor... | python | {
"resource": ""
} |
q227779 | Shell.startup_capabilities | train | def startup_capabilities(cls, rcfile=False, norc=False, stdin=False,
command=False):
"""
Given a set of options related to shell startup, return the actual
options that will be applied.
@returns 4-tuple representing applied value of each option.
"""
... | python | {
"resource": ""
} |
q227780 | PackageIndex.upload_file | train | def upload_file(self, metadata, filename, signer=None, sign_password=None,
filetype='sdist', pyversion='source', keystore=None):
"""
Upload a release file to the index.
:param metadata: A :class:`Metadata` instance defining at least a name
and versio... | python | {
"resource": ""
} |
q227781 | _get_dependency_order | train | def _get_dependency_order(g, node_list):
"""Return list of nodes as close as possible to the ordering in node_list,
but with child nodes earlier in the list than parents."""
access_ = accessibility(g)
deps = dict((k, set(v) - set([k])) for k, v in access_.iteritems())
nodes = node_list + list(set(g.... | python | {
"resource": ""
} |
q227782 | _short_req_str | train | def _short_req_str(package_request):
"""print shortened version of '==X|==Y|==Z' ranged requests."""
if not package_request.conflict:
versions = package_request.range.to_versions()
if versions and len(versions) == len(package_request.range) \
and len(versions) > 1:
re... | python | {
"resource": ""
} |
q227783 | PackageVariant.requires_list | train | def requires_list(self):
"""
It is important that this property is calculated lazily. Getting the
'requires' attribute may trigger a package load, which may be avoided if
this variant is reduced away before that happens.
"""
requires = self.variant.get_requires(build_requ... | python | {
"resource": ""
} |
q227784 | _PackageEntry.sort | train | def sort(self):
"""Sort variants from most correct to consume, to least.
Sort rules:
version_priority:
- sort by highest versions of packages shared with request;
- THEN least number of additional packages added to solve;
- THEN highest versions of additional packages;
... | python | {
"resource": ""
} |
q227785 | _PackageVariantList.get_intersection | train | def get_intersection(self, range_):
"""Get a list of variants that intersect with the given range.
Args:
range_ (`VersionRange`): Package version range.
Returns:
List of `_PackageEntry` objects.
"""
result = []
for entry in self.entries:
... | python | {
"resource": ""
} |
q227786 | _PackageVariantSlice.intersect | train | def intersect(self, range_):
self.solver.intersection_broad_tests_count += 1
"""Remove variants whose version fall outside of the given range."""
if range_.is_any():
return self
if self.solver.optimised:
if range_ in self.been_intersected_with:
r... | python | {
"resource": ""
} |
q227787 | _PackageVariantSlice.reduce_by | train | def reduce_by(self, package_request):
"""Remove variants whos dependencies conflict with the given package
request.
Returns:
(VariantSlice, [Reduction]) tuple, where slice may be None if all
variants were reduced.
"""
if self.pr:
reqstr = _sho... | python | {
"resource": ""
} |
q227788 | _PackageVariantSlice.split | train | def split(self):
"""Split the slice.
Returns:
(`_PackageVariantSlice`, `_PackageVariantSlice`) tuple, where the
first is the preferred slice.
"""
# We sort here in the split in order to sort as late as possible.
# Because splits usually happen after inte... | python | {
"resource": ""
} |
q227789 | _PackageVariantSlice.sort_versions | train | def sort_versions(self):
"""Sort entries by version.
The order is typically descending, but package order functions can
change this.
"""
if self.sorted:
return
for orderer in (self.solver.package_orderers or []):
entries = orderer.reorder(self.en... | python | {
"resource": ""
} |
q227790 | PackageVariantCache.get_variant_slice | train | def get_variant_slice(self, package_name, range_):
"""Get a list of variants from the cache.
Args:
package_name (str): Name of package.
range_ (`VersionRange`): Package version range.
Returns:
`_PackageVariantSlice` object.
"""
variant_list =... | python | {
"resource": ""
} |
q227791 | _PackageScope.intersect | train | def intersect(self, range_):
"""Intersect this scope with a package range.
Returns:
A new copy of this scope, with variants whos version fall outside
of the given range removed. If there were no removals, self is
returned. If all variants were removed, None is return... | python | {
"resource": ""
} |
q227792 | _PackageScope.reduce_by | train | def reduce_by(self, package_request):
"""Reduce this scope wrt a package request.
Returns:
A (_PackageScope, [Reduction]) tuple, where the scope is a new
scope copy with reductions applied, or self if there were no
reductions, or None if the scope was completely redu... | python | {
"resource": ""
} |
q227793 | _PackageScope.split | train | def split(self):
"""Split the scope.
Returns:
A (_PackageScope, _PackageScope) tuple, where the first scope is
guaranteed to have a common dependency. Or None, if splitting is
not applicable to this scope.
"""
if self.package_request.conflict or (len(... | python | {
"resource": ""
} |
q227794 | _ResolvePhase.finalise | train | def finalise(self):
"""Remove conflict requests, detect cyclic dependencies, and reorder
packages wrt dependency and then request order.
Returns:
A new copy of the phase with conflict requests removed and packages
correctly ordered; or, if cyclic dependencies were detect... | python | {
"resource": ""
} |
q227795 | _ResolvePhase.split | train | def split(self):
"""Split the phase.
When a phase is exhausted, it gets split into a pair of phases to be
further solved. The split happens like so:
1) Select the first unsolved package scope.
2) Find some common dependency in the first N variants of the scope.
3) Split ... | python | {
"resource": ""
} |
q227796 | Solver.status | train | def status(self):
"""Return the current status of the solve.
Returns:
SolverStatus: Enum representation of the state of the solver.
"""
if self.request_list.conflict:
return SolverStatus.failed
if self.callback_return == SolverCallbackReturn.fail:
... | python | {
"resource": ""
} |
q227797 | Solver.num_fails | train | def num_fails(self):
"""Return the number of failed solve steps that have been executed.
Note that num_solves is inclusive of failures."""
n = len(self.failed_phase_list)
if self.phase_stack[-1].status in (SolverStatus.failed, SolverStatus.cyclic):
n += 1
return n | python | {
"resource": ""
} |
q227798 | Solver.resolved_packages | train | def resolved_packages(self):
"""Return a list of PackageVariant objects, or None if the resolve did
not complete or was unsuccessful.
"""
if (self.status != SolverStatus.solved):
return None
final_phase = self.phase_stack[-1]
return final_phase._get_solved_va... | python | {
"resource": ""
} |
q227799 | Solver.reset | train | def reset(self):
"""Reset the solver, removing any current solve."""
if not self.request_list.conflict:
phase = _ResolvePhase(self.request_list.requirements, solver=self)
self.pr("resetting...")
self._init()
self._push_phase(phase) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.