Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
Loader.supports_recursion
(self)
RemovedInDjango20Warning: This is an internal property used by the ExtendsNode during the deprecation of non-recursive loaders.
RemovedInDjango20Warning: This is an internal property used by the ExtendsNode during the deprecation of non-recursive loaders.
def supports_recursion(self): """ RemovedInDjango20Warning: This is an internal property used by the ExtendsNode during the deprecation of non-recursive loaders. """ return all(hasattr(loader, 'get_contents') for loader in self.loaders)
[ "def", "supports_recursion", "(", "self", ")", ":", "return", "all", "(", "hasattr", "(", "loader", ",", "'get_contents'", ")", "for", "loader", "in", "self", ".", "loaders", ")" ]
[ 108, 4 ]
[ 113, 78 ]
python
en
['en', 'error', 'th']
False
Loader.find_template
(self, name, dirs=None)
RemovedInDjango20Warning: An internal method to lookup the template name in all the configured loaders.
RemovedInDjango20Warning: An internal method to lookup the template name in all the configured loaders.
def find_template(self, name, dirs=None): """ RemovedInDjango20Warning: An internal method to lookup the template name in all the configured loaders. """ key = self.cache_key(name, dirs) try: result = self.find_template_cache[key] except KeyError: ...
[ "def", "find_template", "(", "self", ",", "name", ",", "dirs", "=", "None", ")", ":", "key", "=", "self", ".", "cache_key", "(", "name", ",", "dirs", ")", "try", ":", "result", "=", "self", ".", "find_template_cache", "[", "key", "]", "except", "KeyE...
[ 115, 4 ]
[ 143, 44 ]
python
en
['en', 'error', 'th']
False
Loader.reset
(self)
Empty the template cache.
Empty the template cache.
def reset(self): "Empty the template cache." self.template_cache.clear() self.find_template_cache.clear() # RemovedInDjango20Warning self.get_template_cache.clear()
[ "def", "reset", "(", "self", ")", ":", "self", ".", "template_cache", ".", "clear", "(", ")", "self", ".", "find_template_cache", ".", "clear", "(", ")", "# RemovedInDjango20Warning", "self", ".", "get_template_cache", ".", "clear", "(", ")" ]
[ 169, 4 ]
[ 173, 39 ]
python
en
['en', 'en', 'en']
True
EconDensity.pdf
(self, X, Y)
Conditional probability density function p(y|x) of the underlying probability model Args: X: x to be conditioned on - numpy array of shape (n_points, ndim_x) Y: y target values for witch the pdf shall be evaluated - numpy array of shape (n_points, ndim_y) Returns: p(X|Y) conditional density...
Conditional probability density function p(y|x) of the underlying probability model
def pdf(self, X, Y): """ Conditional probability density function p(y|x) of the underlying probability model Args: X: x to be conditioned on - numpy array of shape (n_points, ndim_x) Y: y target values for witch the pdf shall be evaluated - numpy array of shape (n_points, ndim_y) Returns: ...
[ "def", "pdf", "(", "self", ",", "X", ",", "Y", ")", ":", "X", ",", "Y", "=", "self", ".", "_handle_input_dimensionality", "(", "X", ",", "Y", ")", "mean", "=", "X", "**", "2", "return", "np", ".", "where", "(", "X", "<", "0", ",", "0", ",", ...
[ 35, 2 ]
[ 47, 81 ]
python
en
['en', 'en', 'en']
True
EconDensity.cdf
(self, X, Y)
Conditional cumulated probability density function P(Y < y | x) of the underlying probability model Args: X: x to be conditioned on - numpy array of shape (n_points, ndim_x) Y: y target values for witch the cdf shall be evaluated - numpy array of shape (n_points, ndim_y) Returns: ...
Conditional cumulated probability density function P(Y < y | x) of the underlying probability model
def cdf(self, X, Y): """ Conditional cumulated probability density function P(Y < y | x) of the underlying probability model Args: X: x to be conditioned on - numpy array of shape (n_points, ndim_x) Y: y target values for witch the cdf shall be evaluated - numpy array of shape (n_points, n...
[ "def", "cdf", "(", "self", ",", "X", ",", "Y", ")", ":", "X", ",", "Y", "=", "self", ".", "_handle_input_dimensionality", "(", "X", ",", "Y", ")", "mean", "=", "X", "**", "2", "return", "np", ".", "where", "(", "X", "<", "0", ",", "0", ",", ...
[ 49, 2 ]
[ 61, 66 ]
python
en
['en', 'en', 'en']
True
EconDensity.simulate_conditional
(self, X)
Draws random samples from the conditional distribution Args: X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, ndim_x) Returns: Conditional random samples y drawn from p(y|x) - numpy array of shape (n_samples, ndim_y)
Draws random samples from the conditional distribution
def simulate_conditional(self, X): """ Draws random samples from the conditional distribution Args: X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, ndim_x) Returns: Conditional random samples y drawn from p(y|x) - numpy array of shape (n_sampl...
[ "def", "simulate_conditional", "(", "self", ",", "X", ")", ":", "if", "X", ".", "ndim", "==", "2", "and", "X", ".", "shape", "[", "1", "]", ":", "X", "=", "X", ".", "flatten", "(", ")", "assert", "X", ".", "ndim", "==", "1", "n_samples", "=", ...
[ 63, 2 ]
[ 80, 15 ]
python
en
['en', 'en', 'en']
True
EconDensity.simulate
(self, n_samples=1000)
Draws random samples from the joint distribution p(x,y) Args: n_samples: (int) number of samples to be drawn from the joint distribution Returns: (X,Y) - random samples drawn from p(x,y) - numpy arrays of shape (n_samples, ndim_x) and (n_samples, ndim_y)
Draws random samples from the joint distribution p(x,y) Args: n_samples: (int) number of samples to be drawn from the joint distribution
def simulate(self, n_samples=1000): """ Draws random samples from the joint distribution p(x,y) Args: n_samples: (int) number of samples to be drawn from the joint distribution Returns: (X,Y) - random samples drawn from p(x,y) - numpy arrays of shape (n_samples, ndim_x) and (n_samples, ndim_y) ...
[ "def", "simulate", "(", "self", ",", "n_samples", "=", "1000", ")", ":", "assert", "n_samples", ">", "0", "X", "=", "np", ".", "abs", "(", "self", ".", "random_state", ".", "standard_normal", "(", "size", "=", "[", "n_samples", "]", ")", ")", "Y", ...
[ 82, 2 ]
[ 94, 15 ]
python
en
['en', 'en', 'en']
True
EconDensity.mean_
(self, x_cond, n_samples=None)
Conditional mean of the distribution Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
Conditional mean of the distribution Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
def mean_(self, x_cond, n_samples=None): """ Conditional mean of the distribution Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y) """ assert x_cond.ndim == ...
[ "def", "mean_", "(", "self", ",", "x_cond", ",", "n_samples", "=", "None", ")", ":", "assert", "x_cond", ".", "ndim", "==", "2", "and", "x_cond", ".", "shape", "[", "1", "]", "==", "self", ".", "ndim_x", "return", "x_cond", "**", "2" ]
[ 96, 2 ]
[ 106, 20 ]
python
en
['en', 'en', 'en']
True
EconDensity.std_
(self, x_cond, n_samples=None)
Conditional mean of the distribution Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
Conditional mean of the distribution Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
def std_(self, x_cond, n_samples=None): """ Conditional mean of the distribution Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y) """ X = self._handle_input_...
[ "def", "std_", "(", "self", ",", "x_cond", ",", "n_samples", "=", "None", ")", ":", "X", "=", "self", ".", "_handle_input_dimensionality", "(", "x_cond", ")", "return", "x_cond", "**", "2" ]
[ 108, 2 ]
[ 118, 20 ]
python
en
['en', 'en', 'en']
True
EconDensity.covariance
(self, x_cond, n_samples=None)
Covariance of the distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y, ndim_y)
Covariance of the distribution conditioned on x_cond
def covariance(self, x_cond, n_samples=None): """ Covariance of the distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim...
[ "def", "covariance", "(", "self", ",", "x_cond", ",", "n_samples", "=", "None", ")", ":", "assert", "x_cond", ".", "ndim", "==", "2", "and", "x_cond", ".", "shape", "[", "1", "]", "==", "self", ".", "ndim_x", "covs", "=", "self", ".", "_std", "(", ...
[ 120, 2 ]
[ 132, 65 ]
python
en
['en', 'en', 'en']
True
EconDensity.value_at_risk
(self, x_cond, alpha=0.01, **kwargs)
Computes the Value-at-Risk (VaR) of the fitted distribution. Only if ndim_y = 1 Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution Returns: VaR values for each x to condition on - numpy array of shape (n...
Computes the Value-at-Risk (VaR) of the fitted distribution. Only if ndim_y = 1
def value_at_risk(self, x_cond, alpha=0.01, **kwargs): """ Computes the Value-at-Risk (VaR) of the fitted distribution. Only if ndim_y = 1 Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution Returns: V...
[ "def", "value_at_risk", "(", "self", ",", "x_cond", ",", "alpha", "=", "0.01", ",", "*", "*", "kwargs", ")", ":", "assert", "self", ".", "ndim_y", "==", "1", ",", "\"Value at Risk can only be computed when ndim_y = 1\"", "assert", "x_cond", ".", "ndim", "==", ...
[ 134, 2 ]
[ 149, 14 ]
python
en
['en', 'en', 'en']
True
EconDensity.conditional_value_at_risk
(self, x_cond, alpha=0.01, **kwargs)
Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of the fitted distribution. Only if ndim_y = 1 Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution n_samples: number of samples for...
Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of the fitted distribution. Only if ndim_y = 1
def conditional_value_at_risk(self, x_cond, alpha=0.01, **kwargs): """ Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of the fitted distribution. Only if ndim_y = 1 Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantil...
[ "def", "conditional_value_at_risk", "(", "self", ",", "x_cond", ",", "alpha", "=", "0.01", ",", "*", "*", "kwargs", ")", ":", "assert", "self", ".", "ndim_y", "==", "1", ",", "\"Value at Risk can only be computed when ndim_y = 1\"", "x_cond", "=", "self", ".", ...
[ 151, 2 ]
[ 170, 15 ]
python
en
['en', 'en', 'en']
True
EconDensity.tail_risk_measures
(self, x_cond, alpha=0.01, n_samples=10 ** 7)
Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution n_samples: number of samples for monte carlo model_fitting Retu...
Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR)
def tail_risk_measures(self, x_cond, alpha=0.01, n_samples=10 ** 7): """ Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) alpha: quantile percentage of the distribution ...
[ "def", "tail_risk_measures", "(", "self", ",", "x_cond", ",", "alpha", "=", "0.01", ",", "n_samples", "=", "10", "**", "7", ")", ":", "assert", "self", ".", "ndim_y", "==", "1", ",", "\"Value at Risk can only be computed when ndim_y = 1\"", "assert", "x_cond", ...
[ 172, 2 ]
[ 189, 22 ]
python
en
['en', 'en', 'en']
True
_WriteWorkspace
(main_gyp, sources_gyp, params)
Create a workspace to wrap main and sources gyp paths.
Create a workspace to wrap main and sources gyp paths.
def _WriteWorkspace(main_gyp, sources_gyp, params): """ Create a workspace to wrap main and sources gyp paths. """ (build_file_root, build_file_ext) = os.path.splitext(main_gyp) workspace_path = build_file_root + ".xcworkspace" options = params["options"] if options.generator_output: workspa...
[ "def", "_WriteWorkspace", "(", "main_gyp", ",", "sources_gyp", ",", "params", ")", ":", "(", "build_file_root", ",", "build_file_ext", ")", "=", "os", ".", "path", ".", "splitext", "(", "main_gyp", ")", "workspace_path", "=", "build_file_root", "+", "\".xcwork...
[ 21, 0 ]
[ 54, 40 ]
python
en
['en', 'en', 'en']
True
_TargetFromSpec
(old_spec, params)
Create fake target for xcode-ninja wrapper.
Create fake target for xcode-ninja wrapper.
def _TargetFromSpec(old_spec, params): """ Create fake target for xcode-ninja wrapper. """ # Determine ninja top level build dir (e.g. /path/to/out). ninja_toplevel = None jobs = 0 if params: options = params["options"] ninja_toplevel = os.path.join( options.toplevel_dir,...
[ "def", "_TargetFromSpec", "(", "old_spec", ",", "params", ")", ":", "# Determine ninja top level build dir (e.g. /path/to/out).", "ninja_toplevel", "=", "None", "jobs", "=", "0", "if", "params", ":", "options", "=", "params", "[", "\"options\"", "]", "ninja_toplevel",...
[ 57, 0 ]
[ 133, 23 ]
python
en
['en', 'en', 'en']
True
IsValidTargetForWrapper
(target_extras, executable_target_pattern, spec)
Limit targets for Xcode wrapper. Xcode sometimes performs poorly with too many targets, so only include proper executable targets, with filters to customize. Arguments: target_extras: Regular expression to always add, matching any target. executable_target_pattern: Regular expression limiting executable ...
Limit targets for Xcode wrapper.
def IsValidTargetForWrapper(target_extras, executable_target_pattern, spec): """Limit targets for Xcode wrapper. Xcode sometimes performs poorly with too many targets, so only include proper executable targets, with filters to customize. Arguments: target_extras: Regular expression to always add, matchin...
[ "def", "IsValidTargetForWrapper", "(", "target_extras", ",", "executable_target_pattern", ",", "spec", ")", ":", "target_name", "=", "spec", ".", "get", "(", "\"target_name\"", ")", "# Always include targets matching target_extras.", "if", "target_extras", "is", "not", ...
[ 136, 0 ]
[ 162, 16 ]
python
en
['en', 'en', 'en']
True
CreateWrapper
(target_list, target_dicts, data, params)
Initialize targets for the ninja wrapper. This sets up the necessary variables in the targets to generate Xcode projects that use ninja as an external builder. Arguments: target_list: List of target pairs: 'base/base.gyp:base'. target_dicts: Dict of target properties keyed on target pair. data: Dict ...
Initialize targets for the ninja wrapper.
def CreateWrapper(target_list, target_dicts, data, params): """Initialize targets for the ninja wrapper. This sets up the necessary variables in the targets to generate Xcode projects that use ninja as an external builder. Arguments: target_list: List of target pairs: 'base/base.gyp:base'. target_dic...
[ "def", "CreateWrapper", "(", "target_list", ",", "target_dicts", ",", "data", ",", "params", ")", ":", "orig_gyp", "=", "params", "[", "\"build_files\"", "]", "[", "0", "]", "for", "gyp_name", ",", "gyp_dict", "in", "data", ".", "items", "(", ")", ":", ...
[ 165, 0 ]
[ 301, 56 ]
python
en
['en', 'en', 'en']
True
copyfileobj
(fsrc, fdst, length=16*1024)
copy data from file-like object fsrc to file-like object fdst
copy data from file-like object fsrc to file-like object fdst
def copyfileobj(fsrc, fdst, length=16*1024): """copy data from file-like object fsrc to file-like object fdst""" while 1: buf = fsrc.read(length) if not buf: break fdst.write(buf)
[ "def", "copyfileobj", "(", "fsrc", ",", "fdst", ",", "length", "=", "16", "*", "1024", ")", ":", "while", "1", ":", "buf", "=", "fsrc", ".", "read", "(", "length", ")", "if", "not", "buf", ":", "break", "fdst", ".", "write", "(", "buf", ")" ]
[ 69, 0 ]
[ 75, 23 ]
python
en
['en', 'en', 'en']
True
copyfile
(src, dst)
Copy data from src to dst
Copy data from src to dst
def copyfile(src, dst): """Copy data from src to dst""" if _samefile(src, dst): raise Error("`%s` and `%s` are the same file" % (src, dst)) for fn in [src, dst]: try: st = os.stat(fn) except OSError: # File most likely does not exist pass ...
[ "def", "copyfile", "(", "src", ",", "dst", ")", ":", "if", "_samefile", "(", "src", ",", "dst", ")", ":", "raise", "Error", "(", "\"`%s` and `%s` are the same file\"", "%", "(", "src", ",", "dst", ")", ")", "for", "fn", "in", "[", "src", ",", "dst", ...
[ 89, 0 ]
[ 107, 35 ]
python
en
['en', 'en', 'en']
True
copymode
(src, dst)
Copy mode bits from src to dst
Copy mode bits from src to dst
def copymode(src, dst): """Copy mode bits from src to dst""" if hasattr(os, 'chmod'): st = os.stat(src) mode = stat.S_IMODE(st.st_mode) os.chmod(dst, mode)
[ "def", "copymode", "(", "src", ",", "dst", ")", ":", "if", "hasattr", "(", "os", ",", "'chmod'", ")", ":", "st", "=", "os", ".", "stat", "(", "src", ")", "mode", "=", "stat", ".", "S_IMODE", "(", "st", ".", "st_mode", ")", "os", ".", "chmod", ...
[ 109, 0 ]
[ 114, 27 ]
python
en
['en', 'en', 'en']
True
copystat
(src, dst)
Copy all stat info (mode bits, atime, mtime, flags) from src to dst
Copy all stat info (mode bits, atime, mtime, flags) from src to dst
def copystat(src, dst): """Copy all stat info (mode bits, atime, mtime, flags) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st.st_mode) if hasattr(os, 'utime'): os.utime(dst, (st.st_atime, st.st_mtime)) if hasattr(os, 'chmod'): os.chmod(dst, mode) if hasattr(os, 'chfl...
[ "def", "copystat", "(", "src", ",", "dst", ")", ":", "st", "=", "os", ".", "stat", "(", "src", ")", "mode", "=", "stat", ".", "S_IMODE", "(", "st", ".", "st_mode", ")", "if", "hasattr", "(", "os", ",", "'utime'", ")", ":", "os", ".", "utime", ...
[ 116, 0 ]
[ 130, 21 ]
python
en
['en', 'en', 'en']
True
copy
(src, dst)
Copy data and mode bits ("cp src dst"). The destination may be a directory.
Copy data and mode bits ("cp src dst").
def copy(src, dst): """Copy data and mode bits ("cp src dst"). The destination may be a directory. """ if os.path.isdir(dst): dst = os.path.join(dst, os.path.basename(src)) copyfile(src, dst) copymode(src, dst)
[ "def", "copy", "(", "src", ",", "dst", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "dst", ")", ":", "dst", "=", "os", ".", "path", ".", "join", "(", "dst", ",", "os", ".", "path", ".", "basename", "(", "src", ")", ")", "copyfile", ...
[ 132, 0 ]
[ 141, 22 ]
python
en
['en', 'en', 'en']
True
copy2
(src, dst)
Copy data and all stat info ("cp -p src dst"). The destination may be a directory.
Copy data and all stat info ("cp -p src dst").
def copy2(src, dst): """Copy data and all stat info ("cp -p src dst"). The destination may be a directory. """ if os.path.isdir(dst): dst = os.path.join(dst, os.path.basename(src)) copyfile(src, dst) copystat(src, dst)
[ "def", "copy2", "(", "src", ",", "dst", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "dst", ")", ":", "dst", "=", "os", ".", "path", ".", "join", "(", "dst", ",", "os", ".", "path", ".", "basename", "(", "src", ")", ")", "copyfile", ...
[ 143, 0 ]
[ 152, 22 ]
python
en
['en', 'en', 'en']
True
ignore_patterns
(*patterns)
Function that can be used as copytree() ignore parameter. Patterns is a sequence of glob-style patterns that are used to exclude files
Function that can be used as copytree() ignore parameter.
def ignore_patterns(*patterns): """Function that can be used as copytree() ignore parameter. Patterns is a sequence of glob-style patterns that are used to exclude files""" def _ignore_patterns(path, names): ignored_names = [] for pattern in patterns: ignored_names.extend(fn...
[ "def", "ignore_patterns", "(", "*", "patterns", ")", ":", "def", "_ignore_patterns", "(", "path", ",", "names", ")", ":", "ignored_names", "=", "[", "]", "for", "pattern", "in", "patterns", ":", "ignored_names", ".", "extend", "(", "fnmatch", ".", "filter"...
[ 154, 0 ]
[ 164, 27 ]
python
en
['en', 'en', 'en']
True
copytree
(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False)
Recursively copy a directory tree. The destination directory must not already exist. If exception(s) occur, an Error is raised with a list of reasons. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the cont...
Recursively copy a directory tree.
def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False): """Recursively copy a directory tree. The destination directory must not already exist. If exception(s) occur, an Error is raised with a list of reasons. If the optional symlinks flag...
[ "def", "copytree", "(", "src", ",", "dst", ",", "symlinks", "=", "False", ",", "ignore", "=", "None", ",", "copy_function", "=", "copy2", ",", "ignore_dangling_symlinks", "=", "False", ")", ":", "names", "=", "os", ".", "listdir", "(", "src", ")", "if"...
[ 166, 0 ]
[ 246, 27 ]
python
en
['en', 'en', 'en']
True
rmtree
(path, ignore_errors=False, onerror=None)
Recursively delete a directory tree. If ignore_errors is set, errors are ignored; otherwise, if onerror is set, it is called to handle the error with arguments (func, path, exc_info) where func is os.listdir, os.remove, or os.rmdir; path is the argument to that function that caused it to fail; and ...
Recursively delete a directory tree.
def rmtree(path, ignore_errors=False, onerror=None): """Recursively delete a directory tree. If ignore_errors is set, errors are ignored; otherwise, if onerror is set, it is called to handle the error with arguments (func, path, exc_info) where func is os.listdir, os.remove, or os.rmdir; path is th...
[ "def", "rmtree", "(", "path", ",", "ignore_errors", "=", "False", ",", "onerror", "=", "None", ")", ":", "if", "ignore_errors", ":", "def", "onerror", "(", "*", "args", ")", ":", "pass", "elif", "onerror", "is", "None", ":", "def", "onerror", "(", "*...
[ 248, 0 ]
[ 294, 47 ]
python
en
['en', 'en', 'en']
True
move
(src, dst)
Recursively move a file or directory to another location. This is similar to the Unix "mv" command. If the destination is a directory or a symlink to a directory, the source is moved inside the directory. The destination path must not already exist. If the destination already exists but is not a d...
Recursively move a file or directory to another location. This is similar to the Unix "mv" command.
def move(src, dst): """Recursively move a file or directory to another location. This is similar to the Unix "mv" command. If the destination is a directory or a symlink to a directory, the source is moved inside the directory. The destination path must not already exist. If the destination al...
[ "def", "move", "(", "src", ",", "dst", ")", ":", "real_dst", "=", "dst", "if", "os", ".", "path", ".", "isdir", "(", "dst", ")", ":", "if", "_samefile", "(", "src", ",", "dst", ")", ":", "# We might be on a case insensitive filesystem,", "# perform the ren...
[ 302, 0 ]
[ 340, 26 ]
python
en
['en', 'en', 'en']
True
_get_gid
(name)
Returns a gid, given a group name.
Returns a gid, given a group name.
def _get_gid(name): """Returns a gid, given a group name.""" if getgrnam is None or name is None: return None try: result = getgrnam(name) except KeyError: result = None if result is not None: return result[2] return None
[ "def", "_get_gid", "(", "name", ")", ":", "if", "getgrnam", "is", "None", "or", "name", "is", "None", ":", "return", "None", "try", ":", "result", "=", "getgrnam", "(", "name", ")", "except", "KeyError", ":", "result", "=", "None", "if", "result", "i...
[ 351, 0 ]
[ 361, 15 ]
python
en
['en', 'en', 'en']
True
_get_uid
(name)
Returns an uid, given a user name.
Returns an uid, given a user name.
def _get_uid(name): """Returns an uid, given a user name.""" if getpwnam is None or name is None: return None try: result = getpwnam(name) except KeyError: result = None if result is not None: return result[2] return None
[ "def", "_get_uid", "(", "name", ")", ":", "if", "getpwnam", "is", "None", "or", "name", "is", "None", ":", "return", "None", "try", ":", "result", "=", "getpwnam", "(", "name", ")", "except", "KeyError", ":", "result", "=", "None", "if", "result", "i...
[ 363, 0 ]
[ 373, 15 ]
python
en
['en', 'en', 'en']
True
_make_tarball
(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, owner=None, group=None, logger=None)
Create a (possibly compressed) tar file from all the files under 'base_dir'. 'compress' must be "gzip" (the default), "bzip2", or None. 'owner' and 'group' can be used to define an owner and a group for the archive that is being built. If not provided, the current owner and group will be used. ...
Create a (possibly compressed) tar file from all the files under 'base_dir'.
def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, owner=None, group=None, logger=None): """Create a (possibly compressed) tar file from all the files under 'base_dir'. 'compress' must be "gzip" (the default), "bzip2", or None. 'owner' and 'group' can be us...
[ "def", "_make_tarball", "(", "base_name", ",", "base_dir", ",", "compress", "=", "\"gzip\"", ",", "verbose", "=", "0", ",", "dry_run", "=", "0", ",", "owner", "=", "None", ",", "group", "=", "None", ",", "logger", "=", "None", ")", ":", "tar_compressio...
[ 375, 0 ]
[ 435, 23 ]
python
en
['en', 'en', 'en']
True
_make_zipfile
(base_name, base_dir, verbose=0, dry_run=0, logger=None)
Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_name' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on the default search path). If neither tool is available, raises ExecError. Retu...
Create a zip file from all the files under 'base_dir'.
def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_name' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on th...
[ "def", "_make_zipfile", "(", "base_name", ",", "base_dir", ",", "verbose", "=", "0", ",", "dry_run", "=", "0", ",", "logger", "=", "None", ")", ":", "zip_filename", "=", "base_name", "+", "\".zip\"", "archive_dir", "=", "os", ".", "path", ".", "dirname",...
[ 454, 0 ]
[ 499, 23 ]
python
en
['en', 'en', 'en']
True
get_archive_formats
()
Returns a list of supported formats for archiving and unarchiving. Each element of the returned sequence is a tuple (name, description)
Returns a list of supported formats for archiving and unarchiving.
def get_archive_formats(): """Returns a list of supported formats for archiving and unarchiving. Each element of the returned sequence is a tuple (name, description) """ formats = [(name, registry[2]) for name, registry in _ARCHIVE_FORMATS.items()] formats.sort() return formats
[ "def", "get_archive_formats", "(", ")", ":", "formats", "=", "[", "(", "name", ",", "registry", "[", "2", "]", ")", "for", "name", ",", "registry", "in", "_ARCHIVE_FORMATS", ".", "items", "(", ")", "]", "formats", ".", "sort", "(", ")", "return", "fo...
[ 512, 0 ]
[ 520, 18 ]
python
en
['en', 'en', 'en']
True
register_archive_format
(name, function, extra_args=None, description='')
Registers an archive format. name is the name of the format. function is the callable that will be used to create archives. If provided, extra_args is a sequence of (name, value) tuples that will be passed as arguments to the callable. description can be provided to describe the format, and will be ret...
Registers an archive format.
def register_archive_format(name, function, extra_args=None, description=''): """Registers an archive format. name is the name of the format. function is the callable that will be used to create archives. If provided, extra_args is a sequence of (name, value) tuples that will be passed as arguments to ...
[ "def", "register_archive_format", "(", "name", ",", "function", ",", "extra_args", "=", "None", ",", "description", "=", "''", ")", ":", "if", "extra_args", "is", "None", ":", "extra_args", "=", "[", "]", "if", "not", "isinstance", "(", "function", ",", ...
[ 522, 0 ]
[ 541, 64 ]
python
en
['en', 'en', 'en']
True
make_archive
(base_name, format, root_dir=None, base_dir=None, verbose=0, dry_run=0, owner=None, group=None, logger=None)
Create an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific extension; 'format' is the archive format: one of "zip", "tar", "bztar" or "gztar". 'root_dir' is a directory that will be the root directory of the archive; ie. we typically chdir int...
Create an archive file (eg. zip or tar).
def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0, dry_run=0, owner=None, group=None, logger=None): """Create an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific extension; 'format' is the archive format: one ...
[ "def", "make_archive", "(", "base_name", ",", "format", ",", "root_dir", "=", "None", ",", "base_dir", "=", "None", ",", "verbose", "=", "0", ",", "dry_run", "=", "0", ",", "owner", "=", "None", ",", "group", "=", "None", ",", "logger", "=", "None", ...
[ 546, 0 ]
[ 598, 19 ]
python
en
['en', 'gd', 'en']
True
get_unpack_formats
()
Returns a list of supported formats for unpacking. Each element of the returned sequence is a tuple (name, extensions, description)
Returns a list of supported formats for unpacking.
def get_unpack_formats(): """Returns a list of supported formats for unpacking. Each element of the returned sequence is a tuple (name, extensions, description) """ formats = [(name, info[0], info[3]) for name, info in _UNPACK_FORMATS.items()] formats.sort() return formats
[ "def", "get_unpack_formats", "(", ")", ":", "formats", "=", "[", "(", "name", ",", "info", "[", "0", "]", ",", "info", "[", "3", "]", ")", "for", "name", ",", "info", "in", "_UNPACK_FORMATS", ".", "items", "(", ")", "]", "formats", ".", "sort", "...
[ 601, 0 ]
[ 610, 18 ]
python
en
['en', 'en', 'en']
True
_check_unpack_options
(extensions, function, extra_args)
Checks what gets registered as an unpacker.
Checks what gets registered as an unpacker.
def _check_unpack_options(extensions, function, extra_args): """Checks what gets registered as an unpacker.""" # first make sure no other unpacker is registered for this extension existing_extensions = {} for name, info in _UNPACK_FORMATS.items(): for ext in info[0]: existing_extensi...
[ "def", "_check_unpack_options", "(", "extensions", ",", "function", ",", "extra_args", ")", ":", "# first make sure no other unpacker is registered for this extension", "existing_extensions", "=", "{", "}", "for", "name", ",", "info", "in", "_UNPACK_FORMATS", ".", "items"...
[ 612, 0 ]
[ 627, 69 ]
python
en
['en', 'en', 'en']
True
register_unpack_format
(name, extensions, function, extra_args=None, description='')
Registers an unpack format. `name` is the name of the format. `extensions` is a list of extensions corresponding to the format. `function` is the callable that will be used to unpack archives. The callable will receive archives to unpack. If it's unable to handle an archive, it needs to raise a Re...
Registers an unpack format.
def register_unpack_format(name, extensions, function, extra_args=None, description=''): """Registers an unpack format. `name` is the name of the format. `extensions` is a list of extensions corresponding to the format. `function` is the callable that will be used to unp...
[ "def", "register_unpack_format", "(", "name", ",", "extensions", ",", "function", ",", "extra_args", "=", "None", ",", "description", "=", "''", ")", ":", "if", "extra_args", "is", "None", ":", "extra_args", "=", "[", "]", "_check_unpack_options", "(", "exte...
[ 630, 0 ]
[ 650, 73 ]
python
en
['en', 'fr', 'en']
True
unregister_unpack_format
(name)
Removes the pack format from the registry.
Removes the pack format from the registry.
def unregister_unpack_format(name): """Removes the pack format from the registry.""" del _UNPACK_FORMATS[name]
[ "def", "unregister_unpack_format", "(", "name", ")", ":", "del", "_UNPACK_FORMATS", "[", "name", "]" ]
[ 652, 0 ]
[ 654, 29 ]
python
en
['en', 'en', 'en']
True
_ensure_directory
(path)
Ensure that the parent directory of `path` exists
Ensure that the parent directory of `path` exists
def _ensure_directory(path): """Ensure that the parent directory of `path` exists""" dirname = os.path.dirname(path) if not os.path.isdir(dirname): os.makedirs(dirname)
[ "def", "_ensure_directory", "(", "path", ")", ":", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "path", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "dirname", ")", ":", "os", ".", "makedirs", "(", "dirname", ")" ]
[ 656, 0 ]
[ 660, 28 ]
python
en
['en', 'en', 'en']
True
_unpack_zipfile
(filename, extract_dir)
Unpack zip `filename` to `extract_dir`
Unpack zip `filename` to `extract_dir`
def _unpack_zipfile(filename, extract_dir): """Unpack zip `filename` to `extract_dir` """ try: import zipfile except ImportError: raise ReadError('zlib not supported, cannot unpack this archive.') if not zipfile.is_zipfile(filename): raise ReadError("%s is not a zip file" % ...
[ "def", "_unpack_zipfile", "(", "filename", ",", "extract_dir", ")", ":", "try", ":", "import", "zipfile", "except", "ImportError", ":", "raise", "ReadError", "(", "'zlib not supported, cannot unpack this archive.'", ")", "if", "not", "zipfile", ".", "is_zipfile", "(...
[ 662, 0 ]
[ 697, 19 ]
python
en
['en', 'nl', 'ur']
False
_unpack_tarfile
(filename, extract_dir)
Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
def _unpack_tarfile(filename, extract_dir): """Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir` """ try: tarobj = tarfile.open(filename) except tarfile.TarError: raise ReadError( "%s is not a compressed or uncompressed tar file" % filename) try: tarobj.extrac...
[ "def", "_unpack_tarfile", "(", "filename", ",", "extract_dir", ")", ":", "try", ":", "tarobj", "=", "tarfile", ".", "open", "(", "filename", ")", "except", "tarfile", ".", "TarError", ":", "raise", "ReadError", "(", "\"%s is not a compressed or uncompressed tar fi...
[ 699, 0 ]
[ 710, 22 ]
python
en
['en', 'id', 'hi']
False
unpack_archive
(filename, extract_dir=None, format=None)
Unpack an archive. `filename` is the name of the archive. `extract_dir` is the name of the target directory, where the archive is unpacked. If not provided, the current working directory is used. `format` is the archive format: one of "zip", "tar", or "gztar". Or any other registered format. If n...
Unpack an archive.
def unpack_archive(filename, extract_dir=None, format=None): """Unpack an archive. `filename` is the name of the archive. `extract_dir` is the name of the target directory, where the archive is unpacked. If not provided, the current working directory is used. `format` is the archive format: one o...
[ "def", "unpack_archive", "(", "filename", ",", "extract_dir", "=", "None", ",", "format", "=", "None", ")", ":", "if", "extract_dir", "is", "None", ":", "extract_dir", "=", "os", ".", "getcwd", "(", ")", "if", "format", "is", "not", "None", ":", "try",...
[ 729, 0 ]
[ 763, 45 ]
python
de
['en', 'fr', 'de']
False
ApiRootView.get
(self, request, format=None)
List supported API versions
List supported API versions
def get(self, request, format=None): '''List supported API versions''' v2 = reverse('api:api_v2_root_view', kwargs={'version': 'v2'}) data = OrderedDict() data['description'] = _('AWX REST API') data['current_version'] = v2 data['available_versions'] = dict(v2=v2) ...
[ "def", "get", "(", "self", ",", "request", ",", "format", "=", "None", ")", ":", "v2", "=", "reverse", "(", "'api:api_v2_root_view'", ",", "kwargs", "=", "{", "'version'", ":", "'v2'", "}", ")", "data", "=", "OrderedDict", "(", ")", "data", "[", "'de...
[ 45, 4 ]
[ 57, 29 ]
python
en
['en', 'en', 'en']
True
ApiVersionRootView.get
(self, request, format=None)
List top level resources
List top level resources
def get(self, request, format=None): '''List top level resources''' data = OrderedDict() data['ping'] = reverse('api:api_v2_ping_view', request=request) data['instances'] = reverse('api:instance_list', request=request) data['instance_groups'] = reverse('api:instance_group_list', ...
[ "def", "get", "(", "self", ",", "request", ",", "format", "=", "None", ")", ":", "data", "=", "OrderedDict", "(", ")", "data", "[", "'ping'", "]", "=", "reverse", "(", "'api:api_v2_ping_view'", ",", "request", "=", "request", ")", "data", "[", "'instan...
[ 80, 4 ]
[ 125, 29 ]
python
en
['en', 'en', 'en']
True
ApiV2PingView.get
(self, request, format=None)
Return some basic information about this instance Everything returned here should be considered public / insecure, as this requires no auth and is intended for use by the installer process.
Return some basic information about this instance
def get(self, request, format=None): """Return some basic information about this instance Everything returned here should be considered public / insecure, as this requires no auth and is intended for use by the installer process. """ response = {'ha': is_ha_environment(), 'versi...
[ "def", "get", "(", "self", ",", "request", ",", "format", "=", "None", ")", ":", "response", "=", "{", "'ha'", ":", "is_ha_environment", "(", ")", ",", "'version'", ":", "get_awx_version", "(", ")", ",", "'active_node'", ":", "settings", ".", "CLUSTER_HO...
[ 142, 4 ]
[ 169, 33 ]
python
en
['en', 'en', 'en']
True
ApiV2ConfigView.get
(self, request, format=None)
Return various sitewide configuration settings
Return various sitewide configuration settings
def get(self, request, format=None): '''Return various sitewide configuration settings''' license_data = get_licenser().validate() if not license_data.get('valid_key', False): license_data = {} pendo_state = settings.PENDO_TRACKING_STATE if settings.PENDO_TRACKING_STATE in...
[ "def", "get", "(", "self", ",", "request", ",", "format", "=", "None", ")", ":", "license_data", "=", "get_licenser", "(", ")", ".", "validate", "(", ")", "if", "not", "license_data", ".", "get", "(", "'valid_key'", ",", "False", ")", ":", "license_dat...
[ 269, 4 ]
[ 315, 29 ]
python
en
['en', 'en', 'en']
True
check_view_restrictions
(document, request)
Check whether there are any view restrictions on this document which are not fulfilled by the given request object. If there are, return an HttpResponse that will notify the user of that restriction (and possibly include a password / login form that will allow them to proceed). If there are no such...
Check whether there are any view restrictions on this document which are not fulfilled by the given request object. If there are, return an HttpResponse that will notify the user of that restriction (and possibly include a password / login form that will allow them to proceed). If there are no such...
def check_view_restrictions(document, request): """ Check whether there are any view restrictions on this document which are not fulfilled by the given request object. If there are, return an HttpResponse that will notify the user of that restriction (and possibly include a password / login form tha...
[ "def", "check_view_restrictions", "(", "document", ",", "request", ")", ":", "for", "restriction", "in", "document", ".", "collection", ".", "get_view_restrictions", "(", ")", ":", "if", "not", "restriction", ".", "accept_request", "(", "request", ")", ":", "i...
[ 162, 0 ]
[ 187, 74 ]
python
en
['en', 'error', 'th']
False
ObjectContainer.__setslice__
(self, section, items)
Not implemented.
Not implemented.
def __setslice__(self, section, items): """ Not implemented. """ raise NotImplementedError
[ "def", "__setslice__", "(", "self", ",", "section", ",", "items", ")", ":", "raise", "NotImplementedError" ]
[ 45, 4 ]
[ 49, 33 ]
python
en
['en', 'error', 'th']
False
ObjectContainer.__iadd__
(self, y)
Not implemented.
Not implemented.
def __iadd__(self, y): """ Not implemented. """ raise NotImplementedError
[ "def", "__iadd__", "(", "self", ",", "y", ")", ":", "raise", "NotImplementedError" ]
[ 51, 4 ]
[ 55, 33 ]
python
en
['en', 'error', 'th']
False
ObjectContainer.__imul__
(self, y)
Not implemented.
Not implemented.
def __imul__(self, y): """ Not implemented. """ raise NotImplementedError
[ "def", "__imul__", "(", "self", ",", "y", ")", ":", "raise", "NotImplementedError" ]
[ 57, 4 ]
[ 61, 33 ]
python
en
['en', 'error', 'th']
False
ObjectContainer.__mul__
(self, y)
Not implemented.
Not implemented.
def __mul__(self, y): """ Not implemented. """ raise NotImplementedError
[ "def", "__mul__", "(", "self", ",", "y", ")", ":", "raise", "NotImplementedError" ]
[ 63, 4 ]
[ 67, 33 ]
python
en
['en', 'error', 'th']
False
ObjectContainer.__rmul__
(self, y)
Not implemented.
Not implemented.
def __rmul__(self, y): """ Not implemented. """ raise NotImplementedError
[ "def", "__rmul__", "(", "self", ",", "y", ")", ":", "raise", "NotImplementedError" ]
[ 69, 4 ]
[ 73, 33 ]
python
en
['en', 'error', 'th']
False
BulkUsersTest.test_client_gravatar_option
(self)
The main purpose of this test is to make sure we return None for avatar_url when client_gravatar is set to True. And we do a sanity check for when it's False, but we leave it to other tests to validate the specific URL.
The main purpose of this test is to make sure we return None for avatar_url when client_gravatar is set to True. And we do a sanity check for when it's False, but we leave it to other tests to validate the specific URL.
def test_client_gravatar_option(self) -> None: reset_emails_in_zulip_realm() self.login("cordelia") hamlet = self.example_user("hamlet") def get_hamlet_avatar(client_gravatar: bool) -> Optional[str]: data = dict(client_gravatar=orjson.dumps(client_gravatar).decode()) ...
[ "def", "test_client_gravatar_option", "(", "self", ")", "->", "None", ":", "reset_emails_in_zulip_realm", "(", ")", "self", ".", "login", "(", "\"cordelia\"", ")", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "def", "get_hamlet_avatar", "(...
[ 1714, 4 ]
[ 1743, 9 ]
python
en
['en', 'error', 'th']
False
GetProfileTest.test_cache_behavior
(self)
Tests whether fetching a user object the normal way, with `get_user`, makes 1 cache query and 1 database query.
Tests whether fetching a user object the normal way, with `get_user`, makes 1 cache query and 1 database query.
def test_cache_behavior(self) -> None: """Tests whether fetching a user object the normal way, with `get_user`, makes 1 cache query and 1 database query. """ realm = get_realm("zulip") email = self.example_user("hamlet").email with queries_captured() as queries: ...
[ "def", "test_cache_behavior", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "email", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", ".", "email", "with", "queries_captured", "(", ")", "as", "queries", ":"...
[ 1747, 4 ]
[ 1759, 51 ]
python
en
['en', 'en', 'en']
True
Adafactor.step
(self, closure: OptLossClosure = None)
r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss.
r"""Performs a single optimization step.
def step(self, closure: OptLossClosure = None) -> OptFloat: r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss. """ loss = None if closure is not None: loss = closure() for group...
[ "def", "step", "(", "self", ",", "closure", ":", "OptLossClosure", "=", "None", ")", "->", "OptFloat", ":", "loss", "=", "None", "if", "closure", "is", "not", "None", ":", "loss", "=", "closure", "(", ")", "for", "group", "in", "self", ".", "param_gr...
[ 122, 4 ]
[ 213, 19 ]
python
en
['en', 'en', 'en']
True
CommonScheduler.fetch_available
(api_uri: str)
HTTP Get to the <api_uri>/scheduler/available :param api_uri: str :return: list of interfaces
HTTP Get to the <api_uri>/scheduler/available :param api_uri: str :return: list of interfaces
def fetch_available(api_uri: str): """ HTTP Get to the <api_uri>/scheduler/available :param api_uri: str :return: list of interfaces """ query = "%s/scheduler/available" % api_uri logger.debug("fetch %s" % query) try: r = requests.get(query) ...
[ "def", "fetch_available", "(", "api_uri", ":", "str", ")", ":", "query", "=", "\"%s/scheduler/available\"", "%", "api_uri", "logger", ".", "debug", "(", "\"fetch %s\"", "%", "query", ")", "try", ":", "r", "=", "requests", ".", "get", "(", "query", ")", "...
[ 25, 4 ]
[ 41, 21 ]
python
en
['en', 'error', 'th']
False
CommonScheduler.apply
(self)
Entrypoint to apply the schedule plan >>> sch = CommonScheduler() >>> sch.apply() :return: True if it's a number require (3 members for Etcd), int number of effective apply (Etcd Proxy)
Entrypoint to apply the schedule plan >>> sch = CommonScheduler() >>> sch.apply() :return: True if it's a number require (3 members for Etcd), int number of effective apply (Etcd Proxy)
def apply(self): """ Entrypoint to apply the schedule plan >>> sch = CommonScheduler() >>> sch.apply() :return: True if it's a number require (3 members for Etcd), int number of effective apply (Etcd Proxy) """ raise NotImplementedError
[ "def", "apply", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 43, 4 ]
[ 51, 33 ]
python
en
['en', 'error', 'th']
False
to_container_path
(path, private_data_dir)
Given a path inside of the host machine filesystem, this returns the expected path which would be observed by the job running inside of the EE container. This only handles the volume mount from private_data_dir to /runner
Given a path inside of the host machine filesystem, this returns the expected path which would be observed by the job running inside of the EE container. This only handles the volume mount from private_data_dir to /runner
def to_container_path(path, private_data_dir): """Given a path inside of the host machine filesystem, this returns the expected path which would be observed by the job running inside of the EE container. This only handles the volume mount from private_data_dir to /runner """ if not os.path.isabs...
[ "def", "to_container_path", "(", "path", ",", "private_data_dir", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "private_data_dir", ")", ":", "raise", "RuntimeError", "(", "'The private_data_dir path must be absolute'", ")", "if", "private_data_dir", ...
[ 49, 0 ]
[ 59, 60 ]
python
en
['en', 'en', 'en']
True
to_host_path
(path, private_data_dir)
Given a path inside of the EE container, this gives the absolute path on the host machine within the private_data_dir
Given a path inside of the EE container, this gives the absolute path on the host machine within the private_data_dir
def to_host_path(path, private_data_dir): """Given a path inside of the EE container, this gives the absolute path on the host machine within the private_data_dir """ if not os.path.isabs(private_data_dir): raise RuntimeError('The private_data_dir path must be absolute') if CONTAINER_ROOT !=...
[ "def", "to_host_path", "(", "path", ",", "private_data_dir", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "private_data_dir", ")", ":", "raise", "RuntimeError", "(", "'The private_data_dir path must be absolute'", ")", "if", "CONTAINER_ROOT", "!=",...
[ 62, 0 ]
[ 70, 60 ]
python
en
['en', 'en', 'en']
True
TestMissedMessages.test_multiple_stream_messages_and_mentions
(self)
Subject should be stream name and topic as usual.
Subject should be stream name and topic as usual.
def test_multiple_stream_messages_and_mentions(self) -> None: """Subject should be stream name and topic as usual.""" hamlet = self.example_user("hamlet") msg_id_1 = self.send_stream_message(self.example_user("iago"), "Denmark", "Regular message") msg_id_2 = self.send_stream_message( ...
[ "def", "test_multiple_stream_messages_and_mentions", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "msg_id_1", "=", "self", ".", "send_stream_message", "(", "self", ".", "example_user", "(", "\"iago\"", ...
[ 1039, 4 ]
[ 1056, 63 ]
python
en
['en', 'en', 'en']
True
TestMissedMessages.test_stream_mentions_multiple_people
(self)
Subject should be stream name and topic as usual.
Subject should be stream name and topic as usual.
def test_stream_mentions_multiple_people(self) -> None: """Subject should be stream name and topic as usual.""" hamlet = self.example_user("hamlet") msg_id_1 = self.send_stream_message( self.example_user("iago"), "Denmark", "@**King Hamlet**" ) msg_id_2 = self.send_st...
[ "def", "test_stream_mentions_multiple_people", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "msg_id_1", "=", "self", ".", "send_stream_message", "(", "self", ".", "example_user", "(", "\"iago\"", ")", ...
[ 1089, 4 ]
[ 1112, 63 ]
python
en
['en', 'en', 'en']
True
TestMissedMessages.test_multiple_stream_messages_different_topics
(self)
Should receive separate emails for each topic within a stream.
Should receive separate emails for each topic within a stream.
def test_multiple_stream_messages_different_topics(self) -> None: """Should receive separate emails for each topic within a stream.""" hamlet = self.example_user("hamlet") msg_id_1 = self.send_stream_message(self.example_user("othello"), "Denmark", "Message1") msg_id_2 = self.send_stream...
[ "def", "test_multiple_stream_messages_different_topics", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "msg_id_1", "=", "self", ".", "send_stream_message", "(", "self", ".", "example_user", "(", "\"othello...
[ 1114, 4 ]
[ 1132, 62 ]
python
en
['en', 'en', 'en']
True
generate_farmed_coin
( block_index: int, puzzle_hash: bytes32, amount: int, )
Generate a (fake) coin which can be used as a starting point for a chain of coin tests.
Generate a (fake) coin which can be used as a starting point for a chain of coin tests.
def generate_farmed_coin( block_index: int, puzzle_hash: bytes32, amount: int, ) -> Coin: """ Generate a (fake) coin which can be used as a starting point for a chain of coin tests. """ return Coin(int_as_bytes32(block_index), puzzle_hash, uint64(amount))
[ "def", "generate_farmed_coin", "(", "block_index", ":", "int", ",", "puzzle_hash", ":", "bytes32", ",", "amount", ":", "int", ",", ")", "->", "Coin", ":", "return", "Coin", "(", "int_as_bytes32", "(", "block_index", ")", ",", "puzzle_hash", ",", "uint64", ...
[ 46, 0 ]
[ 55, 73 ]
python
en
['en', 'error', 'th']
False
issue_cc_from_farmed_coin
( mod_code: Program, coin_checker_for_farmed_coin, block_id: int, inner_puzzle_hash: bytes32, amount: int, )
This is an example of how to issue a cc.
This is an example of how to issue a cc.
def issue_cc_from_farmed_coin( mod_code: Program, coin_checker_for_farmed_coin, block_id: int, inner_puzzle_hash: bytes32, amount: int, ) -> Tuple[Program, SpendBundle]: """ This is an example of how to issue a cc. """ # get a farmed coin farmed_puzzle = ANYONE_CAN_SPEND_PUZZLE ...
[ "def", "issue_cc_from_farmed_coin", "(", "mod_code", ":", "Program", ",", "coin_checker_for_farmed_coin", ",", "block_id", ":", "int", ",", "inner_puzzle_hash", ":", "bytes32", ",", "amount", ":", "int", ",", ")", "->", "Tuple", "[", "Program", ",", "SpendBundle...
[ 58, 0 ]
[ 88, 45 ]
python
en
['en', 'error', 'th']
False
test_spend_through_n
(mod_code, coin_checker_for_farmed_coin, n)
Test to spend ccs from a farmed coin to a cc genesis coin, then to N outputs, then joining back down to two outputs.
Test to spend ccs from a farmed coin to a cc genesis coin, then to N outputs, then joining back down to two outputs.
def test_spend_through_n(mod_code, coin_checker_for_farmed_coin, n): """ Test to spend ccs from a farmed coin to a cc genesis coin, then to N outputs, then joining back down to two outputs. """ ################################ # spend from a farmed coin to a cc genesis coin # get a farmed...
[ "def", "test_spend_through_n", "(", "mod_code", ",", "coin_checker_for_farmed_coin", ",", "n", ")", ":", "################################", "# spend from a farmed coin to a cc genesis coin", "# get a farmed coin", "eve_inner_puzzle", "=", "ANYONE_CAN_SPEND_PUZZLE", "eve_inner_puzzle...
[ 98, 0 ]
[ 174, 36 ]
python
en
['en', 'error', 'th']
False
test_spend_zero_coin
(mod_code: Program, coin_checker_for_farmed_coin)
Test to spend ccs from a farmed coin to a cc genesis coin, then to N outputs, then joining back down to two outputs.
Test to spend ccs from a farmed coin to a cc genesis coin, then to N outputs, then joining back down to two outputs.
def test_spend_zero_coin(mod_code: Program, coin_checker_for_farmed_coin): """ Test to spend ccs from a farmed coin to a cc genesis coin, then to N outputs, then joining back down to two outputs. """ eve_inner_puzzle = ANYONE_CAN_SPEND_PUZZLE eve_inner_puzzle_hash = eve_inner_puzzle.get_tree_ha...
[ "def", "test_spend_zero_coin", "(", "mod_code", ":", "Program", ",", "coin_checker_for_farmed_coin", ")", ":", "eve_inner_puzzle", "=", "ANYONE_CAN_SPEND_PUZZLE", "eve_inner_puzzle_hash", "=", "eve_inner_puzzle", ".", "get_tree_hash", "(", ")", "total_minted", "=", "0x111...
[ 177, 0 ]
[ 224, 36 ]
python
en
['en', 'error', 'th']
False
OracleSpatialAdapter.__init__
(self, geom)
Oracle requires that polygon rings are in proper orientation. This affects spatial operations and an invalid orientation may cause failures. Correct orientations are: * Outer ring - counter clockwise * Inner ring(s) - clockwise
Oracle requires that polygon rings are in proper orientation. This affects spatial operations and an invalid orientation may cause failures. Correct orientations are: * Outer ring - counter clockwise * Inner ring(s) - clockwise
def __init__(self, geom): """ Oracle requires that polygon rings are in proper orientation. This affects spatial operations and an invalid orientation may cause failures. Correct orientations are: * Outer ring - counter clockwise * Inner ring(s) - clockwise """ ...
[ "def", "__init__", "(", "self", ",", "geom", ")", ":", "if", "isinstance", "(", "geom", ",", "Polygon", ")", ":", "self", ".", "_fix_polygon", "(", "geom", ")", "elif", "isinstance", "(", "geom", ",", "GeometryCollection", ")", ":", "self", ".", "_fix_...
[ 10, 4 ]
[ 24, 29 ]
python
en
['en', 'error', 'th']
False
match_erspan3_pkt
(exp_pkt, pkt, ignore_tstamp=True)
Compare ERSPAN_III packets, ignore the timestamp value. Just make sure it is non-zero
Compare ERSPAN_III packets, ignore the timestamp value. Just make sure it is non-zero
def match_erspan3_pkt(exp_pkt, pkt, ignore_tstamp=True): """ Compare ERSPAN_III packets, ignore the timestamp value. Just make sure it is non-zero """ if ignore_tstamp: erspan3 = pkt.getlayer(ERSPAN_III) if erspan3 == None: #self.logger.error("No ERSPAN pkt received") ...
[ "def", "match_erspan3_pkt", "(", "exp_pkt", ",", "pkt", ",", "ignore_tstamp", "=", "True", ")", ":", "if", "ignore_tstamp", ":", "erspan3", "=", "pkt", ".", "getlayer", "(", "ERSPAN_III", ")", "if", "erspan3", "==", "None", ":", "#self.logger.error(\"No ERSPAN...
[ 2, 0 ]
[ 26, 48 ]
python
en
['en', 'error', 'th']
False
verify_erspan3_packet
(test, pkt, ofport)
Check that an expected packet is received
Check that an expected packet is received
def verify_erspan3_packet(test, pkt, ofport): """ Check that an expected packet is received """ logging.debug("Checking for pkt on port %r", ofport) (_, rcv_port, rcv_pkt, pkt_time) = test.dataplane.poll(port_number=ofport, timeout=2, exp_pkt=None) test.assertTrue(rcv_pkt != None, "Did not recei...
[ "def", "verify_erspan3_packet", "(", "test", ",", "pkt", ",", "ofport", ")", ":", "logging", ".", "debug", "(", "\"Checking for pkt on port %r\"", ",", "ofport", ")", "(", "_", ",", "rcv_port", ",", "rcv_pkt", ",", "pkt_time", ")", "=", "test", ".", "datap...
[ 28, 0 ]
[ 37, 98 ]
python
en
['en', 'error', 'th']
False
open_resource
(name)
Open a resource from the zoneinfo subdir for reading. Uses the pkg_resources module if available and no standard file found at the calculated location. It is possible to specify different location for zoneinfo subdir by using the PYTZ_TZDATADIR environment variable.
Open a resource from the zoneinfo subdir for reading.
def open_resource(name): """Open a resource from the zoneinfo subdir for reading. Uses the pkg_resources module if available and no standard file found at the calculated location. It is possible to specify different location for zoneinfo subdir by using the PYTZ_TZDATADIR environment variable. ...
[ "def", "open_resource", "(", "name", ")", ":", "name_parts", "=", "name", ".", "lstrip", "(", "'/'", ")", ".", "split", "(", "'/'", ")", "for", "part", "in", "name_parts", ":", "if", "part", "==", "os", ".", "path", ".", "pardir", "or", "os", ".", ...
[ 76, 0 ]
[ 106, 31 ]
python
en
['en', 'en', 'en']
True
resource_exists
(name)
Return true if the given resource exists
Return true if the given resource exists
def resource_exists(name): """Return true if the given resource exists""" try: open_resource(name).close() return True except IOError: return False
[ "def", "resource_exists", "(", "name", ")", ":", "try", ":", "open_resource", "(", "name", ")", ".", "close", "(", ")", "return", "True", "except", "IOError", ":", "return", "False" ]
[ 109, 0 ]
[ 115, 20 ]
python
en
['en', 'en', 'en']
True
timezone
(zone)
r''' Return a datetime.tzinfo implementation for the given timezone >>> from datetime import datetime, timedelta >>> utc = timezone('UTC') >>> eastern = timezone('US/Eastern') >>> eastern.zone 'US/Eastern' >>> timezone(unicode('US/Eastern')) is eastern True >>> utc_dt = datetime(2002, 1...
r''' Return a datetime.tzinfo implementation for the given timezone
def timezone(zone): r''' Return a datetime.tzinfo implementation for the given timezone >>> from datetime import datetime, timedelta >>> utc = timezone('UTC') >>> eastern = timezone('US/Eastern') >>> eastern.zone 'US/Eastern' >>> timezone(unicode('US/Eastern')) is eastern True >>> u...
[ "def", "timezone", "(", "zone", ")", ":", "if", "zone", ".", "upper", "(", ")", "==", "'UTC'", ":", "return", "utc", "try", ":", "zone", "=", "ascii", "(", "zone", ")", "except", "UnicodeEncodeError", ":", "# All valid timezones are ASCII", "raise", "Unkno...
[ 121, 0 ]
[ 178, 30 ]
python
en
['en', 'en', 'en']
True
_unmunge_zone
(zone)
Undo the time zone name munging done by older versions of pytz.
Undo the time zone name munging done by older versions of pytz.
def _unmunge_zone(zone): """Undo the time zone name munging done by older versions of pytz.""" return zone.replace('_plus_', '+').replace('_minus_', '-')
[ "def", "_unmunge_zone", "(", "zone", ")", ":", "return", "zone", ".", "replace", "(", "'_plus_'", ",", "'+'", ")", ".", "replace", "(", "'_minus_'", ",", "'-'", ")" ]
[ 181, 0 ]
[ 183, 62 ]
python
en
['en', 'en', 'en']
True
_UTC
()
Factory function for utc unpickling. Makes sure that unpickling a utc instance always returns the same module global. These examples belong in the UTC class above, but it is obscured; or in the README.txt, but we are not depending on Python 2.4 so integrating the README.txt examples with the unit ...
Factory function for utc unpickling.
def _UTC(): """Factory function for utc unpickling. Makes sure that unpickling a utc instance always returns the same module global. These examples belong in the UTC class above, but it is obscured; or in the README.txt, but we are not depending on Python 2.4 so integrating the README.txt exam...
[ "def", "_UTC", "(", ")", ":", "return", "utc" ]
[ 243, 0 ]
[ 272, 14 ]
python
en
['en', 'en', 'en']
True
_p
(*args)
Factory function for unpickling pytz tzinfo instances. Just a wrapper around tzinfo.unpickler to save a few bytes in each pickle by shortening the path.
Factory function for unpickling pytz tzinfo instances.
def _p(*args): """Factory function for unpickling pytz tzinfo instances. Just a wrapper around tzinfo.unpickler to save a few bytes in each pickle by shortening the path. """ return unpickler(*args)
[ "def", "_p", "(", "*", "args", ")", ":", "return", "unpickler", "(", "*", "args", ")" ]
[ 276, 0 ]
[ 282, 27 ]
python
en
['en', 'fr', 'en']
True
FixedOffset
(offset, _tzinfos={})
return a fixed-offset timezone based off a number of minutes. >>> one = FixedOffset(-330) >>> one pytz.FixedOffset(-330) >>> str(one.utcoffset(datetime.datetime.now())) '-1 day, 18:30:00' >>> str(one.dst(datetime.datetime.now())) '0:00:00' >>> two = Fixe...
return a fixed-offset timezone based off a number of minutes.
def FixedOffset(offset, _tzinfos={}): """return a fixed-offset timezone based off a number of minutes. >>> one = FixedOffset(-330) >>> one pytz.FixedOffset(-330) >>> str(one.utcoffset(datetime.datetime.now())) '-1 day, 18:30:00' >>> str(one.dst(datetime.datetime.now(...
[ "def", "FixedOffset", "(", "offset", ",", "_tzinfos", "=", "{", "}", ")", ":", "if", "offset", "==", "0", ":", "return", "UTC", "info", "=", "_tzinfos", ".", "get", "(", "offset", ")", "if", "info", "is", "None", ":", "# We haven't seen this one before. ...
[ 409, 0 ]
[ 473, 15 ]
python
en
['en', 'en', 'en']
True
UTC.localize
(self, dt, is_dst=False)
Convert naive time to local time
Convert naive time to local time
def localize(self, dt, is_dst=False): '''Convert naive time to local time''' if dt.tzinfo is not None: raise ValueError('Not naive datetime (tzinfo is already set)') return dt.replace(tzinfo=self)
[ "def", "localize", "(", "self", ",", "dt", ",", "is_dst", "=", "False", ")", ":", "if", "dt", ".", "tzinfo", "is", "not", "None", ":", "raise", "ValueError", "(", "'Not naive datetime (tzinfo is already set)'", ")", "return", "dt", ".", "replace", "(", "tz...
[ 219, 4 ]
[ 223, 38 ]
python
en
['en', 'en', 'en']
True
UTC.normalize
(self, dt, is_dst=False)
Correct the timezone information on the given datetime
Correct the timezone information on the given datetime
def normalize(self, dt, is_dst=False): '''Correct the timezone information on the given datetime''' if dt.tzinfo is self: return dt if dt.tzinfo is None: raise ValueError('Naive time - no tzinfo set') return dt.astimezone(self)
[ "def", "normalize", "(", "self", ",", "dt", ",", "is_dst", "=", "False", ")", ":", "if", "dt", ".", "tzinfo", "is", "self", ":", "return", "dt", "if", "dt", ".", "tzinfo", "is", "None", ":", "raise", "ValueError", "(", "'Naive time - no tzinfo set'", "...
[ 225, 4 ]
[ 231, 34 ]
python
en
['en', 'en', 'en']
True
_CountryTimezoneDict.__call__
(self, iso3166_code)
Backwards compatibility.
Backwards compatibility.
def __call__(self, iso3166_code): """Backwards compatibility.""" return self[iso3166_code]
[ "def", "__call__", "(", "self", ",", "iso3166_code", ")", ":", "return", "self", "[", "iso3166_code", "]" ]
[ 318, 4 ]
[ 320, 33 ]
python
en
['en', 'zu', 'en']
False
_FixedOffset.localize
(self, dt, is_dst=False)
Convert naive time to local time
Convert naive time to local time
def localize(self, dt, is_dst=False): '''Convert naive time to local time''' if dt.tzinfo is not None: raise ValueError('Not naive datetime (tzinfo is already set)') return dt.replace(tzinfo=self)
[ "def", "localize", "(", "self", ",", "dt", ",", "is_dst", "=", "False", ")", ":", "if", "dt", ".", "tzinfo", "is", "not", "None", ":", "raise", "ValueError", "(", "'Not naive datetime (tzinfo is already set)'", ")", "return", "dt", ".", "replace", "(", "tz...
[ 394, 4 ]
[ 398, 38 ]
python
en
['en', 'en', 'en']
True
_FixedOffset.normalize
(self, dt, is_dst=False)
Correct the timezone information on the given datetime
Correct the timezone information on the given datetime
def normalize(self, dt, is_dst=False): '''Correct the timezone information on the given datetime''' if dt.tzinfo is self: return dt if dt.tzinfo is None: raise ValueError('Naive time - no tzinfo set') return dt.astimezone(self)
[ "def", "normalize", "(", "self", ",", "dt", ",", "is_dst", "=", "False", ")", ":", "if", "dt", ".", "tzinfo", "is", "self", ":", "return", "dt", "if", "dt", ".", "tzinfo", "is", "None", ":", "raise", "ValueError", "(", "'Naive time - no tzinfo set'", "...
[ 400, 4 ]
[ 406, 34 ]
python
en
['en', 'en', 'en']
True
get_current_site
(request)
Checks if contrib.sites is installed and returns either the current ``Site`` object or a ``RequestSite`` object based on the request.
Checks if contrib.sites is installed and returns either the current ``Site`` object or a ``RequestSite`` object based on the request.
def get_current_site(request): """ Checks if contrib.sites is installed and returns either the current ``Site`` object or a ``RequestSite`` object based on the request. """ # Imports are inside the function because its point is to avoid importing # the Site models when django.contrib.sites isn't...
[ "def", "get_current_site", "(", "request", ")", ":", "# Imports are inside the function because its point is to avoid importing", "# the Site models when django.contrib.sites isn't installed.", "if", "apps", ".", "is_installed", "(", "'django.contrib.sites'", ")", ":", "from", ".",...
[ 5, 0 ]
[ 17, 35 ]
python
en
['en', 'error', 'th']
False
dump_cache_data
()
Dump all cached data to disk in a pickle file. Not generally intended to be called by client code, but dispatched from tasks within this class - but it's there if you need to force a dump for some reason. :returns: None
Dump all cached data to disk in a pickle file. Not generally intended to be called by client code, but dispatched from tasks within this class - but it's there if you need to force a dump for some reason.
def dump_cache_data(): """ Dump all cached data to disk in a pickle file. Not generally intended to be called by client code, but dispatched from tasks within this class - but it's there if you need to force a dump for some reason. :returns: None """ datahandling._dump_pickle('metasmokeCacheDat...
[ "def", "dump_cache_data", "(", ")", ":", "datahandling", ".", "_dump_pickle", "(", "'metasmokeCacheData.p'", ",", "{", "'cache'", ":", "MetasmokeCache", ".", "_cache", ",", "'expiries'", ":", "MetasmokeCache", ".", "_expiries", "}", ")" ]
[ 147, 0 ]
[ 155, 101 ]
python
en
['en', 'error', 'th']
False
MetasmokeCache.get
(key)
Retrieve a cached value. Will not re-generate expired values - if that's the behaviour you need, use MetasmokeCache.fetch. :param key: the cache key for which to find a value :returns: Tuple - [0] the cached value if it's available and in-date, otherwise None; ...
Retrieve a cached value. Will not re-generate expired values - if that's the behaviour you need, use MetasmokeCache.fetch.
def get(key): """ Retrieve a cached value. Will not re-generate expired values - if that's the behaviour you need, use MetasmokeCache.fetch. :param key: the cache key for which to find a value :returns: Tuple - [0] the cached value if it's available and in-date, otherwise None; ...
[ "def", "get", "(", "key", ")", ":", "if", "key", "in", "MetasmokeCache", ".", "_cache", ":", "if", "(", "key", "in", "MetasmokeCache", ".", "_expiries", "and", "MetasmokeCache", ".", "_expiries", "[", "key", "]", ">=", "int", "(", "time", ".", "time", ...
[ 13, 4 ]
[ 34, 38 ]
python
en
['en', 'error', 'th']
False
MetasmokeCache.fetch
(key, generator=None, expiry=None)
Retrieve a cached value. Will re-generate expired values according to the supplied generator function. :param key: The cache key for which to find a value. :param generator: A generator function that returns a fresh value for the supplied key, used if the value ...
Retrieve a cached value. Will re-generate expired values according to the supplied generator function.
def fetch(key, generator=None, expiry=None): """ Retrieve a cached value. Will re-generate expired values according to the supplied generator function. :param key: The cache key for which to find a value. :param generator: A generator function that returns a fresh value for the su...
[ "def", "fetch", "(", "key", ",", "generator", "=", "None", ",", "expiry", "=", "None", ")", ":", "value", ",", "cache_status", "=", "MetasmokeCache", ".", "get", "(", "key", ")", "if", "value", "is", "not", "None", ":", "# Cache hit. Doesn't matter what ki...
[ 37, 4 ]
[ 66, 37 ]
python
en
['en', 'error', 'th']
False
MetasmokeCache.fetch_from_api
(key, uri, params=None, expiry=None, property_as_list=None)
Retrive a cached value. Will regenerate expired values from the metasmoke API. :param key: The cache key for which to find a value. :param uri: The URI for the API route from which to regenerate an expired value. :param params: Any parameters to be s...
Retrive a cached value. Will regenerate expired values from the metasmoke API.
def fetch_from_api(key, uri, params=None, expiry=None, property_as_list=None): """ Retrive a cached value. Will regenerate expired values from the metasmoke API. :param key: The cache key for which to find a value. :param uri: The URI for the API route from whi...
[ "def", "fetch_from_api", "(", "key", ",", "uri", ",", "params", "=", "None", ",", "expiry", "=", "None", ",", "property_as_list", "=", "None", ")", ":", "def", "generator", "(", ")", ":", "nonlocal", "uri", ",", "params", "if", "params", "is", "None", ...
[ 69, 4 ]
[ 115, 59 ]
python
en
['en', 'error', 'th']
False
MetasmokeCache.insert
(key, value, expiry=None)
Insert a new value into the cache. Will overwrite existing value, if there is one. :param key: The cache key under which to insert the value. :param value: The value to insert. :param expiry: A value in seconds representing the TTL of the cache value. Optional - if absent, the valu...
Insert a new value into the cache. Will overwrite existing value, if there is one.
def insert(key, value, expiry=None): """ Insert a new value into the cache. Will overwrite existing value, if there is one. :param key: The cache key under which to insert the value. :param value: The value to insert. :param expiry: A value in seconds representing the TTL of...
[ "def", "insert", "(", "key", ",", "value", ",", "expiry", "=", "None", ")", ":", "MetasmokeCache", ".", "_cache", "[", "key", "]", "=", "value", "if", "expiry", "is", "not", "None", ":", "MetasmokeCache", ".", "_expiries", "[", "key", "]", "=", "int"...
[ 118, 4 ]
[ 132, 39 ]
python
en
['en', 'error', 'th']
False
MetasmokeCache.delete
(key)
Delete a cached value. :param key: The cache key to delete. :returns: None
Delete a cached value.
def delete(key): """ Delete a cached value. :param key: The cache key to delete. :returns: None """ del MetasmokeCache._cache[key] del MetasmokeCache._expiries[key] tasks.Tasks.do(dump_cache_data)
[ "def", "delete", "(", "key", ")", ":", "del", "MetasmokeCache", ".", "_cache", "[", "key", "]", "del", "MetasmokeCache", ".", "_expiries", "[", "key", "]", "tasks", ".", "Tasks", ".", "do", "(", "dump_cache_data", ")" ]
[ 135, 4 ]
[ 144, 39 ]
python
en
['en', 'error', 'th']
False
RateLimiter.__init__
(self, incoming: bool, reset_seconds=60, percentage_of_limit=100)
The incoming parameter affects whether counters are incremented unconditionally or not. For incoming messages, the counters are always incremeneted. For outgoing messages, the counters are only incremented if they are allowed to be sent by the rate limiter, since we won't send t...
The incoming parameter affects whether counters are incremented unconditionally or not. For incoming messages, the counters are always incremeneted. For outgoing messages, the counters are only incremented if they are allowed to be sent by the rate limiter, since we won't send t...
def __init__(self, incoming: bool, reset_seconds=60, percentage_of_limit=100): """ The incoming parameter affects whether counters are incremented unconditionally or not. For incoming messages, the counters are always incremeneted. For outgoing messages, the counters are only incremented...
[ "def", "__init__", "(", "self", ",", "incoming", ":", "bool", ",", "reset_seconds", "=", "60", ",", "percentage_of_limit", "=", "100", ")", ":", "self", ".", "incoming", "=", "incoming", "self", ".", "reset_seconds", "=", "reset_seconds", "self", ".", "cur...
[ 113, 4 ]
[ 128, 39 ]
python
en
['en', 'error', 'th']
False
RateLimiter.process_msg_and_check
(self, message: Message)
Returns True if message can be processed successfully, false if a rate limit is passed.
Returns True if message can be processed successfully, false if a rate limit is passed.
def process_msg_and_check(self, message: Message) -> bool: """ Returns True if message can be processed successfully, false if a rate limit is passed. """ current_minute = int(time.time() // self.reset_seconds) if current_minute != self.current_minute: self.current_m...
[ "def", "process_msg_and_check", "(", "self", ",", "message", ":", "Message", ")", "->", "bool", ":", "current_minute", "=", "int", "(", "time", ".", "time", "(", ")", "//", "self", ".", "reset_seconds", ")", "if", "current_minute", "!=", "self", ".", "cu...
[ 130, 4 ]
[ 193, 61 ]
python
en
['en', 'error', 'th']
False
get_all_distribution_names
(url=None)
Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names.
Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names.
def get_all_distribution_names(url=None): """ Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names. """ if url is None: url = DEFAULT_INDEX client = ServerProxy(url, timeout=3.0) try: return cli...
[ "def", "get_all_distribution_names", "(", "url", "=", "None", ")", ":", "if", "url", "is", "None", ":", "url", "=", "DEFAULT_INDEX", "client", "=", "ServerProxy", "(", "url", ",", "timeout", "=", "3.0", ")", "try", ":", "return", "client", ".", "list_pac...
[ 40, 0 ]
[ 52, 25 ]
python
en
['en', 'error', 'th']
False
Locator.__init__
(self, scheme='default')
Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` if you need to support existing d...
Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` if you need to support existing d...
def __init__(self, scheme='default'): """ Initialise an instance. :param scheme: Because locators look for most recent versions, they need to know the version scheme to use. This specifies the current PEP-recommended scheme - use ``'legacy'`` ...
[ "def", "__init__", "(", "self", ",", "scheme", "=", "'default'", ")", ":", "self", ".", "_cache", "=", "{", "}", "self", ".", "scheme", "=", "scheme", "# Because of bugs in some of the handlers on some of the platforms,", "# we use our own opener rather than just using ur...
[ 101, 4 ]
[ 118, 35 ]
python
en
['en', 'error', 'th']
False
Locator.get_errors
(self)
Return any errors which have occurred.
Return any errors which have occurred.
def get_errors(self): """ Return any errors which have occurred. """ result = [] while not self.errors.empty(): # pragma: no cover try: e = self.errors.get(False) result.append(e) except self.errors.Empty: c...
[ "def", "get_errors", "(", "self", ")", ":", "result", "=", "[", "]", "while", "not", "self", ".", "errors", ".", "empty", "(", ")", ":", "# pragma: no cover", "try", ":", "e", "=", "self", ".", "errors", ".", "get", "(", "False", ")", "result", "."...
[ 120, 4 ]
[ 132, 21 ]
python
en
['en', 'error', 'th']
False
Locator.clear_errors
(self)
Clear any errors which may have been logged.
Clear any errors which may have been logged.
def clear_errors(self): """ Clear any errors which may have been logged. """ # Just get the errors and throw them away self.get_errors()
[ "def", "clear_errors", "(", "self", ")", ":", "# Just get the errors and throw them away", "self", ".", "get_errors", "(", ")" ]
[ 134, 4 ]
[ 139, 25 ]
python
en
['en', 'error', 'th']
False
Locator._get_project
(self, name)
For a given project, get a dictionary mapping available versions to Distribution instances. This should be implemented in subclasses. If called from a locate() request, self.matcher will be set to a matcher for the requirement to satisfy, otherwise it will be None.
For a given project, get a dictionary mapping available versions to Distribution instances.
def _get_project(self, name): """ For a given project, get a dictionary mapping available versions to Distribution instances. This should be implemented in subclasses. If called from a locate() request, self.matcher will be set to a matcher for the requirement to satisf...
[ "def", "_get_project", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'Please implement in the subclass'", ")" ]
[ 152, 4 ]
[ 162, 69 ]
python
en
['en', 'error', 'th']
False
Locator.get_distribution_names
(self)
Return all the distribution names known to this locator.
Return all the distribution names known to this locator.
def get_distribution_names(self): """ Return all the distribution names known to this locator. """ raise NotImplementedError('Please implement in the subclass')
[ "def", "get_distribution_names", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'Please implement in the subclass'", ")" ]
[ 164, 4 ]
[ 168, 69 ]
python
en
['en', 'error', 'th']
False
Locator.get_project
(self, name)
For a given project, get a dictionary mapping available versions to Distribution instances. This calls _get_project to do all the work, and just implements a caching layer on top.
For a given project, get a dictionary mapping available versions to Distribution instances.
def get_project(self, name): """ For a given project, get a dictionary mapping available versions to Distribution instances. This calls _get_project to do all the work, and just implements a caching layer on top. """ if self._cache is None: # pragma: no cover ...
[ "def", "get_project", "(", "self", ",", "name", ")", ":", "if", "self", ".", "_cache", "is", "None", ":", "# pragma: no cover", "result", "=", "self", ".", "_get_project", "(", "name", ")", "elif", "name", "in", "self", ".", "_cache", ":", "result", "=...
[ 170, 4 ]
[ 185, 21 ]
python
en
['en', 'error', 'th']
False
Locator.score_url
(self, url)
Give an url a score which can be used to choose preferred URLs for a given project release.
Give an url a score which can be used to choose preferred URLs for a given project release.
def score_url(self, url): """ Give an url a score which can be used to choose preferred URLs for a given project release. """ t = urlparse(url) basename = posixpath.basename(t.path) compatible = True is_wheel = basename.endswith('.whl') is_download...
[ "def", "score_url", "(", "self", ",", "url", ")", ":", "t", "=", "urlparse", "(", "url", ")", "basename", "=", "posixpath", ".", "basename", "(", "t", ".", "path", ")", "compatible", "=", "True", "is_wheel", "=", "basename", ".", "endswith", "(", "'....
[ 187, 4 ]
[ 200, 64 ]
python
en
['en', 'error', 'th']
False
Locator.prefer_url
(self, url1, url2)
Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip). The current implementation favours https:// URLs over http://, archives from PyPI over those from other locations, wheel compatibili...
Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip).
def prefer_url(self, url1, url2): """ Choose one of two URLs where both are candidates for distribution archives for the same version of a distribution (for example, .tar.gz vs. zip). The current implementation favours https:// URLs over http://, archives from PyPI over ...
[ "def", "prefer_url", "(", "self", ",", "url1", ",", "url2", ")", ":", "result", "=", "url2", "if", "url1", ":", "s1", "=", "self", ".", "score_url", "(", "url1", ")", "s2", "=", "self", ".", "score_url", "(", "url2", ")", "if", "s1", ">", "s2", ...
[ 202, 4 ]
[ 222, 21 ]
python
en
['en', 'error', 'th']
False
Locator.split_filename
(self, filename, project_name)
Attempt to split a filename in project name, version and Python version.
Attempt to split a filename in project name, version and Python version.
def split_filename(self, filename, project_name): """ Attempt to split a filename in project name, version and Python version. """ return split_filename(filename, project_name)
[ "def", "split_filename", "(", "self", ",", "filename", ",", "project_name", ")", ":", "return", "split_filename", "(", "filename", ",", "project_name", ")" ]
[ 224, 4 ]
[ 228, 53 ]
python
en
['en', 'error', 'th']
False