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,500 | nerdvegas/rez | src/rez/config.py | Config.copy | def copy(self, overrides=None, locked=False):
"""Create a separate copy of this config."""
other = copy.copy(self)
if overrides is not None:
other.overrides = overrides
other.locked = locked
other._uncache()
return other | python | def copy(self, overrides=None, locked=False):
other = copy.copy(self)
if overrides is not None:
other.overrides = overrides
other.locked = locked
other._uncache()
return other | [
"def",
"copy",
"(",
"self",
",",
"overrides",
"=",
"None",
",",
"locked",
"=",
"False",
")",
":",
"other",
"=",
"copy",
".",
"copy",
"(",
"self",
")",
"if",
"overrides",
"is",
"not",
"None",
":",
"other",
".",
"overrides",
"=",
"overrides",
"other",
... | Create a separate copy of this config. | [
"Create",
"a",
"separate",
"copy",
"of",
"this",
"config",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/config.py#L429-L439 |
246,501 | nerdvegas/rez | src/rez/config.py | Config.override | def override(self, key, value):
"""Set a setting to the given value.
Note that `key` can be in dotted form, eg
'plugins.release_hook.emailer.sender'.
"""
keys = key.split('.')
if len(keys) > 1:
if keys[0] != "plugins":
raise AttributeError("no... | python | def override(self, key, value):
keys = key.split('.')
if len(keys) > 1:
if keys[0] != "plugins":
raise AttributeError("no such setting: %r" % key)
self.plugins.override(keys[1:], value)
else:
self.overrides[key] = value
self._uncach... | [
"def",
"override",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"keys",
"=",
"key",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"keys",
")",
">",
"1",
":",
"if",
"keys",
"[",
"0",
"]",
"!=",
"\"plugins\"",
":",
"raise",
"AttributeError",... | Set a setting to the given value.
Note that `key` can be in dotted form, eg
'plugins.release_hook.emailer.sender'. | [
"Set",
"a",
"setting",
"to",
"the",
"given",
"value",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/config.py#L441-L454 |
246,502 | nerdvegas/rez | src/rez/config.py | Config.remove_override | def remove_override(self, key):
"""Remove a setting override, if one exists."""
keys = key.split('.')
if len(keys) > 1:
raise NotImplementedError
elif key in self.overrides:
del self.overrides[key]
self._uncache(key) | python | def remove_override(self, key):
keys = key.split('.')
if len(keys) > 1:
raise NotImplementedError
elif key in self.overrides:
del self.overrides[key]
self._uncache(key) | [
"def",
"remove_override",
"(",
"self",
",",
"key",
")",
":",
"keys",
"=",
"key",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"keys",
")",
">",
"1",
":",
"raise",
"NotImplementedError",
"elif",
"key",
"in",
"self",
".",
"overrides",
":",
"del",
... | Remove a setting override, if one exists. | [
"Remove",
"a",
"setting",
"override",
"if",
"one",
"exists",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/config.py#L459-L466 |
246,503 | nerdvegas/rez | src/rez/config.py | Config.warn | def warn(self, key):
"""Returns True if the warning setting is enabled."""
return (not self.quiet and not self.warn_none and
(self.warn_all or getattr(self, "warn_%s" % key))) | python | def warn(self, key):
return (not self.quiet and not self.warn_none and
(self.warn_all or getattr(self, "warn_%s" % key))) | [
"def",
"warn",
"(",
"self",
",",
"key",
")",
":",
"return",
"(",
"not",
"self",
".",
"quiet",
"and",
"not",
"self",
".",
"warn_none",
"and",
"(",
"self",
".",
"warn_all",
"or",
"getattr",
"(",
"self",
",",
"\"warn_%s\"",
"%",
"key",
")",
")",
")"
] | Returns True if the warning setting is enabled. | [
"Returns",
"True",
"if",
"the",
"warning",
"setting",
"is",
"enabled",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/config.py#L468-L471 |
246,504 | nerdvegas/rez | src/rez/config.py | Config.debug | def debug(self, key):
"""Returns True if the debug setting is enabled."""
return (not self.quiet and not self.debug_none and
(self.debug_all or getattr(self, "debug_%s" % key))) | python | def debug(self, key):
return (not self.quiet and not self.debug_none and
(self.debug_all or getattr(self, "debug_%s" % key))) | [
"def",
"debug",
"(",
"self",
",",
"key",
")",
":",
"return",
"(",
"not",
"self",
".",
"quiet",
"and",
"not",
"self",
".",
"debug_none",
"and",
"(",
"self",
".",
"debug_all",
"or",
"getattr",
"(",
"self",
",",
"\"debug_%s\"",
"%",
"key",
")",
")",
"... | Returns True if the debug setting is enabled. | [
"Returns",
"True",
"if",
"the",
"debug",
"setting",
"is",
"enabled",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/config.py#L473-L476 |
246,505 | nerdvegas/rez | src/rez/config.py | Config.data | def data(self):
"""Returns the entire configuration as a dict.
Note that this will force all plugins to be loaded.
"""
d = {}
for key in self._data:
if key == "plugins":
d[key] = self.plugins.data()
else:
try:
... | python | def data(self):
d = {}
for key in self._data:
if key == "plugins":
d[key] = self.plugins.data()
else:
try:
d[key] = getattr(self, key)
except AttributeError:
pass # unknown key, just leave it... | [
"def",
"data",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"_data",
":",
"if",
"key",
"==",
"\"plugins\"",
":",
"d",
"[",
"key",
"]",
"=",
"self",
".",
"plugins",
".",
"data",
"(",
")",
"else",
":",
"try",
":",... | Returns the entire configuration as a dict.
Note that this will force all plugins to be loaded. | [
"Returns",
"the",
"entire",
"configuration",
"as",
"a",
"dict",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/config.py#L507-L521 |
246,506 | nerdvegas/rez | src/rez/config.py | Config.nonlocal_packages_path | def nonlocal_packages_path(self):
"""Returns package search paths with local path removed."""
paths = self.packages_path[:]
if self.local_packages_path in paths:
paths.remove(self.local_packages_path)
return paths | python | def nonlocal_packages_path(self):
paths = self.packages_path[:]
if self.local_packages_path in paths:
paths.remove(self.local_packages_path)
return paths | [
"def",
"nonlocal_packages_path",
"(",
"self",
")",
":",
"paths",
"=",
"self",
".",
"packages_path",
"[",
":",
"]",
"if",
"self",
".",
"local_packages_path",
"in",
"paths",
":",
"paths",
".",
"remove",
"(",
"self",
".",
"local_packages_path",
")",
"return",
... | Returns package search paths with local path removed. | [
"Returns",
"package",
"search",
"paths",
"with",
"local",
"path",
"removed",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/config.py#L524-L529 |
246,507 | nerdvegas/rez | src/rez/config.py | Config._swap | def _swap(self, other):
"""Swap this config with another.
This is used by the unit tests to swap the config to one that is
shielded from any user config updates. Do not use this method unless
you have good reason.
"""
self.__dict__, other.__dict__ = other.__dict__, self.... | python | def _swap(self, other):
self.__dict__, other.__dict__ = other.__dict__, self.__dict__ | [
"def",
"_swap",
"(",
"self",
",",
"other",
")",
":",
"self",
".",
"__dict__",
",",
"other",
".",
"__dict__",
"=",
"other",
".",
"__dict__",
",",
"self",
".",
"__dict__"
] | Swap this config with another.
This is used by the unit tests to swap the config to one that is
shielded from any user config updates. Do not use this method unless
you have good reason. | [
"Swap",
"this",
"config",
"with",
"another",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/config.py#L568-L575 |
246,508 | nerdvegas/rez | src/rez/config.py | Config._create_main_config | def _create_main_config(cls, overrides=None):
"""See comment block at top of 'rezconfig' describing how the main
config is assembled."""
filepaths = []
filepaths.append(get_module_root_config())
filepath = os.getenv("REZ_CONFIG_FILE")
if filepath:
filepaths.ex... | python | def _create_main_config(cls, overrides=None):
filepaths = []
filepaths.append(get_module_root_config())
filepath = os.getenv("REZ_CONFIG_FILE")
if filepath:
filepaths.extend(filepath.split(os.pathsep))
filepath = os.path.expanduser("~/.rezconfig")
filepaths.a... | [
"def",
"_create_main_config",
"(",
"cls",
",",
"overrides",
"=",
"None",
")",
":",
"filepaths",
"=",
"[",
"]",
"filepaths",
".",
"append",
"(",
"get_module_root_config",
"(",
")",
")",
"filepath",
"=",
"os",
".",
"getenv",
"(",
"\"REZ_CONFIG_FILE\"",
")",
... | See comment block at top of 'rezconfig' describing how the main
config is assembled. | [
"See",
"comment",
"block",
"at",
"top",
"of",
"rezconfig",
"describing",
"how",
"the",
"main",
"config",
"is",
"assembled",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/config.py#L600-L612 |
246,509 | nerdvegas/rez | src/rez/utils/platform_mapped.py | platform_mapped | def platform_mapped(func):
"""Decorates functions for lookups within a config.platform_map dictionary.
The first level key is mapped to the func.__name__ of the decorated function.
Regular expressions are used on the second level key, values.
Note that there is no guaranteed order within the dictionary... | python | def platform_mapped(func):
def inner(*args, **kwargs):
# Since platform is being used within config lazy import config to prevent
# circular dependencies
from rez.config import config
# Original result
result = func(*args, **kwargs)
# The function name is used as p... | [
"def",
"platform_mapped",
"(",
"func",
")",
":",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Since platform is being used within config lazy import config to prevent",
"# circular dependencies",
"from",
"rez",
".",
"config",
"import",
"conf... | Decorates functions for lookups within a config.platform_map dictionary.
The first level key is mapped to the func.__name__ of the decorated function.
Regular expressions are used on the second level key, values.
Note that there is no guaranteed order within the dictionary evaluation. Only the first matchi... | [
"Decorates",
"functions",
"for",
"lookups",
"within",
"a",
"config",
".",
"platform_map",
"dictionary",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/platform_mapped.py#L4-L42 |
246,510 | nerdvegas/rez | src/rez/vendor/pygraph/algorithms/pagerank.py | pagerank | def pagerank(graph, damping_factor=0.85, max_iterations=100, min_delta=0.00001):
"""
Compute and return the PageRank in an directed graph.
@type graph: digraph
@param graph: Digraph.
@type damping_factor: number
@param damping_factor: PageRank dumping factor.
@type max_... | python | def pagerank(graph, damping_factor=0.85, max_iterations=100, min_delta=0.00001):
nodes = graph.nodes()
graph_size = len(nodes)
if graph_size == 0:
return {}
min_value = (1.0-damping_factor)/graph_size #value for nodes without inbound links
# itialize the page rank dict with 1/N for all ... | [
"def",
"pagerank",
"(",
"graph",
",",
"damping_factor",
"=",
"0.85",
",",
"max_iterations",
"=",
"100",
",",
"min_delta",
"=",
"0.00001",
")",
":",
"nodes",
"=",
"graph",
".",
"nodes",
"(",
")",
"graph_size",
"=",
"len",
"(",
"nodes",
")",
"if",
"graph... | Compute and return the PageRank in an directed graph.
@type graph: digraph
@param graph: Digraph.
@type damping_factor: number
@param damping_factor: PageRank dumping factor.
@type max_iterations: number
@param max_iterations: Maximum number of iterations.
@type ... | [
"Compute",
"and",
"return",
"the",
"PageRank",
"in",
"an",
"directed",
"graph",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/algorithms/pagerank.py#L32-L76 |
246,511 | nerdvegas/rez | src/rez/package_py_utils.py | exec_command | def exec_command(attr, cmd):
"""Runs a subproc to calculate a package attribute.
"""
import subprocess
p = popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode:
from rez.exceptions import InvalidPackageError
raise InvalidPackageE... | python | def exec_command(attr, cmd):
import subprocess
p = popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode:
from rez.exceptions import InvalidPackageError
raise InvalidPackageError(
"Error determining package attribute '%s':\n%s... | [
"def",
"exec_command",
"(",
"attr",
",",
"cmd",
")",
":",
"import",
"subprocess",
"p",
"=",
"popen",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"out",
",",
"err",
"=",
"p",
".",
"c... | Runs a subproc to calculate a package attribute. | [
"Runs",
"a",
"subproc",
"to",
"calculate",
"a",
"package",
"attribute",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_py_utils.py#L163-L176 |
246,512 | nerdvegas/rez | src/rez/package_py_utils.py | exec_python | def exec_python(attr, src, executable="python"):
"""Runs a python subproc to calculate a package attribute.
Args:
attr (str): Name of package attribute being created.
src (list of str): Python code to execute, will be converted into
semicolon-delimited single line of code.
Retu... | python | def exec_python(attr, src, executable="python"):
import subprocess
if isinstance(src, basestring):
src = [src]
p = popen([executable, "-c", "; ".join(src)],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode:
from rez.exception... | [
"def",
"exec_python",
"(",
"attr",
",",
"src",
",",
"executable",
"=",
"\"python\"",
")",
":",
"import",
"subprocess",
"if",
"isinstance",
"(",
"src",
",",
"basestring",
")",
":",
"src",
"=",
"[",
"src",
"]",
"p",
"=",
"popen",
"(",
"[",
"executable",
... | Runs a python subproc to calculate a package attribute.
Args:
attr (str): Name of package attribute being created.
src (list of str): Python code to execute, will be converted into
semicolon-delimited single line of code.
Returns:
str: Output of python process. | [
"Runs",
"a",
"python",
"subproc",
"to",
"calculate",
"a",
"package",
"attribute",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_py_utils.py#L179-L204 |
246,513 | nerdvegas/rez | src/rez/package_py_utils.py | find_site_python | def find_site_python(module_name, paths=None):
"""Find the rez native python package that contains the given module.
This function is used by python 'native' rez installers to find the native
rez python package that represents the python installation that this module
is installed into.
Note:
... | python | def find_site_python(module_name, paths=None):
from rez.packages_ import iter_packages
import subprocess
import ast
import os
py_cmd = 'import {x}; print {x}.__path__'.format(x=module_name)
p = popen(["python", "-c", py_cmd], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
o... | [
"def",
"find_site_python",
"(",
"module_name",
",",
"paths",
"=",
"None",
")",
":",
"from",
"rez",
".",
"packages_",
"import",
"iter_packages",
"import",
"subprocess",
"import",
"ast",
"import",
"os",
"py_cmd",
"=",
"'import {x}; print {x}.__path__'",
".",
"format... | Find the rez native python package that contains the given module.
This function is used by python 'native' rez installers to find the native
rez python package that represents the python installation that this module
is installed into.
Note:
This function is dependent on the behavior found in... | [
"Find",
"the",
"rez",
"native",
"python",
"package",
"that",
"contains",
"the",
"given",
"module",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_py_utils.py#L207-L264 |
246,514 | nerdvegas/rez | src/rez/vendor/pygraph/algorithms/critical.py | _intersection | def _intersection(A,B):
"""
A simple function to find an intersection between two arrays.
@type A: List
@param A: First List
@type B: List
@param B: Second List
@rtype: List
@return: List of Intersections
"""
intersection = []
for i in A:
if i in B:
... | python | def _intersection(A,B):
intersection = []
for i in A:
if i in B:
intersection.append(i)
return intersection | [
"def",
"_intersection",
"(",
"A",
",",
"B",
")",
":",
"intersection",
"=",
"[",
"]",
"for",
"i",
"in",
"A",
":",
"if",
"i",
"in",
"B",
":",
"intersection",
".",
"append",
"(",
"i",
")",
"return",
"intersection"
] | A simple function to find an intersection between two arrays.
@type A: List
@param A: First List
@type B: List
@param B: Second List
@rtype: List
@return: List of Intersections | [
"A",
"simple",
"function",
"to",
"find",
"an",
"intersection",
"between",
"two",
"arrays",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/algorithms/critical.py#L38-L55 |
246,515 | nerdvegas/rez | src/rez/vendor/pygraph/algorithms/critical.py | critical_path | def critical_path(graph):
"""
Compute and return the critical path in an acyclic directed weighted graph.
@attention: This function is only meaningful for directed weighted acyclic graphs
@type graph: digraph
@param graph: Digraph
@rtype: List
@return: List containing all the... | python | def critical_path(graph):
#if the graph contains a cycle we return an empty array
if not len(find_cycle(graph)) == 0:
return []
#this empty dictionary will contain a tuple for every single node
#the tuple contains the information about the most costly predecessor
#of the given node and... | [
"def",
"critical_path",
"(",
"graph",
")",
":",
"#if the graph contains a cycle we return an empty array",
"if",
"not",
"len",
"(",
"find_cycle",
"(",
"graph",
")",
")",
"==",
"0",
":",
"return",
"[",
"]",
"#this empty dictionary will contain a tuple for every single node... | Compute and return the critical path in an acyclic directed weighted graph.
@attention: This function is only meaningful for directed weighted acyclic graphs
@type graph: digraph
@param graph: Digraph
@rtype: List
@return: List containing all the nodes in the path (or an empty array ... | [
"Compute",
"and",
"return",
"the",
"critical",
"path",
"in",
"an",
"acyclic",
"directed",
"weighted",
"graph",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/algorithms/critical.py#L98-L163 |
246,516 | nerdvegas/rez | src/rezplugins/build_system/custom.py | CustomBuildSystem.build | def build(self, context, variant, build_path, install_path, install=False,
build_type=BuildType.local):
"""Perform the build.
Note that most of the func args aren't used here - that's because this
info is already passed to the custom build command via environment
variables... | python | def build(self, context, variant, build_path, install_path, install=False,
build_type=BuildType.local):
ret = {}
if self.write_build_scripts:
# write out the script that places the user in a build env, where
# they can run bez directly themselves.
build... | [
"def",
"build",
"(",
"self",
",",
"context",
",",
"variant",
",",
"build_path",
",",
"install_path",
",",
"install",
"=",
"False",
",",
"build_type",
"=",
"BuildType",
".",
"local",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"self",
".",
"write_build_scripts"... | Perform the build.
Note that most of the func args aren't used here - that's because this
info is already passed to the custom build command via environment
variables. | [
"Perform",
"the",
"build",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/build_system/custom.py#L87-L176 |
246,517 | nerdvegas/rez | src/rezplugins/release_vcs/hg.py | HgReleaseVCS._create_tag_highlevel | def _create_tag_highlevel(self, tag_name, message=None):
"""Create a tag on the toplevel repo if there is no patch repo,
or a tag on the patch repo and bookmark on the top repo if there is a
patch repo
Returns a list where each entry is a dict for each bookmark or tag
created, w... | python | def _create_tag_highlevel(self, tag_name, message=None):
results = []
if self.patch_path:
# make a tag on the patch queue
tagged = self._create_tag_lowlevel(tag_name, message=message,
patch=True)
if tagged:
... | [
"def",
"_create_tag_highlevel",
"(",
"self",
",",
"tag_name",
",",
"message",
"=",
"None",
")",
":",
"results",
"=",
"[",
"]",
"if",
"self",
".",
"patch_path",
":",
"# make a tag on the patch queue",
"tagged",
"=",
"self",
".",
"_create_tag_lowlevel",
"(",
"ta... | Create a tag on the toplevel repo if there is no patch repo,
or a tag on the patch repo and bookmark on the top repo if there is a
patch repo
Returns a list where each entry is a dict for each bookmark or tag
created, which looks like {'type': ('bookmark' or 'tag'), 'patch': bool} | [
"Create",
"a",
"tag",
"on",
"the",
"toplevel",
"repo",
"if",
"there",
"is",
"no",
"patch",
"repo",
"or",
"a",
"tag",
"on",
"the",
"patch",
"repo",
"and",
"bookmark",
"on",
"the",
"top",
"repo",
"if",
"there",
"is",
"a",
"patch",
"repo"
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/hg.py#L58-L82 |
246,518 | nerdvegas/rez | src/rezplugins/release_vcs/hg.py | HgReleaseVCS._create_tag_lowlevel | def _create_tag_lowlevel(self, tag_name, message=None, force=True,
patch=False):
"""Create a tag on the toplevel or patch repo
If the tag exists, and force is False, no tag is made. If force is True,
and a tag exists, but it is a direct ancestor of the current commi... | python | def _create_tag_lowlevel(self, tag_name, message=None, force=True,
patch=False):
# check if tag already exists, and if it does, if it is a direct
# ancestor, and there is NO difference in the files between the tagged
# state and current state
#
# This... | [
"def",
"_create_tag_lowlevel",
"(",
"self",
",",
"tag_name",
",",
"message",
"=",
"None",
",",
"force",
"=",
"True",
",",
"patch",
"=",
"False",
")",
":",
"# check if tag already exists, and if it does, if it is a direct",
"# ancestor, and there is NO difference in the file... | Create a tag on the toplevel or patch repo
If the tag exists, and force is False, no tag is made. If force is True,
and a tag exists, but it is a direct ancestor of the current commit,
and there is no difference in filestate between the current commit
and the tagged commit, no tag is ma... | [
"Create",
"a",
"tag",
"on",
"the",
"toplevel",
"or",
"patch",
"repo"
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/hg.py#L84-L137 |
246,519 | nerdvegas/rez | src/rezplugins/release_vcs/hg.py | HgReleaseVCS.is_ancestor | def is_ancestor(self, commit1, commit2, patch=False):
"""Returns True if commit1 is a direct ancestor of commit2, or False
otherwise.
This method considers a commit to be a direct ancestor of itself"""
result = self.hg("log", "-r", "first(%s::%s)" % (commit1, commit2),
... | python | def is_ancestor(self, commit1, commit2, patch=False):
result = self.hg("log", "-r", "first(%s::%s)" % (commit1, commit2),
"--template", "exists", patch=patch)
return "exists" in result | [
"def",
"is_ancestor",
"(",
"self",
",",
"commit1",
",",
"commit2",
",",
"patch",
"=",
"False",
")",
":",
"result",
"=",
"self",
".",
"hg",
"(",
"\"log\"",
",",
"\"-r\"",
",",
"\"first(%s::%s)\"",
"%",
"(",
"commit1",
",",
"commit2",
")",
",",
"\"--temp... | Returns True if commit1 is a direct ancestor of commit2, or False
otherwise.
This method considers a commit to be a direct ancestor of itself | [
"Returns",
"True",
"if",
"commit1",
"is",
"a",
"direct",
"ancestor",
"of",
"commit2",
"or",
"False",
"otherwise",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/hg.py#L159-L166 |
246,520 | nerdvegas/rez | src/rez/utils/patching.py | get_patched_request | def get_patched_request(requires, patchlist):
"""Apply patch args to a request.
For example, consider:
>>> print get_patched_request(["foo-5", "bah-8.1"], ["foo-6"])
["foo-6", "bah-8.1"]
>>> print get_patched_request(["foo-5", "bah-8.1"], ["^bah"])
["foo-5"]
The following ... | python | def get_patched_request(requires, patchlist):
# rules from table in docstring above
rules = {
'': (True, True, True ),
'!': (False, False, False),
'~': (False, False, True ),
'^': (True, True, True )
}
requires = [Requirement(x) if not isinstance(x, Requirement) els... | [
"def",
"get_patched_request",
"(",
"requires",
",",
"patchlist",
")",
":",
"# rules from table in docstring above",
"rules",
"=",
"{",
"''",
":",
"(",
"True",
",",
"True",
",",
"True",
")",
",",
"'!'",
":",
"(",
"False",
",",
"False",
",",
"False",
")",
... | Apply patch args to a request.
For example, consider:
>>> print get_patched_request(["foo-5", "bah-8.1"], ["foo-6"])
["foo-6", "bah-8.1"]
>>> print get_patched_request(["foo-5", "bah-8.1"], ["^bah"])
["foo-5"]
The following rules apply wrt how normal/conflict/weak patches over... | [
"Apply",
"patch",
"args",
"to",
"a",
"request",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/patching.py#L4-L78 |
246,521 | nerdvegas/rez | src/support/shotgun_toolkit/rez_app_launch.py | AppLaunch.execute | def execute(self, app_path, app_args, version, **kwargs):
"""
The execute functon of the hook will be called to start the required application
:param app_path: (str) The path of the application executable
:param app_args: (str) Any arguments the application may require
:param ve... | python | def execute(self, app_path, app_args, version, **kwargs):
multi_launchapp = self.parent
extra = multi_launchapp.get_setting("extra")
use_rez = False
if self.check_rez():
from rez.resolved_context import ResolvedContext
from rez.config import config
#... | [
"def",
"execute",
"(",
"self",
",",
"app_path",
",",
"app_args",
",",
"version",
",",
"*",
"*",
"kwargs",
")",
":",
"multi_launchapp",
"=",
"self",
".",
"parent",
"extra",
"=",
"multi_launchapp",
".",
"get_setting",
"(",
"\"extra\"",
")",
"use_rez",
"=",
... | The execute functon of the hook will be called to start the required application
:param app_path: (str) The path of the application executable
:param app_args: (str) Any arguments the application may require
:param version: (str) version of the application being run if set in the "versions" set... | [
"The",
"execute",
"functon",
"of",
"the",
"hook",
"will",
"be",
"called",
"to",
"start",
"the",
"required",
"application"
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/support/shotgun_toolkit/rez_app_launch.py#L37-L117 |
246,522 | nerdvegas/rez | src/support/shotgun_toolkit/rez_app_launch.py | AppLaunch.check_rez | def check_rez(self, strict=True):
"""
Checks to see if a Rez package is available in the current environment.
If it is available, add it to the system path, exposing the Rez Python API
:param strict: (bool) If True, raise an error if Rez is not available as a package.
... | python | def check_rez(self, strict=True):
system = sys.platform
if system == "win32":
rez_cmd = 'rez-env rez -- echo %REZ_REZ_ROOT%'
else:
rez_cmd = 'rez-env rez -- printenv REZ_REZ_ROOT'
process = subprocess.Popen(rez_cmd, stdout=subprocess.PIPE, shell=True)
re... | [
"def",
"check_rez",
"(",
"self",
",",
"strict",
"=",
"True",
")",
":",
"system",
"=",
"sys",
".",
"platform",
"if",
"system",
"==",
"\"win32\"",
":",
"rez_cmd",
"=",
"'rez-env rez -- echo %REZ_REZ_ROOT%'",
"else",
":",
"rez_cmd",
"=",
"'rez-env rez -- printenv R... | Checks to see if a Rez package is available in the current environment.
If it is available, add it to the system path, exposing the Rez Python API
:param strict: (bool) If True, raise an error if Rez is not available as a package.
This will prevent the app from being launc... | [
"Checks",
"to",
"see",
"if",
"a",
"Rez",
"package",
"is",
"available",
"in",
"the",
"current",
"environment",
".",
"If",
"it",
"is",
"available",
"add",
"it",
"to",
"the",
"system",
"path",
"exposing",
"the",
"Rez",
"Python",
"API"
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/support/shotgun_toolkit/rez_app_launch.py#L119-L155 |
246,523 | nerdvegas/rez | src/rezplugins/release_vcs/svn.py | get_last_changed_revision | def get_last_changed_revision(client, url):
"""
util func, get last revision of url
"""
try:
svn_entries = client.info2(url,
pysvn.Revision(pysvn.opt_revision_kind.head),
recurse=False)
if not svn_entries:
... | python | def get_last_changed_revision(client, url):
try:
svn_entries = client.info2(url,
pysvn.Revision(pysvn.opt_revision_kind.head),
recurse=False)
if not svn_entries:
raise ReleaseVCSError("svn.info2() returned no results o... | [
"def",
"get_last_changed_revision",
"(",
"client",
",",
"url",
")",
":",
"try",
":",
"svn_entries",
"=",
"client",
".",
"info2",
"(",
"url",
",",
"pysvn",
".",
"Revision",
"(",
"pysvn",
".",
"opt_revision_kind",
".",
"head",
")",
",",
"recurse",
"=",
"Fa... | util func, get last revision of url | [
"util",
"func",
"get",
"last",
"revision",
"of",
"url"
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/svn.py#L26-L38 |
246,524 | nerdvegas/rez | src/rezplugins/release_vcs/svn.py | get_svn_login | def get_svn_login(realm, username, may_save):
"""
provide svn with permissions. @TODO this will have to be updated to take
into account automated releases etc.
"""
import getpass
print "svn requires a password for the user %s:" % username
pwd = ''
while not pwd.strip():
pwd = ge... | python | def get_svn_login(realm, username, may_save):
import getpass
print "svn requires a password for the user %s:" % username
pwd = ''
while not pwd.strip():
pwd = getpass.getpass("--> ")
return True, username, pwd, False | [
"def",
"get_svn_login",
"(",
"realm",
",",
"username",
",",
"may_save",
")",
":",
"import",
"getpass",
"print",
"\"svn requires a password for the user %s:\"",
"%",
"username",
"pwd",
"=",
"''",
"while",
"not",
"pwd",
".",
"strip",
"(",
")",
":",
"pwd",
"=",
... | provide svn with permissions. @TODO this will have to be updated to take
into account automated releases etc. | [
"provide",
"svn",
"with",
"permissions",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/svn.py#L41-L53 |
246,525 | nerdvegas/rez | src/rez/vendor/pygraph/readwrite/markup.py | read | def read(string):
"""
Read a graph from a XML document 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 XML format specifying a graph.
@rtype: graph
@return: Graph
"""
dom = parseS... | python | def read(string):
dom = parseString(string)
if dom.getElementsByTagName("graph"):
G = graph()
elif dom.getElementsByTagName("digraph"):
G = digraph()
elif dom.getElementsByTagName("hypergraph"):
return read_hypergraph(string)
else:
raise InvalidGraphType
# Re... | [
"def",
"read",
"(",
"string",
")",
":",
"dom",
"=",
"parseString",
"(",
"string",
")",
"if",
"dom",
".",
"getElementsByTagName",
"(",
"\"graph\"",
")",
":",
"G",
"=",
"graph",
"(",
")",
"elif",
"dom",
".",
"getElementsByTagName",
"(",
"\"digraph\"",
")",... | Read a graph from a XML document 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 XML format specifying a graph.
@rtype: graph
@return: Graph | [
"Read",
"a",
"graph",
"from",
"a",
"XML",
"document",
"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/markup.py#L91-L132 |
246,526 | nerdvegas/rez | src/rez/vendor/pygraph/readwrite/markup.py | read_hypergraph | def read_hypergraph(string):
"""
Read a graph from a XML document. Nodes and hyperedges specified in the input will be added
to the current graph.
@type string: string
@param string: Input string in XML format specifying a graph.
@rtype: hypergraph
@return: Hypergraph
"""
... | python | def read_hypergraph(string):
hgr = hypergraph()
dom = parseString(string)
for each_node in dom.getElementsByTagName("node"):
hgr.add_node(each_node.getAttribute('id'))
for each_node in dom.getElementsByTagName("hyperedge"):
hgr.add_hyperedge(each_node.getAttribute('id'))
dom = p... | [
"def",
"read_hypergraph",
"(",
"string",
")",
":",
"hgr",
"=",
"hypergraph",
"(",
")",
"dom",
"=",
"parseString",
"(",
"string",
")",
"for",
"each_node",
"in",
"dom",
".",
"getElementsByTagName",
"(",
"\"node\"",
")",
":",
"hgr",
".",
"add_node",
"(",
"e... | Read a graph from a XML document. Nodes and hyperedges specified in the input will be added
to the current graph.
@type string: string
@param string: Input string in XML format specifying a graph.
@rtype: hypergraph
@return: Hypergraph | [
"Read",
"a",
"graph",
"from",
"a",
"XML",
"document",
".",
"Nodes",
"and",
"hyperedges",
"specified",
"in",
"the",
"input",
"will",
"be",
"added",
"to",
"the",
"current",
"graph",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/readwrite/markup.py#L172-L195 |
246,527 | nerdvegas/rez | src/rez/utils/diff_packages.py | diff_packages | def diff_packages(pkg1, pkg2=None):
"""Invoke a diff editor to show the difference between the source of two
packages.
Args:
pkg1 (`Package`): Package to diff.
pkg2 (`Package`): Package to diff against. If None, the next most recent
package version is used.
"""
if pkg2 i... | python | def diff_packages(pkg1, pkg2=None):
if pkg2 is None:
it = iter_packages(pkg1.name)
pkgs = [x for x in it if x.version < pkg1.version]
if not pkgs:
raise RezError("No package to diff with - %s is the earliest "
"package version" % pkg1.qualified_name)
... | [
"def",
"diff_packages",
"(",
"pkg1",
",",
"pkg2",
"=",
"None",
")",
":",
"if",
"pkg2",
"is",
"None",
":",
"it",
"=",
"iter_packages",
"(",
"pkg1",
".",
"name",
")",
"pkgs",
"=",
"[",
"x",
"for",
"x",
"in",
"it",
"if",
"x",
".",
"version",
"<",
... | Invoke a diff editor to show the difference between the source of two
packages.
Args:
pkg1 (`Package`): Package to diff.
pkg2 (`Package`): Package to diff against. If None, the next most recent
package version is used. | [
"Invoke",
"a",
"diff",
"editor",
"to",
"show",
"the",
"difference",
"between",
"the",
"source",
"of",
"two",
"packages",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/diff_packages.py#L10-L49 |
246,528 | nerdvegas/rez | src/rez/cli/_util.py | sigint_handler | def sigint_handler(signum, frame):
"""Exit gracefully on ctrl-C."""
global _handled_int
if not _handled_int:
_handled_int = True
if not _env_var_true("_REZ_QUIET_ON_SIG"):
print >> sys.stderr, "Interrupted by user"
sigbase_handler(signum, frame) | python | def sigint_handler(signum, frame):
global _handled_int
if not _handled_int:
_handled_int = True
if not _env_var_true("_REZ_QUIET_ON_SIG"):
print >> sys.stderr, "Interrupted by user"
sigbase_handler(signum, frame) | [
"def",
"sigint_handler",
"(",
"signum",
",",
"frame",
")",
":",
"global",
"_handled_int",
"if",
"not",
"_handled_int",
":",
"_handled_int",
"=",
"True",
"if",
"not",
"_env_var_true",
"(",
"\"_REZ_QUIET_ON_SIG\"",
")",
":",
"print",
">>",
"sys",
".",
"stderr",
... | Exit gracefully on ctrl-C. | [
"Exit",
"gracefully",
"on",
"ctrl",
"-",
"C",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/cli/_util.py#L141-L148 |
246,529 | nerdvegas/rez | src/rez/cli/_util.py | sigterm_handler | def sigterm_handler(signum, frame):
"""Exit gracefully on terminate."""
global _handled_term
if not _handled_term:
_handled_term = True
if not _env_var_true("_REZ_QUIET_ON_SIG"):
print >> sys.stderr, "Terminated by user"
sigbase_handler(signum, frame) | python | def sigterm_handler(signum, frame):
global _handled_term
if not _handled_term:
_handled_term = True
if not _env_var_true("_REZ_QUIET_ON_SIG"):
print >> sys.stderr, "Terminated by user"
sigbase_handler(signum, frame) | [
"def",
"sigterm_handler",
"(",
"signum",
",",
"frame",
")",
":",
"global",
"_handled_term",
"if",
"not",
"_handled_term",
":",
"_handled_term",
"=",
"True",
"if",
"not",
"_env_var_true",
"(",
"\"_REZ_QUIET_ON_SIG\"",
")",
":",
"print",
">>",
"sys",
".",
"stder... | Exit gracefully on terminate. | [
"Exit",
"gracefully",
"on",
"terminate",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/cli/_util.py#L151-L158 |
246,530 | nerdvegas/rez | src/rez/cli/_util.py | LazyArgumentParser.format_help | def format_help(self):
"""Sets up all sub-parsers when help is requested."""
if self._subparsers:
for action in self._subparsers._actions:
if isinstance(action, LazySubParsersAction):
for parser_name, parser in action._name_parser_map.iteritems():
... | python | def format_help(self):
if self._subparsers:
for action in self._subparsers._actions:
if isinstance(action, LazySubParsersAction):
for parser_name, parser in action._name_parser_map.iteritems():
action._setup_subparser(parser_name, parser)
... | [
"def",
"format_help",
"(",
"self",
")",
":",
"if",
"self",
".",
"_subparsers",
":",
"for",
"action",
"in",
"self",
".",
"_subparsers",
".",
"_actions",
":",
"if",
"isinstance",
"(",
"action",
",",
"LazySubParsersAction",
")",
":",
"for",
"parser_name",
","... | Sets up all sub-parsers when help is requested. | [
"Sets",
"up",
"all",
"sub",
"-",
"parsers",
"when",
"help",
"is",
"requested",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/cli/_util.py#L110-L117 |
246,531 | nerdvegas/rez | src/rez/utils/formatting.py | is_valid_package_name | def is_valid_package_name(name, raise_error=False):
"""Test the validity of a package name string.
Args:
name (str): Name to test.
raise_error (bool): If True, raise an exception on failure
Returns:
bool.
"""
is_valid = PACKAGE_NAME_REGEX.match(name)
if raise_error and ... | python | def is_valid_package_name(name, raise_error=False):
is_valid = PACKAGE_NAME_REGEX.match(name)
if raise_error and not is_valid:
raise PackageRequestError("Not a valid package name: %r" % name)
return is_valid | [
"def",
"is_valid_package_name",
"(",
"name",
",",
"raise_error",
"=",
"False",
")",
":",
"is_valid",
"=",
"PACKAGE_NAME_REGEX",
".",
"match",
"(",
"name",
")",
"if",
"raise_error",
"and",
"not",
"is_valid",
":",
"raise",
"PackageRequestError",
"(",
"\"Not a vali... | Test the validity of a package name string.
Args:
name (str): Name to test.
raise_error (bool): If True, raise an exception on failure
Returns:
bool. | [
"Test",
"the",
"validity",
"of",
"a",
"package",
"name",
"string",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L27-L40 |
246,532 | nerdvegas/rez | src/rez/utils/formatting.py | expand_abbreviations | def expand_abbreviations(txt, fields):
"""Expand abbreviations in a format string.
If an abbreviation does not match a field, or matches multiple fields, it
is left unchanged.
Example:
>>> fields = ("hey", "there", "dude")
>>> expand_abbreviations("hello {d}", fields)
'hello d... | python | def expand_abbreviations(txt, fields):
def _expand(matchobj):
s = matchobj.group("var")
if s not in fields:
matches = [x for x in fields if x.startswith(s)]
if len(matches) == 1:
s = matches[0]
return "{%s}" % s
return re.sub(FORMAT_VAR_REGEX, _exp... | [
"def",
"expand_abbreviations",
"(",
"txt",
",",
"fields",
")",
":",
"def",
"_expand",
"(",
"matchobj",
")",
":",
"s",
"=",
"matchobj",
".",
"group",
"(",
"\"var\"",
")",
"if",
"s",
"not",
"in",
"fields",
":",
"matches",
"=",
"[",
"x",
"for",
"x",
"... | Expand abbreviations in a format string.
If an abbreviation does not match a field, or matches multiple fields, it
is left unchanged.
Example:
>>> fields = ("hey", "there", "dude")
>>> expand_abbreviations("hello {d}", fields)
'hello dude'
Args:
txt (str): Format stri... | [
"Expand",
"abbreviations",
"in",
"a",
"format",
"string",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L174-L200 |
246,533 | nerdvegas/rez | src/rez/utils/formatting.py | dict_to_attributes_code | def dict_to_attributes_code(dict_):
"""Given a nested dict, generate a python code equivalent.
Example:
>>> d = {'foo': 'bah', 'colors': {'red': 1, 'blue': 2}}
>>> print dict_to_attributes_code(d)
foo = 'bah'
colors.red = 1
colors.blue = 2
Returns:
str.
... | python | def dict_to_attributes_code(dict_):
lines = []
for key, value in dict_.iteritems():
if isinstance(value, dict):
txt = dict_to_attributes_code(value)
lines_ = txt.split('\n')
for line in lines_:
if not line.startswith(' '):
line = "%... | [
"def",
"dict_to_attributes_code",
"(",
"dict_",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"dict_",
".",
"iteritems",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"txt",
"=",
"dict_to_attributes_code",
... | Given a nested dict, generate a python code equivalent.
Example:
>>> d = {'foo': 'bah', 'colors': {'red': 1, 'blue': 2}}
>>> print dict_to_attributes_code(d)
foo = 'bah'
colors.red = 1
colors.blue = 2
Returns:
str. | [
"Given",
"a",
"nested",
"dict",
"generate",
"a",
"python",
"code",
"equivalent",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L247-L279 |
246,534 | nerdvegas/rez | src/rez/utils/formatting.py | columnise | def columnise(rows, padding=2):
"""Print rows of entries in aligned columns."""
strs = []
maxwidths = {}
for row in rows:
for i, e in enumerate(row):
se = str(e)
nse = len(se)
w = maxwidths.get(i, -1)
if nse > w:
maxwidths[i] = nse... | python | def columnise(rows, padding=2):
strs = []
maxwidths = {}
for row in rows:
for i, e in enumerate(row):
se = str(e)
nse = len(se)
w = maxwidths.get(i, -1)
if nse > w:
maxwidths[i] = nse
for row in rows:
s = ''
for i,... | [
"def",
"columnise",
"(",
"rows",
",",
"padding",
"=",
"2",
")",
":",
"strs",
"=",
"[",
"]",
"maxwidths",
"=",
"{",
"}",
"for",
"row",
"in",
"rows",
":",
"for",
"i",
",",
"e",
"in",
"enumerate",
"(",
"row",
")",
":",
"se",
"=",
"str",
"(",
"e"... | Print rows of entries in aligned columns. | [
"Print",
"rows",
"of",
"entries",
"in",
"aligned",
"columns",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L282-L304 |
246,535 | nerdvegas/rez | src/rez/utils/formatting.py | print_colored_columns | def print_colored_columns(printer, rows, padding=2):
"""Like `columnise`, but with colored rows.
Args:
printer (`colorize.Printer`): Printer object.
Note:
The last entry in each row is the row color, or None for no coloring.
"""
rows_ = [x[:-1] for x in rows]
colors = [x[-1] fo... | python | def print_colored_columns(printer, rows, padding=2):
rows_ = [x[:-1] for x in rows]
colors = [x[-1] for x in rows]
for col, line in zip(colors, columnise(rows_, padding=padding)):
printer(line, col) | [
"def",
"print_colored_columns",
"(",
"printer",
",",
"rows",
",",
"padding",
"=",
"2",
")",
":",
"rows_",
"=",
"[",
"x",
"[",
":",
"-",
"1",
"]",
"for",
"x",
"in",
"rows",
"]",
"colors",
"=",
"[",
"x",
"[",
"-",
"1",
"]",
"for",
"x",
"in",
"r... | Like `columnise`, but with colored rows.
Args:
printer (`colorize.Printer`): Printer object.
Note:
The last entry in each row is the row color, or None for no coloring. | [
"Like",
"columnise",
"but",
"with",
"colored",
"rows",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L307-L319 |
246,536 | nerdvegas/rez | src/rez/utils/formatting.py | expanduser | def expanduser(path):
"""Expand '~' to home directory in the given string.
Note that this function deliberately differs from the builtin
os.path.expanduser() on Linux systems, which expands strings such as
'~sclaus' to that user's homedir. This is problematic in rez because the
string '~packagename... | python | def expanduser(path):
if '~' not in path:
return path
if os.name == "nt":
if 'HOME' in os.environ:
userhome = os.environ['HOME']
elif 'USERPROFILE' in os.environ:
userhome = os.environ['USERPROFILE']
elif 'HOMEPATH' in os.environ:
drive = os.e... | [
"def",
"expanduser",
"(",
"path",
")",
":",
"if",
"'~'",
"not",
"in",
"path",
":",
"return",
"path",
"if",
"os",
".",
"name",
"==",
"\"nt\"",
":",
"if",
"'HOME'",
"in",
"os",
".",
"environ",
":",
"userhome",
"=",
"os",
".",
"environ",
"[",
"'HOME'"... | Expand '~' to home directory in the given string.
Note that this function deliberately differs from the builtin
os.path.expanduser() on Linux systems, which expands strings such as
'~sclaus' to that user's homedir. This is problematic in rez because the
string '~packagename' may inadvertently convert t... | [
"Expand",
"~",
"to",
"home",
"directory",
"in",
"the",
"given",
"string",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L439-L473 |
246,537 | nerdvegas/rez | src/rez/utils/formatting.py | as_block_string | def as_block_string(txt):
"""Return a string formatted as a python block comment string, like the one
you're currently reading. Special characters are escaped if necessary.
"""
import json
lines = []
for line in txt.split('\n'):
line_ = json.dumps(line)
line_ = line_[1:-1].rstri... | python | def as_block_string(txt):
import json
lines = []
for line in txt.split('\n'):
line_ = json.dumps(line)
line_ = line_[1:-1].rstrip() # drop double quotes
lines.append(line_)
return '"""\n%s\n"""' % '\n'.join(lines) | [
"def",
"as_block_string",
"(",
"txt",
")",
":",
"import",
"json",
"lines",
"=",
"[",
"]",
"for",
"line",
"in",
"txt",
".",
"split",
"(",
"'\\n'",
")",
":",
"line_",
"=",
"json",
".",
"dumps",
"(",
"line",
")",
"line_",
"=",
"line_",
"[",
"1",
":"... | Return a string formatted as a python block comment string, like the one
you're currently reading. Special characters are escaped if necessary. | [
"Return",
"a",
"string",
"formatted",
"as",
"a",
"python",
"block",
"comment",
"string",
"like",
"the",
"one",
"you",
"re",
"currently",
"reading",
".",
"Special",
"characters",
"are",
"escaped",
"if",
"necessary",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L476-L488 |
246,538 | nerdvegas/rez | src/rez/utils/formatting.py | StringFormatMixin.format | def format(self, s, pretty=None, expand=None):
"""Format a string.
Args:
s (str): String to format, eg "hello {name}"
pretty (bool): If True, references to non-string attributes such as
lists are converted to basic form, with characters such as
br... | python | def format(self, s, pretty=None, expand=None):
if pretty is None:
pretty = self.format_pretty
if expand is None:
expand = self.format_expand
formatter = ObjectStringFormatter(self, pretty=pretty, expand=expand)
return formatter.format(s) | [
"def",
"format",
"(",
"self",
",",
"s",
",",
"pretty",
"=",
"None",
",",
"expand",
"=",
"None",
")",
":",
"if",
"pretty",
"is",
"None",
":",
"pretty",
"=",
"self",
".",
"format_pretty",
"if",
"expand",
"is",
"None",
":",
"expand",
"=",
"self",
".",... | Format a string.
Args:
s (str): String to format, eg "hello {name}"
pretty (bool): If True, references to non-string attributes such as
lists are converted to basic form, with characters such as
brackets and parenthesis removed. If None, defaults to the
... | [
"Format",
"a",
"string",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L150-L171 |
246,539 | nerdvegas/rez | src/rez/vendor/version/version.py | Version.copy | def copy(self):
"""Returns a copy of the version."""
other = Version(None)
other.tokens = self.tokens[:]
other.seps = self.seps[:]
return other | python | def copy(self):
other = Version(None)
other.tokens = self.tokens[:]
other.seps = self.seps[:]
return other | [
"def",
"copy",
"(",
"self",
")",
":",
"other",
"=",
"Version",
"(",
"None",
")",
"other",
".",
"tokens",
"=",
"self",
".",
"tokens",
"[",
":",
"]",
"other",
".",
"seps",
"=",
"self",
".",
"seps",
"[",
":",
"]",
"return",
"other"
] | Returns a copy of the version. | [
"Returns",
"a",
"copy",
"of",
"the",
"version",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L297-L302 |
246,540 | nerdvegas/rez | src/rez/vendor/version/version.py | Version.trim | def trim(self, len_):
"""Return a copy of the version, possibly with less tokens.
Args:
len_ (int): New version length. If >= current length, an
unchanged copy of the version is returned.
"""
other = Version(None)
other.tokens = self.tokens[:len_]
... | python | def trim(self, len_):
other = Version(None)
other.tokens = self.tokens[:len_]
other.seps = self.seps[:len_ - 1]
return other | [
"def",
"trim",
"(",
"self",
",",
"len_",
")",
":",
"other",
"=",
"Version",
"(",
"None",
")",
"other",
".",
"tokens",
"=",
"self",
".",
"tokens",
"[",
":",
"len_",
"]",
"other",
".",
"seps",
"=",
"self",
".",
"seps",
"[",
":",
"len_",
"-",
"1",... | Return a copy of the version, possibly with less tokens.
Args:
len_ (int): New version length. If >= current length, an
unchanged copy of the version is returned. | [
"Return",
"a",
"copy",
"of",
"the",
"version",
"possibly",
"with",
"less",
"tokens",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L304-L314 |
246,541 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.union | def union(self, other):
"""OR together version ranges.
Calculates the union of this range with one or more other ranges.
Args:
other: VersionRange object (or list of) to OR with.
Returns:
New VersionRange object representing the union.
"""
if no... | python | def union(self, other):
if not hasattr(other, "__iter__"):
other = [other]
bounds = self.bounds[:]
for range in other:
bounds += range.bounds
bounds = self._union(bounds)
range = VersionRange(None)
range.bounds = bounds
return range | [
"def",
"union",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"hasattr",
"(",
"other",
",",
"\"__iter__\"",
")",
":",
"other",
"=",
"[",
"other",
"]",
"bounds",
"=",
"self",
".",
"bounds",
"[",
":",
"]",
"for",
"range",
"in",
"other",
":",
"b... | OR together version ranges.
Calculates the union of this range with one or more other ranges.
Args:
other: VersionRange object (or list of) to OR with.
Returns:
New VersionRange object representing the union. | [
"OR",
"together",
"version",
"ranges",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L814-L834 |
246,542 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.intersection | def intersection(self, other):
"""AND together version ranges.
Calculates the intersection of this range with one or more other ranges.
Args:
other: VersionRange object (or list of) to AND with.
Returns:
New VersionRange object representing the intersection, or... | python | def intersection(self, other):
if not hasattr(other, "__iter__"):
other = [other]
bounds = self.bounds
for range in other:
bounds = self._intersection(bounds, range.bounds)
if not bounds:
return None
range = VersionRange(None)
... | [
"def",
"intersection",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"hasattr",
"(",
"other",
",",
"\"__iter__\"",
")",
":",
"other",
"=",
"[",
"other",
"]",
"bounds",
"=",
"self",
".",
"bounds",
"for",
"range",
"in",
"other",
":",
"bounds",
"=",... | AND together version ranges.
Calculates the intersection of this range with one or more other ranges.
Args:
other: VersionRange object (or list of) to AND with.
Returns:
New VersionRange object representing the intersection, or None if
no ranges intersect. | [
"AND",
"together",
"version",
"ranges",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L836-L859 |
246,543 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.inverse | def inverse(self):
"""Calculate the inverse of the range.
Returns:
New VersionRange object representing the inverse of this range, or
None if there is no inverse (ie, this range is the any range).
"""
if self.is_any():
return None
else:
... | python | def inverse(self):
if self.is_any():
return None
else:
bounds = self._inverse(self.bounds)
range = VersionRange(None)
range.bounds = bounds
return range | [
"def",
"inverse",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_any",
"(",
")",
":",
"return",
"None",
"else",
":",
"bounds",
"=",
"self",
".",
"_inverse",
"(",
"self",
".",
"bounds",
")",
"range",
"=",
"VersionRange",
"(",
"None",
")",
"range",
".... | Calculate the inverse of the range.
Returns:
New VersionRange object representing the inverse of this range, or
None if there is no inverse (ie, this range is the any range). | [
"Calculate",
"the",
"inverse",
"of",
"the",
"range",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L861-L874 |
246,544 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.split | def split(self):
"""Split into separate contiguous ranges.
Returns:
A list of VersionRange objects. For example, the range "3|5+" will
be split into ["3", "5+"].
"""
ranges = []
for bound in self.bounds:
range = VersionRange(None)
... | python | def split(self):
ranges = []
for bound in self.bounds:
range = VersionRange(None)
range.bounds = [bound]
ranges.append(range)
return ranges | [
"def",
"split",
"(",
"self",
")",
":",
"ranges",
"=",
"[",
"]",
"for",
"bound",
"in",
"self",
".",
"bounds",
":",
"range",
"=",
"VersionRange",
"(",
"None",
")",
"range",
".",
"bounds",
"=",
"[",
"bound",
"]",
"ranges",
".",
"append",
"(",
"range",... | Split into separate contiguous ranges.
Returns:
A list of VersionRange objects. For example, the range "3|5+" will
be split into ["3", "5+"]. | [
"Split",
"into",
"separate",
"contiguous",
"ranges",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L887-L899 |
246,545 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.as_span | def as_span(cls, lower_version=None, upper_version=None,
lower_inclusive=True, upper_inclusive=True):
"""Create a range from lower_version..upper_version.
Args:
lower_version: Version object representing lower bound of the range.
upper_version: Version object rep... | python | def as_span(cls, lower_version=None, upper_version=None,
lower_inclusive=True, upper_inclusive=True):
lower = (None if lower_version is None
else _LowerBound(lower_version, lower_inclusive))
upper = (None if upper_version is None
else _UpperBound(upper_v... | [
"def",
"as_span",
"(",
"cls",
",",
"lower_version",
"=",
"None",
",",
"upper_version",
"=",
"None",
",",
"lower_inclusive",
"=",
"True",
",",
"upper_inclusive",
"=",
"True",
")",
":",
"lower",
"=",
"(",
"None",
"if",
"lower_version",
"is",
"None",
"else",
... | Create a range from lower_version..upper_version.
Args:
lower_version: Version object representing lower bound of the range.
upper_version: Version object representing upper bound of the range.
Returns:
`VersionRange` object. | [
"Create",
"a",
"range",
"from",
"lower_version",
"..",
"upper_version",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L902-L921 |
246,546 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.from_version | def from_version(cls, version, op=None):
"""Create a range from a version.
Args:
version: Version object. This is used as the upper/lower bound of
the range.
op: Operation as a string. One of 'gt'/'>', 'gte'/'>=', lt'/'<',
'lte'/'<=', 'eq'/'=='. I... | python | def from_version(cls, version, op=None):
lower = None
upper = None
if op is None:
lower = _LowerBound(version, True)
upper = _UpperBound(version.next(), False)
elif op in ("eq", "=="):
lower = _LowerBound(version, True)
upper = _UpperBound... | [
"def",
"from_version",
"(",
"cls",
",",
"version",
",",
"op",
"=",
"None",
")",
":",
"lower",
"=",
"None",
"upper",
"=",
"None",
"if",
"op",
"is",
"None",
":",
"lower",
"=",
"_LowerBound",
"(",
"version",
",",
"True",
")",
"upper",
"=",
"_UpperBound"... | Create a range from a version.
Args:
version: Version object. This is used as the upper/lower bound of
the range.
op: Operation as a string. One of 'gt'/'>', 'gte'/'>=', lt'/'<',
'lte'/'<=', 'eq'/'=='. If None, a bounded range will be created
... | [
"Create",
"a",
"range",
"from",
"a",
"version",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L924-L960 |
246,547 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.from_versions | def from_versions(cls, versions):
"""Create a range from a list of versions.
This method creates a range that contains only the given versions and
no other. Typically the range looks like (for eg) "==3|==4|==5.1".
Args:
versions: List of Version objects.
Returns:
... | python | def from_versions(cls, versions):
range = cls(None)
range.bounds = []
for version in dedup(sorted(versions)):
lower = _LowerBound(version, True)
upper = _UpperBound(version, True)
bound = _Bound(lower, upper)
range.bounds.append(bound)
retu... | [
"def",
"from_versions",
"(",
"cls",
",",
"versions",
")",
":",
"range",
"=",
"cls",
"(",
"None",
")",
"range",
".",
"bounds",
"=",
"[",
"]",
"for",
"version",
"in",
"dedup",
"(",
"sorted",
"(",
"versions",
")",
")",
":",
"lower",
"=",
"_LowerBound",
... | Create a range from a list of versions.
This method creates a range that contains only the given versions and
no other. Typically the range looks like (for eg) "==3|==4|==5.1".
Args:
versions: List of Version objects.
Returns:
`VersionRange` object. | [
"Create",
"a",
"range",
"from",
"a",
"list",
"of",
"versions",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L963-L982 |
246,548 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.to_versions | def to_versions(self):
"""Returns exact version ranges as Version objects, or None if there
are no exact version ranges present.
"""
versions = []
for bound in self.bounds:
if bound.lower.inclusive and bound.upper.inclusive \
and (bound.lower.versi... | python | def to_versions(self):
versions = []
for bound in self.bounds:
if bound.lower.inclusive and bound.upper.inclusive \
and (bound.lower.version == bound.upper.version):
versions.append(bound.lower.version)
return versions or None | [
"def",
"to_versions",
"(",
"self",
")",
":",
"versions",
"=",
"[",
"]",
"for",
"bound",
"in",
"self",
".",
"bounds",
":",
"if",
"bound",
".",
"lower",
".",
"inclusive",
"and",
"bound",
".",
"upper",
".",
"inclusive",
"and",
"(",
"bound",
".",
"lower"... | Returns exact version ranges as Version objects, or None if there
are no exact version ranges present. | [
"Returns",
"exact",
"version",
"ranges",
"as",
"Version",
"objects",
"or",
"None",
"if",
"there",
"are",
"no",
"exact",
"version",
"ranges",
"present",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L984-L994 |
246,549 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.contains_version | def contains_version(self, version):
"""Returns True if version is contained in this range."""
if len(self.bounds) < 5:
# not worth overhead of binary search
for bound in self.bounds:
i = bound.version_containment(version)
if i == 0:
... | python | def contains_version(self, version):
if len(self.bounds) < 5:
# not worth overhead of binary search
for bound in self.bounds:
i = bound.version_containment(version)
if i == 0:
return True
if i == -1:
... | [
"def",
"contains_version",
"(",
"self",
",",
"version",
")",
":",
"if",
"len",
"(",
"self",
".",
"bounds",
")",
"<",
"5",
":",
"# not worth overhead of binary search",
"for",
"bound",
"in",
"self",
".",
"bounds",
":",
"i",
"=",
"bound",
".",
"version_conta... | Returns True if version is contained in this range. | [
"Returns",
"True",
"if",
"version",
"is",
"contained",
"in",
"this",
"range",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L996-L1010 |
246,550 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.iter_intersecting | def iter_intersecting(self, iterable, key=None, descending=False):
"""Like `iter_intersect_test`, but returns intersections only.
Returns:
An iterator that returns items from `iterable` that intersect.
"""
return _ContainsVersionIterator(self, iterable, key, descending,
... | python | def iter_intersecting(self, iterable, key=None, descending=False):
return _ContainsVersionIterator(self, iterable, key, descending,
mode=_ContainsVersionIterator.MODE_INTERSECTING) | [
"def",
"iter_intersecting",
"(",
"self",
",",
"iterable",
",",
"key",
"=",
"None",
",",
"descending",
"=",
"False",
")",
":",
"return",
"_ContainsVersionIterator",
"(",
"self",
",",
"iterable",
",",
"key",
",",
"descending",
",",
"mode",
"=",
"_ContainsVersi... | Like `iter_intersect_test`, but returns intersections only.
Returns:
An iterator that returns items from `iterable` that intersect. | [
"Like",
"iter_intersect_test",
"but",
"returns",
"intersections",
"only",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L1033-L1040 |
246,551 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.iter_non_intersecting | def iter_non_intersecting(self, iterable, key=None, descending=False):
"""Like `iter_intersect_test`, but returns non-intersections only.
Returns:
An iterator that returns items from `iterable` that don't intersect.
"""
return _ContainsVersionIterator(self, iterable, key, de... | python | def iter_non_intersecting(self, iterable, key=None, descending=False):
return _ContainsVersionIterator(self, iterable, key, descending,
mode=_ContainsVersionIterator.MODE_NON_INTERSECTING) | [
"def",
"iter_non_intersecting",
"(",
"self",
",",
"iterable",
",",
"key",
"=",
"None",
",",
"descending",
"=",
"False",
")",
":",
"return",
"_ContainsVersionIterator",
"(",
"self",
",",
"iterable",
",",
"key",
",",
"descending",
",",
"mode",
"=",
"_ContainsV... | Like `iter_intersect_test`, but returns non-intersections only.
Returns:
An iterator that returns items from `iterable` that don't intersect. | [
"Like",
"iter_intersect_test",
"but",
"returns",
"non",
"-",
"intersections",
"only",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L1042-L1049 |
246,552 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.span | def span(self):
"""Return a contiguous range that is a superset of this range.
Returns:
A VersionRange object representing the span of this range. For
example, the span of "2+<4|6+<8" would be "2+<8".
"""
other = VersionRange(None)
bound = _Bound(self.bou... | python | def span(self):
other = VersionRange(None)
bound = _Bound(self.bounds[0].lower, self.bounds[-1].upper)
other.bounds = [bound]
return other | [
"def",
"span",
"(",
"self",
")",
":",
"other",
"=",
"VersionRange",
"(",
"None",
")",
"bound",
"=",
"_Bound",
"(",
"self",
".",
"bounds",
"[",
"0",
"]",
".",
"lower",
",",
"self",
".",
"bounds",
"[",
"-",
"1",
"]",
".",
"upper",
")",
"other",
"... | Return a contiguous range that is a superset of this range.
Returns:
A VersionRange object representing the span of this range. For
example, the span of "2+<4|6+<8" would be "2+<8". | [
"Return",
"a",
"contiguous",
"range",
"that",
"is",
"a",
"superset",
"of",
"this",
"range",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L1051-L1061 |
246,553 | nerdvegas/rez | src/rez/vendor/version/version.py | VersionRange.visit_versions | def visit_versions(self, func):
"""Visit each version in the range, and apply a function to each.
This is for advanced usage only.
If `func` returns a `Version`, this call will change the versions in
place.
It is possible to change versions in a way that is nonsensical - for
... | python | def visit_versions(self, func):
for bound in self.bounds:
if bound.lower is not _LowerBound.min:
result = func(bound.lower.version)
if isinstance(result, Version):
bound.lower.version = result
if bound.upper is not _UpperBound.inf:
... | [
"def",
"visit_versions",
"(",
"self",
",",
"func",
")",
":",
"for",
"bound",
"in",
"self",
".",
"bounds",
":",
"if",
"bound",
".",
"lower",
"is",
"not",
"_LowerBound",
".",
"min",
":",
"result",
"=",
"func",
"(",
"bound",
".",
"lower",
".",
"version"... | Visit each version in the range, and apply a function to each.
This is for advanced usage only.
If `func` returns a `Version`, this call will change the versions in
place.
It is possible to change versions in a way that is nonsensical - for
example setting an upper bound to a ... | [
"Visit",
"each",
"version",
"in",
"the",
"range",
"and",
"apply",
"a",
"function",
"to",
"each",
"."
] | 1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7 | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L1065-L1092 |
246,554 | getsentry/raven-python | raven/transport/http.py | HTTPTransport.send | def send(self, url, data, headers):
"""
Sends a request to a remote webserver using HTTP POST.
"""
req = urllib2.Request(url, headers=headers)
try:
response = urlopen(
url=req,
data=data,
timeout=self.timeout,
... | python | def send(self, url, data, headers):
req = urllib2.Request(url, headers=headers)
try:
response = urlopen(
url=req,
data=data,
timeout=self.timeout,
verify_ssl=self.verify_ssl,
ca_certs=self.ca_certs,
... | [
"def",
"send",
"(",
"self",
",",
"url",
",",
"data",
",",
"headers",
")",
":",
"req",
"=",
"urllib2",
".",
"Request",
"(",
"url",
",",
"headers",
"=",
"headers",
")",
"try",
":",
"response",
"=",
"urlopen",
"(",
"url",
"=",
"req",
",",
"data",
"=... | Sends a request to a remote webserver using HTTP POST. | [
"Sends",
"a",
"request",
"to",
"a",
"remote",
"webserver",
"using",
"HTTP",
"POST",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/transport/http.py#L31-L58 |
246,555 | getsentry/raven-python | raven/contrib/django/views.py | extract_auth_vars | def extract_auth_vars(request):
"""
raven-js will pass both Authorization and X-Sentry-Auth depending on the browser
and server configurations.
"""
if request.META.get('HTTP_X_SENTRY_AUTH', '').startswith('Sentry'):
return request.META['HTTP_X_SENTRY_AUTH']
elif request.META.get('HTTP_AU... | python | def extract_auth_vars(request):
if request.META.get('HTTP_X_SENTRY_AUTH', '').startswith('Sentry'):
return request.META['HTTP_X_SENTRY_AUTH']
elif request.META.get('HTTP_AUTHORIZATION', '').startswith('Sentry'):
return request.META['HTTP_AUTHORIZATION']
else:
# Try to construct from ... | [
"def",
"extract_auth_vars",
"(",
"request",
")",
":",
"if",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_SENTRY_AUTH'",
",",
"''",
")",
".",
"startswith",
"(",
"'Sentry'",
")",
":",
"return",
"request",
".",
"META",
"[",
"'HTTP_X_SENTRY_AUTH'",
"]",
"... | raven-js will pass both Authorization and X-Sentry-Auth depending on the browser
and server configurations. | [
"raven",
"-",
"js",
"will",
"pass",
"both",
"Authorization",
"and",
"X",
"-",
"Sentry",
"-",
"Auth",
"depending",
"on",
"the",
"browser",
"and",
"server",
"configurations",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/django/views.py#L61-L79 |
246,556 | getsentry/raven-python | raven/events.py | Exception._get_value | def _get_value(self, exc_type, exc_value, exc_traceback):
"""
Convert exception info to a value for the values list.
"""
stack_info = get_stack_info(
iter_traceback_frames(exc_traceback),
transformer=self.transform,
capture_locals=self.client.capture_l... | python | def _get_value(self, exc_type, exc_value, exc_traceback):
stack_info = get_stack_info(
iter_traceback_frames(exc_traceback),
transformer=self.transform,
capture_locals=self.client.capture_locals,
)
exc_module = getattr(exc_type, '__module__', None)
if... | [
"def",
"_get_value",
"(",
"self",
",",
"exc_type",
",",
"exc_value",
",",
"exc_traceback",
")",
":",
"stack_info",
"=",
"get_stack_info",
"(",
"iter_traceback_frames",
"(",
"exc_traceback",
")",
",",
"transformer",
"=",
"self",
".",
"transform",
",",
"capture_lo... | Convert exception info to a value for the values list. | [
"Convert",
"exception",
"info",
"to",
"a",
"value",
"for",
"the",
"values",
"list",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/events.py#L90-L110 |
246,557 | getsentry/raven-python | raven/breadcrumbs.py | record | def record(message=None, timestamp=None, level=None, category=None,
data=None, type=None, processor=None):
"""Records a breadcrumb for all active clients. This is what integration
code should use rather than invoking the `captureBreadcrumb` method
on a specific client.
"""
if timestamp i... | python | def record(message=None, timestamp=None, level=None, category=None,
data=None, type=None, processor=None):
if timestamp is None:
timestamp = time()
for ctx in raven.context.get_active_contexts():
ctx.breadcrumbs.record(timestamp, level, message, category,
... | [
"def",
"record",
"(",
"message",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"level",
"=",
"None",
",",
"category",
"=",
"None",
",",
"data",
"=",
"None",
",",
"type",
"=",
"None",
",",
"processor",
"=",
"None",
")",
":",
"if",
"timestamp",
"i... | Records a breadcrumb for all active clients. This is what integration
code should use rather than invoking the `captureBreadcrumb` method
on a specific client. | [
"Records",
"a",
"breadcrumb",
"for",
"all",
"active",
"clients",
".",
"This",
"is",
"what",
"integration",
"code",
"should",
"use",
"rather",
"than",
"invoking",
"the",
"captureBreadcrumb",
"method",
"on",
"a",
"specific",
"client",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/breadcrumbs.py#L116-L126 |
246,558 | getsentry/raven-python | raven/breadcrumbs.py | ignore_logger | def ignore_logger(name_or_logger, allow_level=None):
"""Ignores a logger during breadcrumb recording.
"""
def handler(logger, level, msg, args, kwargs):
if allow_level is not None and \
level >= allow_level:
return False
return True
register_special_log_handler(nam... | python | def ignore_logger(name_or_logger, allow_level=None):
def handler(logger, level, msg, args, kwargs):
if allow_level is not None and \
level >= allow_level:
return False
return True
register_special_log_handler(name_or_logger, handler) | [
"def",
"ignore_logger",
"(",
"name_or_logger",
",",
"allow_level",
"=",
"None",
")",
":",
"def",
"handler",
"(",
"logger",
",",
"level",
",",
"msg",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"allow_level",
"is",
"not",
"None",
"and",
"level",
">=",
"... | Ignores a logger during breadcrumb recording. | [
"Ignores",
"a",
"logger",
"during",
"breadcrumb",
"recording",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/breadcrumbs.py#L275-L283 |
246,559 | getsentry/raven-python | raven/utils/serializer/manager.py | Serializer.transform | def transform(self, value, **kwargs):
"""
Primary function which handles recursively transforming
values via their serializers
"""
if value is None:
return None
objid = id(value)
if objid in self.context:
return '<...>'
self.contex... | python | def transform(self, value, **kwargs):
if value is None:
return None
objid = id(value)
if objid in self.context:
return '<...>'
self.context.add(objid)
try:
for serializer in self.serializers:
try:
if serial... | [
"def",
"transform",
"(",
"self",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"objid",
"=",
"id",
"(",
"value",
")",
"if",
"objid",
"in",
"self",
".",
"context",
":",
"return",
"'<...>'",
"sel... | Primary function which handles recursively transforming
values via their serializers | [
"Primary",
"function",
"which",
"handles",
"recursively",
"transforming",
"values",
"via",
"their",
"serializers"
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/utils/serializer/manager.py#L52-L85 |
246,560 | getsentry/raven-python | raven/contrib/tornado/__init__.py | AsyncSentryClient.send | def send(self, auth_header=None, callback=None, **data):
"""
Serializes the message and passes the payload onto ``send_encoded``.
"""
message = self.encode(data)
return self.send_encoded(message, auth_header=auth_header, callback=callback) | python | def send(self, auth_header=None, callback=None, **data):
message = self.encode(data)
return self.send_encoded(message, auth_header=auth_header, callback=callback) | [
"def",
"send",
"(",
"self",
",",
"auth_header",
"=",
"None",
",",
"callback",
"=",
"None",
",",
"*",
"*",
"data",
")",
":",
"message",
"=",
"self",
".",
"encode",
"(",
"data",
")",
"return",
"self",
".",
"send_encoded",
"(",
"message",
",",
"auth_hea... | Serializes the message and passes the payload onto ``send_encoded``. | [
"Serializes",
"the",
"message",
"and",
"passes",
"the",
"payload",
"onto",
"send_encoded",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/tornado/__init__.py#L47-L53 |
246,561 | getsentry/raven-python | raven/contrib/tornado/__init__.py | AsyncSentryClient._send_remote | def _send_remote(self, url, data, headers=None, callback=None):
"""
Initialise a Tornado AsyncClient and send the request to the sentry
server. If the callback is a callable, it will be called with the
response.
"""
if headers is None:
headers = {}
re... | python | def _send_remote(self, url, data, headers=None, callback=None):
if headers is None:
headers = {}
return AsyncHTTPClient().fetch(
url, callback, method="POST", body=data, headers=headers,
validate_cert=self.validate_cert
) | [
"def",
"_send_remote",
"(",
"self",
",",
"url",
",",
"data",
",",
"headers",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"{",
"}",
"return",
"AsyncHTTPClient",
"(",
")",
".",
"fetch",
"(",
... | Initialise a Tornado AsyncClient and send the request to the sentry
server. If the callback is a callable, it will be called with the
response. | [
"Initialise",
"a",
"Tornado",
"AsyncClient",
"and",
"send",
"the",
"request",
"to",
"the",
"sentry",
"server",
".",
"If",
"the",
"callback",
"is",
"a",
"callable",
"it",
"will",
"be",
"called",
"with",
"the",
"response",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/tornado/__init__.py#L82-L94 |
246,562 | getsentry/raven-python | raven/contrib/tornado/__init__.py | SentryMixin.get_sentry_data_from_request | def get_sentry_data_from_request(self):
"""
Extracts the data required for 'sentry.interfaces.Http' from the
current request being handled by the request handler
:param return: A dictionary.
"""
return {
'request': {
'url': self.request.full_u... | python | def get_sentry_data_from_request(self):
return {
'request': {
'url': self.request.full_url(),
'method': self.request.method,
'data': self.request.body,
'query_string': self.request.query,
'cookies': self.request.headers.... | [
"def",
"get_sentry_data_from_request",
"(",
"self",
")",
":",
"return",
"{",
"'request'",
":",
"{",
"'url'",
":",
"self",
".",
"request",
".",
"full_url",
"(",
")",
",",
"'method'",
":",
"self",
".",
"request",
".",
"method",
",",
"'data'",
":",
"self",
... | Extracts the data required for 'sentry.interfaces.Http' from the
current request being handled by the request handler
:param return: A dictionary. | [
"Extracts",
"the",
"data",
"required",
"for",
"sentry",
".",
"interfaces",
".",
"Http",
"from",
"the",
"current",
"request",
"being",
"handled",
"by",
"the",
"request",
"handler"
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/tornado/__init__.py#L147-L163 |
246,563 | getsentry/raven-python | raven/base.py | Client.get_public_dsn | def get_public_dsn(self, scheme=None):
"""
Returns a public DSN which is consumable by raven-js
>>> # Return scheme-less DSN
>>> print client.get_public_dsn()
>>> # Specify a scheme to use (http or https)
>>> print client.get_public_dsn('https')
"""
if s... | python | def get_public_dsn(self, scheme=None):
if self.is_enabled():
url = self.remote.get_public_dsn()
if scheme:
return '%s:%s' % (scheme, url)
return url | [
"def",
"get_public_dsn",
"(",
"self",
",",
"scheme",
"=",
"None",
")",
":",
"if",
"self",
".",
"is_enabled",
"(",
")",
":",
"url",
"=",
"self",
".",
"remote",
".",
"get_public_dsn",
"(",
")",
"if",
"scheme",
":",
"return",
"'%s:%s'",
"%",
"(",
"schem... | Returns a public DSN which is consumable by raven-js
>>> # Return scheme-less DSN
>>> print client.get_public_dsn()
>>> # Specify a scheme to use (http or https)
>>> print client.get_public_dsn('https') | [
"Returns",
"a",
"public",
"DSN",
"which",
"is",
"consumable",
"by",
"raven",
"-",
"js"
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L330-L345 |
246,564 | getsentry/raven-python | raven/base.py | Client.capture | def capture(self, event_type, data=None, date=None, time_spent=None,
extra=None, stack=None, tags=None, sample_rate=None,
**kwargs):
"""
Captures and processes an event and pipes it off to SentryClient.send.
To use structured data (interfaces) with capture:
... | python | def capture(self, event_type, data=None, date=None, time_spent=None,
extra=None, stack=None, tags=None, sample_rate=None,
**kwargs):
if not self.is_enabled():
return
exc_info = kwargs.get('exc_info')
if exc_info is not None:
if self.skip_e... | [
"def",
"capture",
"(",
"self",
",",
"event_type",
",",
"data",
"=",
"None",
",",
"date",
"=",
"None",
",",
"time_spent",
"=",
"None",
",",
"extra",
"=",
"None",
",",
"stack",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"sample_rate",
"=",
"None",
"... | Captures and processes an event and pipes it off to SentryClient.send.
To use structured data (interfaces) with capture:
>>> capture('raven.events.Message', message='foo', data={
>>> 'request': {
>>> 'url': '...',
>>> 'data': {},
>>> 'query_s... | [
"Captures",
"and",
"processes",
"an",
"event",
"and",
"pipes",
"it",
"off",
"to",
"SentryClient",
".",
"send",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L577-L657 |
246,565 | getsentry/raven-python | raven/base.py | Client._log_failed_submission | def _log_failed_submission(self, data):
"""
Log a reasonable representation of an event that should have been sent
to Sentry
"""
message = data.pop('message', '<no message value>')
output = [message]
if 'exception' in data and 'stacktrace' in data['exception']['va... | python | def _log_failed_submission(self, data):
message = data.pop('message', '<no message value>')
output = [message]
if 'exception' in data and 'stacktrace' in data['exception']['values'][-1]:
# try to reconstruct a reasonable version of the exception
for frame in data['excepti... | [
"def",
"_log_failed_submission",
"(",
"self",
",",
"data",
")",
":",
"message",
"=",
"data",
".",
"pop",
"(",
"'message'",
",",
"'<no message value>'",
")",
"output",
"=",
"[",
"message",
"]",
"if",
"'exception'",
"in",
"data",
"and",
"'stacktrace'",
"in",
... | Log a reasonable representation of an event that should have been sent
to Sentry | [
"Log",
"a",
"reasonable",
"representation",
"of",
"an",
"event",
"that",
"should",
"have",
"been",
"sent",
"to",
"Sentry"
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L696-L712 |
246,566 | getsentry/raven-python | raven/base.py | Client.send_encoded | def send_encoded(self, message, auth_header=None, **kwargs):
"""
Given an already serialized message, signs the message and passes the
payload off to ``send_remote``.
"""
client_string = 'raven-python/%s' % (raven.VERSION,)
if not auth_header:
timestamp = tim... | python | def send_encoded(self, message, auth_header=None, **kwargs):
client_string = 'raven-python/%s' % (raven.VERSION,)
if not auth_header:
timestamp = time.time()
auth_header = get_auth_header(
protocol=self.protocol_version,
timestamp=timestamp,
... | [
"def",
"send_encoded",
"(",
"self",
",",
"message",
",",
"auth_header",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"client_string",
"=",
"'raven-python/%s'",
"%",
"(",
"raven",
".",
"VERSION",
",",
")",
"if",
"not",
"auth_header",
":",
"timestamp",
... | Given an already serialized message, signs the message and passes the
payload off to ``send_remote``. | [
"Given",
"an",
"already",
"serialized",
"message",
"signs",
"the",
"message",
"and",
"passes",
"the",
"payload",
"off",
"to",
"send_remote",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L752-L781 |
246,567 | getsentry/raven-python | raven/base.py | Client.captureQuery | def captureQuery(self, query, params=(), engine=None, **kwargs):
"""
Creates an event for a SQL query.
>>> client.captureQuery('SELECT * FROM foo')
"""
return self.capture(
'raven.events.Query', query=query, params=params, engine=engine,
**kwargs) | python | def captureQuery(self, query, params=(), engine=None, **kwargs):
return self.capture(
'raven.events.Query', query=query, params=params, engine=engine,
**kwargs) | [
"def",
"captureQuery",
"(",
"self",
",",
"query",
",",
"params",
"=",
"(",
")",
",",
"engine",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"capture",
"(",
"'raven.events.Query'",
",",
"query",
"=",
"query",
",",
"params",
"... | Creates an event for a SQL query.
>>> client.captureQuery('SELECT * FROM foo') | [
"Creates",
"an",
"event",
"for",
"a",
"SQL",
"query",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L892-L900 |
246,568 | getsentry/raven-python | raven/base.py | Client.captureBreadcrumb | def captureBreadcrumb(self, *args, **kwargs):
"""
Records a breadcrumb with the current context. They will be
sent with the next event.
"""
# Note: framework integration should not call this method but
# instead use the raven.breadcrumbs.record_breadcrumb function
... | python | def captureBreadcrumb(self, *args, **kwargs):
# Note: framework integration should not call this method but
# instead use the raven.breadcrumbs.record_breadcrumb function
# which will record to the correct client automatically.
self.context.breadcrumbs.record(*args, **kwargs) | [
"def",
"captureBreadcrumb",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Note: framework integration should not call this method but",
"# instead use the raven.breadcrumbs.record_breadcrumb function",
"# which will record to the correct client automatically.",
... | Records a breadcrumb with the current context. They will be
sent with the next event. | [
"Records",
"a",
"breadcrumb",
"with",
"the",
"current",
"context",
".",
"They",
"will",
"be",
"sent",
"with",
"the",
"next",
"event",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L908-L916 |
246,569 | getsentry/raven-python | raven/transport/registry.py | TransportRegistry.register_scheme | def register_scheme(self, scheme, cls):
"""
It is possible to inject new schemes at runtime
"""
if scheme in self._schemes:
raise DuplicateScheme()
urlparse.register_scheme(scheme)
# TODO (vng): verify the interface of the new class
self._schemes[sche... | python | def register_scheme(self, scheme, cls):
if scheme in self._schemes:
raise DuplicateScheme()
urlparse.register_scheme(scheme)
# TODO (vng): verify the interface of the new class
self._schemes[scheme] = cls | [
"def",
"register_scheme",
"(",
"self",
",",
"scheme",
",",
"cls",
")",
":",
"if",
"scheme",
"in",
"self",
".",
"_schemes",
":",
"raise",
"DuplicateScheme",
"(",
")",
"urlparse",
".",
"register_scheme",
"(",
"scheme",
")",
"# TODO (vng): verify the interface of t... | It is possible to inject new schemes at runtime | [
"It",
"is",
"possible",
"to",
"inject",
"new",
"schemes",
"at",
"runtime"
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/transport/registry.py#L40-L49 |
246,570 | getsentry/raven-python | raven/contrib/flask.py | Sentry.get_http_info | def get_http_info(self, request):
"""
Determine how to retrieve actual data by using request.mimetype.
"""
if self.is_json_type(request.mimetype):
retriever = self.get_json_data
else:
retriever = self.get_form_data
return self.get_http_info_with_re... | python | def get_http_info(self, request):
if self.is_json_type(request.mimetype):
retriever = self.get_json_data
else:
retriever = self.get_form_data
return self.get_http_info_with_retriever(request, retriever) | [
"def",
"get_http_info",
"(",
"self",
",",
"request",
")",
":",
"if",
"self",
".",
"is_json_type",
"(",
"request",
".",
"mimetype",
")",
":",
"retriever",
"=",
"self",
".",
"get_json_data",
"else",
":",
"retriever",
"=",
"self",
".",
"get_form_data",
"retur... | Determine how to retrieve actual data by using request.mimetype. | [
"Determine",
"how",
"to",
"retrieve",
"actual",
"data",
"by",
"using",
"request",
".",
"mimetype",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/flask.py#L194-L202 |
246,571 | getsentry/raven-python | raven/conf/__init__.py | setup_logging | def setup_logging(handler, exclude=EXCLUDE_LOGGER_DEFAULTS):
"""
Configures logging to pipe to Sentry.
- ``exclude`` is a list of loggers that shouldn't go to Sentry.
For a typical Python install:
>>> from raven.handlers.logging import SentryHandler
>>> client = Sentry(...)
>>> setup_logg... | python | def setup_logging(handler, exclude=EXCLUDE_LOGGER_DEFAULTS):
logger = logging.getLogger()
if handler.__class__ in map(type, logger.handlers):
return False
logger.addHandler(handler)
# Add StreamHandler to sentry's default so you can catch missed exceptions
for logger_name in exclude:
... | [
"def",
"setup_logging",
"(",
"handler",
",",
"exclude",
"=",
"EXCLUDE_LOGGER_DEFAULTS",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"if",
"handler",
".",
"__class__",
"in",
"map",
"(",
"type",
",",
"logger",
".",
"handlers",
")",
":",
... | Configures logging to pipe to Sentry.
- ``exclude`` is a list of loggers that shouldn't go to Sentry.
For a typical Python install:
>>> from raven.handlers.logging import SentryHandler
>>> client = Sentry(...)
>>> setup_logging(SentryHandler(client))
Within Django:
>>> from raven.contri... | [
"Configures",
"logging",
"to",
"pipe",
"to",
"Sentry",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/conf/__init__.py#L26-L57 |
246,572 | getsentry/raven-python | raven/utils/stacks.py | to_dict | def to_dict(dictish):
"""
Given something that closely resembles a dictionary, we attempt
to coerce it into a propery dictionary.
"""
if hasattr(dictish, 'iterkeys'):
m = dictish.iterkeys
elif hasattr(dictish, 'keys'):
m = dictish.keys
else:
raise ValueError(dictish)
... | python | def to_dict(dictish):
if hasattr(dictish, 'iterkeys'):
m = dictish.iterkeys
elif hasattr(dictish, 'keys'):
m = dictish.keys
else:
raise ValueError(dictish)
return dict((k, dictish[k]) for k in m()) | [
"def",
"to_dict",
"(",
"dictish",
")",
":",
"if",
"hasattr",
"(",
"dictish",
",",
"'iterkeys'",
")",
":",
"m",
"=",
"dictish",
".",
"iterkeys",
"elif",
"hasattr",
"(",
"dictish",
",",
"'keys'",
")",
":",
"m",
"=",
"dictish",
".",
"keys",
"else",
":",... | Given something that closely resembles a dictionary, we attempt
to coerce it into a propery dictionary. | [
"Given",
"something",
"that",
"closely",
"resembles",
"a",
"dictionary",
"we",
"attempt",
"to",
"coerce",
"it",
"into",
"a",
"propery",
"dictionary",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/utils/stacks.py#L96-L108 |
246,573 | getsentry/raven-python | raven/utils/stacks.py | slim_frame_data | def slim_frame_data(frames, frame_allowance=25):
"""
Removes various excess metadata from middle frames which go beyond
``frame_allowance``.
Returns ``frames``.
"""
frames_len = 0
app_frames = []
system_frames = []
for frame in frames:
frames_len += 1
if frame.get('i... | python | def slim_frame_data(frames, frame_allowance=25):
frames_len = 0
app_frames = []
system_frames = []
for frame in frames:
frames_len += 1
if frame.get('in_app'):
app_frames.append(frame)
else:
system_frames.append(frame)
if frames_len <= frame_allowance... | [
"def",
"slim_frame_data",
"(",
"frames",
",",
"frame_allowance",
"=",
"25",
")",
":",
"frames_len",
"=",
"0",
"app_frames",
"=",
"[",
"]",
"system_frames",
"=",
"[",
"]",
"for",
"frame",
"in",
"frames",
":",
"frames_len",
"+=",
"1",
"if",
"frame",
".",
... | Removes various excess metadata from middle frames which go beyond
``frame_allowance``.
Returns ``frames``. | [
"Removes",
"various",
"excess",
"metadata",
"from",
"middle",
"frames",
"which",
"go",
"beyond",
"frame_allowance",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/utils/stacks.py#L167-L215 |
246,574 | getsentry/raven-python | raven/contrib/webpy/utils.py | get_data_from_request | def get_data_from_request():
"""Returns request data extracted from web.ctx."""
return {
'request': {
'url': '%s://%s%s' % (web.ctx['protocol'], web.ctx['host'], web.ctx['path']),
'query_string': web.ctx.query,
'method': web.ctx.method,
'data': web.data(),... | python | def get_data_from_request():
return {
'request': {
'url': '%s://%s%s' % (web.ctx['protocol'], web.ctx['host'], web.ctx['path']),
'query_string': web.ctx.query,
'method': web.ctx.method,
'data': web.data(),
'headers': dict(get_headers(web.ctx.enviro... | [
"def",
"get_data_from_request",
"(",
")",
":",
"return",
"{",
"'request'",
":",
"{",
"'url'",
":",
"'%s://%s%s'",
"%",
"(",
"web",
".",
"ctx",
"[",
"'protocol'",
"]",
",",
"web",
".",
"ctx",
"[",
"'host'",
"]",
",",
"web",
".",
"ctx",
"[",
"'path'",
... | Returns request data extracted from web.ctx. | [
"Returns",
"request",
"data",
"extracted",
"from",
"web",
".",
"ctx",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/webpy/utils.py#L15-L26 |
246,575 | getsentry/raven-python | raven/contrib/django/resolver.py | get_regex | def get_regex(resolver_or_pattern):
"""Utility method for django's deprecated resolver.regex"""
try:
regex = resolver_or_pattern.regex
except AttributeError:
regex = resolver_or_pattern.pattern.regex
return regex | python | def get_regex(resolver_or_pattern):
try:
regex = resolver_or_pattern.regex
except AttributeError:
regex = resolver_or_pattern.pattern.regex
return regex | [
"def",
"get_regex",
"(",
"resolver_or_pattern",
")",
":",
"try",
":",
"regex",
"=",
"resolver_or_pattern",
".",
"regex",
"except",
"AttributeError",
":",
"regex",
"=",
"resolver_or_pattern",
".",
"pattern",
".",
"regex",
"return",
"regex"
] | Utility method for django's deprecated resolver.regex | [
"Utility",
"method",
"for",
"django",
"s",
"deprecated",
"resolver",
".",
"regex"
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/django/resolver.py#L11-L17 |
246,576 | getsentry/raven-python | raven/utils/basic.py | once | def once(func):
"""Runs a thing once and once only."""
lock = threading.Lock()
def new_func(*args, **kwargs):
if new_func.called:
return
with lock:
if new_func.called:
return
rv = func(*args, **kwargs)
new_func.called = True
... | python | def once(func):
lock = threading.Lock()
def new_func(*args, **kwargs):
if new_func.called:
return
with lock:
if new_func.called:
return
rv = func(*args, **kwargs)
new_func.called = True
return rv
new_func = update_... | [
"def",
"once",
"(",
"func",
")",
":",
"lock",
"=",
"threading",
".",
"Lock",
"(",
")",
"def",
"new_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"new_func",
".",
"called",
":",
"return",
"with",
"lock",
":",
"if",
"new_func",
... | Runs a thing once and once only. | [
"Runs",
"a",
"thing",
"once",
"and",
"once",
"only",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/utils/basic.py#L75-L91 |
246,577 | getsentry/raven-python | raven/contrib/django/utils.py | get_host | def get_host(request):
"""
A reimplementation of Django's get_host, without the
SuspiciousOperation check.
"""
# We try three options, in order of decreasing preference.
if settings.USE_X_FORWARDED_HOST and (
'HTTP_X_FORWARDED_HOST' in request.META):
host = request.META['HTTP... | python | def get_host(request):
# We try three options, in order of decreasing preference.
if settings.USE_X_FORWARDED_HOST and (
'HTTP_X_FORWARDED_HOST' in request.META):
host = request.META['HTTP_X_FORWARDED_HOST']
elif 'HTTP_HOST' in request.META:
host = request.META['HTTP_HOST']
e... | [
"def",
"get_host",
"(",
"request",
")",
":",
"# We try three options, in order of decreasing preference.",
"if",
"settings",
".",
"USE_X_FORWARDED_HOST",
"and",
"(",
"'HTTP_X_FORWARDED_HOST'",
"in",
"request",
".",
"META",
")",
":",
"host",
"=",
"request",
".",
"META"... | A reimplementation of Django's get_host, without the
SuspiciousOperation check. | [
"A",
"reimplementation",
"of",
"Django",
"s",
"get_host",
"without",
"the",
"SuspiciousOperation",
"check",
"."
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/django/utils.py#L84-L101 |
246,578 | getsentry/raven-python | raven/contrib/django/models.py | install_middleware | def install_middleware(middleware_name, lookup_names=None):
"""
Install specified middleware
"""
if lookup_names is None:
lookup_names = (middleware_name,)
# default settings.MIDDLEWARE is None
middleware_attr = 'MIDDLEWARE' if getattr(settings,
... | python | def install_middleware(middleware_name, lookup_names=None):
if lookup_names is None:
lookup_names = (middleware_name,)
# default settings.MIDDLEWARE is None
middleware_attr = 'MIDDLEWARE' if getattr(settings,
'MIDDLEWARE',
... | [
"def",
"install_middleware",
"(",
"middleware_name",
",",
"lookup_names",
"=",
"None",
")",
":",
"if",
"lookup_names",
"is",
"None",
":",
"lookup_names",
"=",
"(",
"middleware_name",
",",
")",
"# default settings.MIDDLEWARE is None",
"middleware_attr",
"=",
"'MIDDLEWA... | Install specified middleware | [
"Install",
"specified",
"middleware"
] | d891c20f0f930153f508e9d698d9de42e910face | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/django/models.py#L222-L238 |
246,579 | sebp/scikit-survival | sksurv/meta/base.py | _fit_and_score | def _fit_and_score(est, x, y, scorer, train_index, test_index, parameters, fit_params, predict_params):
"""Train survival model on given data and return its score on test data"""
X_train, y_train = _safe_split(est, x, y, train_index)
train_params = fit_params.copy()
# Training
est.set_params(**para... | python | def _fit_and_score(est, x, y, scorer, train_index, test_index, parameters, fit_params, predict_params):
X_train, y_train = _safe_split(est, x, y, train_index)
train_params = fit_params.copy()
# Training
est.set_params(**parameters)
est.fit(X_train, y_train, **train_params)
# Testing
test_p... | [
"def",
"_fit_and_score",
"(",
"est",
",",
"x",
",",
"y",
",",
"scorer",
",",
"train_index",
",",
"test_index",
",",
"parameters",
",",
"fit_params",
",",
"predict_params",
")",
":",
"X_train",
",",
"y_train",
"=",
"_safe_split",
"(",
"est",
",",
"x",
","... | Train survival model on given data and return its score on test data | [
"Train",
"survival",
"model",
"on",
"given",
"data",
"and",
"return",
"its",
"score",
"on",
"test",
"data"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/base.py#L17-L35 |
246,580 | sebp/scikit-survival | sksurv/linear_model/coxnet.py | CoxnetSurvivalAnalysis._interpolate_coefficients | def _interpolate_coefficients(self, alpha):
"""Interpolate coefficients by calculating the weighted average of coefficient vectors corresponding to
neighbors of alpha in the list of alphas constructed during training."""
exact = False
coef_idx = None
for i, val in enumerate(self.... | python | def _interpolate_coefficients(self, alpha):
exact = False
coef_idx = None
for i, val in enumerate(self.alphas_):
if val > alpha:
coef_idx = i
elif alpha - val < numpy.finfo(numpy.float).eps:
coef_idx = i
exact = True
... | [
"def",
"_interpolate_coefficients",
"(",
"self",
",",
"alpha",
")",
":",
"exact",
"=",
"False",
"coef_idx",
"=",
"None",
"for",
"i",
",",
"val",
"in",
"enumerate",
"(",
"self",
".",
"alphas_",
")",
":",
"if",
"val",
">",
"alpha",
":",
"coef_idx",
"=",
... | Interpolate coefficients by calculating the weighted average of coefficient vectors corresponding to
neighbors of alpha in the list of alphas constructed during training. | [
"Interpolate",
"coefficients",
"by",
"calculating",
"the",
"weighted",
"average",
"of",
"coefficient",
"vectors",
"corresponding",
"to",
"neighbors",
"of",
"alpha",
"in",
"the",
"list",
"of",
"alphas",
"constructed",
"during",
"training",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/linear_model/coxnet.py#L239-L263 |
246,581 | sebp/scikit-survival | sksurv/linear_model/coxnet.py | CoxnetSurvivalAnalysis.predict | def predict(self, X, alpha=None):
"""The linear predictor of the model.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Test data of which to calculate log-likelihood from
alpha : float, optional
Constant that multiplies the penalty... | python | def predict(self, X, alpha=None):
X = check_array(X)
coef = self._get_coef(alpha)
return numpy.dot(X, coef) | [
"def",
"predict",
"(",
"self",
",",
"X",
",",
"alpha",
"=",
"None",
")",
":",
"X",
"=",
"check_array",
"(",
"X",
")",
"coef",
"=",
"self",
".",
"_get_coef",
"(",
"alpha",
")",
"return",
"numpy",
".",
"dot",
"(",
"X",
",",
"coef",
")"
] | The linear predictor of the model.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Test data of which to calculate log-likelihood from
alpha : float, optional
Constant that multiplies the penalty terms. If the same alpha was used during tra... | [
"The",
"linear",
"predictor",
"of",
"the",
"model",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/linear_model/coxnet.py#L265-L285 |
246,582 | sebp/scikit-survival | sksurv/meta/ensemble_selection.py | BaseEnsembleSelection._create_base_ensemble | def _create_base_ensemble(self, out, n_estimators, n_folds):
"""For each base estimator collect models trained on each fold"""
ensemble_scores = numpy.empty((n_estimators, n_folds))
base_ensemble = numpy.empty_like(ensemble_scores, dtype=numpy.object)
for model, fold, score, est in out:
... | python | def _create_base_ensemble(self, out, n_estimators, n_folds):
ensemble_scores = numpy.empty((n_estimators, n_folds))
base_ensemble = numpy.empty_like(ensemble_scores, dtype=numpy.object)
for model, fold, score, est in out:
ensemble_scores[model, fold] = score
base_ensemble... | [
"def",
"_create_base_ensemble",
"(",
"self",
",",
"out",
",",
"n_estimators",
",",
"n_folds",
")",
":",
"ensemble_scores",
"=",
"numpy",
".",
"empty",
"(",
"(",
"n_estimators",
",",
"n_folds",
")",
")",
"base_ensemble",
"=",
"numpy",
".",
"empty_like",
"(",
... | For each base estimator collect models trained on each fold | [
"For",
"each",
"base",
"estimator",
"collect",
"models",
"trained",
"on",
"each",
"fold"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L152-L160 |
246,583 | sebp/scikit-survival | sksurv/meta/ensemble_selection.py | BaseEnsembleSelection._create_cv_ensemble | def _create_cv_ensemble(self, base_ensemble, idx_models_included, model_names=None):
"""For each selected base estimator, average models trained on each fold"""
fitted_models = numpy.empty(len(idx_models_included), dtype=numpy.object)
for i, idx in enumerate(idx_models_included):
mod... | python | def _create_cv_ensemble(self, base_ensemble, idx_models_included, model_names=None):
fitted_models = numpy.empty(len(idx_models_included), dtype=numpy.object)
for i, idx in enumerate(idx_models_included):
model_name = self.base_estimators[idx][0] if model_names is None else model_names[idx]
... | [
"def",
"_create_cv_ensemble",
"(",
"self",
",",
"base_ensemble",
",",
"idx_models_included",
",",
"model_names",
"=",
"None",
")",
":",
"fitted_models",
"=",
"numpy",
".",
"empty",
"(",
"len",
"(",
"idx_models_included",
")",
",",
"dtype",
"=",
"numpy",
".",
... | For each selected base estimator, average models trained on each fold | [
"For",
"each",
"selected",
"base",
"estimator",
"average",
"models",
"trained",
"on",
"each",
"fold"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L162-L170 |
246,584 | sebp/scikit-survival | sksurv/meta/ensemble_selection.py | BaseEnsembleSelection._get_base_estimators | def _get_base_estimators(self, X):
"""Takes special care of estimators using custom kernel function
Parameters
----------
X : array, shape = (n_samples, n_features)
Samples to pre-compute kernel matrix from.
Returns
-------
base_estimators : list
... | python | def _get_base_estimators(self, X):
base_estimators = []
kernel_cache = {}
kernel_fns = {}
for i, (name, estimator) in enumerate(self.base_estimators):
if hasattr(estimator, 'kernel') and callable(estimator.kernel):
if not hasattr(estimator, '_get_kernel'):
... | [
"def",
"_get_base_estimators",
"(",
"self",
",",
"X",
")",
":",
"base_estimators",
"=",
"[",
"]",
"kernel_cache",
"=",
"{",
"}",
"kernel_fns",
"=",
"{",
"}",
"for",
"i",
",",
"(",
"name",
",",
"estimator",
")",
"in",
"enumerate",
"(",
"self",
".",
"b... | Takes special care of estimators using custom kernel function
Parameters
----------
X : array, shape = (n_samples, n_features)
Samples to pre-compute kernel matrix from.
Returns
-------
base_estimators : list
Same as `self.base_estimators`, expec... | [
"Takes",
"special",
"care",
"of",
"estimators",
"using",
"custom",
"kernel",
"function"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L172-L214 |
246,585 | sebp/scikit-survival | sksurv/meta/ensemble_selection.py | BaseEnsembleSelection._restore_base_estimators | def _restore_base_estimators(self, kernel_cache, out, X, cv):
"""Restore custom kernel functions of estimators for predictions"""
train_folds = {fold: train_index for fold, (train_index, _) in enumerate(cv)}
for idx, fold, _, est in out:
if idx in kernel_cache:
if no... | python | def _restore_base_estimators(self, kernel_cache, out, X, cv):
train_folds = {fold: train_index for fold, (train_index, _) in enumerate(cv)}
for idx, fold, _, est in out:
if idx in kernel_cache:
if not hasattr(est, 'fit_X_'):
raise ValueError(
... | [
"def",
"_restore_base_estimators",
"(",
"self",
",",
"kernel_cache",
",",
"out",
",",
"X",
",",
"cv",
")",
":",
"train_folds",
"=",
"{",
"fold",
":",
"train_index",
"for",
"fold",
",",
"(",
"train_index",
",",
"_",
")",
"in",
"enumerate",
"(",
"cv",
")... | Restore custom kernel functions of estimators for predictions | [
"Restore",
"custom",
"kernel",
"functions",
"of",
"estimators",
"for",
"predictions"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L216-L230 |
246,586 | sebp/scikit-survival | sksurv/meta/ensemble_selection.py | BaseEnsembleSelection._fit_and_score_ensemble | def _fit_and_score_ensemble(self, X, y, cv, **fit_params):
"""Create a cross-validated model by training a model for each fold with the same model parameters"""
fit_params_steps = self._split_fit_params(fit_params)
folds = list(cv.split(X, y))
# Take care of custom kernel functions
... | python | def _fit_and_score_ensemble(self, X, y, cv, **fit_params):
fit_params_steps = self._split_fit_params(fit_params)
folds = list(cv.split(X, y))
# Take care of custom kernel functions
base_estimators, kernel_cache = self._get_base_estimators(X)
out = Parallel(
n_jobs=... | [
"def",
"_fit_and_score_ensemble",
"(",
"self",
",",
"X",
",",
"y",
",",
"cv",
",",
"*",
"*",
"fit_params",
")",
":",
"fit_params_steps",
"=",
"self",
".",
"_split_fit_params",
"(",
"fit_params",
")",
"folds",
"=",
"list",
"(",
"cv",
".",
"split",
"(",
... | Create a cross-validated model by training a model for each fold with the same model parameters | [
"Create",
"a",
"cross",
"-",
"validated",
"model",
"by",
"training",
"a",
"model",
"for",
"each",
"fold",
"with",
"the",
"same",
"model",
"parameters"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L232-L257 |
246,587 | sebp/scikit-survival | sksurv/meta/ensemble_selection.py | BaseEnsembleSelection.fit | def fit(self, X, y=None, **fit_params):
"""Fit ensemble of models
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Training data.
y : array-like, optional
Target data if base estimators are supervised.
Returns
------... | python | def fit(self, X, y=None, **fit_params):
self._check_params()
cv = check_cv(self.cv, X)
self._fit(X, y, cv, **fit_params)
return self | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"*",
"*",
"fit_params",
")",
":",
"self",
".",
"_check_params",
"(",
")",
"cv",
"=",
"check_cv",
"(",
"self",
".",
"cv",
",",
"X",
")",
"self",
".",
"_fit",
"(",
"X",
",",
"y",
... | Fit ensemble of models
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Training data.
y : array-like, optional
Target data if base estimators are supervised.
Returns
-------
self | [
"Fit",
"ensemble",
"of",
"models"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L277-L297 |
246,588 | sebp/scikit-survival | sksurv/io/arffwrite.py | writearff | def writearff(data, filename, relation_name=None, index=True):
"""Write ARFF file
Parameters
----------
data : :class:`pandas.DataFrame`
DataFrame containing data
filename : string or file-like object
Path to ARFF file or file-like object. In the latter case,
the handle is ... | python | def writearff(data, filename, relation_name=None, index=True):
if isinstance(filename, str):
fp = open(filename, 'w')
if relation_name is None:
relation_name = os.path.basename(filename)
else:
fp = filename
if relation_name is None:
relation_name = "pand... | [
"def",
"writearff",
"(",
"data",
",",
"filename",
",",
"relation_name",
"=",
"None",
",",
"index",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"str",
")",
":",
"fp",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"if",
"relation_... | Write ARFF file
Parameters
----------
data : :class:`pandas.DataFrame`
DataFrame containing data
filename : string or file-like object
Path to ARFF file or file-like object. In the latter case,
the handle is closed by calling this function.
relation_name : string, optional... | [
"Write",
"ARFF",
"file"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/io/arffwrite.py#L23-L57 |
246,589 | sebp/scikit-survival | sksurv/io/arffwrite.py | _write_header | def _write_header(data, fp, relation_name, index):
"""Write header containing attribute names and types"""
fp.write("@relation {0}\n\n".format(relation_name))
if index:
data = data.reset_index()
attribute_names = _sanitize_column_names(data)
for column, series in data.iteritems():
... | python | def _write_header(data, fp, relation_name, index):
fp.write("@relation {0}\n\n".format(relation_name))
if index:
data = data.reset_index()
attribute_names = _sanitize_column_names(data)
for column, series in data.iteritems():
name = attribute_names[column]
fp.write("@attribute... | [
"def",
"_write_header",
"(",
"data",
",",
"fp",
",",
"relation_name",
",",
"index",
")",
":",
"fp",
".",
"write",
"(",
"\"@relation {0}\\n\\n\"",
".",
"format",
"(",
"relation_name",
")",
")",
"if",
"index",
":",
"data",
"=",
"data",
".",
"reset_index",
... | Write header containing attribute names and types | [
"Write",
"header",
"containing",
"attribute",
"names",
"and",
"types"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/io/arffwrite.py#L60-L85 |
246,590 | sebp/scikit-survival | sksurv/io/arffwrite.py | _sanitize_column_names | def _sanitize_column_names(data):
"""Replace illegal characters with underscore"""
new_names = {}
for name in data.columns:
new_names[name] = _ILLEGAL_CHARACTER_PAT.sub("_", name)
return new_names | python | def _sanitize_column_names(data):
new_names = {}
for name in data.columns:
new_names[name] = _ILLEGAL_CHARACTER_PAT.sub("_", name)
return new_names | [
"def",
"_sanitize_column_names",
"(",
"data",
")",
":",
"new_names",
"=",
"{",
"}",
"for",
"name",
"in",
"data",
".",
"columns",
":",
"new_names",
"[",
"name",
"]",
"=",
"_ILLEGAL_CHARACTER_PAT",
".",
"sub",
"(",
"\"_\"",
",",
"name",
")",
"return",
"new... | Replace illegal characters with underscore | [
"Replace",
"illegal",
"characters",
"with",
"underscore"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/io/arffwrite.py#L88-L93 |
246,591 | sebp/scikit-survival | sksurv/io/arffwrite.py | _write_data | def _write_data(data, fp):
"""Write the data section"""
fp.write("@data\n")
def to_str(x):
if pandas.isnull(x):
return '?'
else:
return str(x)
data = data.applymap(to_str)
n_rows = data.shape[0]
for i in range(n_rows):
str_values = list(data.iloc... | python | def _write_data(data, fp):
fp.write("@data\n")
def to_str(x):
if pandas.isnull(x):
return '?'
else:
return str(x)
data = data.applymap(to_str)
n_rows = data.shape[0]
for i in range(n_rows):
str_values = list(data.iloc[i, :].apply(_check_str_array))
... | [
"def",
"_write_data",
"(",
"data",
",",
"fp",
")",
":",
"fp",
".",
"write",
"(",
"\"@data\\n\"",
")",
"def",
"to_str",
"(",
"x",
")",
":",
"if",
"pandas",
".",
"isnull",
"(",
"x",
")",
":",
"return",
"'?'",
"else",
":",
"return",
"str",
"(",
"x",... | Write the data section | [
"Write",
"the",
"data",
"section"
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/io/arffwrite.py#L130-L146 |
246,592 | sebp/scikit-survival | sksurv/meta/stacking.py | Stacking.fit | def fit(self, X, y=None, **fit_params):
"""Fit base estimators.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Training data.
y : array-like, optional
Target data if base estimators are supervised.
Returns
-------
... | python | def fit(self, X, y=None, **fit_params):
X = numpy.asarray(X)
self._fit_estimators(X, y, **fit_params)
Xt = self._predict_estimators(X)
self.meta_estimator.fit(Xt, y)
return self | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"*",
"*",
"fit_params",
")",
":",
"X",
"=",
"numpy",
".",
"asarray",
"(",
"X",
")",
"self",
".",
"_fit_estimators",
"(",
"X",
",",
"y",
",",
"*",
"*",
"fit_params",
")",
"Xt",
"... | Fit base estimators.
Parameters
----------
X : array-like, shape = (n_samples, n_features)
Training data.
y : array-like, optional
Target data if base estimators are supervised.
Returns
-------
self | [
"Fit",
"base",
"estimators",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/stacking.py#L115-L135 |
246,593 | sebp/scikit-survival | sksurv/column.py | standardize | def standardize(table, with_std=True):
"""
Perform Z-Normalization on each numeric column of the given table.
Parameters
----------
table : pandas.DataFrame or numpy.ndarray
Data to standardize.
with_std : bool, optional, default: True
If ``False`` data is only centered and not... | python | def standardize(table, with_std=True):
if isinstance(table, pandas.DataFrame):
cat_columns = table.select_dtypes(include=['category']).columns
else:
cat_columns = []
new_frame = _apply_along_column(table, standardize_column, with_std=with_std)
# work around for apply converting categor... | [
"def",
"standardize",
"(",
"table",
",",
"with_std",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"table",
",",
"pandas",
".",
"DataFrame",
")",
":",
"cat_columns",
"=",
"table",
".",
"select_dtypes",
"(",
"include",
"=",
"[",
"'category'",
"]",
")",
... | Perform Z-Normalization on each numeric column of the given table.
Parameters
----------
table : pandas.DataFrame or numpy.ndarray
Data to standardize.
with_std : bool, optional, default: True
If ``False`` data is only centered and not converted to unit variance.
Returns
-----... | [
"Perform",
"Z",
"-",
"Normalization",
"on",
"each",
"numeric",
"column",
"of",
"the",
"given",
"table",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/column.py#L47-L77 |
246,594 | sebp/scikit-survival | sksurv/column.py | encode_categorical | def encode_categorical(table, columns=None, **kwargs):
"""
Encode categorical columns with `M` categories into `M-1` columns according
to the one-hot scheme.
Parameters
----------
table : pandas.DataFrame
Table with categorical columns to encode.
columns : list-like, optional, defa... | python | def encode_categorical(table, columns=None, **kwargs):
if isinstance(table, pandas.Series):
if not is_categorical_dtype(table.dtype) and not table.dtype.char == "O":
raise TypeError("series must be of categorical dtype, but was {}".format(table.dtype))
return _encode_categorical_series(t... | [
"def",
"encode_categorical",
"(",
"table",
",",
"columns",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"table",
",",
"pandas",
".",
"Series",
")",
":",
"if",
"not",
"is_categorical_dtype",
"(",
"table",
".",
"dtype",
")",
"... | Encode categorical columns with `M` categories into `M-1` columns according
to the one-hot scheme.
Parameters
----------
table : pandas.DataFrame
Table with categorical columns to encode.
columns : list-like, optional, default: None
Column names in the DataFrame to be encoded.
... | [
"Encode",
"categorical",
"columns",
"with",
"M",
"categories",
"into",
"M",
"-",
"1",
"columns",
"according",
"to",
"the",
"one",
"-",
"hot",
"scheme",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/column.py#L97-L146 |
246,595 | sebp/scikit-survival | sksurv/column.py | categorical_to_numeric | def categorical_to_numeric(table):
"""Encode categorical columns to numeric by converting each category to
an integer value.
Parameters
----------
table : pandas.DataFrame
Table with categorical columns to encode.
Returns
-------
encoded : pandas.DataFrame
Table with ca... | python | def categorical_to_numeric(table):
def transform(column):
if is_categorical_dtype(column.dtype):
return column.cat.codes
if column.dtype.char == "O":
try:
nc = column.astype(numpy.int64)
except ValueError:
classes = column.dropna().... | [
"def",
"categorical_to_numeric",
"(",
"table",
")",
":",
"def",
"transform",
"(",
"column",
")",
":",
"if",
"is_categorical_dtype",
"(",
"column",
".",
"dtype",
")",
":",
"return",
"column",
".",
"cat",
".",
"codes",
"if",
"column",
".",
"dtype",
".",
"c... | Encode categorical columns to numeric by converting each category to
an integer value.
Parameters
----------
table : pandas.DataFrame
Table with categorical columns to encode.
Returns
-------
encoded : pandas.DataFrame
Table with categorical columns encoded as numeric.
... | [
"Encode",
"categorical",
"columns",
"to",
"numeric",
"by",
"converting",
"each",
"category",
"to",
"an",
"integer",
"value",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/column.py#L171-L208 |
246,596 | sebp/scikit-survival | sksurv/util.py | check_y_survival | def check_y_survival(y_or_event, *args, allow_all_censored=False):
"""Check that array correctly represents an outcome for survival analysis.
Parameters
----------
y_or_event : structured array with two fields, or boolean array
If a structured array, it must contain the binary event indicator
... | python | def check_y_survival(y_or_event, *args, allow_all_censored=False):
if len(args) == 0:
y = y_or_event
if not isinstance(y, numpy.ndarray) or y.dtype.fields is None or len(y.dtype.fields) != 2:
raise ValueError('y must be a structured array with the first field'
... | [
"def",
"check_y_survival",
"(",
"y_or_event",
",",
"*",
"args",
",",
"allow_all_censored",
"=",
"False",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"y",
"=",
"y_or_event",
"if",
"not",
"isinstance",
"(",
"y",
",",
"numpy",
".",
"ndarray",... | Check that array correctly represents an outcome for survival analysis.
Parameters
----------
y_or_event : structured array with two fields, or boolean array
If a structured array, it must contain the binary event indicator
as first field, and time of event or time of censoring as
s... | [
"Check",
"that",
"array",
"correctly",
"represents",
"an",
"outcome",
"for",
"survival",
"analysis",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/util.py#L104-L164 |
246,597 | sebp/scikit-survival | sksurv/util.py | check_arrays_survival | def check_arrays_survival(X, y, **kwargs):
"""Check that all arrays have consistent first dimensions.
Parameters
----------
X : array-like
Data matrix containing feature vectors.
y : structured array with two fields
A structured array containing the binary event indicator
a... | python | def check_arrays_survival(X, y, **kwargs):
event, time = check_y_survival(y)
kwargs.setdefault("dtype", numpy.float64)
X = check_array(X, ensure_min_samples=2, **kwargs)
check_consistent_length(X, event, time)
return X, event, time | [
"def",
"check_arrays_survival",
"(",
"X",
",",
"y",
",",
"*",
"*",
"kwargs",
")",
":",
"event",
",",
"time",
"=",
"check_y_survival",
"(",
"y",
")",
"kwargs",
".",
"setdefault",
"(",
"\"dtype\"",
",",
"numpy",
".",
"float64",
")",
"X",
"=",
"check_arra... | Check that all arrays have consistent first dimensions.
Parameters
----------
X : array-like
Data matrix containing feature vectors.
y : structured array with two fields
A structured array containing the binary event indicator
as first field, and time of event or time of censor... | [
"Check",
"that",
"all",
"arrays",
"have",
"consistent",
"first",
"dimensions",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/util.py#L167-L198 |
246,598 | sebp/scikit-survival | sksurv/util.py | Surv.from_arrays | def from_arrays(event, time, name_event=None, name_time=None):
"""Create structured array.
Parameters
----------
event : array-like
Event indicator. A boolean array or array with values 0/1.
time : array-like
Observed time.
name_event : str|None
... | python | def from_arrays(event, time, name_event=None, name_time=None):
name_event = name_event or 'event'
name_time = name_time or 'time'
if name_time == name_event:
raise ValueError('name_time must be different from name_event')
time = numpy.asanyarray(time, dtype=numpy.float_)
... | [
"def",
"from_arrays",
"(",
"event",
",",
"time",
",",
"name_event",
"=",
"None",
",",
"name_time",
"=",
"None",
")",
":",
"name_event",
"=",
"name_event",
"or",
"'event'",
"name_time",
"=",
"name_time",
"or",
"'time'",
"if",
"name_time",
"==",
"name_event",
... | Create structured array.
Parameters
----------
event : array-like
Event indicator. A boolean array or array with values 0/1.
time : array-like
Observed time.
name_event : str|None
Name of event, optional, default: 'event'
name_time : s... | [
"Create",
"structured",
"array",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/util.py#L28-L73 |
246,599 | sebp/scikit-survival | sksurv/util.py | Surv.from_dataframe | def from_dataframe(event, time, data):
"""Create structured array from data frame.
Parameters
----------
event : object
Identifier of column containing event indicator.
time : object
Identifier of column containing time.
data : pandas.DataFrame
... | python | def from_dataframe(event, time, data):
if not isinstance(data, pandas.DataFrame):
raise TypeError(
"exepected pandas.DataFrame, but got {!r}".format(type(data)))
return Surv.from_arrays(
data.loc[:, event].values,
data.loc[:, time].values,
... | [
"def",
"from_dataframe",
"(",
"event",
",",
"time",
",",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"pandas",
".",
"DataFrame",
")",
":",
"raise",
"TypeError",
"(",
"\"exepected pandas.DataFrame, but got {!r}\"",
".",
"format",
"(",
"type",... | Create structured array from data frame.
Parameters
----------
event : object
Identifier of column containing event indicator.
time : object
Identifier of column containing time.
data : pandas.DataFrame
Dataset.
Returns
------... | [
"Create",
"structured",
"array",
"from",
"data",
"frame",
"."
] | cfc99fd20454cdd6f4f20fe331b39f2191ccaabc | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/util.py#L76-L101 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.