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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
color_style | () |
Returns a Style object from the Django color scheme.
|
Returns a Style object from the Django color scheme.
| def color_style():
"""
Returns a Style object from the Django color scheme.
"""
if not supports_color():
return no_style()
return make_style(os.environ.get('DJANGO_COLORS', '')) | [
"def",
"color_style",
"(",
")",
":",
"if",
"not",
"supports_color",
"(",
")",
":",
"return",
"no_style",
"(",
")",
"return",
"make_style",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'DJANGO_COLORS'",
",",
"''",
")",
")"
] | [
67,
0
] | [
73,
58
] | python | en | ['en', 'error', 'th'] | False |
_ToGypPath | (path) | Converts a path to the format used by gyp. | Converts a path to the format used by gyp. | def _ToGypPath(path):
"""Converts a path to the format used by gyp."""
if os.sep == "\\" and os.altsep == "/":
return path.replace("\\", "/")
return path | [
"def",
"_ToGypPath",
"(",
"path",
")",
":",
"if",
"os",
".",
"sep",
"==",
"\"\\\\\"",
"and",
"os",
".",
"altsep",
"==",
"\"/\"",
":",
"return",
"path",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
")",
"return",
"path"
] | [
123,
0
] | [
127,
15
] | python | en | ['en', 'en', 'en'] | True |
_ResolveParent | (path, base_path_components) | Resolves |path|, which starts with at least one '../'. Returns an empty
string if the path shouldn't be considered. See _AddSources() for a
description of |base_path_components|. | Resolves |path|, which starts with at least one '../'. Returns an empty
string if the path shouldn't be considered. See _AddSources() for a
description of |base_path_components|. | def _ResolveParent(path, base_path_components):
"""Resolves |path|, which starts with at least one '../'. Returns an empty
string if the path shouldn't be considered. See _AddSources() for a
description of |base_path_components|."""
depth = 0
while path.startswith("../"):
depth += 1
path... | [
"def",
"_ResolveParent",
"(",
"path",
",",
"base_path_components",
")",
":",
"depth",
"=",
"0",
"while",
"path",
".",
"startswith",
"(",
"\"../\"",
")",
":",
"depth",
"+=",
"1",
"path",
"=",
"path",
"[",
"3",
":",
"]",
"# Relative includes may go outside the... | [
130,
0
] | [
148,
5
] | python | en | ['en', 'en', 'en'] | True |
_AddSources | (sources, base_path, base_path_components, result) | Extracts valid sources from |sources| and adds them to |result|. Each
source file is relative to |base_path|, but may contain '..'. To make
resolving '..' easier |base_path_components| contains each of the
directories in |base_path|. Additionally each source may contain variables.
Such sources are ignored as it... | Extracts valid sources from |sources| and adds them to |result|. Each
source file is relative to |base_path|, but may contain '..'. To make
resolving '..' easier |base_path_components| contains each of the
directories in |base_path|. Additionally each source may contain variables.
Such sources are ignored as it... | def _AddSources(sources, base_path, base_path_components, result):
"""Extracts valid sources from |sources| and adds them to |result|. Each
source file is relative to |base_path|, but may contain '..'. To make
resolving '..' easier |base_path_components| contains each of the
directories in |base_path|. Additi... | [
"def",
"_AddSources",
"(",
"sources",
",",
"base_path",
",",
"base_path_components",
",",
"result",
")",
":",
"# NOTE: gyp paths are always posix style.",
"for",
"source",
"in",
"sources",
":",
"if",
"not",
"len",
"(",
"source",
")",
"or",
"source",
".",
"starts... | [
151,
0
] | [
172,
67
] | python | en | ['en', 'en', 'en'] | True |
_ToLocalPath | (toplevel_dir, path) | Converts |path| to a path relative to |toplevel_dir|. | Converts |path| to a path relative to |toplevel_dir|. | def _ToLocalPath(toplevel_dir, path):
"""Converts |path| to a path relative to |toplevel_dir|."""
if path == toplevel_dir:
return ""
if path.startswith(toplevel_dir + "/"):
return path[len(toplevel_dir) + len("/") :]
return path | [
"def",
"_ToLocalPath",
"(",
"toplevel_dir",
",",
"path",
")",
":",
"if",
"path",
"==",
"toplevel_dir",
":",
"return",
"\"\"",
"if",
"path",
".",
"startswith",
"(",
"toplevel_dir",
"+",
"\"/\"",
")",
":",
"return",
"path",
"[",
"len",
"(",
"toplevel_dir",
... | [
180,
0
] | [
186,
15
] | python | en | ['en', 'en', 'en'] | True |
_WasBuildFileModified | (build_file, data, files, toplevel_dir) | Returns true if the build file |build_file| is either in |files| or
one of the files included by |build_file| is in |files|. |toplevel_dir| is
the root of the source tree. | Returns true if the build file |build_file| is either in |files| or
one of the files included by |build_file| is in |files|. |toplevel_dir| is
the root of the source tree. | def _WasBuildFileModified(build_file, data, files, toplevel_dir):
"""Returns true if the build file |build_file| is either in |files| or
one of the files included by |build_file| is in |files|. |toplevel_dir| is
the root of the source tree."""
if _ToLocalPath(toplevel_dir, _ToGypPath(build_file)) in files:
... | [
"def",
"_WasBuildFileModified",
"(",
"build_file",
",",
"data",
",",
"files",
",",
"toplevel_dir",
")",
":",
"if",
"_ToLocalPath",
"(",
"toplevel_dir",
",",
"_ToGypPath",
"(",
"build_file",
")",
")",
"in",
"files",
":",
"if",
"debug",
":",
"print",
"(",
"\... | [
289,
0
] | [
316,
16
] | python | en | ['en', 'en', 'en'] | True |
_GetOrCreateTargetByName | (targets, target_name) | Creates or returns the Target at targets[target_name]. If there is no
Target for |target_name| one is created. Returns a tuple of whether a new
Target was created and the Target. | Creates or returns the Target at targets[target_name]. If there is no
Target for |target_name| one is created. Returns a tuple of whether a new
Target was created and the Target. | def _GetOrCreateTargetByName(targets, target_name):
"""Creates or returns the Target at targets[target_name]. If there is no
Target for |target_name| one is created. Returns a tuple of whether a new
Target was created and the Target."""
if target_name in targets:
return False, targets[target_name]
... | [
"def",
"_GetOrCreateTargetByName",
"(",
"targets",
",",
"target_name",
")",
":",
"if",
"target_name",
"in",
"targets",
":",
"return",
"False",
",",
"targets",
"[",
"target_name",
"]",
"target",
"=",
"Target",
"(",
"target_name",
")",
"targets",
"[",
"target_na... | [
319,
0
] | [
327,
23
] | python | en | ['en', 'en', 'en'] | True |
_DoesTargetTypeRequireBuild | (target_dict) | Returns true if the target type is such that it needs to be built. | Returns true if the target type is such that it needs to be built. | def _DoesTargetTypeRequireBuild(target_dict):
"""Returns true if the target type is such that it needs to be built."""
# If a 'none' target has rules or actions we assume it requires a build.
return bool(
target_dict["type"] != "none"
or target_dict.get("actions")
or target_dict.get(... | [
"def",
"_DoesTargetTypeRequireBuild",
"(",
"target_dict",
")",
":",
"# If a 'none' target has rules or actions we assume it requires a build.",
"return",
"bool",
"(",
"target_dict",
"[",
"\"type\"",
"]",
"!=",
"\"none\"",
"or",
"target_dict",
".",
"get",
"(",
"\"actions\"",... | [
330,
0
] | [
337,
5
] | python | en | ['en', 'en', 'en'] | True |
_GenerateTargets | (data, target_list, target_dicts, toplevel_dir, files, build_files) | Returns a tuple of the following:
. A dictionary mapping from fully qualified name to Target.
. A list of the targets that have a source file in |files|.
. Targets that constitute the 'all' target. See description at top of file
for details on the 'all' target.
This sets the |match_status| of the targets th... | Returns a tuple of the following:
. A dictionary mapping from fully qualified name to Target.
. A list of the targets that have a source file in |files|.
. Targets that constitute the 'all' target. See description at top of file
for details on the 'all' target.
This sets the |match_status| of the targets th... | def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files, build_files):
"""Returns a tuple of the following:
. A dictionary mapping from fully qualified name to Target.
. A list of the targets that have a source file in |files|.
. Targets that constitute the 'all' target. See description at t... | [
"def",
"_GenerateTargets",
"(",
"data",
",",
"target_list",
",",
"target_dicts",
",",
"toplevel_dir",
",",
"files",
",",
"build_files",
")",
":",
"# Maps from target name to Target.",
"name_to_target",
"=",
"{",
"}",
"# Targets that matched.",
"matching_targets",
"=",
... | [
340,
0
] | [
424,
71
] | python | en | ['en', 'en', 'en'] | True |
_GetUnqualifiedToTargetMapping | (all_targets, to_find) | Returns a tuple of the following:
. mapping (dictionary) from unqualified name to Target for all the
Targets in |to_find|.
. any target names not found. If this is empty all targets were found. | Returns a tuple of the following:
. mapping (dictionary) from unqualified name to Target for all the
Targets in |to_find|.
. any target names not found. If this is empty all targets were found. | def _GetUnqualifiedToTargetMapping(all_targets, to_find):
"""Returns a tuple of the following:
. mapping (dictionary) from unqualified name to Target for all the
Targets in |to_find|.
. any target names not found. If this is empty all targets were found."""
result = {}
if not to_find:
return... | [
"def",
"_GetUnqualifiedToTargetMapping",
"(",
"all_targets",
",",
"to_find",
")",
":",
"result",
"=",
"{",
"}",
"if",
"not",
"to_find",
":",
"return",
"{",
"}",
",",
"[",
"]",
"to_find",
"=",
"set",
"(",
"to_find",
")",
"for",
"target_name",
"in",
"all_t... | [
427,
0
] | [
443,
39
] | python | en | ['en', 'en', 'en'] | True |
_DoesTargetDependOnMatchingTargets | (target) | Returns true if |target| or any of its dependencies is one of the
targets containing the files supplied as input to analyzer. This updates
|matches| of the Targets as it recurses.
target: the Target to look for. | Returns true if |target| or any of its dependencies is one of the
targets containing the files supplied as input to analyzer. This updates
|matches| of the Targets as it recurses.
target: the Target to look for. | def _DoesTargetDependOnMatchingTargets(target):
"""Returns true if |target| or any of its dependencies is one of the
targets containing the files supplied as input to analyzer. This updates
|matches| of the Targets as it recurses.
target: the Target to look for."""
if target.match_status == MATCH_STATUS_D... | [
"def",
"_DoesTargetDependOnMatchingTargets",
"(",
"target",
")",
":",
"if",
"target",
".",
"match_status",
"==",
"MATCH_STATUS_DOESNT_MATCH",
":",
"return",
"False",
"if",
"(",
"target",
".",
"match_status",
"==",
"MATCH_STATUS_MATCHES",
"or",
"target",
".",
"match_... | [
446,
0
] | [
464,
16
] | python | en | ['en', 'en', 'en'] | True |
_GetTargetsDependingOnMatchingTargets | (possible_targets) | Returns the list of Targets in |possible_targets| that depend (either
directly on indirectly) on at least one of the targets containing the files
supplied as input to analyzer.
possible_targets: targets to search from. | Returns the list of Targets in |possible_targets| that depend (either
directly on indirectly) on at least one of the targets containing the files
supplied as input to analyzer.
possible_targets: targets to search from. | def _GetTargetsDependingOnMatchingTargets(possible_targets):
"""Returns the list of Targets in |possible_targets| that depend (either
directly on indirectly) on at least one of the targets containing the files
supplied as input to analyzer.
possible_targets: targets to search from."""
found = []
print... | [
"def",
"_GetTargetsDependingOnMatchingTargets",
"(",
"possible_targets",
")",
":",
"found",
"=",
"[",
"]",
"print",
"(",
"\"Targets that matched by dependency:\"",
")",
"for",
"target",
"in",
"possible_targets",
":",
"if",
"_DoesTargetDependOnMatchingTargets",
"(",
"targe... | [
467,
0
] | [
477,
16
] | python | en | ['en', 'en', 'en'] | True |
_AddCompileTargets | (target, roots, add_if_no_ancestor, result) | Recurses through all targets that depend on |target|, adding all targets
that need to be built (and are in |roots|) to |result|.
roots: set of root targets.
add_if_no_ancestor: If true and there are no ancestors of |target| then add
|target| to |result|. |target| must still be in |roots|.
result: targets that... | Recurses through all targets that depend on |target|, adding all targets
that need to be built (and are in |roots|) to |result|.
roots: set of root targets.
add_if_no_ancestor: If true and there are no ancestors of |target| then add
|target| to |result|. |target| must still be in |roots|.
result: targets that... | def _AddCompileTargets(target, roots, add_if_no_ancestor, result):
"""Recurses through all targets that depend on |target|, adding all targets
that need to be built (and are in |roots|) to |result|.
roots: set of root targets.
add_if_no_ancestor: If true and there are no ancestors of |target| then add
|targ... | [
"def",
"_AddCompileTargets",
"(",
"target",
",",
"roots",
",",
"add_if_no_ancestor",
",",
"result",
")",
":",
"if",
"target",
".",
"visited",
":",
"return",
"target",
".",
"visited",
"=",
"True",
"target",
".",
"in_roots",
"=",
"target",
"in",
"roots",
"fo... | [
480,
0
] | [
534,
46
] | python | en | ['en', 'en', 'en'] | True |
_GetCompileTargets | (matching_targets, supplied_targets) | Returns the set of Targets that require a build.
matching_targets: targets that changed and need to be built.
supplied_targets: set of targets supplied to analyzer to search from. | Returns the set of Targets that require a build.
matching_targets: targets that changed and need to be built.
supplied_targets: set of targets supplied to analyzer to search from. | def _GetCompileTargets(matching_targets, supplied_targets):
"""Returns the set of Targets that require a build.
matching_targets: targets that changed and need to be built.
supplied_targets: set of targets supplied to analyzer to search from."""
result = set()
for target in matching_targets:
pri... | [
"def",
"_GetCompileTargets",
"(",
"matching_targets",
",",
"supplied_targets",
")",
":",
"result",
"=",
"set",
"(",
")",
"for",
"target",
"in",
"matching_targets",
":",
"print",
"(",
"\"finding compile targets for match\"",
",",
"target",
".",
"name",
")",
"_AddCo... | [
537,
0
] | [
545,
17
] | python | en | ['en', 'en', 'en'] | True |
_WriteOutput | (params, **values) | Writes the output, either to stdout or a file is specified. | Writes the output, either to stdout or a file is specified. | def _WriteOutput(params, **values):
"""Writes the output, either to stdout or a file is specified."""
if "error" in values:
print("Error:", values["error"])
if "status" in values:
print(values["status"])
if "targets" in values:
values["targets"].sort()
print("Supplied tar... | [
"def",
"_WriteOutput",
"(",
"params",
",",
"*",
"*",
"values",
")",
":",
"if",
"\"error\"",
"in",
"values",
":",
"print",
"(",
"\"Error:\"",
",",
"values",
"[",
"\"error\"",
"]",
")",
"if",
"\"status\"",
"in",
"values",
":",
"print",
"(",
"values",
"["... | [
548,
0
] | [
589,
66
] | python | en | ['en', 'en', 'en'] | True |
_WasGypIncludeFileModified | (params, files) | Returns true if one of the files in |files| is in the set of included
files. | Returns true if one of the files in |files| is in the set of included
files. | def _WasGypIncludeFileModified(params, files):
"""Returns true if one of the files in |files| is in the set of included
files."""
if params["options"].includes:
for include in params["options"].includes:
if _ToGypPath(os.path.normpath(include)) in files:
print("Include file... | [
"def",
"_WasGypIncludeFileModified",
"(",
"params",
",",
"files",
")",
":",
"if",
"params",
"[",
"\"options\"",
"]",
".",
"includes",
":",
"for",
"include",
"in",
"params",
"[",
"\"options\"",
"]",
".",
"includes",
":",
"if",
"_ToGypPath",
"(",
"os",
".",
... | [
592,
0
] | [
600,
16
] | python | en | ['en', 'en', 'en'] | True |
_NamesNotIn | (names, mapping) | Returns a list of the values in |names| that are not in |mapping|. | Returns a list of the values in |names| that are not in |mapping|. | def _NamesNotIn(names, mapping):
"""Returns a list of the values in |names| that are not in |mapping|."""
return [name for name in names if name not in mapping] | [
"def",
"_NamesNotIn",
"(",
"names",
",",
"mapping",
")",
":",
"return",
"[",
"name",
"for",
"name",
"in",
"names",
"if",
"name",
"not",
"in",
"mapping",
"]"
] | [
603,
0
] | [
605,
58
] | python | en | ['en', 'en', 'en'] | True |
_LookupTargets | (names, mapping) | Returns a list of the mapping[name] for each value in |names| that is in
|mapping|. | Returns a list of the mapping[name] for each value in |names| that is in
|mapping|. | def _LookupTargets(names, mapping):
"""Returns a list of the mapping[name] for each value in |names| that is in
|mapping|."""
return [mapping[name] for name in names if name in mapping] | [
"def",
"_LookupTargets",
"(",
"names",
",",
"mapping",
")",
":",
"return",
"[",
"mapping",
"[",
"name",
"]",
"for",
"name",
"in",
"names",
"if",
"name",
"in",
"mapping",
"]"
] | [
608,
0
] | [
611,
63
] | python | en | ['en', 'en', 'en'] | True |
CalculateVariables | (default_variables, params) | Calculate additional variables for use in the build (called by gyp). | Calculate additional variables for use in the build (called by gyp). | def CalculateVariables(default_variables, params):
"""Calculate additional variables for use in the build (called by gyp)."""
flavor = gyp.common.GetFlavor(params)
if flavor == "mac":
default_variables.setdefault("OS", "mac")
elif flavor == "win":
default_variables.setdefault("OS", "win"... | [
"def",
"CalculateVariables",
"(",
"default_variables",
",",
"params",
")",
":",
"flavor",
"=",
"gyp",
".",
"common",
".",
"GetFlavor",
"(",
"params",
")",
"if",
"flavor",
"==",
"\"mac\"",
":",
"default_variables",
".",
"setdefault",
"(",
"\"OS\"",
",",
"\"ma... | [
614,
0
] | [
626,
60
] | python | en | ['en', 'en', 'en'] | True |
GenerateOutput | (target_list, target_dicts, data, params) | Called by gyp as the final stage. Outputs results. | Called by gyp as the final stage. Outputs results. | def GenerateOutput(target_list, target_dicts, data, params):
"""Called by gyp as the final stage. Outputs results."""
config = Config()
try:
config.Init(params)
if not config.files:
raise Exception(
"Must specify files to analyze via config_path generator " "flag... | [
"def",
"GenerateOutput",
"(",
"target_list",
",",
"target_dicts",
",",
"data",
",",
"params",
")",
":",
"config",
"=",
"Config",
"(",
")",
"try",
":",
"config",
".",
"Init",
"(",
"params",
")",
"if",
"not",
"config",
".",
"files",
":",
"raise",
"Except... | [
746,
0
] | [
808,
42
] | python | en | ['en', 'en', 'en'] | True |
Config.Init | (self, params) | Initializes Config. This is a separate method as it raises an exception
if there is a parse error. | Initializes Config. This is a separate method as it raises an exception
if there is a parse error. | def Init(self, params):
"""Initializes Config. This is a separate method as it raises an exception
if there is a parse error."""
generator_flags = params.get("generator_flags", {})
config_path = generator_flags.get("config_path", None)
if not config_path:
return
t... | [
"def",
"Init",
"(",
"self",
",",
"params",
")",
":",
"generator_flags",
"=",
"params",
".",
"get",
"(",
"\"generator_flags\"",
",",
"{",
"}",
")",
"config_path",
"=",
"generator_flags",
".",
"get",
"(",
"\"config_path\"",
",",
"None",
")",
"if",
"not",
"... | [
265,
4
] | [
286,
68
] | python | en | ['en', 'en', 'en'] | True |
TargetCalculator._supplied_target_names_no_all | (self) | Returns the supplied test targets without 'all'. | Returns the supplied test targets without 'all'. | def _supplied_target_names_no_all(self):
"""Returns the supplied test targets without 'all'."""
result = self._supplied_target_names()
result.discard("all")
return result | [
"def",
"_supplied_target_names_no_all",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"_supplied_target_names",
"(",
")",
"result",
".",
"discard",
"(",
"\"all\"",
")",
"return",
"result"
] | [
662,
4
] | [
666,
21
] | python | en | ['en', 'en', 'en'] | True |
TargetCalculator.is_build_impacted | (self) | Returns true if the supplied files impact the build at all. | Returns true if the supplied files impact the build at all. | def is_build_impacted(self):
"""Returns true if the supplied files impact the build at all."""
return self._changed_targets | [
"def",
"is_build_impacted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_changed_targets"
] | [
668,
4
] | [
670,
36
] | python | en | ['en', 'en', 'en'] | True |
TargetCalculator.find_matching_test_target_names | (self) | Returns the set of output test targets. | Returns the set of output test targets. | def find_matching_test_target_names(self):
"""Returns the set of output test targets."""
assert self.is_build_impacted()
# Find the test targets first. 'all' is special cased to mean all the
# root targets. To deal with all the supplied |test_targets| are expanded
# to include th... | [
"def",
"find_matching_test_target_names",
"(",
"self",
")",
":",
"assert",
"self",
".",
"is_build_impacted",
"(",
")",
"# Find the test targets first. 'all' is special cased to mean all the",
"# root targets. To deal with all the supplied |test_targets| are expanded",
"# to include the r... | [
672,
4
] | [
718,
36
] | python | en | ['en', 'en', 'en'] | True |
TargetCalculator.find_matching_compile_target_names | (self) | Returns the set of output compile targets. | Returns the set of output compile targets. | def find_matching_compile_target_names(self):
"""Returns the set of output compile targets."""
assert self.is_build_impacted()
# Compile targets are found by searching up from changed targets.
# Reset the visited status for _GetBuildTargets.
for target in self._name_to_target.val... | [
"def",
"find_matching_compile_target_names",
"(",
"self",
")",
":",
"assert",
"self",
".",
"is_build_impacted",
"(",
")",
"# Compile targets are found by searching up from changed targets.",
"# Reset the visited status for _GetBuildTargets.",
"for",
"target",
"in",
"self",
".",
... | [
720,
4
] | [
743,
9
] | python | en | ['en', 'en', 'en'] | True |
dispatch_hook | (key, hooks, hook_data, **kwargs) | Dispatches a hook dictionary on a given piece of data. | Dispatches a hook dictionary on a given piece of data. | def dispatch_hook(key, hooks, hook_data, **kwargs):
"""Dispatches a hook dictionary on a given piece of data."""
hooks = hooks or {}
hooks = hooks.get(key)
if hooks:
if hasattr(hooks, '__call__'):
hooks = [hooks]
for hook in hooks:
_hook_data = hook(hook_data, **k... | [
"def",
"dispatch_hook",
"(",
"key",
",",
"hooks",
",",
"hook_data",
",",
"*",
"*",
"kwargs",
")",
":",
"hooks",
"=",
"hooks",
"or",
"{",
"}",
"hooks",
"=",
"hooks",
".",
"get",
"(",
"key",
")",
"if",
"hooks",
":",
"if",
"hasattr",
"(",
"hooks",
"... | [
22,
0
] | [
33,
20
] | python | en | ['en', 'en', 'en'] | True |
Deserializer | (object_list, **options) |
Deserialize simple Python objects back into Django ORM instances.
It's expected that you pass the Python objects themselves (instead of a
stream or a string) to the constructor
|
Deserialize simple Python objects back into Django ORM instances. | def Deserializer(object_list, **options):
"""
Deserialize simple Python objects back into Django ORM instances.
It's expected that you pass the Python objects themselves (instead of a
stream or a string) to the constructor
"""
db = options.pop('using', DEFAULT_DB_ALIAS)
ignore = options.pop... | [
"def",
"Deserializer",
"(",
"object_list",
",",
"*",
"*",
"options",
")",
":",
"db",
"=",
"options",
".",
"pop",
"(",
"'using'",
",",
"DEFAULT_DB_ALIAS",
")",
"ignore",
"=",
"options",
".",
"pop",
"(",
"'ignorenonexistent'",
",",
"False",
")",
"field_names... | [
84,
0
] | [
183,
52
] | python | en | ['en', 'error', 'th'] | False |
_get_model | (model_identifier) |
Helper to look up a model from an "app_label.model_name" string.
|
Helper to look up a model from an "app_label.model_name" string.
| def _get_model(model_identifier):
"""
Helper to look up a model from an "app_label.model_name" string.
"""
try:
return apps.get_model(model_identifier)
except (LookupError, TypeError):
raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier) | [
"def",
"_get_model",
"(",
"model_identifier",
")",
":",
"try",
":",
"return",
"apps",
".",
"get_model",
"(",
"model_identifier",
")",
"except",
"(",
"LookupError",
",",
"TypeError",
")",
":",
"raise",
"base",
".",
"DeserializationError",
"(",
"\"Invalid model id... | [
186,
0
] | [
193,
92
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.__init__ | (self, url=None) |
Initialise an instance.
:param url: The URL of the index. If not specified, the URL for PyPI is
used.
|
Initialise an instance. | def __init__(self, url=None):
"""
Initialise an instance.
:param url: The URL of the index. If not specified, the URL for PyPI is
used.
"""
self.url = url or DEFAULT_INDEX
self.read_configuration()
scheme, netloc, path, params, query, frag = u... | [
"def",
"__init__",
"(",
"self",
",",
"url",
"=",
"None",
")",
":",
"self",
".",
"url",
"=",
"url",
"or",
"DEFAULT_INDEX",
"self",
".",
"read_configuration",
"(",
")",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
",",
"frag",
"="... | [
35,
4
] | [
62,
24
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex._get_pypirc_command | (self) |
Get the distutils command for interacting with PyPI configurations.
:return: the command.
|
Get the distutils command for interacting with PyPI configurations.
:return: the command.
| def _get_pypirc_command(self):
"""
Get the distutils command for interacting with PyPI configurations.
:return: the command.
"""
from distutils.core import Distribution
from distutils.config import PyPIRCCommand
d = Distribution()
return PyPIRCCommand(d) | [
"def",
"_get_pypirc_command",
"(",
"self",
")",
":",
"from",
"distutils",
".",
"core",
"import",
"Distribution",
"from",
"distutils",
".",
"config",
"import",
"PyPIRCCommand",
"d",
"=",
"Distribution",
"(",
")",
"return",
"PyPIRCCommand",
"(",
"d",
")"
] | [
64,
4
] | [
72,
31
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.read_configuration | (self) |
Read the PyPI access configuration as supported by distutils, getting
PyPI to do the actual work. This populates ``username``, ``password``,
``realm`` and ``url`` attributes from the configuration.
|
Read the PyPI access configuration as supported by distutils, getting
PyPI to do the actual work. This populates ``username``, ``password``,
``realm`` and ``url`` attributes from the configuration.
| def read_configuration(self):
"""
Read the PyPI access configuration as supported by distutils, getting
PyPI to do the actual work. This populates ``username``, ``password``,
``realm`` and ``url`` attributes from the configuration.
"""
# get distutils to do the work
... | [
"def",
"read_configuration",
"(",
"self",
")",
":",
"# get distutils to do the work",
"c",
"=",
"self",
".",
"_get_pypirc_command",
"(",
")",
"c",
".",
"repository",
"=",
"self",
".",
"url",
"cfg",
"=",
"c",
".",
"_read_pypirc",
"(",
")",
"self",
".",
"use... | [
74,
4
] | [
87,
50
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.save_configuration | (self) |
Save the PyPI access configuration. You must have set ``username`` and
``password`` attributes before calling this method.
Again, distutils is used to do the actual work.
|
Save the PyPI access configuration. You must have set ``username`` and
``password`` attributes before calling this method. | def save_configuration(self):
"""
Save the PyPI access configuration. You must have set ``username`` and
``password`` attributes before calling this method.
Again, distutils is used to do the actual work.
"""
self.check_credentials()
# get distutils to do the wor... | [
"def",
"save_configuration",
"(",
"self",
")",
":",
"self",
".",
"check_credentials",
"(",
")",
"# get distutils to do the work",
"c",
"=",
"self",
".",
"_get_pypirc_command",
"(",
")",
"c",
".",
"_store_pypirc",
"(",
"self",
".",
"username",
",",
"self",
".",... | [
89,
4
] | [
99,
53
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.check_credentials | (self) |
Check that ``username`` and ``password`` have been set, and raise an
exception if not.
|
Check that ``username`` and ``password`` have been set, and raise an
exception if not.
| def check_credentials(self):
"""
Check that ``username`` and ``password`` have been set, and raise an
exception if not.
"""
if self.username is None or self.password is None:
raise DistlibException('username and password must be set')
pm = HTTPPasswordMgr()
... | [
"def",
"check_credentials",
"(",
"self",
")",
":",
"if",
"self",
".",
"username",
"is",
"None",
"or",
"self",
".",
"password",
"is",
"None",
":",
"raise",
"DistlibException",
"(",
"'username and password must be set'",
")",
"pm",
"=",
"HTTPPasswordMgr",
"(",
"... | [
101,
4
] | [
111,
56
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.register | (self, metadata) |
Register a distribution on PyPI, using the provided metadata.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the distribution to be
registered.
:return: The HTTP response received from PyPI upon su... |
Register a distribution on PyPI, using the provided metadata. | def register(self, metadata):
"""
Register a distribution on PyPI, using the provided metadata.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the distribution to be
registered.
:return: The... | [
"def",
"register",
"(",
"self",
",",
"metadata",
")",
":",
"self",
".",
"check_credentials",
"(",
")",
"metadata",
".",
"validate",
"(",
")",
"d",
"=",
"metadata",
".",
"todict",
"(",
")",
"d",
"[",
"':action'",
"]",
"=",
"'verify'",
"request",
"=",
... | [
113,
4
] | [
131,
41
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex._reader | (self, name, stream, outbuf) |
Thread runner for reading lines of from a subprocess into a buffer.
:param name: The logical name of the stream (used for logging only).
:param stream: The stream to read from. This will typically a pipe
connected to the output stream of a subprocess.
:param outb... |
Thread runner for reading lines of from a subprocess into a buffer. | def _reader(self, name, stream, outbuf):
"""
Thread runner for reading lines of from a subprocess into a buffer.
:param name: The logical name of the stream (used for logging only).
:param stream: The stream to read from. This will typically a pipe
connected to th... | [
"def",
"_reader",
"(",
"self",
",",
"name",
",",
"stream",
",",
"outbuf",
")",
":",
"while",
"True",
":",
"s",
"=",
"stream",
".",
"readline",
"(",
")",
"if",
"not",
"s",
":",
"break",
"s",
"=",
"s",
".",
"decode",
"(",
"'utf-8'",
")",
".",
"rs... | [
133,
4
] | [
149,
22
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.get_sign_command | (self, filename, signer, sign_password,
keystore=None) |
Return a suitable command for signing a file.
:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
private key used for signing.
:para... |
Return a suitable command for signing a file. | def get_sign_command(self, filename, signer, sign_password,
keystore=None):
"""
Return a suitable command for signing a file.
:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_pas... | [
"def",
"get_sign_command",
"(",
"self",
",",
"filename",
",",
"signer",
",",
"sign_password",
",",
"keystore",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"self",
".",
"gpg",
",",
"'--status-fd'",
",",
"'2'",
",",
"'--no-tty'",
"]",
"if",
"keystore",
"is",
... | [
151,
4
] | [
178,
22
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.run_command | (self, cmd, input_data=None) |
Run a command in a child process , passing it any input data specified.
:param cmd: The command to run.
:param input_data: If specified, this must be a byte string containing
data to be sent to the child process.
:return: A tuple consisting of the subprocess'... |
Run a command in a child process , passing it any input data specified. | def run_command(self, cmd, input_data=None):
"""
Run a command in a child process , passing it any input data specified.
:param cmd: The command to run.
:param input_data: If specified, this must be a byte string containing
data to be sent to the child process... | [
"def",
"run_command",
"(",
"self",
",",
"cmd",
",",
"input_data",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"'stdout'",
":",
"subprocess",
".",
"PIPE",
",",
"'stderr'",
":",
"subprocess",
".",
"PIPE",
",",
"}",
"if",
"input_data",
"is",
"not",
"None",... | [
180,
4
] | [
213,
43
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.sign_file | (self, filename, signer, sign_password, keystore=None) |
Sign a file.
:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
private key used for signing.
:param keystore: The path to a directo... |
Sign a file. | def sign_file(self, filename, signer, sign_password, keystore=None):
"""
Sign a file.
:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
... | [
"def",
"sign_file",
"(",
"self",
",",
"filename",
",",
"signer",
",",
"sign_password",
",",
"keystore",
"=",
"None",
")",
":",
"cmd",
",",
"sig_file",
"=",
"self",
".",
"get_sign_command",
"(",
"filename",
",",
"signer",
",",
"sign_password",
",",
"keystor... | [
215,
4
] | [
236,
23
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.upload_file | (self, metadata, filename, signer=None, sign_password=None,
filetype='sdist', pyversion='source', keystore=None) |
Upload a release file to the index.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the file to be uploaded.
:param filename: The pathname of the file to be uploaded.
:param signer: The identifier of the signer of t... |
Upload a release file to the index. | def upload_file(self, metadata, filename, signer=None, sign_password=None,
filetype='sdist', pyversion='source', keystore=None):
"""
Upload a release file to the index.
:param metadata: A :class:`Metadata` instance defining at least a name
and versio... | [
"def",
"upload_file",
"(",
"self",
",",
"metadata",
",",
"filename",
",",
"signer",
"=",
"None",
",",
"sign_password",
"=",
"None",
",",
"filetype",
"=",
"'sdist'",
",",
"pyversion",
"=",
"'source'",
",",
"keystore",
"=",
"None",
")",
":",
"self",
".",
... | [
238,
4
] | [
293,
41
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.upload_documentation | (self, metadata, doc_dir) |
Upload documentation to the index.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the documentation to be
uploaded.
:param doc_dir: The pathname of the directory which contains the
... |
Upload documentation to the index. | def upload_documentation(self, metadata, doc_dir):
"""
Upload documentation to the index.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the documentation to be
uploaded.
:param doc_dir: The... | [
"def",
"upload_documentation",
"(",
"self",
",",
"metadata",
",",
"doc_dir",
")",
":",
"self",
".",
"check_credentials",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"doc_dir",
")",
":",
"raise",
"DistlibException",
"(",
"'not a directory: %r... | [
295,
4
] | [
321,
41
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.get_verify_command | (self, signature_filename, data_filename,
keystore=None) |
Return a suitable command for verifying a file.
:param signature_filename: The pathname to the file containing the
signature.
:param data_filename: The pathname to the file containing the
signed data.
:param keystore: The... |
Return a suitable command for verifying a file. | def get_verify_command(self, signature_filename, data_filename,
keystore=None):
"""
Return a suitable command for verifying a file.
:param signature_filename: The pathname to the file containing the
signature.
:param data_fil... | [
"def",
"get_verify_command",
"(",
"self",
",",
"signature_filename",
",",
"data_filename",
",",
"keystore",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"self",
".",
"gpg",
",",
"'--status-fd'",
",",
"'2'",
",",
"'--no-tty'",
"]",
"if",
"keystore",
"is",
"None"... | [
323,
4
] | [
345,
18
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.verify_signature | (self, signature_filename, data_filename,
keystore=None) |
Verify a signature for a file.
:param signature_filename: The pathname to the file containing the
signature.
:param data_filename: The pathname to the file containing the
signed data.
:param keystore: The path to a direct... |
Verify a signature for a file. | def verify_signature(self, signature_filename, data_filename,
keystore=None):
"""
Verify a signature for a file.
:param signature_filename: The pathname to the file containing the
signature.
:param data_filename: The pathname t... | [
"def",
"verify_signature",
"(",
"self",
",",
"signature_filename",
",",
"data_filename",
",",
"keystore",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"gpg",
":",
"raise",
"DistlibException",
"(",
"'verification unavailable because gpg '",
"'unavailable'",
")",
... | [
347,
4
] | [
370,
22
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.download_file | (self, url, destfile, digest=None, reporthook=None) |
This is a convenience method for downloading a file from an URL.
Normally, this will be a file from the index, though currently
no check is made for this (i.e. a file can be downloaded from
anywhere).
The method is just like the :func:`urlretrieve` function in the
stand... |
This is a convenience method for downloading a file from an URL.
Normally, this will be a file from the index, though currently
no check is made for this (i.e. a file can be downloaded from
anywhere). | def download_file(self, url, destfile, digest=None, reporthook=None):
"""
This is a convenience method for downloading a file from an URL.
Normally, this will be a file from the index, though currently
no check is made for this (i.e. a file can be downloaded from
anywhere).
... | [
"def",
"download_file",
"(",
"self",
",",
"url",
",",
"destfile",
",",
"digest",
"=",
"None",
",",
"reporthook",
"=",
"None",
")",
":",
"if",
"digest",
"is",
"None",
":",
"digester",
"=",
"None",
"logger",
".",
"debug",
"(",
"'No digest specified'",
")",... | [
372,
4
] | [
447,
55
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.send_request | (self, req) |
Send a standard library :class:`Request` to PyPI and return its
response.
:param req: The request to send.
:return: The HTTP response from PyPI (a standard library HTTPResponse).
|
Send a standard library :class:`Request` to PyPI and return its
response. | def send_request(self, req):
"""
Send a standard library :class:`Request` to PyPI and return its
response.
:param req: The request to send.
:return: The HTTP response from PyPI (a standard library HTTPResponse).
"""
handlers = []
if self.password_handler:... | [
"def",
"send_request",
"(",
"self",
",",
"req",
")",
":",
"handlers",
"=",
"[",
"]",
"if",
"self",
".",
"password_handler",
":",
"handlers",
".",
"append",
"(",
"self",
".",
"password_handler",
")",
"if",
"self",
".",
"ssl_verifier",
":",
"handlers",
"."... | [
449,
4
] | [
463,
31
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.encode_request | (self, fields, files) |
Encode fields and files for posting to an HTTP server.
:param fields: The fields to send as a list of (fieldname, value)
tuples.
:param files: The files to send as a list of (fieldname, filename,
file_bytes) tuple.
|
Encode fields and files for posting to an HTTP server. | def encode_request(self, fields, files):
"""
Encode fields and files for posting to an HTTP server.
:param fields: The fields to send as a list of (fieldname, value)
tuples.
:param files: The files to send as a list of (fieldname, filename,
f... | [
"def",
"encode_request",
"(",
"self",
",",
"fields",
",",
"files",
")",
":",
"# Adapted from packaging, which in turn was adapted from",
"# http://code.activestate.com/recipes/146306",
"parts",
"=",
"[",
"]",
"boundary",
"=",
"self",
".",
"boundary",
"for",
"k",
",",
... | [
465,
4
] | [
506,
47
] | python | en | ['en', 'error', 'th'] | False |
_error | (msg) | Print msg and optionally exit with return code exit_. | Print msg and optionally exit with return code exit_. | def _error(msg):
"""Print msg and optionally exit with return code exit_."""
sys.stderr.write('[ERROR] {}\n'.format(msg))
return 1 | [
"def",
"_error",
"(",
"msg",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'[ERROR] {}\\n'",
".",
"format",
"(",
"msg",
")",
")",
"return",
"1"
] | [
150,
0
] | [
153,
12
] | python | en | ['en', 'en', 'en'] | True |
is_health_for_plan | (healthz: dict) |
Healthy for starting the plan class
:param healthz:
:return: bool
|
Healthy for starting the plan class
:param healthz:
:return: bool
| def is_health_for_plan(healthz: dict):
"""
Healthy for starting the plan class
:param healthz:
:return: bool
"""
if healthz["global"] is True:
return True
if healthz["db"] is True and healthz["matchbox"]["/"] is True:
return True
return False | [
"def",
"is_health_for_plan",
"(",
"healthz",
":",
"dict",
")",
":",
"if",
"healthz",
"[",
"\"global\"",
"]",
"is",
"True",
":",
"return",
"True",
"if",
"healthz",
"[",
"\"db\"",
"]",
"is",
"True",
"and",
"healthz",
"[",
"\"matchbox\"",
"]",
"[",
"\"/\"",... | [
89,
0
] | [
101,
16
] | python | en | ['en', 'error', 'th'] | False |
Kubernetes2Tiers.apply | (self) |
Schedule and synchronise the state for matchbox
:return: the number of synchronised machines
|
Schedule and synchronise the state for matchbox
:return: the number of synchronised machines
| def apply(self):
"""
Schedule and synchronise the state for matchbox
:return: the number of synchronised machines
"""
while self._sch_k8s_control_plane.apply(nb_try=5, seconds_sleep=1) is False:
time.sleep(self.wait)
self._sch_k8s_node.apply(nb_try=5, seconds... | [
"def",
"apply",
"(",
"self",
")",
":",
"while",
"self",
".",
"_sch_k8s_control_plane",
".",
"apply",
"(",
"nb_try",
"=",
"5",
",",
"seconds_sleep",
"=",
"1",
")",
"is",
"False",
":",
"time",
".",
"sleep",
"(",
"self",
".",
"wait",
")",
"self",
".",
... | [
65,
4
] | [
74,
59
] | python | en | ['en', 'error', 'th'] | False |
is_testing | (argv=None) | Return True if running django or py.test unit tests. | Return True if running django or py.test unit tests. | def is_testing(argv=None):
import sys
'''Return True if running django or py.test unit tests.'''
if 'PYTEST_CURRENT_TEST' in os.environ.keys():
return True
argv = sys.argv if argv is None else argv
if len(argv) >= 1 and ('py.test' in argv[0] or 'py/test.py' in argv[0]):
return True
... | [
"def",
"is_testing",
"(",
"argv",
"=",
"None",
")",
":",
"import",
"sys",
"if",
"'PYTEST_CURRENT_TEST'",
"in",
"os",
".",
"environ",
".",
"keys",
"(",
")",
":",
"return",
"True",
"argv",
"=",
"sys",
".",
"argv",
"if",
"argv",
"is",
"None",
"else",
"a... | [
22,
0
] | [
33,
16
] | python | en | ['en', 'mt', 'en'] | True |
load_file | (filename) | Loads a YAML file from the given filename.
If the filename is omitted or None, attempts will be made to load it from
its normal location in the parent of the utils directory.
The awx_data dict loaded with this method supports value randomization,
thanks to the RandomizeValues class. See that class for... | Loads a YAML file from the given filename. | def load_file(filename):
"""Loads a YAML file from the given filename.
If the filename is omitted or None, attempts will be made to load it from
its normal location in the parent of the utils directory.
The awx_data dict loaded with this method supports value randomization,
thanks to the Randomize... | [
"def",
"load_file",
"(",
"filename",
")",
":",
"from",
"py",
".",
"path",
"import",
"local",
"if",
"filename",
"is",
"None",
":",
"this_file",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
"path",
"=",
"local",
"(",
"this_file",
")",
... | [
64,
0
] | [
96,
28
] | python | en | ['en', 'en', 'en'] | True |
calculate_iterations_quality | (
difficulty_constant_factor: uint128,
quality_string: bytes32,
size: int,
difficulty: uint64,
cc_sp_output_hash: bytes32,
) |
Calculates the number of iterations from the quality. This is derives as the difficulty times the constant factor
times a random number between 0 and 1 (based on quality string), divided by plot size.
|
Calculates the number of iterations from the quality. This is derives as the difficulty times the constant factor
times a random number between 0 and 1 (based on quality string), divided by plot size.
| def calculate_iterations_quality(
difficulty_constant_factor: uint128,
quality_string: bytes32,
size: int,
difficulty: uint64,
cc_sp_output_hash: bytes32,
) -> uint64:
"""
Calculates the number of iterations from the quality. This is derives as the difficulty times the constant factor
ti... | [
"def",
"calculate_iterations_quality",
"(",
"difficulty_constant_factor",
":",
"uint128",
",",
"quality_string",
":",
"bytes32",
",",
"size",
":",
"int",
",",
"difficulty",
":",
"uint64",
",",
"cc_sp_output_hash",
":",
"bytes32",
",",
")",
"->",
"uint64",
":",
"... | [
45,
0
] | [
64,
32
] | python | en | ['en', 'error', 'th'] | False |
test_org_and_user_credential_access | (alice, organization) | Address specific bug where any user could make an org credential
in another org without any permissions to that org
| Address specific bug where any user could make an org credential
in another org without any permissions to that org
| def test_org_and_user_credential_access(alice, organization):
"""Address specific bug where any user could make an org credential
in another org without any permissions to that org
"""
# Owner is both user and org, but org permission should still be checked
assert not CredentialAccess(alice).can_add... | [
"def",
"test_org_and_user_credential_access",
"(",
"alice",
",",
"organization",
")",
":",
"# Owner is both user and org, but org permission should still be checked",
"assert",
"not",
"CredentialAccess",
"(",
"alice",
")",
".",
"can_add",
"(",
"{",
"'name'",
":",
"'New cred... | [
71,
0
] | [
76,
126
] | python | en | ['en', 'en', 'en'] | True |
_simple_domain_name_validator | (value) |
Validates that the given value contains no whitespaces to prevent common
typos.
|
Validates that the given value contains no whitespaces to prevent common
typos.
| def _simple_domain_name_validator(value):
"""
Validates that the given value contains no whitespaces to prevent common
typos.
"""
if not value:
return
checks = ((s in value) for s in string.whitespace)
if any(checks):
raise ValidationError(
_("The domain name cann... | [
"def",
"_simple_domain_name_validator",
"(",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"checks",
"=",
"(",
"(",
"s",
"in",
"value",
")",
"for",
"s",
"in",
"string",
".",
"whitespace",
")",
"if",
"any",
"(",
"checks",
")",
":",
"raise",
... | [
14,
0
] | [
26,
9
] | python | en | ['en', 'error', 'th'] | False |
clear_site_cache | (sender, **kwargs) |
Clears the cache (if primed) each time a site is saved or deleted
|
Clears the cache (if primed) each time a site is saved or deleted
| def clear_site_cache(sender, **kwargs):
"""
Clears the cache (if primed) each time a site is saved or deleted
"""
instance = kwargs['instance']
using = kwargs['using']
try:
del SITE_CACHE[instance.pk]
except KeyError:
pass
try:
del SITE_CACHE[Site.objects.using(us... | [
"def",
"clear_site_cache",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"kwargs",
"[",
"'instance'",
"]",
"using",
"=",
"kwargs",
"[",
"'using'",
"]",
"try",
":",
"del",
"SITE_CACHE",
"[",
"instance",
".",
"pk",
"]",
"except",
"Ke... | [
107,
0
] | [
120,
12
] | python | en | ['en', 'error', 'th'] | False |
SiteManager.get_current | (self, request=None) |
Returns the current Site based on the SITE_ID in the project's settings.
If SITE_ID isn't defined, it returns the site with domain matching
request.get_host(). The ``Site`` object is cached the first time it's
retrieved from the database.
|
Returns the current Site based on the SITE_ID in the project's settings.
If SITE_ID isn't defined, it returns the site with domain matching
request.get_host(). The ``Site`` object is cached the first time it's
retrieved from the database.
| def get_current(self, request=None):
"""
Returns the current Site based on the SITE_ID in the project's settings.
If SITE_ID isn't defined, it returns the site with domain matching
request.get_host(). The ``Site`` object is cached the first time it's
retrieved from the database.
... | [
"def",
"get_current",
"(",
"self",
",",
"request",
"=",
"None",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"if",
"getattr",
"(",
"settings",
",",
"'SITE_ID'",
",",
"''",
")",
":",
"site_id",
"=",
"settings",
".",
"SITE_ID",
"return",
... | [
52,
4
] | [
71,
9
] | python | en | ['en', 'error', 'th'] | False |
SiteManager.clear_cache | (self) | Clears the ``Site`` object cache. | Clears the ``Site`` object cache. | def clear_cache(self):
"""Clears the ``Site`` object cache."""
global SITE_CACHE
SITE_CACHE = {} | [
"def",
"clear_cache",
"(",
"self",
")",
":",
"global",
"SITE_CACHE",
"SITE_CACHE",
"=",
"{",
"}"
] | [
73,
4
] | [
76,
23
] | python | en | ['en', 'en', 'en'] | True |
AzureRMVirtualMachineScaleSet.get_vmss | (self) |
Get the VMSS
:return: VirtualMachineScaleSet object
|
Get the VMSS | def get_vmss(self):
'''
Get the VMSS
:return: VirtualMachineScaleSet object
'''
try:
vmss = self.compute_client.virtual_machine_scale_sets.get(self.resource_group, self.name)
return vmss
except CloudError as exc:
self.fail("Error getti... | [
"def",
"get_vmss",
"(",
"self",
")",
":",
"try",
":",
"vmss",
"=",
"self",
".",
"compute_client",
".",
"virtual_machine_scale_sets",
".",
"get",
"(",
"self",
".",
"resource_group",
",",
"self",
".",
"name",
")",
"return",
"vmss",
"except",
"CloudError",
"a... | [
919,
4
] | [
929,
102
] | python | en | ['en', 'error', 'th'] | False |
AzureRMVirtualMachineScaleSet.serialize_vmss | (self, vmss) |
Convert a VirtualMachineScaleSet object to dict.
:param vm: VirtualMachineScaleSet object
:return: dict
|
Convert a VirtualMachineScaleSet object to dict. | def serialize_vmss(self, vmss):
'''
Convert a VirtualMachineScaleSet object to dict.
:param vm: VirtualMachineScaleSet object
:return: dict
'''
result = self.serialize_obj(vmss, AZURE_OBJECT_CLASS, enum_modules=AZURE_ENUM_MODULES)
result['id'] = vmss.id
... | [
"def",
"serialize_vmss",
"(",
"self",
",",
"vmss",
")",
":",
"result",
"=",
"self",
".",
"serialize_obj",
"(",
"vmss",
",",
"AZURE_OBJECT_CLASS",
",",
"enum_modules",
"=",
"AZURE_ENUM_MODULES",
")",
"result",
"[",
"'id'",
"]",
"=",
"vmss",
".",
"id",
"resu... | [
963,
4
] | [
978,
21
] | python | en | ['en', 'error', 'th'] | False |
AzureRMVirtualMachineScaleSet.vm_size_is_valid | (self) |
Validate self.vm_size against the list of virtual machine sizes available for the account and location.
:return: boolean
|
Validate self.vm_size against the list of virtual machine sizes available for the account and location. | def vm_size_is_valid(self):
'''
Validate self.vm_size against the list of virtual machine sizes available for the account and location.
:return: boolean
'''
try:
sizes = self.compute_client.virtual_machine_sizes.list(self.location)
except CloudError as exc:
... | [
"def",
"vm_size_is_valid",
"(",
"self",
")",
":",
"try",
":",
"sizes",
"=",
"self",
".",
"compute_client",
".",
"virtual_machine_sizes",
".",
"list",
"(",
"self",
".",
"location",
")",
"except",
"CloudError",
"as",
"exc",
":",
"self",
".",
"fail",
"(",
"... | [
1038,
4
] | [
1051,
20
] | python | en | ['en', 'error', 'th'] | False |
UniversalDetector.reset | (self) |
Reset the UniversalDetector and all of its probers back to their
initial states. This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents.
|
Reset the UniversalDetector and all of its probers back to their
initial states. This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents.
| def reset(self):
"""
Reset the UniversalDetector and all of its probers back to their
initial states. This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents.
"""
self.result = {'encoding': None, 'confidence': 0.0... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"result",
"=",
"{",
"'encoding'",
":",
"None",
",",
"'confidence'",
":",
"0.0",
",",
"'language'",
":",
"None",
"}",
"self",
".",
"done",
"=",
"False",
"self",
".",
"_got_data",
"=",
"False",
"self"... | [
93,
4
] | [
108,
26
] | python | en | ['en', 'error', 'th'] | False |
UniversalDetector.feed | (self, byte_str) |
Takes a chunk of a document and feeds it through all of the relevant
charset probers.
After calling ``feed``, you can check the value of the ``done``
attribute to see if you need to continue feeding the
``UniversalDetector`` more data, or if it has made a prediction
(in... |
Takes a chunk of a document and feeds it through all of the relevant
charset probers. | def feed(self, byte_str):
"""
Takes a chunk of a document and feeds it through all of the relevant
charset probers.
After calling ``feed``, you can check the value of the ``done``
attribute to see if you need to continue feeding the
``UniversalDetector`` more data, or if... | [
"def",
"feed",
"(",
"self",
",",
"byte_str",
")",
":",
"if",
"self",
".",
"done",
":",
"return",
"if",
"not",
"len",
"(",
"byte_str",
")",
":",
"return",
"if",
"not",
"isinstance",
"(",
"byte_str",
",",
"bytearray",
")",
":",
"byte_str",
"=",
"bytear... | [
110,
4
] | [
217,
42
] | python | en | ['en', 'error', 'th'] | False |
UniversalDetector.close | (self) |
Stop analyzing the current document and come up with a final
prediction.
:returns: The ``result`` attribute, a ``dict`` with the keys
`encoding`, `confidence`, and `language`.
|
Stop analyzing the current document and come up with a final
prediction. | def close(self):
"""
Stop analyzing the current document and come up with a final
prediction.
:returns: The ``result`` attribute, a ``dict`` with the keys
`encoding`, `confidence`, and `language`.
"""
# Don't bother with checks if we're already done
... | [
"def",
"close",
"(",
"self",
")",
":",
"# Don't bother with checks if we're already done",
"if",
"self",
".",
"done",
":",
"return",
"self",
".",
"result",
"self",
".",
"done",
"=",
"True",
"if",
"not",
"self",
".",
"_got_data",
":",
"self",
".",
"logger",
... | [
219,
4
] | [
285,
26
] | python | en | ['en', 'error', 'th'] | False |
QHM.step | (self, closure: OptLossClosure = None) | Performs a single optimization step.
Arguments:
closure: A closure that reevaluates the model and returns the loss.
| Performs a single optimization step. | def step(self, closure: OptLossClosure = None) -> OptFloat:
"""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... | [
77,
4
] | [
115,
19
] | python | en | ['en', 'en', 'en'] | True |
SonarrHookTests.test_sonarr_test | (self) |
Tests if sonarr test payload is handled correctly
|
Tests if sonarr test payload is handled correctly
| def test_sonarr_test(self) -> None:
"""
Tests if sonarr test payload is handled correctly
"""
expected_topic = "Sonarr - Test"
expected_message = "Sonarr webhook has been successfully configured."
self.check_webhook("sonarr_test", expected_topic, expected_message) | [
"def",
"test_sonarr_test",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Sonarr - Test\"",
"expected_message",
"=",
"\"Sonarr webhook has been successfully configured.\"",
"self",
".",
"check_webhook",
"(",
"\"sonarr_test\"",
",",
"expected_topic",
",",
"... | [
8,
4
] | [
14,
75
] | python | en | ['en', 'error', 'th'] | False |
SonarrHookTests.test_sonarr_series_deleted | (self) |
Tests if sonarr series deleted payload is handled correctly
|
Tests if sonarr series deleted payload is handled correctly
| def test_sonarr_series_deleted(self) -> None:
"""
Tests if sonarr series deleted payload is handled correctly
"""
expected_topic = "Breaking Bad"
expected_message = "Breaking Bad has been deleted."
self.check_webhook("sonarr_series_deleted", expected_topic, expected_messa... | [
"def",
"test_sonarr_series_deleted",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Breaking Bad\"",
"expected_message",
"=",
"\"Breaking Bad has been deleted.\"",
"self",
".",
"check_webhook",
"(",
"\"sonarr_series_deleted\"",
",",
"expected_topic",
",",
... | [
16,
4
] | [
22,
85
] | python | en | ['en', 'error', 'th'] | False |
SonarrHookTests.test_sonarr_health_check_warning | (self) |
Tests if sonarr health check warning payload is handled correctly
|
Tests if sonarr health check warning payload is handled correctly
| def test_sonarr_health_check_warning(self) -> None:
"""
Tests if sonarr health check warning payload is handled correctly
"""
expected_topic = "Health warning"
expected_message = "Indexers unavailable due to failures for more than 6 hours: Academic Torrents - Jackett, ACG - Jacke... | [
"def",
"test_sonarr_health_check_warning",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Health warning\"",
"expected_message",
"=",
"\"Indexers unavailable due to failures for more than 6 hours: Academic Torrents - Jackett, ACG - Jackett, KickAssTorrent - Jackett, EXT Tor... | [
24,
4
] | [
30,
91
] | python | en | ['en', 'error', 'th'] | False |
SonarrHookTests.test_sonarr_health_check_error | (self) |
Tests if sonarr health check error payload is handled correctly
|
Tests if sonarr health check error payload is handled correctly
| def test_sonarr_health_check_error(self) -> None:
"""
Tests if sonarr health check error payload is handled correctly
"""
expected_topic = "Health error"
expected_message = "No indexers available with RSS sync enabled, Sonarr will not grab new releases automatically."
sel... | [
"def",
"test_sonarr_health_check_error",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Health error\"",
"expected_message",
"=",
"\"No indexers available with RSS sync enabled, Sonarr will not grab new releases automatically.\"",
"self",
".",
"check_webhook",
"(",
... | [
32,
4
] | [
38,
89
] | python | en | ['en', 'error', 'th'] | False |
SonarrHookTests.test_sonarr_episodes_renamed | (self) |
Tests if sonarr episodes renamed payload is handled correctly
|
Tests if sonarr episodes renamed payload is handled correctly
| def test_sonarr_episodes_renamed(self) -> None:
"""
Tests if sonarr episodes renamed payload is handled correctly
"""
expected_topic = "The L Word"
expected_message = "The L Word episodes have been renamed."
self.check_webhook("sonarr_episodes_renamed", expected_topic, ex... | [
"def",
"test_sonarr_episodes_renamed",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"The L Word\"",
"expected_message",
"=",
"\"The L Word episodes have been renamed.\"",
"self",
".",
"check_webhook",
"(",
"\"sonarr_episodes_renamed\"",
",",
"expected_topic",... | [
40,
4
] | [
46,
87
] | python | en | ['en', 'error', 'th'] | False |
SonarrHookTests.test_sonarr_episode_imported | (self) |
Tests if sonarr episode imported payload is handled correctly
|
Tests if sonarr episode imported payload is handled correctly
| def test_sonarr_episode_imported(self) -> None:
"""
Tests if sonarr episode imported payload is handled correctly
"""
expected_topic = "Grey's Anatomy"
expected_message = "Grey's Anatomy - 17x9 - In My Life has been imported."
self.check_webhook("sonarr_episode_imported",... | [
"def",
"test_sonarr_episode_imported",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Grey's Anatomy\"",
"expected_message",
"=",
"\"Grey's Anatomy - 17x9 - In My Life has been imported.\"",
"self",
".",
"check_webhook",
"(",
"\"sonarr_episode_imported\"",
",",
... | [
48,
4
] | [
54,
87
] | python | en | ['en', 'error', 'th'] | False |
SonarrHookTests.test_sonarr_episode_imported_upgrade | (self) |
Tests if sonarr episode imported upgrade payload is handled correctly
|
Tests if sonarr episode imported upgrade payload is handled correctly
| def test_sonarr_episode_imported_upgrade(self) -> None:
"""
Tests if sonarr episode imported upgrade payload is handled correctly
"""
expected_topic = "NCIS"
expected_message = "NCIS - 18x10 - Watchdog has been upgraded from SDTV to HDTV-720p."
self.check_webhook("sonarr_... | [
"def",
"test_sonarr_episode_imported_upgrade",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"NCIS\"",
"expected_message",
"=",
"\"NCIS - 18x10 - Watchdog has been upgraded from SDTV to HDTV-720p.\"",
"self",
".",
"check_webhook",
"(",
"\"sonarr_episode_imported_u... | [
56,
4
] | [
62,
95
] | python | en | ['en', 'error', 'th'] | False |
SonarrHookTests.test_sonarr_episode_grabbed | (self) |
Tests if sonarr episode grabbed payload is handled correctly
|
Tests if sonarr episode grabbed payload is handled correctly
| def test_sonarr_episode_grabbed(self) -> None:
"""
Tests if sonarr episode grabbed payload is handled correctly
"""
expected_topic = "NCIS"
expected_message = "NCIS - 18x10 - Watchdog has been grabbed."
self.check_webhook("sonarr_episode_grabbed", expected_topic, expected... | [
"def",
"test_sonarr_episode_grabbed",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"NCIS\"",
"expected_message",
"=",
"\"NCIS - 18x10 - Watchdog has been grabbed.\"",
"self",
".",
"check_webhook",
"(",
"\"sonarr_episode_grabbed\"",
",",
"expected_topic",
",... | [
64,
4
] | [
70,
86
] | python | en | ['en', 'error', 'th'] | False |
SonarrHookTests.test_sonarr_episode_deleted | (self) |
Tests if sonarr episode deleted payload is handled correctly
|
Tests if sonarr episode deleted payload is handled correctly
| def test_sonarr_episode_deleted(self) -> None:
"""
Tests if sonarr episode deleted payload is handled correctly
"""
expected_topic = "Breaking Bad"
expected_message = "Breaking Bad - 1x1 - Pilot has been deleted."
self.check_webhook("sonarr_episode_deleted", expected_topi... | [
"def",
"test_sonarr_episode_deleted",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Breaking Bad\"",
"expected_message",
"=",
"\"Breaking Bad - 1x1 - Pilot has been deleted.\"",
"self",
".",
"check_webhook",
"(",
"\"sonarr_episode_deleted\"",
",",
"expected_t... | [
72,
4
] | [
78,
86
] | python | en | ['en', 'error', 'th'] | False |
SonarrHookTests.test_sonarr_episode_deleted_upgrade | (self) |
Tests if sonarr episode deleted upgrade payload is handled correctly
|
Tests if sonarr episode deleted upgrade payload is handled correctly
| def test_sonarr_episode_deleted_upgrade(self) -> None:
"""
Tests if sonarr episode deleted upgrade payload is handled correctly
"""
expected_topic = "S.W.A.T. (2017)"
expected_message = (
"S.W.A.T. (2017) - 4x10 - Buried has been deleted due to quality upgrade."
... | [
"def",
"test_sonarr_episode_deleted_upgrade",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"S.W.A.T. (2017)\"",
"expected_message",
"=",
"(",
"\"S.W.A.T. (2017) - 4x10 - Buried has been deleted due to quality upgrade.\"",
")",
"self",
".",
"check_webhook",
"(",... | [
80,
4
] | [
88,
94
] | python | en | ['en', 'error', 'th'] | False |
disassemble | (sexp) |
This version of `disassemble` also disassembles condition opcodes like `ASSERT_ANNOUNCEMENT_CONSUMED`.
|
This version of `disassemble` also disassembles condition opcodes like `ASSERT_ANNOUNCEMENT_CONSUMED`.
| def disassemble(sexp):
"""
This version of `disassemble` also disassembles condition opcodes like `ASSERT_ANNOUNCEMENT_CONSUMED`.
"""
kfa = dict(KEYWORD_FROM_ATOM)
kfa.update((Program.to(k).as_atom(), v) for k, v in KFA.items())
return bu_disassemble(sexp, kfa) | [
"def",
"disassemble",
"(",
"sexp",
")",
":",
"kfa",
"=",
"dict",
"(",
"KEYWORD_FROM_ATOM",
")",
"kfa",
".",
"update",
"(",
"(",
"Program",
".",
"to",
"(",
"k",
")",
".",
"as_atom",
"(",
")",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"KFA",
"."... | [
23,
0
] | [
29,
36
] | python | en | ['en', 'error', 'th'] | False |
coin_as_program | (coin: Coin) |
Convenience function for when putting `coin_info` into a solution.
|
Convenience function for when putting `coin_info` into a solution.
| def coin_as_program(coin: Coin) -> Program:
"""
Convenience function for when putting `coin_info` into a solution.
"""
return Program.to([coin.parent_coin_info, coin.puzzle_hash, coin.amount]) | [
"def",
"coin_as_program",
"(",
"coin",
":",
"Coin",
")",
"->",
"Program",
":",
"return",
"Program",
".",
"to",
"(",
"[",
"coin",
".",
"parent_coin_info",
",",
"coin",
".",
"puzzle_hash",
",",
"coin",
".",
"amount",
"]",
")"
] | [
32,
0
] | [
36,
77
] | python | en | ['en', 'error', 'th'] | False |
debug_spend_bundle | (spend_bundle: SpendBundle) |
Print a lot of useful information about a `SpendBundle` that might help with debugging
its clvm.
|
Print a lot of useful information about a `SpendBundle` that might help with debugging
its clvm.
| def debug_spend_bundle(spend_bundle: SpendBundle) -> None:
"""
Print a lot of useful information about a `SpendBundle` that might help with debugging
its clvm.
"""
pks = []
msgs = []
created_announcements: List[List[bytes]] = []
asserted_annoucements = []
print("=" * 80)
for c... | [
"def",
"debug_spend_bundle",
"(",
"spend_bundle",
":",
"SpendBundle",
")",
"->",
"None",
":",
"pks",
"=",
"[",
"]",
"msgs",
"=",
"[",
"]",
"created_announcements",
":",
"List",
"[",
"List",
"[",
"bytes",
"]",
"]",
"=",
"[",
"]",
"asserted_annoucements",
... | [
43,
0
] | [
148,
58
] | python | en | ['en', 'error', 'th'] | False |
method_decorator | (decorator, name='') |
Converts a function decorator into a method decorator
|
Converts a function decorator into a method decorator
| def method_decorator(decorator, name=''):
"""
Converts a function decorator into a method decorator
"""
# 'obj' can be a class or a function. If 'obj' is a function at the time it
# is passed to _dec, it will eventually be a method of the class it is
# defined on. If 'obj' is a class, the 'name... | [
"def",
"method_decorator",
"(",
"decorator",
",",
"name",
"=",
"''",
")",
":",
"# 'obj' can be a class or a function. If 'obj' is a function at the time it",
"# is passed to _dec, it will eventually be a method of the class it is",
"# defined on. If 'obj' is a class, the 'name' is required ... | [
19,
0
] | [
92,
15
] | python | en | ['en', 'error', 'th'] | False |
decorator_from_middleware_with_args | (middleware_class) |
Like decorator_from_middleware, but returns a function
that accepts the arguments to be passed to the middleware_class.
Use like::
cache_page = decorator_from_middleware_with_args(CacheMiddleware)
# ...
@cache_page(3600)
def my_view(request):
# ...
|
Like decorator_from_middleware, but returns a function
that accepts the arguments to be passed to the middleware_class.
Use like:: | def decorator_from_middleware_with_args(middleware_class):
"""
Like decorator_from_middleware, but returns a function
that accepts the arguments to be passed to the middleware_class.
Use like::
cache_page = decorator_from_middleware_with_args(CacheMiddleware)
# ...
@cache_pa... | [
"def",
"decorator_from_middleware_with_args",
"(",
"middleware_class",
")",
":",
"return",
"make_middleware_decorator",
"(",
"middleware_class",
")"
] | [
95,
0
] | [
108,
54
] | python | en | ['en', 'error', 'th'] | False |
decorator_from_middleware | (middleware_class) |
Given a middleware class (not an instance), returns a view decorator. This
lets you use middleware functionality on a per-view basis. The middleware
is created with no params passed.
|
Given a middleware class (not an instance), returns a view decorator. This
lets you use middleware functionality on a per-view basis. The middleware
is created with no params passed.
| def decorator_from_middleware(middleware_class):
"""
Given a middleware class (not an instance), returns a view decorator. This
lets you use middleware functionality on a per-view basis. The middleware
is created with no params passed.
"""
return make_middleware_decorator(middleware_class)() | [
"def",
"decorator_from_middleware",
"(",
"middleware_class",
")",
":",
"return",
"make_middleware_decorator",
"(",
"middleware_class",
")",
"(",
")"
] | [
111,
0
] | [
117,
56
] | python | en | ['en', 'error', 'th'] | False |
available_attrs | (fn) |
Return the list of functools-wrappable attributes on a callable.
This is required as a workaround for http://bugs.python.org/issue3445
under Python 2.
|
Return the list of functools-wrappable attributes on a callable.
This is required as a workaround for http://bugs.python.org/issue3445
under Python 2.
| def available_attrs(fn):
"""
Return the list of functools-wrappable attributes on a callable.
This is required as a workaround for http://bugs.python.org/issue3445
under Python 2.
"""
if six.PY3:
return WRAPPER_ASSIGNMENTS
else:
return tuple(a for a in WRAPPER_ASSIGNMENTS if ... | [
"def",
"available_attrs",
"(",
"fn",
")",
":",
"if",
"six",
".",
"PY3",
":",
"return",
"WRAPPER_ASSIGNMENTS",
"else",
":",
"return",
"tuple",
"(",
"a",
"for",
"a",
"in",
"WRAPPER_ASSIGNMENTS",
"if",
"hasattr",
"(",
"fn",
",",
"a",
")",
")"
] | [
120,
0
] | [
129,
70
] | python | en | ['en', 'error', 'th'] | False |
FullNodeAPI.new_peak | (self, request: full_node_protocol.NewPeak, peer: ws.WSKaleConnection) |
A peer notifies us that they have added a new peak to their blockchain. If we don't have it,
we can ask for it.
|
A peer notifies us that they have added a new peak to their blockchain. If we don't have it,
we can ask for it.
| async def new_peak(self, request: full_node_protocol.NewPeak, peer: ws.WSKaleConnection) -> Optional[Message]:
"""
A peer notifies us that they have added a new peak to their blockchain. If we don't have it,
we can ask for it.
"""
async with self.full_node.new_peak_lock:
... | [
"async",
"def",
"new_peak",
"(",
"self",
",",
"request",
":",
"full_node_protocol",
".",
"NewPeak",
",",
"peer",
":",
"ws",
".",
"WSKaleConnection",
")",
"->",
"Optional",
"[",
"Message",
"]",
":",
"async",
"with",
"self",
".",
"full_node",
".",
"new_peak_... | [
97,
4
] | [
103,
63
] | python | en | ['en', 'error', 'th'] | False |
FullNodeAPI.new_transaction | (
self, transaction: full_node_protocol.NewTransaction, peer: ws.WSKaleConnection
) |
A peer notifies us of a new transaction.
Requests a full transaction if we haven't seen it previously, and if the fees are enough.
|
A peer notifies us of a new transaction.
Requests a full transaction if we haven't seen it previously, and if the fees are enough.
| async def new_transaction(
self, transaction: full_node_protocol.NewTransaction, peer: ws.WSKaleConnection
) -> Optional[Message]:
"""
A peer notifies us of a new transaction.
Requests a full transaction if we haven't seen it previously, and if the fees are enough.
"""
... | [
"async",
"def",
"new_transaction",
"(",
"self",
",",
"transaction",
":",
"full_node_protocol",
".",
"NewTransaction",
",",
"peer",
":",
"ws",
".",
"WSKaleConnection",
")",
"->",
"Optional",
"[",
"Message",
"]",
":",
"# Ignore if syncing",
"if",
"self",
".",
"f... | [
107,
4
] | [
189,
19
] | python | en | ['en', 'error', 'th'] | False |
FullNodeAPI.request_transaction | (self, request: full_node_protocol.RequestTransaction) | Peer has requested a full transaction from us. | Peer has requested a full transaction from us. | async def request_transaction(self, request: full_node_protocol.RequestTransaction) -> Optional[Message]:
"""Peer has requested a full transaction from us."""
# Ignore if syncing
if self.full_node.sync_store.get_sync_mode():
return None
spend_bundle = self.full_node.mempool_m... | [
"async",
"def",
"request_transaction",
"(",
"self",
",",
"request",
":",
"full_node_protocol",
".",
"RequestTransaction",
")",
"->",
"Optional",
"[",
"Message",
"]",
":",
"# Ignore if syncing",
"if",
"self",
".",
"full_node",
".",
"sync_store",
".",
"get_sync_mode... | [
192,
4
] | [
204,
18
] | python | en | ['en', 'en', 'en'] | True |
FullNodeAPI.respond_transaction | (
self,
tx: full_node_protocol.RespondTransaction,
peer: ws.WSKaleConnection,
tx_bytes: bytes = b"",
test: bool = False,
) |
Receives a full transaction from peer.
If tx is added to mempool, send tx_id to others. (new_transaction)
|
Receives a full transaction from peer.
If tx is added to mempool, send tx_id to others. (new_transaction)
| async def respond_transaction(
self,
tx: full_node_protocol.RespondTransaction,
peer: ws.WSKaleConnection,
tx_bytes: bytes = b"",
test: bool = False,
) -> Optional[Message]:
"""
Receives a full transaction from peer.
If tx is added to mempool, send tx_... | [
"async",
"def",
"respond_transaction",
"(",
"self",
",",
"tx",
":",
"full_node_protocol",
".",
"RespondTransaction",
",",
"peer",
":",
"ws",
".",
"WSKaleConnection",
",",
"tx_bytes",
":",
"bytes",
"=",
"b\"\"",
",",
"test",
":",
"bool",
"=",
"False",
",",
... | [
209,
4
] | [
227,
19
] | python | en | ['en', 'error', 'th'] | False |
FullNodeAPI.respond_block | (
self,
respond_block: full_node_protocol.RespondBlock,
peer: ws.WSKaleConnection,
) |
Receive a full block from a peer full node (or ourselves).
|
Receive a full block from a peer full node (or ourselves).
| async def respond_block(
self,
respond_block: full_node_protocol.RespondBlock,
peer: ws.WSKaleConnection,
) -> Optional[Message]:
"""
Receive a full block from a peer full node (or ourselves).
"""
self.log.warning(f"Received unsolicited/late block from peer {... | [
"async",
"def",
"respond_block",
"(",
"self",
",",
"respond_block",
":",
"full_node_protocol",
".",
"RespondBlock",
",",
"peer",
":",
"ws",
".",
"WSKaleConnection",
",",
")",
"->",
"Optional",
"[",
"Message",
"]",
":",
"self",
".",
"log",
".",
"warning",
"... | [
357,
4
] | [
367,
19
] | python | en | ['en', 'error', 'th'] | False |
FullNodeAPI.declare_proof_of_space | (
self, request: farmer_protocol.DeclareProofOfSpace, peer: ws.WSKaleConnection
) |
Creates a block body and header, with the proof of space, coinbase, and fee targets provided
by the farmer, and sends the hash of the header data back to the farmer.
|
Creates a block body and header, with the proof of space, coinbase, and fee targets provided
by the farmer, and sends the hash of the header data back to the farmer.
| async def declare_proof_of_space(
self, request: farmer_protocol.DeclareProofOfSpace, peer: ws.WSKaleConnection
) -> Optional[Message]:
"""
Creates a block body and header, with the proof of space, coinbase, and fee targets provided
by the farmer, and sends the hash of the header dat... | [
"async",
"def",
"declare_proof_of_space",
"(",
"self",
",",
"request",
":",
"farmer_protocol",
".",
"DeclareProofOfSpace",
",",
"peer",
":",
"ws",
".",
"WSKaleConnection",
")",
"->",
"Optional",
"[",
"Message",
"]",
":",
"if",
"self",
".",
"full_node",
".",
... | [
640,
4
] | [
924,
19
] | python | en | ['en', 'error', 'th'] | False |
FullNodeAPI.signed_values | (
self, farmer_request: farmer_protocol.SignedValues, peer: ws.WSKaleConnection
) |
Signature of header hash, by the harvester. This is enough to create an unfinished
block, which only needs a Proof of Time to be finished. If the signature is valid,
we call the unfinished_block routine.
|
Signature of header hash, by the harvester. This is enough to create an unfinished
block, which only needs a Proof of Time to be finished. If the signature is valid,
we call the unfinished_block routine.
| async def signed_values(
self, farmer_request: farmer_protocol.SignedValues, peer: ws.WSKaleConnection
) -> Optional[Message]:
"""
Signature of header hash, by the harvester. This is enough to create an unfinished
block, which only needs a Proof of Time to be finished. If the signatu... | [
"async",
"def",
"signed_values",
"(",
"self",
",",
"farmer_request",
":",
"farmer_protocol",
".",
"SignedValues",
",",
"peer",
":",
"ws",
".",
"WSKaleConnection",
")",
"->",
"Optional",
"[",
"Message",
"]",
":",
"candidate_tuple",
":",
"Optional",
"[",
"Tuple"... | [
928,
4
] | [
988,
19
] | python | en | ['en', 'error', 'th'] | False |
validate_unfinished_header_block | (
constants: ConsensusConstants,
blocks: BlockchainInterface,
header_block: UnfinishedHeaderBlock,
check_filter: bool,
expected_difficulty: uint64,
expected_sub_slot_iters: uint64,
skip_overflow_last_ss_validation: bool = False,
skip_vdf_is_valid: bool = False,
check_sub_epoch_summar... |
Validates an unfinished header block. This is a block without the infusion VDFs (unfinished)
and without transactions and transaction info (header). Returns (required_iters, error).
This method is meant to validate only the unfinished part of the block. However, the finished_sub_slots
refers to all su... |
Validates an unfinished header block. This is a block without the infusion VDFs (unfinished)
and without transactions and transaction info (header). Returns (required_iters, error). | def validate_unfinished_header_block(
constants: ConsensusConstants,
blocks: BlockchainInterface,
header_block: UnfinishedHeaderBlock,
check_filter: bool,
expected_difficulty: uint64,
expected_sub_slot_iters: uint64,
skip_overflow_last_ss_validation: bool = False,
skip_vdf_is_valid: bool... | [
"def",
"validate_unfinished_header_block",
"(",
"constants",
":",
"ConsensusConstants",
",",
"blocks",
":",
"BlockchainInterface",
",",
"header_block",
":",
"UnfinishedHeaderBlock",
",",
"check_filter",
":",
"bool",
",",
"expected_difficulty",
":",
"uint64",
",",
"expec... | [
37,
0
] | [
823,
31
] | python | en | ['en', 'error', 'th'] | False |
validate_finished_header_block | (
constants: ConsensusConstants,
blocks: BlockchainInterface,
header_block: HeaderBlock,
check_filter: bool,
expected_difficulty: uint64,
expected_sub_slot_iters: uint64,
check_sub_epoch_summary=True,
) |
Fully validates the header of a block. A header block is the same as a full block, but
without transactions and transaction info. Returns (required_iters, error).
|
Fully validates the header of a block. A header block is the same as a full block, but
without transactions and transaction info. Returns (required_iters, error).
| def validate_finished_header_block(
constants: ConsensusConstants,
blocks: BlockchainInterface,
header_block: HeaderBlock,
check_filter: bool,
expected_difficulty: uint64,
expected_sub_slot_iters: uint64,
check_sub_epoch_summary=True,
) -> Tuple[Optional[uint64], Optional[ValidationError]]:
... | [
"def",
"validate_finished_header_block",
"(",
"constants",
":",
"ConsensusConstants",
",",
"blocks",
":",
"BlockchainInterface",
",",
"header_block",
":",
"HeaderBlock",
",",
"check_filter",
":",
"bool",
",",
"expected_difficulty",
":",
"uint64",
",",
"expected_sub_slot... | [
826,
0
] | [
1062,
31
] | python | en | ['en', 'error', 'th'] | False |
LineString.__init__ | (self, *args, **kwargs) |
Initializes on the given sequence -- may take lists, tuples, NumPy arrays
of X,Y pairs, or Point objects. If Point objects are used, ownership is
_not_ transferred to the LineString object.
Examples:
ls = LineString((1, 1), (2, 2))
ls = LineString([(1, 1), (2, 2)])
... |
Initializes on the given sequence -- may take lists, tuples, NumPy arrays
of X,Y pairs, or Point objects. If Point objects are used, ownership is
_not_ transferred to the LineString object. | def __init__(self, *args, **kwargs):
"""
Initializes on the given sequence -- may take lists, tuples, NumPy arrays
of X,Y pairs, or Point objects. If Point objects are used, ownership is
_not_ transferred to the LineString object.
Examples:
ls = LineString((1, 1), (2, ... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# If only one argument provided, set the coords array appropriately",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"coords",
"=",
"args",
"[",
"0",
"]",
"else",
":",
"c... | [
14,
4
] | [
89,
76
] | python | en | ['en', 'error', 'th'] | False |
LineString.__iter__ | (self) | Allows iteration over this LineString. | Allows iteration over this LineString. | def __iter__(self):
"Allows iteration over this LineString."
for i in range(len(self)):
yield self[i] | [
"def",
"__iter__",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
")",
")",
":",
"yield",
"self",
"[",
"i",
"]"
] | [
91,
4
] | [
94,
25
] | python | en | ['en', 'en', 'en'] | True |
LineString.__len__ | (self) | Returns the number of points in this LineString. | Returns the number of points in this LineString. | def __len__(self):
"Returns the number of points in this LineString."
return len(self._cs) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"_cs",
")"
] | [
96,
4
] | [
98,
28
] | python | en | ['en', 'en', 'en'] | True |
LineString.tuple | (self) | Returns a tuple version of the geometry from the coordinate sequence. | Returns a tuple version of the geometry from the coordinate sequence. | def tuple(self):
"Returns a tuple version of the geometry from the coordinate sequence."
return self._cs.tuple | [
"def",
"tuple",
"(",
"self",
")",
":",
"return",
"self",
".",
"_cs",
".",
"tuple"
] | [
133,
4
] | [
135,
29
] | python | en | ['en', 'en', 'en'] | True |
LineString._listarr | (self, func) |
Internal routine that returns a sequence (list) corresponding with
the given function. Will return a numpy array if possible.
|
Internal routine that returns a sequence (list) corresponding with
the given function. Will return a numpy array if possible.
| def _listarr(self, func):
"""
Internal routine that returns a sequence (list) corresponding with
the given function. Will return a numpy array if possible.
"""
lst = [func(i) for i in range(len(self))]
if numpy:
return numpy.array(lst) # ARRRR!
else:... | [
"def",
"_listarr",
"(",
"self",
",",
"func",
")",
":",
"lst",
"=",
"[",
"func",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
")",
")",
"]",
"if",
"numpy",
":",
"return",
"numpy",
".",
"array",
"(",
"lst",
")",
"# ARRRR!",
... | [
138,
4
] | [
147,
22
] | python | en | ['en', 'error', 'th'] | False |
LineString.array | (self) | Returns a numpy array for the LineString. | Returns a numpy array for the LineString. | def array(self):
"Returns a numpy array for the LineString."
return self._listarr(self._cs.__getitem__) | [
"def",
"array",
"(",
"self",
")",
":",
"return",
"self",
".",
"_listarr",
"(",
"self",
".",
"_cs",
".",
"__getitem__",
")"
] | [
150,
4
] | [
152,
50
] | python | en | ['en', 'en', 'en'] | True |
LineString.x | (self) | Returns a list or numpy array of the X variable. | Returns a list or numpy array of the X variable. | def x(self):
"Returns a list or numpy array of the X variable."
return self._listarr(self._cs.getX) | [
"def",
"x",
"(",
"self",
")",
":",
"return",
"self",
".",
"_listarr",
"(",
"self",
".",
"_cs",
".",
"getX",
")"
] | [
155,
4
] | [
157,
43
] | python | en | ['en', 'ga', 'en'] | True |
LineString.y | (self) | Returns a list or numpy array of the Y variable. | Returns a list or numpy array of the Y variable. | def y(self):
"Returns a list or numpy array of the Y variable."
return self._listarr(self._cs.getY) | [
"def",
"y",
"(",
"self",
")",
":",
"return",
"self",
".",
"_listarr",
"(",
"self",
".",
"_cs",
".",
"getY",
")"
] | [
160,
4
] | [
162,
43
] | python | en | ['en', 'en', 'en'] | True |
LineString.z | (self) | Returns a list or numpy array of the Z variable. | Returns a list or numpy array of the Z variable. | def z(self):
"Returns a list or numpy array of the Z variable."
if not self.hasz:
return None
else:
return self._listarr(self._cs.getZ) | [
"def",
"z",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"hasz",
":",
"return",
"None",
"else",
":",
"return",
"self",
".",
"_listarr",
"(",
"self",
".",
"_cs",
".",
"getZ",
")"
] | [
165,
4
] | [
170,
47
] | python | en | ['en', 'en', 'en'] | True |
NovoGrad.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... | [
85,
4
] | [
158,
19
] | python | en | ['en', 'en', 'en'] | True |
FileBasedCache._cull | (self) |
Removes random cache entries if max_entries is reached at a ratio
of num_entries / cull_frequency. A value of 0 for CULL_FREQUENCY means
that the entire cache will be purged.
|
Removes random cache entries if max_entries is reached at a ratio
of num_entries / cull_frequency. A value of 0 for CULL_FREQUENCY means
that the entire cache will be purged.
| def _cull(self):
"""
Removes random cache entries if max_entries is reached at a ratio
of num_entries / cull_frequency. A value of 0 for CULL_FREQUENCY means
that the entire cache will be purged.
"""
filelist = self._list_cache_files()
num_entries = len(filelist)
... | [
"def",
"_cull",
"(",
"self",
")",
":",
"filelist",
"=",
"self",
".",
"_list_cache_files",
"(",
")",
"num_entries",
"=",
"len",
"(",
"filelist",
")",
"if",
"num_entries",
"<",
"self",
".",
"_max_entries",
":",
"return",
"# return early if no culling is required",... | [
84,
4
] | [
100,
31
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.