id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
246,200
nerdvegas/rez
src/rez/package_help.py
PackageHelp.print_info
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
def print_info(self, buf=None): 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])
[ "def", "print_info", "(", "self", ",", "buf", "=", "None", ")", ":", "buf", "=", "buf", "or", "sys", ".", "stdout", "print", ">>", "buf", ",", "\"Sections:\"", "for", "i", ",", "section", "in", "enumerate", "(", "self", ".", "_sections", ")", ":", ...
Print help sections.
[ "Print", "help", "sections", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_help.py#L99-L104
246,201
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.set_servers
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
def set_servers(self, servers): self.servers = [_Host(s, self.debug, dead_retry=self.dead_retry, socket_timeout=self.socket_timeout, flush_on_reconnect=self.flush_on_reconnect) for s in servers] self._init_buckets()
[ "def", "set_servers", "(", "self", ",", "servers", ")", ":", "self", ".", "servers", "=", "[", "_Host", "(", "s", ",", "self", ".", "debug", ",", "dead_retry", "=", "self", ".", "dead_retry", ",", "socket_timeout", "=", "self", ".", "socket_timeout", "...
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:port", weight)}, where C{weight} is an int...
[ "Set", "the", "pool", "of", "servers", "used", "by", "this", "client", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L240-L254
246,202
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.get_stats
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
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...
[ "def", "get_stats", "(", "self", ",", "stat_args", "=", "None", ")", ":", "data", "=", "[", "]", "for", "s", "in", "self", ".", "servers", ":", "if", "not", "s", ".", "connect", "(", ")", ":", "continue", "if", "s", ".", "family", "==", "socket",...
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/value pairs specifying the name of th...
[ "Get", "statistics", "from", "each", "of", "the", "servers", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L256-L290
246,203
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.delete_multi
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
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...
[ "def", "delete_multi", "(", "self", ",", "keys", ",", "time", "=", "0", ",", "key_prefix", "=", "''", ")", ":", "self", ".", "_statlog", "(", "'delete_multi'", ")", "server_keys", ",", "prefixed_to_orig_key", "=", "self", ".", "_map_and_prefix_keys", "(", ...
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_multi(['key1', 'key2']) 1 >>> mc.get_multi(['key1', 'key...
[ "Delete", "multiple", "keys", "in", "the", "memcache", "doing", "just", "one", "query", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L365-L429
246,204
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.delete
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
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....
[ "def", "delete", "(", "self", ",", "key", ",", "time", "=", "0", ")", ":", "if", "self", ".", "do_check_key", ":", "self", ".", "check_key", "(", "key", ")", "server", ",", "key", "=", "self", ".", "_get_server", "(", "key", ")", "if", "not", "se...
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
[ "Deletes", "a", "key", "from", "the", "memcache", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L431-L459
246,205
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.add
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
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)
[ "def", "add", "(", "self", ",", "key", ",", "val", ",", "time", "=", "0", ",", "min_compress_len", "=", "0", ")", ":", "return", "self", ".", "_set", "(", "\"add\"", ",", "key", ",", "val", ",", "time", ",", "min_compress_len", ")" ]
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
[ "Add", "new", "key", "with", "value", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L517-L526
246,206
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.append
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
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...
[ "def", "append", "(", "self", ",", "key", ",", "val", ",", "time", "=", "0", ",", "min_compress_len", "=", "0", ")", ":", "return", "self", ".", "_set", "(", "\"append\"", ",", "key", ",", "val", ",", "time", ",", "min_compress_len", ")" ]
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
[ "Append", "the", "value", "to", "the", "end", "of", "the", "existing", "key", "s", "value", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L528-L537
246,207
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.prepend
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
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"...
[ "def", "prepend", "(", "self", ",", "key", ",", "val", ",", "time", "=", "0", ",", "min_compress_len", "=", "0", ")", ":", "return", "self", ".", "_set", "(", "\"prepend\"", ",", "key", ",", "val", ",", "time", ",", "min_compress_len", ")" ]
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
[ "Prepend", "the", "value", "to", "the", "beginning", "of", "the", "existing", "key", "s", "value", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L539-L548
246,208
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.replace
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
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,...
[ "def", "replace", "(", "self", ",", "key", ",", "val", ",", "time", "=", "0", ",", "min_compress_len", "=", "0", ")", ":", "return", "self", ".", "_set", "(", "\"replace\"", ",", "key", ",", "val", ",", "time", ",", "min_compress_len", ")" ]
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
[ "Replace", "existing", "key", "with", "value", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L550-L559
246,209
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.set
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
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 ...
[ "def", "set", "(", "self", ",", "key", ",", "val", ",", "time", "=", "0", ",", "min_compress_len", "=", "0", ")", ":", "return", "self", ".", "_set", "(", "\"set\"", ",", "key", ",", "val", ",", "time", ",", "min_compress_len", ")" ]
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 a hash value. You may prefer, for example, to keep all o...
[ "Unconditionally", "sets", "a", "key", "to", "a", "given", "value", "in", "the", "memcache", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L561-L585
246,210
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.set_multi
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
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 ...
[ "def", "set_multi", "(", "self", ",", "mapping", ",", "time", "=", "0", ",", "key_prefix", "=", "''", ",", "min_compress_len", "=", "0", ")", ":", "self", ".", "_statlog", "(", "'set_multi'", ")", "server_keys", ",", "prefixed_to_orig_key", "=", "self", ...
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 This method is recommended over regular L{set} as it lowers the number of tota...
[ "Sets", "multiple", "keys", "in", "the", "memcache", "doing", "just", "one", "query", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L658-L755
246,211
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
Client.get_multi
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
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...
[ "def", "get_multi", "(", "self", ",", "keys", ",", "key_prefix", "=", "''", ")", ":", "self", ".", "_statlog", "(", "'get_multi'", ")", "server_keys", ",", "prefixed_to_orig_key", "=", "self", ".", "_map_and_prefix_keys", "(", "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_multi({'k1' : 1, 'k2' : 2}, key_prefix='pfx_') == [] 1 ...
[ "Retrieves", "multiple", "keys", "from", "the", "memcache", "doing", "just", "one", "query", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L908-L978
246,212
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
_Host.readline
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
def readline(self, raise_exception=False): buf = self.buffer if self.socket: recv = self.socket.recv else: recv = lambda bufsize: '' while True: index = buf.find('\r\n') if index >= 0: break data = recv(4096) ...
[ "def", "readline", "(", "self", ",", "raise_exception", "=", "False", ")", ":", "buf", "=", "self", ".", "buffer", "if", "self", ".", "socket", ":", "recv", "=", "self", ".", "socket", ".", "recv", "else", ":", "recv", "=", "lambda", "bufsize", ":", ...
Read a line and return it. If "raise_exception" is set, raise _ConnectionDeadError if the read fails, otherwise return an empty string.
[ "Read", "a", "line", "and", "return", "it", ".", "If", "raise_exception", "is", "set", "raise", "_ConnectionDeadError", "if", "the", "read", "fails", "otherwise", "return", "an", "empty", "string", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L1168-L1194
246,213
nerdvegas/rez
src/rezplugins/package_repository/memory.py
MemoryPackageRepository.create_repository
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
def create_repository(cls, repository_data): location = "memory{%s}" % hex(id(repository_data)) resource_pool = ResourcePool(cache_size=None) repo = MemoryPackageRepository(location, resource_pool) repo.data = repository_data return repo
[ "def", "create_repository", "(", "cls", ",", "repository_data", ")", ":", "location", "=", "\"memory{%s}\"", "%", "hex", "(", "id", "(", "repository_data", ")", ")", "resource_pool", "=", "ResourcePool", "(", "cache_size", "=", "None", ")", "repo", "=", "Mem...
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, which we do not want to cache and that do not ...
[ "Create", "a", "standalone", "in", "-", "memory", "repository", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/package_repository/memory.py#L134-L152
246,214
nerdvegas/rez
src/build_utils/distlib/metadata.py
LegacyMetadata.read_file
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
def read_file(self, fileob): 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: continue if field in _LISTFIELDS: ...
[ "def", "read_file", "(", "self", ",", "fileob", ")", ":", "msg", "=", "message_from_file", "(", "fileob", ")", "self", ".", "_fields", "[", "'Metadata-Version'", "]", "=", "msg", "[", "'metadata-version'", "]", "# When reading, get all the fields we can", "for", ...
Read the metadata values from a file object.
[ "Read", "the", "metadata", "values", "from", "a", "file", "object", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/build_utils/distlib/metadata.py#L334-L354
246,215
nerdvegas/rez
src/build_utils/distlib/metadata.py
LegacyMetadata.check
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
def check(self, strict=False): self.set_metadata_version() # XXX should check the versions (if the file was loaded) missing, warnings = [], [] for attr in ('Name', 'Version'): # required by PEP 345 if attr not in self: missing.append(attr) if stric...
[ "def", "check", "(", "self", ",", "strict", "=", "False", ")", ":", "self", ".", "set_metadata_version", "(", ")", "# XXX should check the versions (if the file was loaded)", "missing", ",", "warnings", "=", "[", "]", ",", "[", "]", "for", "attr", "in", "(", ...
Check if the metadata is compliant. If strict is True then raise if no Name or Version are provided
[ "Check", "if", "the", "metadata", "is", "compliant", ".", "If", "strict", "is", "True", "then", "raise", "if", "no", "Name", "or", "Version", "are", "provided" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/build_utils/distlib/metadata.py#L487-L529
246,216
nerdvegas/rez
src/rezgui/util.py
create_pane
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
def create_pane(widgets, horizontal, parent_widget=None, compact=False, compact_spacing=2): pane = parent_widget or QtGui.QWidget() type_ = QtGui.QHBoxLayout if horizontal else QtGui.QVBoxLayout layout = type_() if compact: layout.setSpacing(compact_spacing) layout.setCon...
[ "def", "create_pane", "(", "widgets", ",", "horizontal", ",", "parent_widget", "=", "None", ",", "compact", "=", "False", ",", "compact_spacing", "=", "2", ")", ":", "pane", "=", "parent_widget", "or", "QtGui", ".", "QWidget", "(", ")", "type_", "=", "Qt...
Create a widget containing an aligned set of widgets. Args: widgets (list of `QWidget`). horizontal (bool). align (str): One of: - 'left', 'right' (horizontal); - 'top', 'bottom' (vertical) parent_widget (`QWidget`): Owner widget, QWidget is created if this ...
[ "Create", "a", "widget", "containing", "an", "aligned", "set", "of", "widgets", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezgui/util.py#L7-L44
246,217
nerdvegas/rez
src/rezgui/util.py
get_icon
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
def get_icon(name, as_qicon=False): filename = name + ".png" icon = icons.get(filename) if not icon: path = os.path.dirname(__file__) path = os.path.join(path, "icons") filepath = os.path.join(path, filename) if not os.path.exists(filepath): filepath = os.path.joi...
[ "def", "get_icon", "(", "name", ",", "as_qicon", "=", "False", ")", ":", "filename", "=", "name", "+", "\".png\"", "icon", "=", "icons", ".", "get", "(", "filename", ")", "if", "not", "icon", ":", "path", "=", "os", ".", "path", ".", "dirname", "("...
Returns a `QPixmap` containing the given image, or a QIcon if `as_qicon` is True
[ "Returns", "a", "QPixmap", "containing", "the", "given", "image", "or", "a", "QIcon", "if", "as_qicon", "is", "True" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezgui/util.py#L50-L65
246,218
nerdvegas/rez
src/rezgui/util.py
interp_color
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
def interp_color(a, b, f): 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.QColor.fromRgbF(*c)
[ "def", "interp_color", "(", "a", ",", "b", ",", "f", ")", ":", "a_", "=", "(", "a", ".", "redF", "(", ")", ",", "a", ".", "greenF", "(", ")", ",", "a", ".", "blueF", "(", ")", ")", "b_", "=", "(", "b", ".", "redF", "(", ")", ",", "b", ...
Interpolate between two colors. Returns: `QColor` object.
[ "Interpolate", "between", "two", "colors", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezgui/util.py#L105-L116
246,219
nerdvegas/rez
src/rezgui/util.py
create_toolbutton
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
def create_toolbutton(entries, parent=None): btn = QtGui.QToolButton(parent) menu = QtGui.QMenu() actions = [] for label, slot in entries: action = add_menu_action(menu, label, slot) actions.append(action) btn.setPopupMode(QtGui.QToolButton.MenuButtonPopup) btn.setDefaultAction...
[ "def", "create_toolbutton", "(", "entries", ",", "parent", "=", "None", ")", ":", "btn", "=", "QtGui", ".", "QToolButton", "(", "parent", ")", "menu", "=", "QtGui", ".", "QMenu", "(", ")", "actions", "=", "[", "]", "for", "label", ",", "slot", "in", ...
Create a toolbutton. Args: entries: List of (label, slot) tuples. Returns: `QtGui.QToolBar`.
[ "Create", "a", "toolbutton", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezgui/util.py#L119-L139
246,220
nerdvegas/rez
src/build_utils/distlib/locators.py
SimpleScrapingLocator.get_page
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
def get_page(self, url): # http://peak.telecommunity.com/DevCenter/EasyInstall#package-index-api scheme, netloc, path, _, _, _ = urlparse(url) if scheme == 'file' and os.path.isdir(url2pathname(path)): url = urljoin(ensure_slash(url), 'index.html') if url in self._page_cache...
[ "def", "get_page", "(", "self", ",", "url", ")", ":", "# http://peak.telecommunity.com/DevCenter/EasyInstall#package-index-api", "scheme", ",", "netloc", ",", "path", ",", "_", ",", "_", ",", "_", "=", "urlparse", "(", "url", ")", "if", "scheme", "==", "'file'...
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).
[ "Get", "the", "HTML", "for", "an", "URL", "possibly", "from", "an", "in", "-", "memory", "cache", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/build_utils/distlib/locators.py#L673-L730
246,221
nerdvegas/rez
src/rez/package_search.py
get_reverse_dependency_tree
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
def get_reverse_dependency_tree(package_name, depth=None, paths=None, build_requires=False, private_build_requires=False): pkgs_list = [[package_name]] g = digraph() g.add_node(package_name) # build reverse lookup it = iter_package_fam...
[ "def", "get_reverse_dependency_tree", "(", "package_name", ",", "depth", "=", "None", ",", "paths", "=", "None", ",", "build_requires", "=", "False", ",", "private_build_requires", "=", "False", ")", ":", "pkgs_list", "=", "[", "[", "package_name", "]", "]", ...
Find packages that depend on the given package. This is a reverse dependency lookup. A tree is constructed, showing what packages depend on the given package, with an optional depth limit. A resolve does not occur. Only the latest version of each package is used, and requirements from all variants of t...
[ "Find", "packages", "that", "depend", "on", "the", "given", "package", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_search.py#L25-L121
246,222
nerdvegas/rez
src/rez/package_search.py
get_plugins
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
def get_plugins(package_name, paths=None): pkg = get_latest_package(package_name, paths=paths, error=True) if not pkg.has_plugins: return [] it = iter_package_families(paths) package_names = set(x.name for x in it) bar = ProgressBar("Searching", len(package_names)) plugin_pkgs = [] ...
[ "def", "get_plugins", "(", "package_name", ",", "paths", "=", "None", ")", ":", "pkg", "=", "get_latest_package", "(", "package_name", ",", "paths", "=", "paths", ",", "error", "=", "True", ")", "if", "not", "pkg", ".", "has_plugins", ":", "return", "[",...
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 that are plugins of the given package.
[ "Find", "packages", "that", "are", "plugins", "of", "the", "given", "package", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_search.py#L124-L157
246,223
nerdvegas/rez
src/rez/package_search.py
ResourceSearcher.search
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
def search(self, resources_request=None): # Find matching package families name_pattern, version_range = self._parse_request(resources_request) family_names = set( x.name for x in iter_package_families(paths=self.package_paths) if fnmatch.fnmatch(x.name, name_pattern) ...
[ "def", "search", "(", "self", ",", "resources_request", "=", "None", ")", ":", "# Find matching package families", "name_pattern", ",", "version_range", "=", "self", ".", "_parse_request", "(", "resources_request", ")", "family_names", "=", "set", "(", "x", ".", ...
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 (family, package, variant); - List of `Resour...
[ "Search", "for", "resources", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_search.py#L210-L305
246,224
nerdvegas/rez
src/rez/package_search.py
ResourceSearchResultFormatter.print_search_results
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
def print_search_results(self, search_results, buf=sys.stdout): formatted_lines = self.format_search_results(search_results) pr = Printer(buf) for txt, style in formatted_lines: pr(txt, style)
[ "def", "print_search_results", "(", "self", ",", "search_results", ",", "buf", "=", "sys", ".", "stdout", ")", ":", "formatted_lines", "=", "self", ".", "format_search_results", "(", "search_results", ")", "pr", "=", "Printer", "(", "buf", ")", "for", "txt",...
Print formatted search results. Args: search_results (list of `ResourceSearchResult`): Search to format.
[ "Print", "formatted", "search", "results", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_search.py#L347-L357
246,225
nerdvegas/rez
src/rez/package_search.py
ResourceSearchResultFormatter.format_search_results
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
def format_search_results(self, search_results): formatted_lines = [] for search_result in search_results: lines = self._format_search_result(search_result) formatted_lines.extend(lines) return formatted_lines
[ "def", "format_search_results", "(", "self", ",", "search_results", ")", ":", "formatted_lines", "=", "[", "]", "for", "search_result", "in", "search_results", ":", "lines", "=", "self", ".", "_format_search_result", "(", "search_result", ")", "formatted_lines", "...
Format search results. Args: search_results (list of `ResourceSearchResult`): Search to format. Returns: List of 2-tuple: Text and color to print in.
[ "Format", "search", "results", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_search.py#L359-L374
246,226
nerdvegas/rez
src/rez/vendor/pygraph/readwrite/dot.py
read
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
def read(string): dotG = pydot.graph_from_dot_data(string) if (dotG.get_type() == "graph"): G = graph() elif (dotG.get_type() == "digraph"): G = digraph() elif (dotG.get_type() == "hypergraph"): return read_hypergraph(string) else: raise InvalidGraphType ...
[ "def", "read", "(", "string", ")", ":", "dotG", "=", "pydot", ".", "graph_from_dot_data", "(", "string", ")", "if", "(", "dotG", ".", "get_type", "(", ")", "==", "\"graph\"", ")", ":", "G", "=", "graph", "(", ")", "elif", "(", "dotG", ".", "get_typ...
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
[ "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", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/readwrite/dot.py#L47-L104
246,227
nerdvegas/rez
src/rez/vendor/pygraph/readwrite/dot.py
read_hypergraph
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
def read_hypergraph(string): hgr = hypergraph() dotG = pydot.graph_from_dot_data(string) # Read the hypernode nodes... # Note 1: We need to assume that all of the nodes are listed since we need to know if they # are a hyperedge or a normal node # Note 2: We should read in all of t...
[ "def", "read_hypergraph", "(", "string", ")", ":", "hgr", "=", "hypergraph", "(", ")", "dotG", "=", "pydot", ".", "graph_from_dot_data", "(", "string", ")", "# Read the hypernode nodes...", "# Note 1: We need to assume that all of the nodes are listed since we need to know if...
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: Hypergraph
[ "Read", "a", "hypergraph", "from", "a", "string", "in", "dot", "format", ".", "Nodes", "and", "edges", "specified", "in", "the", "input", "will", "be", "added", "to", "the", "current", "hypergraph", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/readwrite/dot.py#L179-L213
246,228
nerdvegas/rez
src/rez/vendor/pydot/pydot.py
graph_from_dot_file
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
def graph_from_dot_file(path): fd = file(path, 'rb') data = fd.read() fd.close() return graph_from_dot_data(data)
[ "def", "graph_from_dot_file", "(", "path", ")", ":", "fd", "=", "file", "(", "path", ",", "'rb'", ")", "data", "=", "fd", ".", "read", "(", ")", "fd", ".", "close", "(", ")", "return", "graph_from_dot_data", "(", "data", ")" ]
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.
[ "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"...
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pydot/pydot.py#L220-L232
246,229
nerdvegas/rez
src/rez/vendor/pydot/pydot.py
__find_executables
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
def __find_executables(path): success = False progs = {'dot': '', 'twopi': '', 'neato': '', 'circo': '', 'fdp': '', 'sfdp': ''} was_quoted = False path = path.strip() if path.startswith('"') and path.endswith('"'): path = path[1:-1] was_quoted = True if os.path.isdir(p...
[ "def", "__find_executables", "(", "path", ")", ":", "success", "=", "False", "progs", "=", "{", "'dot'", ":", "''", ",", "'twopi'", ":", "''", ",", "'neato'", ":", "''", ",", "'circo'", ":", "''", ",", "'fdp'", ":", "''", ",", "'sfdp'", ":", "''", ...
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
[ "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",...
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pydot/pydot.py#L347-L398
246,230
nerdvegas/rez
src/rez/vendor/pydot/pydot.py
Edge.to_string
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
def to_string(self): 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_string() ] elif isinstance(src, (int, long)): edge = [ str(src) ] ...
[ "def", "to_string", "(", "self", ")", ":", "src", "=", "self", ".", "parse_node_ref", "(", "self", ".", "get_source", "(", ")", ")", "dst", "=", "self", ".", "parse_node_ref", "(", "self", ".", "get_destination", "(", ")", ")", "if", "isinstance", "(",...
Returns a string representation of the edge in dot language.
[ "Returns", "a", "string", "representation", "of", "the", "edge", "in", "dot", "language", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pydot/pydot.py#L974-L1019
246,231
nerdvegas/rez
src/rez/vendor/pydot/pydot.py
Graph.get_node
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
def get_node(self, name): match = list() if self.obj_dict['nodes'].has_key(name): match.extend( [ Node( obj_dict = obj_dict ) for obj_dict in self.obj_dict['nodes'][name] ]) return match
[ "def", "get_node", "(", "self", ",", "name", ")", ":", "match", "=", "list", "(", ")", "if", "self", ".", "obj_dict", "[", "'nodes'", "]", ".", "has_key", "(", "name", ")", ":", "match", ".", "extend", "(", "[", "Node", "(", "obj_dict", "=", "obj...
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.
[ "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", ...
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pydot/pydot.py#L1323-L1340
246,232
nerdvegas/rez
src/rez/vendor/pydot/pydot.py
Graph.add_edge
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
def add_edge(self, graph_edge): if not isinstance(graph_edge, Edge): raise TypeError('add_edge() received a non edge class object: ' + str(graph_edge)) edge_points = ( graph_edge.get_source(), graph_edge.get_destination() ) if self.obj_dict['edges'].has_key(edge_points): ...
[ "def", "add_edge", "(", "self", ",", "graph_edge", ")", ":", "if", "not", "isinstance", "(", "graph_edge", ",", "Edge", ")", ":", "raise", "TypeError", "(", "'add_edge() received a non edge class object: '", "+", "str", "(", "graph_edge", ")", ")", "edge_points"...
Adds an edge object to the graph. It takes a edge object as its only argument and returns None.
[ "Adds", "an", "edge", "object", "to", "the", "graph", ".", "It", "takes", "a", "edge", "object", "as", "its", "only", "argument", "and", "returns", "None", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pydot/pydot.py#L1365-L1389
246,233
nerdvegas/rez
src/rez/vendor/pydot/pydot.py
Graph.add_subgraph
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
def add_subgraph(self, sgraph): if not isinstance(sgraph, Subgraph) and not isinstance(sgraph, Cluster): raise TypeError('add_subgraph() received a non subgraph class object:' + str(sgraph)) if self.obj_dict['subgraphs'].has_key(sgraph.get_name()): sgraph_li...
[ "def", "add_subgraph", "(", "self", ",", "sgraph", ")", ":", "if", "not", "isinstance", "(", "sgraph", ",", "Subgraph", ")", "and", "not", "isinstance", "(", "sgraph", ",", "Cluster", ")", ":", "raise", "TypeError", "(", "'add_subgraph() received a non subgrap...
Adds an subgraph object to the graph. It takes a subgraph object as its only argument and returns None.
[ "Adds", "an", "subgraph", "object", "to", "the", "graph", ".", "It", "takes", "a", "subgraph", "object", "as", "its", "only", "argument", "and", "returns", "None", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pydot/pydot.py#L1488-L1508
246,234
nerdvegas/rez
src/rez/vendor/pydot/pydot.py
Graph.to_string
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
def to_string(self): graph = list() if self.obj_dict.get('strict', None) is not None: if self==self.get_parent_graph() and self.obj_dict['strict']: graph.append('strict ') if self.obj_dict['name'] == '': if 'show_keyword' in...
[ "def", "to_string", "(", "self", ")", ":", "graph", "=", "list", "(", ")", "if", "self", ".", "obj_dict", ".", "get", "(", "'strict'", ",", "None", ")", "is", "not", "None", ":", "if", "self", "==", "self", ".", "get_parent_graph", "(", ")", "and",...
Returns a string representation of the graph in dot language. It will return the graph and all its subelements in string from.
[ "Returns", "a", "string", "representation", "of", "the", "graph", "in", "dot", "language", ".", "It", "will", "return", "the", "graph", "and", "all", "its", "subelements", "in", "string", "from", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pydot/pydot.py#L1576-L1670
246,235
nerdvegas/rez
src/rez/vendor/pydot/pydot.py
Dot.create
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
def create(self, prog=None, format='ps'): if prog is None: prog = self.prog if isinstance(prog, (list, tuple)): prog, args = prog[0], prog[1:] else: args = [] if self.progs is None: self.progs = find_graphviz() ...
[ "def", "create", "(", "self", ",", "prog", "=", "None", ",", "format", "=", "'ps'", ")", ":", "if", "prog", "is", "None", ":", "prog", "=", "self", ".", "prog", "if", "isinstance", "(", "prog", ",", "(", "list", ",", "tuple", ")", ")", ":", "pr...
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 string is the operation is successful. ...
[ "Creates", "and", "returns", "a", "Postscript", "representation", "of", "the", "graph", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pydot/pydot.py#L1915-L2034
246,236
nerdvegas/rez
src/rez/utils/yaml.py
dump_yaml
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
def dump_yaml(data, Dumper=_Dumper, default_flow_style=False): content = yaml.dump(data, default_flow_style=default_flow_style, Dumper=Dumper) return content.strip()
[ "def", "dump_yaml", "(", "data", ",", "Dumper", "=", "_Dumper", ",", "default_flow_style", "=", "False", ")", ":", "content", "=", "yaml", ".", "dump", "(", "data", ",", "default_flow_style", "=", "default_flow_style", ",", "Dumper", "=", "Dumper", ")", "r...
Returns data as yaml-formatted string.
[ "Returns", "data", "as", "yaml", "-", "formatted", "string", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/yaml.py#L64-L69
246,237
nerdvegas/rez
src/rez/utils/yaml.py
load_yaml
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
def load_yaml(filepath): with open(filepath) as f: txt = f.read() return yaml.load(txt)
[ "def", "load_yaml", "(", "filepath", ")", ":", "with", "open", "(", "filepath", ")", "as", "f", ":", "txt", "=", "f", ".", "read", "(", ")", "return", "yaml", ".", "load", "(", "txt", ")" ]
Convenience function for loading yaml-encoded data from disk.
[ "Convenience", "function", "for", "loading", "yaml", "-", "encoded", "data", "from", "disk", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/yaml.py#L72-L76
246,238
nerdvegas/rez
src/rez/utils/memcached.py
memcached_client
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
def memcached_client(servers=config.memcached_uri, debug=config.debug_memcache): key = None try: client, key = scoped_instance_manager.acquire(servers, debug=debug) yield client finally: if key: scoped_instance_manager.release(key)
[ "def", "memcached_client", "(", "servers", "=", "config", ".", "memcached_uri", ",", "debug", "=", "config", ".", "debug_memcache", ")", ":", "key", "=", "None", "try", ":", "client", ",", "key", "=", "scoped_instance_manager", ".", "acquire", "(", "servers"...
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 reconnections are avoided. Typically an initial scope (using 'with' construct) is made...
[ "Get", "a", "shared", "memcached", "instance", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/memcached.py#L207-L226
246,239
nerdvegas/rez
src/rez/utils/memcached.py
pool_memcached_connections
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
def pool_memcached_connections(func): if isgeneratorfunction(func): def wrapper(*nargs, **kwargs): with memcached_client(): for result in func(*nargs, **kwargs): yield result else: def wrapper(*nargs, **kwargs): with memcached_client():...
[ "def", "pool_memcached_connections", "(", "func", ")", ":", "if", "isgeneratorfunction", "(", "func", ")", ":", "def", "wrapper", "(", "*", "nargs", ",", "*", "*", "kwargs", ")", ":", "with", "memcached_client", "(", ")", ":", "for", "result", "in", "fun...
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.
[ "Function", "decorator", "to", "pool", "memcached", "connections", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/memcached.py#L229-L245
246,240
nerdvegas/rez
src/rez/utils/memcached.py
memcached
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
def memcached(servers, key=None, from_cache=None, to_cache=None, time=0, min_compress_len=0, debug=False): def default_key(func, *nargs, **kwargs): parts = [func.__module__] argnames = getargspec(func).args if argnames: if argnames[0] == "cls": cls_...
[ "def", "memcached", "(", "servers", ",", "key", "=", "None", ",", "from_cache", "=", "None", ",", "to_cache", "=", "None", ",", "time", "=", "0", ",", "min_compress_len", "=", "0", ",", "debug", "=", "False", ")", ":", "def", "default_key", "(", "fun...
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 event of a cache hit, the data is translated by `from_cache` if provided, before being returned. If you do not want a res...
[ "memcached", "memoization", "function", "decorator", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/memcached.py#L248-L375
246,241
nerdvegas/rez
src/rez/utils/memcached.py
Client.client
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
def client(self): if self._client is None: self._client = Client_(self.servers) return self._client
[ "def", "client", "(", "self", ")", ":", "if", "self", ".", "_client", "is", "None", ":", "self", ".", "_client", "=", "Client_", "(", "self", ".", "servers", ")", "return", "self", ".", "_client" ]
Get the native memcache client. Returns: `memcache.Client` instance.
[ "Get", "the", "native", "memcache", "client", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/memcached.py#L48-L56
246,242
nerdvegas/rez
src/rez/utils/memcached.py
Client.flush
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
def flush(self, hard=False): if not self.servers: return if hard: self.client.flush_all() self.reset_stats() else: from uuid import uuid4 tag = uuid4().hex if self.debug: tag = "flushed" + tag sel...
[ "def", "flush", "(", "self", ",", "hard", "=", "False", ")", ":", "if", "not", "self", ".", "servers", ":", "return", "if", "hard", ":", "self", ".", "client", ".", "flush_all", "(", ")", "self", ".", "reset_stats", "(", ")", "else", ":", "from", ...
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.
[ "Drop", "existing", "entries", "from", "the", "cache", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/memcached.py#L119-L137
246,243
nerdvegas/rez
src/rez/vendor/pygraph/algorithms/searching.py
depth_first_search
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
def depth_first_search(graph, root=None, filter=null()): recursionlimit = getrecursionlimit() setrecursionlimit(max(len(graph.nodes())*2,recursionlimit)) def dfs(node): """ Depth-first search subfunction. """ visited[node] = 1 pre.append(node) # Explore recur...
[ "def", "depth_first_search", "(", "graph", ",", "root", "=", "None", ",", "filter", "=", "null", "(", ")", ")", ":", "recursionlimit", "=", "getrecursionlimit", "(", ")", "setrecursionlimit", "(", "max", "(", "len", "(", "graph", ".", "nodes", "(", ")", ...
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 dictionary and two lists: 1. Generated spanning tree 2. Grap...
[ "Depth", "-", "first", "search", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/algorithms/searching.py#L39-L96
246,244
nerdvegas/rez
src/rez/vendor/pygraph/algorithms/searching.py
breadth_first_search
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
def breadth_first_search(graph, root=None, filter=null()): def bfs(): """ Breadth-first search subfunction. """ while (queue != []): node = queue.pop(0) for other in graph[node]: if (other not in spanning_tree and filter(other, nod...
[ "def", "breadth_first_search", "(", "graph", ",", "root", "=", "None", ",", "filter", "=", "null", "(", ")", ")", ":", "def", "bfs", "(", ")", ":", "\"\"\"\n Breadth-first search subfunction.\n \"\"\"", "while", "(", "queue", "!=", "[", "]", ")",...
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 dictionary and a list. 1. Generated spanning tree 2. Graph's le...
[ "Breadth", "-", "first", "search", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/algorithms/searching.py#L101-L153
246,245
nerdvegas/rez
src/rez/package_resources_.py
PackageResource.normalize_variables
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
def normalize_variables(cls, variables): # 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(PackageResource, cls).normalize_variables(variables)
[ "def", "normalize_variables", "(", "cls", ",", "variables", ")", ":", "# if the version is False, empty string, etc, throw it out", "if", "variables", ".", "get", "(", "'version'", ",", "True", ")", "in", "(", "''", ",", "False", ",", "'_NO_VERSION'", ",", "None",...
Make sure version is treated consistently
[ "Make", "sure", "version", "is", "treated", "consistently" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_resources_.py#L300-L306
246,246
nerdvegas/rez
src/rez/vendor/argcomplete/my_shlex.py
shlex.push_source
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
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 ...
[ "def", "push_source", "(", "self", ",", "newstream", ",", "newfile", "=", "None", ")", ":", "if", "isinstance", "(", "newstream", ",", "basestring", ")", ":", "newstream", "=", "StringIO", "(", "newstream", ")", "self", ".", "filestack", ".", "appendleft",...
Push an input source onto the lexer's input source stack.
[ "Push", "an", "input", "source", "onto", "the", "lexer", "s", "input", "source", "stack", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/argcomplete/my_shlex.py#L100-L107
246,247
nerdvegas/rez
src/rez/vendor/argcomplete/my_shlex.py
shlex.error_leader
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
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)
[ "def", "error_leader", "(", "self", ",", "infile", "=", "None", ",", "lineno", "=", "None", ")", ":", "if", "infile", "is", "None", ":", "infile", "=", "self", ".", "infile", "if", "lineno", "is", "None", ":", "lineno", "=", "self", ".", "lineno", ...
Emit a C-compiler-like, Emacs-friendly error-message leader.
[ "Emit", "a", "C", "-", "compiler", "-", "like", "Emacs", "-", "friendly", "error", "-", "message", "leader", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/argcomplete/my_shlex.py#L278-L284
246,248
nerdvegas/rez
src/rez/system.py
System.rez_bin_path
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
def rez_bin_path(self): binpath = None if sys.argv and sys.argv[0]: executable = sys.argv[0] path = which("rezolve", env={"PATH":os.path.dirname(executable), "PATHEXT":os.environ.get("PATHEXT", ...
[ "def", "rez_bin_path", "(", "self", ")", ":", "binpath", "=", "None", "if", "sys", ".", "argv", "and", "sys", ".", "argv", "[", "0", "]", ":", "executable", "=", "sys", ".", "argv", "[", "0", "]", "path", "=", "which", "(", "\"rezolve\"", ",", "e...
Get path containing rez binaries, or None if no binaries are available, or Rez is not a production install.
[ "Get", "path", "containing", "rez", "binaries", "or", "None", "if", "no", "binaries", "are", "available", "or", "Rez", "is", "not", "a", "production", "install", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/system.py#L191-L214
246,249
nerdvegas/rez
src/rez/system.py
System.get_summary_string
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
def get_summary_string(self): from rez.plugin_managers import plugin_manager txt = "Rez %s" % __version__ txt += "\n\n%s" % plugin_manager.get_summary_string() return txt
[ "def", "get_summary_string", "(", "self", ")", ":", "from", "rez", ".", "plugin_managers", "import", "plugin_manager", "txt", "=", "\"Rez %s\"", "%", "__version__", "txt", "+=", "\"\\n\\n%s\"", "%", "plugin_manager", ".", "get_summary_string", "(", ")", "return", ...
Get a string summarising the state of Rez as a whole. Returns: String.
[ "Get", "a", "string", "summarising", "the", "state", "of", "Rez", "as", "a", "whole", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/system.py#L221-L231
246,250
nerdvegas/rez
src/rez/system.py
System.clear_caches
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
def clear_caches(self, hard=False): from rez.package_repository import package_repository_manager from rez.utils.memcached import memcached_client package_repository_manager.clear_caches() if hard: with memcached_client() as client: client.flush()
[ "def", "clear_caches", "(", "self", ",", "hard", "=", "False", ")", ":", "from", "rez", ".", "package_repository", "import", "package_repository_manager", "from", "rez", ".", "utils", ".", "memcached", "import", "memcached_client", "package_repository_manager", ".",...
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 visible. Args: hard (bool): Perf...
[ "Clear", "all", "caches", "in", "Rez", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/system.py#L233-L252
246,251
nerdvegas/rez
src/rez/resolver.py
Resolver.solve
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
def solve(self): 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.from_cache = False solver = self....
[ "def", "solve", "(", "self", ")", ":", "with", "log_duration", "(", "self", ".", "_print", ",", "\"memcache get (resolve) took %s\"", ")", ":", "solver_dict", "=", "self", ".", "_get_cached_solve", "(", ")", "if", "solver_dict", ":", "self", ".", "from_cache",...
Perform the solve.
[ "Perform", "the", "solve", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/resolver.py#L107-L123
246,252
nerdvegas/rez
src/rez/resolver.py
Resolver._set_cached_solve
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
def _set_cached_solve(self, solver_dict): if self.status_ != ResolverStatus.solved: return # don't cache failed solves if not (self.caching and self.memcached_servers): return # most recent release times get stored with solve result in the cache releases_since_...
[ "def", "_set_cached_solve", "(", "self", ",", "solver_dict", ")", ":", "if", "self", ".", "status_", "!=", "ResolverStatus", ".", "solved", ":", "return", "# don't cache failed solves", "if", "not", "(", "self", ".", "caching", "and", "self", ".", "memcached_s...
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, - then store the solve to a non-times...
[ "Store", "a", "solve", "to", "memcached", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/resolver.py#L310-L356
246,253
nerdvegas/rez
src/rez/resolver.py
Resolver._memcache_key
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
def _memcache_key(self, timestamped=False): 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.uid) t = ["resolve", request, ...
[ "def", "_memcache_key", "(", "self", ",", "timestamped", "=", "False", ")", ":", "request", "=", "tuple", "(", "map", "(", "str", ",", "self", ".", "package_requests", ")", ")", "repo_ids", "=", "[", "]", "for", "path", "in", "self", ".", "package_path...
Makes a key suitable as a memcache entry.
[ "Makes", "a", "key", "suitable", "as", "a", "memcache", "entry", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/resolver.py#L358-L377
246,254
nerdvegas/rez
src/rez/shells.py
create_shell
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
def create_shell(shell=None, **kwargs): if not shell: shell = config.default_shell if not shell: from rez.system import system shell = system.shell from rez.plugin_managers import plugin_manager return plugin_manager.create_instance('shell', shell, **kwargs)
[ "def", "create_shell", "(", "shell", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "shell", ":", "shell", "=", "config", ".", "default_shell", "if", "not", "shell", ":", "from", "rez", ".", "system", "import", "system", "shell", "=", "...
Returns a Shell of the given type, or the current shell type if shell is None.
[ "Returns", "a", "Shell", "of", "the", "given", "type", "or", "the", "current", "shell", "type", "if", "shell", "is", "None", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/shells.py#L25-L35
246,255
nerdvegas/rez
src/rez/shells.py
Shell.startup_capabilities
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
def startup_capabilities(cls, rcfile=False, norc=False, stdin=False, command=False): raise NotImplementedError
[ "def", "startup_capabilities", "(", "cls", ",", "rcfile", "=", "False", ",", "norc", "=", "False", ",", "stdin", "=", "False", ",", "command", "=", "False", ")", ":", "raise", "NotImplementedError" ]
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.
[ "Given", "a", "set", "of", "options", "related", "to", "shell", "startup", "return", "the", "actual", "options", "that", "will", "be", "applied", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/shells.py#L54-L61
246,256
nerdvegas/rez
src/rez/vendor/distlib/index.py
PackageIndex.upload_file
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
def upload_file(self, metadata, filename, signer=None, sign_password=None, filetype='sdist', pyversion='source', keystore=None): self.check_credentials() if not os.path.exists(filename): raise DistlibException('not found: %s' % filename) metadata.validate() ...
[ "def", "upload_file", "(", "self", ",", "metadata", ",", "filename", ",", "signer", "=", "None", ",", "sign_password", "=", "None", ",", "filetype", "=", "'sdist'", ",", "pyversion", "=", "'source'", ",", "keystore", "=", "None", ")", ":", "self", ".", ...
Upload a release file to the index. :param metadata: A :class:`Metadata` instance defining at least a name and version number for the file to be uploaded. :param filename: The pathname of the file to be uploaded. :param signer: The identifier of the signer of the file. ...
[ "Upload", "a", "release", "file", "to", "the", "index", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/distlib/index.py#L238-L293
246,257
nerdvegas/rez
src/rez/solver.py
_get_dependency_order
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
def _get_dependency_order(g, node_list): access_ = accessibility(g) deps = dict((k, set(v) - set([k])) for k, v in access_.iteritems()) nodes = node_list + list(set(g.nodes()) - set(node_list)) ordered_nodes = [] while nodes: n_ = nodes[0] n_deps = deps.get(n_) if (n_ in ord...
[ "def", "_get_dependency_order", "(", "g", ",", "node_list", ")", ":", "access_", "=", "accessibility", "(", "g", ")", "deps", "=", "dict", "(", "(", "k", ",", "set", "(", "v", ")", "-", "set", "(", "[", "k", "]", ")", ")", "for", "k", ",", "v",...
Return list of nodes as close as possible to the ordering in node_list, but with child nodes earlier in the list than parents.
[ "Return", "list", "of", "nodes", "as", "close", "as", "possible", "to", "the", "ordering", "in", "node_list", "but", "with", "child", "nodes", "earlier", "in", "the", "list", "than", "parents", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1110-L1136
246,258
nerdvegas/rez
src/rez/solver.py
_short_req_str
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
def _short_req_str(package_request): if not package_request.conflict: versions = package_request.range.to_versions() if versions and len(versions) == len(package_request.range) \ and len(versions) > 1: return "%s-%s(%d)" % (package_request.name, ...
[ "def", "_short_req_str", "(", "package_request", ")", ":", "if", "not", "package_request", ".", "conflict", ":", "versions", "=", "package_request", ".", "range", ".", "to_versions", "(", ")", "if", "versions", "and", "len", "(", "versions", ")", "==", "len"...
print shortened version of '==X|==Y|==Z' ranged requests.
[ "print", "shortened", "version", "of", "==", "X|", "==", "Y|", "==", "Z", "ranged", "requests", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L2275-L2284
246,259
nerdvegas/rez
src/rez/solver.py
PackageVariant.requires_list
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
def requires_list(self): requires = self.variant.get_requires(build_requires=self.building) reqlist = RequirementList(requires) if reqlist.conflict: raise ResolveError( "The package %s has an internal requirements conflict: %s" % (str(self), str(reqli...
[ "def", "requires_list", "(", "self", ")", ":", "requires", "=", "self", ".", "variant", ".", "get_requires", "(", "build_requires", "=", "self", ".", "building", ")", "reqlist", "=", "RequirementList", "(", "requires", ")", "if", "reqlist", ".", "conflict", ...
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.
[ "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", "b...
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L299-L313
246,260
nerdvegas/rez
src/rez/solver.py
_PackageEntry.sort
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
def sort(self): if self.sorted: return def key(variant): requested_key = [] names = set() for i, request in enumerate(self.solver.request_list): if not request.conflict: req = variant.requires_list.get(request.name) ...
[ "def", "sort", "(", "self", ")", ":", "if", "self", ".", "sorted", ":", "return", "def", "key", "(", "variant", ")", ":", "requested_key", "=", "[", "]", "names", "=", "set", "(", ")", "for", "i", ",", "request", "in", "enumerate", "(", "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; - THEN alphabetical...
[ "Sort", "variants", "from", "most", "correct", "to", "consume", "to", "least", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L370-L427
246,261
nerdvegas/rez
src/rez/solver.py
_PackageVariantList.get_intersection
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
def get_intersection(self, range_): result = [] for entry in self.entries: package, value = entry if value is None: continue # package was blocked by package filters if package.version not in range_: continue if isinsta...
[ "def", "get_intersection", "(", "self", ",", "range_", ")", ":", "result", "=", "[", "]", "for", "entry", "in", "self", ".", "entries", ":", "package", ",", "value", "=", "entry", "if", "value", "is", "None", ":", "continue", "# package was blocked by pack...
Get a list of variants that intersect with the given range. Args: range_ (`VersionRange`): Package version range. Returns: List of `_PackageEntry` objects.
[ "Get", "a", "list", "of", "variants", "that", "intersect", "with", "the", "given", "range", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L453-L502
246,262
nerdvegas/rez
src/rez/solver.py
_PackageVariantSlice.intersect
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
def intersect(self, range_): self.solver.intersection_broad_tests_count += 1 if range_.is_any(): return self if self.solver.optimised: if range_ in self.been_intersected_with: return self if self.pr: self.pr.passive("intersecting %s ...
[ "def", "intersect", "(", "self", ",", "range_", ")", ":", "self", ".", "solver", ".", "intersection_broad_tests_count", "+=", "1", "if", "range_", ".", "is_any", "(", ")", ":", "return", "self", "if", "self", ".", "solver", ".", "optimised", ":", "if", ...
Remove variants whose version fall outside of the given range.
[ "Remove", "variants", "whose", "version", "fall", "outside", "of", "the", "given", "range", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L594-L622
246,263
nerdvegas/rez
src/rez/solver.py
_PackageVariantSlice.reduce_by
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
def reduce_by(self, package_request): if self.pr: reqstr = _short_req_str(package_request) self.pr.passive("reducing %s wrt %s...", self, reqstr) if self.solver.optimised: if package_request in self.been_reduced_by: return (self, []) if (pack...
[ "def", "reduce_by", "(", "self", ",", "package_request", ")", ":", "if", "self", ".", "pr", ":", "reqstr", "=", "_short_req_str", "(", "package_request", ")", "self", ".", "pr", ".", "passive", "(", "\"reducing %s wrt %s...\"", ",", "self", ",", "reqstr", ...
Remove variants whos dependencies conflict with the given package request. Returns: (VariantSlice, [Reduction]) tuple, where slice may be None if all variants were reduced.
[ "Remove", "variants", "whos", "dependencies", "conflict", "with", "the", "given", "package", "request", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L624-L645
246,264
nerdvegas/rez
src/rez/solver.py
_PackageVariantSlice.split
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
def split(self): # We sort here in the split in order to sort as late as possible. # Because splits usually happen after intersections/reductions, this # means there can be less entries to sort. # self.sort_versions() def _split(i_entry, n_variants, common_fams=None): ...
[ "def", "split", "(", "self", ")", ":", "# We sort here in the split in order to sort as late as possible.", "# Because splits usually happen after intersections/reductions, this", "# means there can be less entries to sort.", "#", "self", ".", "sort_versions", "(", ")", "def", "_spli...
Split the slice. Returns: (`_PackageVariantSlice`, `_PackageVariantSlice`) tuple, where the first is the preferred slice.
[ "Split", "the", "slice", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L730-L801
246,265
nerdvegas/rez
src/rez/solver.py
_PackageVariantSlice.sort_versions
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
def sort_versions(self): if self.sorted: return for orderer in (self.solver.package_orderers or []): entries = orderer.reorder(self.entries, key=lambda x: x.package) if entries is not None: self.entries = entries self.sorted = True ...
[ "def", "sort_versions", "(", "self", ")", ":", "if", "self", ".", "sorted", ":", "return", "for", "orderer", "in", "(", "self", ".", "solver", ".", "package_orderers", "or", "[", "]", ")", ":", "entries", "=", "orderer", ".", "reorder", "(", "self", ...
Sort entries by version. The order is typically descending, but package order functions can change this.
[ "Sort", "entries", "by", "version", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L803-L827
246,266
nerdvegas/rez
src/rez/solver.py
PackageVariantCache.get_variant_slice
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
def get_variant_slice(self, package_name, range_): variant_list = self.variant_lists.get(package_name) if variant_list is None: variant_list = _PackageVariantList(package_name, self.solver) self.variant_lists[package_name] = variant_list entries = variant_list.get_inter...
[ "def", "get_variant_slice", "(", "self", ",", "package_name", ",", "range_", ")", ":", "variant_list", "=", "self", ".", "variant_lists", ".", "get", "(", "package_name", ")", "if", "variant_list", "is", "None", ":", "variant_list", "=", "_PackageVariantList", ...
Get a list of variants from the cache. Args: package_name (str): Name of package. range_ (`VersionRange`): Package version range. Returns: `_PackageVariantSlice` object.
[ "Get", "a", "list", "of", "variants", "from", "the", "cache", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L902-L925
246,267
nerdvegas/rez
src/rez/solver.py
_PackageScope.intersect
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
def intersect(self, range_): new_slice = None if self.package_request.conflict: if self.package_request.range is None: new_slice = self.solver._get_variant_slice( self.package_name, range_) else: new_range = range_ - self.packa...
[ "def", "intersect", "(", "self", ",", "range_", ")", ":", "new_slice", "=", "None", "if", "self", ".", "package_request", ".", "conflict", ":", "if", "self", ".", "package_request", ".", "range", "is", "None", ":", "new_slice", "=", "self", ".", "solver"...
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 returned.
[ "Intersect", "this", "scope", "with", "a", "package", "range", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L956-L994
246,268
nerdvegas/rez
src/rez/solver.py
_PackageScope.reduce_by
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
def reduce_by(self, package_request): self.solver.reduction_broad_tests_count += 1 if self.package_request.conflict: # conflict scopes don't reduce. Instead, other scopes will be # reduced against a conflict scope. return (self, []) # perform the reduction ...
[ "def", "reduce_by", "(", "self", ",", "package_request", ")", ":", "self", ".", "solver", ".", "reduction_broad_tests_count", "+=", "1", "if", "self", ".", "package_request", ".", "conflict", ":", "# conflict scopes don't reduce. Instead, other scopes will be", "# reduc...
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 reduced.
[ "Reduce", "this", "scope", "wrt", "a", "package", "request", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L996-L1037
246,269
nerdvegas/rez
src/rez/solver.py
_PackageScope.split
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
def split(self): if self.package_request.conflict or (len(self.variant_slice) == 1): return None else: r = self.variant_slice.split() if r is None: return None else: slice, next_slice = r scope = self._copy(s...
[ "def", "split", "(", "self", ")", ":", "if", "self", ".", "package_request", ".", "conflict", "or", "(", "len", "(", "self", ".", "variant_slice", ")", "==", "1", ")", ":", "return", "None", "else", ":", "r", "=", "self", ".", "variant_slice", ".", ...
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.
[ "Split", "the", "scope", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1059-L1077
246,270
nerdvegas/rez
src/rez/solver.py
_ResolvePhase.finalise
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
def finalise(self): assert(self._is_solved()) g = self._get_minimal_graph() scopes = dict((x.package_name, x) for x in self.scopes if not x.package_request.conflict) # check for cyclic dependencies fam_cycle = find_cycle(g) if fam_cycle: ...
[ "def", "finalise", "(", "self", ")", ":", "assert", "(", "self", ".", "_is_solved", "(", ")", ")", "g", "=", "self", ".", "_get_minimal_graph", "(", ")", "scopes", "=", "dict", "(", "(", "x", ".", "package_name", ",", "x", ")", "for", "x", "in", ...
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 detected, a new phase mar...
[ "Remove", "conflict", "requests", "detect", "cyclic", "dependencies", "and", "reorder", "packages", "wrt", "dependency", "and", "then", "request", "order", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1368-L1410
246,271
nerdvegas/rez
src/rez/solver.py
_ResolvePhase.split
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
def split(self): assert(self.status == SolverStatus.exhausted) scopes = [] next_scopes = [] split_i = None for i, scope in enumerate(self.scopes): if split_i is None: r = scope.split() if r is not None: scope_, nex...
[ "def", "split", "(", "self", ")", ":", "assert", "(", "self", ".", "status", "==", "SolverStatus", ".", "exhausted", ")", "scopes", "=", "[", "]", "next_scopes", "=", "[", "]", "split_i", "=", "None", "for", "i", ",", "scope", "in", "enumerate", "(",...
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 the scope into two: [:N] and...
[ "Split", "the", "phase", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1412-L1466
246,272
nerdvegas/rez
src/rez/solver.py
Solver.status
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
def status(self): if self.request_list.conflict: return SolverStatus.failed if self.callback_return == SolverCallbackReturn.fail: # the solve has failed because a callback has nominated the most # recent failure as the reason. return SolverStatus.failed ...
[ "def", "status", "(", "self", ")", ":", "if", "self", ".", "request_list", ".", "conflict", ":", "return", "SolverStatus", ".", "failed", "if", "self", ".", "callback_return", "==", "SolverCallbackReturn", ".", "fail", ":", "# the solve has failed because a callba...
Return the current status of the solve. Returns: SolverStatus: Enum representation of the state of the solver.
[ "Return", "the", "current", "status", "of", "the", "solve", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1881-L1906
246,273
nerdvegas/rez
src/rez/solver.py
Solver.num_fails
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
def num_fails(self): n = len(self.failed_phase_list) if self.phase_stack[-1].status in (SolverStatus.failed, SolverStatus.cyclic): n += 1 return n
[ "def", "num_fails", "(", "self", ")", ":", "n", "=", "len", "(", "self", ".", "failed_phase_list", ")", "if", "self", ".", "phase_stack", "[", "-", "1", "]", ".", "status", "in", "(", "SolverStatus", ".", "failed", ",", "SolverStatus", ".", "cyclic", ...
Return the number of failed solve steps that have been executed. Note that num_solves is inclusive of failures.
[ "Return", "the", "number", "of", "failed", "solve", "steps", "that", "have", "been", "executed", ".", "Note", "that", "num_solves", "is", "inclusive", "of", "failures", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1914-L1920
246,274
nerdvegas/rez
src/rez/solver.py
Solver.resolved_packages
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
def resolved_packages(self): if (self.status != SolverStatus.solved): return None final_phase = self.phase_stack[-1] return final_phase._get_solved_variants()
[ "def", "resolved_packages", "(", "self", ")", ":", "if", "(", "self", ".", "status", "!=", "SolverStatus", ".", "solved", ")", ":", "return", "None", "final_phase", "=", "self", ".", "phase_stack", "[", "-", "1", "]", "return", "final_phase", ".", "_get_...
Return a list of PackageVariant objects, or None if the resolve did not complete or was unsuccessful.
[ "Return", "a", "list", "of", "PackageVariant", "objects", "or", "None", "if", "the", "resolve", "did", "not", "complete", "or", "was", "unsuccessful", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1928-L1936
246,275
nerdvegas/rez
src/rez/solver.py
Solver.reset
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
def reset(self): if not self.request_list.conflict: phase = _ResolvePhase(self.request_list.requirements, solver=self) self.pr("resetting...") self._init() self._push_phase(phase)
[ "def", "reset", "(", "self", ")", ":", "if", "not", "self", ".", "request_list", ".", "conflict", ":", "phase", "=", "_ResolvePhase", "(", "self", ".", "request_list", ".", "requirements", ",", "solver", "=", "self", ")", "self", ".", "pr", "(", "\"res...
Reset the solver, removing any current solve.
[ "Reset", "the", "solver", "removing", "any", "current", "solve", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1938-L1944
246,276
nerdvegas/rez
src/rez/solver.py
Solver.solve
def solve(self): """Attempt to solve the request. """ if self.solve_begun: raise ResolveError("cannot run solve() on a solve that has " "already been started") t1 = time.time() pt1 = package_repo_stats.package_load_time # itera...
python
def solve(self): if self.solve_begun: raise ResolveError("cannot run solve() on a solve that has " "already been started") t1 = time.time() pt1 = package_repo_stats.package_load_time # iteratively solve phases while self.status == Solv...
[ "def", "solve", "(", "self", ")", ":", "if", "self", ".", "solve_begun", ":", "raise", "ResolveError", "(", "\"cannot run solve() on a solve that has \"", "\"already been started\"", ")", "t1", "=", "time", ".", "time", "(", ")", "pt1", "=", "package_repo_stats", ...
Attempt to solve the request.
[ "Attempt", "to", "solve", "the", "request", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1946-L1974
246,277
nerdvegas/rez
src/rez/solver.py
Solver.solve_step
def solve_step(self): """Perform a single solve step. """ self.solve_begun = True if self.status != SolverStatus.unsolved: return if self.pr: self.pr.header("SOLVE #%d (%d fails so far)...", self.solve_count + 1, self.num_fails)...
python
def solve_step(self): self.solve_begun = True if self.status != SolverStatus.unsolved: return if self.pr: self.pr.header("SOLVE #%d (%d fails so far)...", self.solve_count + 1, self.num_fails) phase = self._pop_phase() if phas...
[ "def", "solve_step", "(", "self", ")", ":", "self", ".", "solve_begun", "=", "True", "if", "self", ".", "status", "!=", "SolverStatus", ".", "unsolved", ":", "return", "if", "self", ".", "pr", ":", "self", ".", "pr", ".", "header", "(", "\"SOLVE #%d (%...
Perform a single solve step.
[ "Perform", "a", "single", "solve", "step", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L2013-L2062
246,278
nerdvegas/rez
src/rez/solver.py
Solver.failure_reason
def failure_reason(self, failure_index=None): """Get the reason for a failure. Args: failure_index: Index of the fail to return the graph for (can be negative). If None, the most appropriate failure is chosen according to these rules: - If the...
python
def failure_reason(self, failure_index=None): phase, _ = self._get_failed_phase(failure_index) return phase.failure_reason
[ "def", "failure_reason", "(", "self", ",", "failure_index", "=", "None", ")", ":", "phase", ",", "_", "=", "self", ".", "_get_failed_phase", "(", "failure_index", ")", "return", "phase", ".", "failure_reason" ]
Get the reason for a failure. Args: failure_index: Index of the fail to return the graph for (can be negative). If None, the most appropriate failure is chosen according to these rules: - If the fail is cyclic, the most recent fail (the one containing...
[ "Get", "the", "reason", "for", "a", "failure", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L2064-L2080
246,279
nerdvegas/rez
src/rez/solver.py
Solver.failure_packages
def failure_packages(self, failure_index=None): """Get packages involved in a failure. Args: failure_index: See `failure_reason`. Returns: A list of Requirement objects. """ phase, _ = self._get_failed_phase(failure_index) fr = phase.failure_reas...
python
def failure_packages(self, failure_index=None): phase, _ = self._get_failed_phase(failure_index) fr = phase.failure_reason return fr.involved_requirements() if fr else None
[ "def", "failure_packages", "(", "self", ",", "failure_index", "=", "None", ")", ":", "phase", ",", "_", "=", "self", ".", "_get_failed_phase", "(", "failure_index", ")", "fr", "=", "phase", ".", "failure_reason", "return", "fr", ".", "involved_requirements", ...
Get packages involved in a failure. Args: failure_index: See `failure_reason`. Returns: A list of Requirement objects.
[ "Get", "packages", "involved", "in", "a", "failure", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L2092-L2103
246,280
nerdvegas/rez
src/rez/solver.py
Solver.get_graph
def get_graph(self): """Returns the most recent solve graph. This gives a graph showing the latest state of the solve. The specific graph returned depends on the solve status. When status is: unsolved: latest unsolved graph is returned; solved: final solved graph is returned; ...
python
def get_graph(self): st = self.status if st in (SolverStatus.solved, SolverStatus.unsolved): phase = self._latest_nonfailed_phase() return phase.get_graph() else: return self.get_fail_graph()
[ "def", "get_graph", "(", "self", ")", ":", "st", "=", "self", ".", "status", "if", "st", "in", "(", "SolverStatus", ".", "solved", ",", "SolverStatus", ".", "unsolved", ")", ":", "phase", "=", "self", ".", "_latest_nonfailed_phase", "(", ")", "return", ...
Returns the most recent solve graph. This gives a graph showing the latest state of the solve. The specific graph returned depends on the solve status. When status is: unsolved: latest unsolved graph is returned; solved: final solved graph is returned; failed: most appropria...
[ "Returns", "the", "most", "recent", "solve", "graph", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L2105-L2123
246,281
nerdvegas/rez
src/rez/solver.py
Solver.get_fail_graph
def get_fail_graph(self, failure_index=None): """Returns a graph showing a solve failure. Args: failure_index: See `failure_reason` Returns: A pygraph.digraph object. """ phase, _ = self._get_failed_phase(failure_index) return phase.get_graph()
python
def get_fail_graph(self, failure_index=None): phase, _ = self._get_failed_phase(failure_index) return phase.get_graph()
[ "def", "get_fail_graph", "(", "self", ",", "failure_index", "=", "None", ")", ":", "phase", ",", "_", "=", "self", ".", "_get_failed_phase", "(", "failure_index", ")", "return", "phase", ".", "get_graph", "(", ")" ]
Returns a graph showing a solve failure. Args: failure_index: See `failure_reason` Returns: A pygraph.digraph object.
[ "Returns", "a", "graph", "showing", "a", "solve", "failure", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L2125-L2135
246,282
nerdvegas/rez
src/rez/solver.py
Solver.dump
def dump(self): """Print a formatted summary of the current solve state.""" from rez.utils.formatting import columnise rows = [] for i, phase in enumerate(self.phase_stack): rows.append((self._depth_label(i), phase.status, str(phase))) print "status: %s (%s)" % (sel...
python
def dump(self): from rez.utils.formatting import columnise rows = [] for i, phase in enumerate(self.phase_stack): rows.append((self._depth_label(i), phase.status, str(phase))) print "status: %s (%s)" % (self.status.name, self.status.description) print "initial reque...
[ "def", "dump", "(", "self", ")", ":", "from", "rez", ".", "utils", ".", "formatting", "import", "columnise", "rows", "=", "[", "]", "for", "i", ",", "phase", "in", "enumerate", "(", "self", ".", "phase_stack", ")", ":", "rows", ".", "append", "(", ...
Print a formatted summary of the current solve state.
[ "Print", "a", "formatted", "summary", "of", "the", "current", "solve", "state", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L2137-L2157
246,283
nerdvegas/rez
src/rez/utils/filesystem.py
make_path_writable
def make_path_writable(path): """Temporarily make `path` writable, if possible. Does nothing if: - config setting 'make_package_temporarily_writable' is False; - this can't be done (eg we don't own `path`). Args: path (str): Path to make temporarily writable """ from rez.co...
python
def make_path_writable(path): from rez.config import config try: orig_mode = os.stat(path).st_mode new_mode = orig_mode if config.make_package_temporarily_writable and \ not os.access(path, os.W_OK): new_mode = orig_mode | stat.S_IWUSR # make writab...
[ "def", "make_path_writable", "(", "path", ")", ":", "from", "rez", ".", "config", "import", "config", "try", ":", "orig_mode", "=", "os", ".", "stat", "(", "path", ")", ".", "st_mode", "new_mode", "=", "orig_mode", "if", "config", ".", "make_package_tempor...
Temporarily make `path` writable, if possible. Does nothing if: - config setting 'make_package_temporarily_writable' is False; - this can't be done (eg we don't own `path`). Args: path (str): Path to make temporarily writable
[ "Temporarily", "make", "path", "writable", "if", "possible", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L76-L112
246,284
nerdvegas/rez
src/rez/utils/filesystem.py
get_existing_path
def get_existing_path(path, topmost_path=None): """Get the longest parent path in `path` that exists. If `path` exists, it is returned. Args: path (str): Path to test topmost_path (str): Do not test this path or above Returns: str: Existing path, or None if no path was found. ...
python
def get_existing_path(path, topmost_path=None): prev_path = None if topmost_path: topmost_path = os.path.normpath(topmost_path) while True: if os.path.exists(path): return path path = os.path.dirname(path) if path == prev_path: return None ...
[ "def", "get_existing_path", "(", "path", ",", "topmost_path", "=", "None", ")", ":", "prev_path", "=", "None", "if", "topmost_path", ":", "topmost_path", "=", "os", ".", "path", ".", "normpath", "(", "topmost_path", ")", "while", "True", ":", "if", "os", ...
Get the longest parent path in `path` that exists. If `path` exists, it is returned. Args: path (str): Path to test topmost_path (str): Do not test this path or above Returns: str: Existing path, or None if no path was found.
[ "Get", "the", "longest", "parent", "path", "in", "path", "that", "exists", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L126-L154
246,285
nerdvegas/rez
src/rez/utils/filesystem.py
safe_makedirs
def safe_makedirs(path): """Safe makedirs. Works in a multithreaded scenario. """ if not os.path.exists(path): try: os.makedirs(path) except OSError: if not os.path.exists(path): raise
python
def safe_makedirs(path): if not os.path.exists(path): try: os.makedirs(path) except OSError: if not os.path.exists(path): raise
[ "def", "safe_makedirs", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "try", ":", "os", ".", "makedirs", "(", "path", ")", "except", "OSError", ":", "if", "not", "os", ".", "path", ".", "exists", "("...
Safe makedirs. Works in a multithreaded scenario.
[ "Safe", "makedirs", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L157-L167
246,286
nerdvegas/rez
src/rez/utils/filesystem.py
safe_remove
def safe_remove(path): """Safely remove the given file or directory. Works in a multithreaded scenario. """ if not os.path.exists(path): return try: if os.path.isdir(path) and not os.path.islink(path): shutil.rmtree(path) else: os.remove(path) ex...
python
def safe_remove(path): if not os.path.exists(path): return try: if os.path.isdir(path) and not os.path.islink(path): shutil.rmtree(path) else: os.remove(path) except OSError: if os.path.exists(path): raise
[ "def", "safe_remove", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "try", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", "and", "not", "os", ".", "path", ".", "islink", "(...
Safely remove the given file or directory. Works in a multithreaded scenario.
[ "Safely", "remove", "the", "given", "file", "or", "directory", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L170-L185
246,287
nerdvegas/rez
src/rez/utils/filesystem.py
replacing_symlink
def replacing_symlink(source, link_name): """Create symlink that overwrites any existing target. """ with make_tmp_name(link_name) as tmp_link_name: os.symlink(source, tmp_link_name) replace_file_or_dir(link_name, tmp_link_name)
python
def replacing_symlink(source, link_name): with make_tmp_name(link_name) as tmp_link_name: os.symlink(source, tmp_link_name) replace_file_or_dir(link_name, tmp_link_name)
[ "def", "replacing_symlink", "(", "source", ",", "link_name", ")", ":", "with", "make_tmp_name", "(", "link_name", ")", "as", "tmp_link_name", ":", "os", ".", "symlink", "(", "source", ",", "tmp_link_name", ")", "replace_file_or_dir", "(", "link_name", ",", "tm...
Create symlink that overwrites any existing target.
[ "Create", "symlink", "that", "overwrites", "any", "existing", "target", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L188-L193
246,288
nerdvegas/rez
src/rez/utils/filesystem.py
replacing_copy
def replacing_copy(src, dest, follow_symlinks=False): """Perform copy that overwrites any existing target. Will copy/copytree `src` to `dest`, and will remove `dest` if it exists, regardless of what it is. If `follow_symlinks` is False, symlinks are preserved, otherwise their contents are copied. ...
python
def replacing_copy(src, dest, follow_symlinks=False): with make_tmp_name(dest) as tmp_dest: if os.path.islink(src) and not follow_symlinks: # special case - copy just a symlink src_ = os.readlink(src) os.symlink(src_, tmp_dest) elif os.path.isdir(src): ...
[ "def", "replacing_copy", "(", "src", ",", "dest", ",", "follow_symlinks", "=", "False", ")", ":", "with", "make_tmp_name", "(", "dest", ")", "as", "tmp_dest", ":", "if", "os", ".", "path", ".", "islink", "(", "src", ")", "and", "not", "follow_symlinks", ...
Perform copy that overwrites any existing target. Will copy/copytree `src` to `dest`, and will remove `dest` if it exists, regardless of what it is. If `follow_symlinks` is False, symlinks are preserved, otherwise their contents are copied. Note that this behavior is different to `shutil.copy`, w...
[ "Perform", "copy", "that", "overwrites", "any", "existing", "target", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L196-L220
246,289
nerdvegas/rez
src/rez/utils/filesystem.py
replace_file_or_dir
def replace_file_or_dir(dest, source): """Replace `dest` with `source`. Acts like an `os.rename` if `dest` does not exist. Otherwise, `dest` is deleted and `src` is renamed to `dest`. """ from rez.vendor.atomicwrites import replace_atomic if not os.path.exists(dest): try: o...
python
def replace_file_or_dir(dest, source): from rez.vendor.atomicwrites import replace_atomic if not os.path.exists(dest): try: os.rename(source, dest) return except: if not os.path.exists(dest): raise try: replace_atomic(source, dest...
[ "def", "replace_file_or_dir", "(", "dest", ",", "source", ")", ":", "from", "rez", ".", "vendor", ".", "atomicwrites", "import", "replace_atomic", "if", "not", "os", ".", "path", ".", "exists", "(", "dest", ")", ":", "try", ":", "os", ".", "rename", "(...
Replace `dest` with `source`. Acts like an `os.rename` if `dest` does not exist. Otherwise, `dest` is deleted and `src` is renamed to `dest`.
[ "Replace", "dest", "with", "source", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L223-L247
246,290
nerdvegas/rez
src/rez/utils/filesystem.py
make_tmp_name
def make_tmp_name(name): """Generates a tmp name for a file or dir. This is a tempname that sits in the same dir as `name`. If it exists on disk at context exit time, it is deleted. """ path, base = os.path.split(name) tmp_base = ".tmp-%s-%s" % (base, uuid4().hex) tmp_name = os.path.join(pa...
python
def make_tmp_name(name): path, base = os.path.split(name) tmp_base = ".tmp-%s-%s" % (base, uuid4().hex) tmp_name = os.path.join(path, tmp_base) try: yield tmp_name finally: safe_remove(tmp_name)
[ "def", "make_tmp_name", "(", "name", ")", ":", "path", ",", "base", "=", "os", ".", "path", ".", "split", "(", "name", ")", "tmp_base", "=", "\".tmp-%s-%s\"", "%", "(", "base", ",", "uuid4", "(", ")", ".", "hex", ")", "tmp_name", "=", "os", ".", ...
Generates a tmp name for a file or dir. This is a tempname that sits in the same dir as `name`. If it exists on disk at context exit time, it is deleted.
[ "Generates", "a", "tmp", "name", "for", "a", "file", "or", "dir", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L267-L280
246,291
nerdvegas/rez
src/rez/utils/filesystem.py
is_subdirectory
def is_subdirectory(path_a, path_b): """Returns True if `path_a` is a subdirectory of `path_b`.""" path_a = os.path.realpath(path_a) path_b = os.path.realpath(path_b) relative = os.path.relpath(path_a, path_b) return (not relative.startswith(os.pardir + os.sep))
python
def is_subdirectory(path_a, path_b): path_a = os.path.realpath(path_a) path_b = os.path.realpath(path_b) relative = os.path.relpath(path_a, path_b) return (not relative.startswith(os.pardir + os.sep))
[ "def", "is_subdirectory", "(", "path_a", ",", "path_b", ")", ":", "path_a", "=", "os", ".", "path", ".", "realpath", "(", "path_a", ")", "path_b", "=", "os", ".", "path", ".", "realpath", "(", "path_b", ")", "relative", "=", "os", ".", "path", ".", ...
Returns True if `path_a` is a subdirectory of `path_b`.
[ "Returns", "True", "if", "path_a", "is", "a", "subdirectory", "of", "path_b", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L283-L288
246,292
nerdvegas/rez
src/rez/utils/filesystem.py
find_matching_symlink
def find_matching_symlink(path, source): """Find a symlink under `path` that points at `source`. If source is relative, it is considered relative to `path`. Returns: str: Name of symlink found, or None. """ def to_abs(target): if os.path.isabs(target): return target ...
python
def find_matching_symlink(path, source): def to_abs(target): if os.path.isabs(target): return target else: return os.path.normpath(os.path.join(path, target)) abs_source = to_abs(source) for name in os.listdir(path): linkpath = os.path.join(path, name) ...
[ "def", "find_matching_symlink", "(", "path", ",", "source", ")", ":", "def", "to_abs", "(", "target", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "target", ")", ":", "return", "target", "else", ":", "return", "os", ".", "path", ".", "normpa...
Find a symlink under `path` that points at `source`. If source is relative, it is considered relative to `path`. Returns: str: Name of symlink found, or None.
[ "Find", "a", "symlink", "under", "path", "that", "points", "at", "source", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L291-L314
246,293
nerdvegas/rez
src/rez/utils/filesystem.py
copy_or_replace
def copy_or_replace(src, dst): '''try to copy with mode, and if it fails, try replacing ''' try: shutil.copy(src, dst) except (OSError, IOError), e: # It's possible that the file existed, but was owned by someone # else - in that situation, shutil.copy might then fail when it ...
python
def copy_or_replace(src, dst): '''try to copy with mode, and if it fails, try replacing ''' try: shutil.copy(src, dst) except (OSError, IOError), e: # It's possible that the file existed, but was owned by someone # else - in that situation, shutil.copy might then fail when it ...
[ "def", "copy_or_replace", "(", "src", ",", "dst", ")", ":", "try", ":", "shutil", ".", "copy", "(", "src", ",", "dst", ")", "except", "(", "OSError", ",", "IOError", ")", ",", "e", ":", "# It's possible that the file existed, but was owned by someone", "# else...
try to copy with mode, and if it fails, try replacing
[ "try", "to", "copy", "with", "mode", "and", "if", "it", "fails", "try", "replacing" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L317-L347
246,294
nerdvegas/rez
src/rez/utils/filesystem.py
movetree
def movetree(src, dst): """Attempts a move, and falls back to a copy+delete if this fails """ try: shutil.move(src, dst) except: copytree(src, dst, symlinks=True, hardlinks=True) shutil.rmtree(src)
python
def movetree(src, dst): try: shutil.move(src, dst) except: copytree(src, dst, symlinks=True, hardlinks=True) shutil.rmtree(src)
[ "def", "movetree", "(", "src", ",", "dst", ")", ":", "try", ":", "shutil", ".", "move", "(", "src", ",", "dst", ")", "except", ":", "copytree", "(", "src", ",", "dst", ",", "symlinks", "=", "True", ",", "hardlinks", "=", "True", ")", "shutil", "....
Attempts a move, and falls back to a copy+delete if this fails
[ "Attempts", "a", "move", "and", "falls", "back", "to", "a", "copy", "+", "delete", "if", "this", "fails" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L404-L411
246,295
nerdvegas/rez
src/rez/utils/filesystem.py
safe_chmod
def safe_chmod(path, mode): """Set the permissions mode on path, but only if it differs from the current mode. """ if stat.S_IMODE(os.stat(path).st_mode) != mode: os.chmod(path, mode)
python
def safe_chmod(path, mode): if stat.S_IMODE(os.stat(path).st_mode) != mode: os.chmod(path, mode)
[ "def", "safe_chmod", "(", "path", ",", "mode", ")", ":", "if", "stat", ".", "S_IMODE", "(", "os", ".", "stat", "(", "path", ")", ".", "st_mode", ")", "!=", "mode", ":", "os", ".", "chmod", "(", "path", ",", "mode", ")" ]
Set the permissions mode on path, but only if it differs from the current mode.
[ "Set", "the", "permissions", "mode", "on", "path", "but", "only", "if", "it", "differs", "from", "the", "current", "mode", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L414-L418
246,296
nerdvegas/rez
src/rez/utils/filesystem.py
encode_filesystem_name
def encode_filesystem_name(input_str): """Encodes an arbitrary unicode string to a generic filesystem-compatible non-unicode filename. The result after encoding will only contain the standard ascii lowercase letters (a-z), the digits (0-9), or periods, underscores, or dashes (".", "_", or "-"). No...
python
def encode_filesystem_name(input_str): if isinstance(input_str, str): input_str = unicode(input_str) elif not isinstance(input_str, unicode): raise TypeError("input_str must be a basestring") as_is = u'abcdefghijklmnopqrstuvwxyz0123456789.-' uppercase = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ...
[ "def", "encode_filesystem_name", "(", "input_str", ")", ":", "if", "isinstance", "(", "input_str", ",", "str", ")", ":", "input_str", "=", "unicode", "(", "input_str", ")", "elif", "not", "isinstance", "(", "input_str", ",", "unicode", ")", ":", "raise", "...
Encodes an arbitrary unicode string to a generic filesystem-compatible non-unicode filename. The result after encoding will only contain the standard ascii lowercase letters (a-z), the digits (0-9), or periods, underscores, or dashes (".", "_", or "-"). No uppercase letters will be used, for comap...
[ "Encodes", "an", "arbitrary", "unicode", "string", "to", "a", "generic", "filesystem", "-", "compatible", "non", "-", "unicode", "filename", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L433-L499
246,297
nerdvegas/rez
src/rez/utils/filesystem.py
decode_filesystem_name
def decode_filesystem_name(filename): """Decodes a filename encoded using the rules given in encode_filesystem_name to a unicode string. """ result = [] remain = filename i = 0 while remain: # use match, to ensure it matches from the start of the string... match = _FILESYSTEM...
python
def decode_filesystem_name(filename): result = [] remain = filename i = 0 while remain: # use match, to ensure it matches from the start of the string... match = _FILESYSTEM_TOKEN_RE.match(remain) if not match: raise ValueError("incorrectly encoded filesystem name %r"...
[ "def", "decode_filesystem_name", "(", "filename", ")", ":", "result", "=", "[", "]", "remain", "=", "filename", "i", "=", "0", "while", "remain", ":", "# use match, to ensure it matches from the start of the string...", "match", "=", "_FILESYSTEM_TOKEN_RE", ".", "matc...
Decodes a filename encoded using the rules given in encode_filesystem_name to a unicode string.
[ "Decodes", "a", "filename", "encoded", "using", "the", "rules", "given", "in", "encode_filesystem_name", "to", "a", "unicode", "string", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L506-L555
246,298
nerdvegas/rez
src/rez/utils/filesystem.py
walk_up_dirs
def walk_up_dirs(path): """Yields absolute directories starting with the given path, and iterating up through all it's parents, until it reaches a root directory""" prev_path = None current_path = os.path.abspath(path) while current_path != prev_path: yield current_path prev_path = c...
python
def walk_up_dirs(path): prev_path = None current_path = os.path.abspath(path) while current_path != prev_path: yield current_path prev_path = current_path current_path = os.path.dirname(prev_path)
[ "def", "walk_up_dirs", "(", "path", ")", ":", "prev_path", "=", "None", "current_path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "while", "current_path", "!=", "prev_path", ":", "yield", "current_path", "prev_path", "=", "current_path", "cur...
Yields absolute directories starting with the given path, and iterating up through all it's parents, until it reaches a root directory
[ "Yields", "absolute", "directories", "starting", "with", "the", "given", "path", "and", "iterating", "up", "through", "all", "it", "s", "parents", "until", "it", "reaches", "a", "root", "directory" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/filesystem.py#L575-L583
246,299
nerdvegas/rez
src/rez/wrapper.py
Wrapper.run
def run(self, *args): """Invoke the wrapped script. Returns: Return code of the command, or 0 if the command is not run. """ if self.prefix_char is None: prefix_char = config.suite_alias_prefix_char else: prefix_char = self.prefix_char ...
python
def run(self, *args): if self.prefix_char is None: prefix_char = config.suite_alias_prefix_char else: prefix_char = self.prefix_char if prefix_char == '': # empty prefix char means we don't support the '+' args return self._run_no_args(args) ...
[ "def", "run", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "prefix_char", "is", "None", ":", "prefix_char", "=", "config", ".", "suite_alias_prefix_char", "else", ":", "prefix_char", "=", "self", ".", "prefix_char", "if", "prefix_char", "=="...
Invoke the wrapped script. Returns: Return code of the command, or 0 if the command is not run.
[ "Invoke", "the", "wrapped", "script", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/wrapper.py#L66-L81