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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
SettingModuleProxy.get_setting | (self, model_name) |
Get a setting instance
|
Get a setting instance
| def get_setting(self, model_name):
"""
Get a setting instance
"""
Model = registry.get_by_natural_key(self.app_label, model_name)
if Model is None:
return None
if isinstance(self.request_or_site, Site):
return Model.for_site(self.request_or_site)
... | [
"def",
"get_setting",
"(",
"self",
",",
"model_name",
")",
":",
"Model",
"=",
"registry",
".",
"get_by_natural_key",
"(",
"self",
".",
"app_label",
",",
"model_name",
")",
"if",
"Model",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"self",... | [
42,
4
] | [
53,
54
] | python | en | ['en', 'error', 'th'] | False |
Loader.get_template | (self, template_name, template_dirs=None, skip=None) |
Calls self.get_template_sources() and returns a Template object for
the first template matching template_name. If skip is provided,
template origins in skip are ignored. This is used to avoid recursion
during template extending.
|
Calls self.get_template_sources() and returns a Template object for
the first template matching template_name. If skip is provided,
template origins in skip are ignored. This is used to avoid recursion
during template extending.
| def get_template(self, template_name, template_dirs=None, skip=None):
"""
Calls self.get_template_sources() and returns a Template object for
the first template matching template_name. If skip is provided,
template origins in skip are ignored. This is used to avoid recursion
duri... | [
"def",
"get_template",
"(",
"self",
",",
"template_name",
",",
"template_dirs",
"=",
"None",
",",
"skip",
"=",
"None",
")",
":",
"tried",
"=",
"[",
"]",
"args",
"=",
"[",
"template_name",
"]",
"# RemovedInDjango20Warning: Add template_dirs for compatibility with",
... | [
16,
4
] | [
46,
62
] | python | en | ['en', 'error', 'th'] | False |
Loader.get_template_sources | (self, template_name) |
An iterator that yields possible matching template paths for a
template name.
|
An iterator that yields possible matching template paths for a
template name.
| def get_template_sources(self, template_name):
"""
An iterator that yields possible matching template paths for a
template name.
"""
raise NotImplementedError(
'subclasses of Loader must provide a get_template_sources() method'
) | [
"def",
"get_template_sources",
"(",
"self",
",",
"template_name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of Loader must provide a get_template_sources() method'",
")"
] | [
72,
4
] | [
79,
9
] | python | en | ['en', 'error', 'th'] | False |
Loader.load_template_source | (self, template_name, template_dirs=None) |
RemovedInDjango20Warning: Returns a tuple containing the source and
origin for the given template name.
|
RemovedInDjango20Warning: Returns a tuple containing the source and
origin for the given template name.
| def load_template_source(self, template_name, template_dirs=None):
"""
RemovedInDjango20Warning: Returns a tuple containing the source and
origin for the given template name.
"""
raise NotImplementedError(
'subclasses of Loader must provide a load_template_source() me... | [
"def",
"load_template_source",
"(",
"self",
",",
"template_name",
",",
"template_dirs",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of Loader must provide a load_template_source() method'",
")"
] | [
81,
4
] | [
88,
9
] | python | en | ['en', 'error', 'th'] | False |
Loader.reset | (self) |
Resets any state maintained by the loader instance (e.g. cached
templates or cached loader modules).
|
Resets any state maintained by the loader instance (e.g. cached
templates or cached loader modules).
| def reset(self):
"""
Resets any state maintained by the loader instance (e.g. cached
templates or cached loader modules).
"""
pass | [
"def",
"reset",
"(",
"self",
")",
":",
"pass"
] | [
90,
4
] | [
95,
12
] | python | en | ['en', 'error', 'th'] | False |
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 hasattr(self, 'get_contents') | [
"def",
"supports_recursion",
"(",
"self",
")",
":",
"return",
"hasattr",
"(",
"self",
",",
"'get_contents'",
")"
] | [
98,
4
] | [
103,
44
] | python | en | ['en', 'error', 'th'] | False |
IdentityFlow.__init__ | (self, params, n_dims, name='IdentityFlow') |
:param params: shape (?, 1), this will become alpha and define the slow of ReLU for x < 0
:param n_dims: Dimension of the distribution that's being transformed
|
:param params: shape (?, 1), this will become alpha and define the slow of ReLU for x < 0
:param n_dims: Dimension of the distribution that's being transformed
| def __init__(self, params, n_dims, name='IdentityFlow'):
"""
:param params: shape (?, 1), this will become alpha and define the slow of ReLU for x < 0
:param n_dims: Dimension of the distribution that's being transformed
"""
super(IdentityFlow, self).__init__(params,
... | [
"def",
"__init__",
"(",
"self",
",",
"params",
",",
"n_dims",
",",
"name",
"=",
"'IdentityFlow'",
")",
":",
"super",
"(",
"IdentityFlow",
",",
"self",
")",
".",
"__init__",
"(",
"params",
",",
"n_dims",
",",
"name",
"=",
"name",
")"
] | [
9,
4
] | [
16,
53
] | python | en | ['en', 'error', 'th'] | False |
IdentityFlow.get_param_size | (n_dims) |
:param n_dims: The dimension of the distribution to be transformed by the flow. For this flow it's irrelevant
:return: (int) The dimension of the parameter space for the flow. This flow doesn't have parameters, hence it's always 0
|
:param n_dims: The dimension of the distribution to be transformed by the flow. For this flow it's irrelevant
:return: (int) The dimension of the parameter space for the flow. This flow doesn't have parameters, hence it's always 0
| def get_param_size(n_dims):
"""
:param n_dims: The dimension of the distribution to be transformed by the flow. For this flow it's irrelevant
:return: (int) The dimension of the parameter space for the flow. This flow doesn't have parameters, hence it's always 0
"""
return 0 | [
"def",
"get_param_size",
"(",
"n_dims",
")",
":",
"return",
"0"
] | [
19,
4
] | [
24,
16
] | python | en | ['en', 'error', 'th'] | False |
get_inferior | () | Get current inferior | Get current inferior | def get_inferior():
"""Get current inferior"""
try:
if len(gdb.inferiors()) == 0:
print ("No gdb inferior could be found.")
return -1
else:
inferior = gdb.inferiors()[0]
return inferior
except AttributeError:
print ("This gdb's python s... | [
"def",
"get_inferior",
"(",
")",
":",
"try",
":",
"if",
"len",
"(",
"gdb",
".",
"inferiors",
"(",
")",
")",
"==",
"0",
":",
"print",
"(",
"\"No gdb inferior could be found.\"",
")",
"return",
"-",
"1",
"else",
":",
"inferior",
"=",
"gdb",
".",
"inferio... | [
100,
0
] | [
111,
14
] | python | en | ['it', 'la', 'en'] | False |
read_from_memory | (addr, size) | Read data with specified size from the specified memory | Read data with specified size from the specified memory | def read_from_memory(addr, size):
"""Read data with specified size from the specified memory"""
inferior = get_inferior()
# ( check the address is inside the enclave)
if inferior == -1 or addr == 0:
print ("Error happens in read_from_memory: addr = {0:x}".format(int(addr)))
return None
... | [
"def",
"read_from_memory",
"(",
"addr",
",",
"size",
")",
":",
"inferior",
"=",
"get_inferior",
"(",
")",
"# ( check the address is inside the enclave)",
"if",
"inferior",
"==",
"-",
"1",
"or",
"addr",
"==",
"0",
":",
"print",
"(",
"\"Error happens in read_from_me... | [
113,
0
] | [
125,
19
] | python | en | ['en', 'en', 'en'] | True |
write_to_memory | (addr, buf) | Write a specified buffer to the specified memory | Write a specified buffer to the specified memory | def write_to_memory(addr, buf):
"""Write a specified buffer to the specified memory"""
inferior = get_inferior()
if inferior == -1 or addr == 0:
print ("Error happens in write_to_memory: addr = {0:x}".format(int(addr)))
return -1
try:
inferior.write_memory(addr, buf)
retu... | [
"def",
"write_to_memory",
"(",
"addr",
",",
"buf",
")",
":",
"inferior",
"=",
"get_inferior",
"(",
")",
"if",
"inferior",
"==",
"-",
"1",
"or",
"addr",
"==",
"0",
":",
"print",
"(",
"\"Error happens in write_to_memory: addr = {0:x}\"",
".",
"format",
"(",
"i... | [
127,
0
] | [
138,
17
] | python | en | ['en', 'en', 'en'] | True |
load_enclave_symbol | (enclave_path, enclave_base_addr) | Load enclave symbol file into current debug session | Load enclave symbol file into current debug session | def load_enclave_symbol(enclave_path, enclave_base_addr):
"""Load enclave symbol file into current debug session"""
if os.path.exists(enclave_path) == True:
enclave_path = os.path.abspath(enclave_path)
else:
enclave_path = target_path_to_host_path(enclave_path)
gdb_cmd = load_symbol_cmd.... | [
"def",
"load_enclave_symbol",
"(",
"enclave_path",
",",
"enclave_base_addr",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"enclave_path",
")",
"==",
"True",
":",
"enclave_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"enclave_path",
")",
"e... | [
154,
0
] | [
169,
15
] | python | en | ['en', 'da', 'en'] | True |
enable_oeenclave_debug | (oe_enclave_addr) | For a given OE enclave, load its symbol and enable debug flag for all its TCS | For a given OE enclave, load its symbol and enable debug flag for all its TCS | def enable_oeenclave_debug(oe_enclave_addr):
"""For a given OE enclave, load its symbol and enable debug flag for all its TCS"""
enclave = oe_debug_enclave_t(oe_enclave_addr)
# Check if magic matches
if not enclave.is_valid():
return False
# No version specific checks.
# The contract ... | [
"def",
"enable_oeenclave_debug",
"(",
"oe_enclave_addr",
")",
":",
"enclave",
"=",
"oe_debug_enclave_t",
"(",
"oe_enclave_addr",
")",
"# Check if magic matches",
"if",
"not",
"enclave",
".",
"is_valid",
"(",
")",
":",
"return",
"False",
"# No version specific checks.",
... | [
197,
0
] | [
228,
15
] | python | en | ['en', 'en', 'en'] | True |
update_untrusted_ocall_frame | (frame_pointer, ocallcontext_tuple) | Update the untrusted ocall frame, so that untrusted stack can stitch withe the trusted stack | Update the untrusted ocall frame, so that untrusted stack can stitch withe the trusted stack | def update_untrusted_ocall_frame(frame_pointer, ocallcontext_tuple):
"""Update the untrusted ocall frame, so that untrusted stack can stitch withe the trusted stack"""
if frame_pointer == 0 or ocallcontext_tuple == 0:
return False
# print ("Trusted ocall context at:{:#x}, rbp:{:#x}, return address:{... | [
"def",
"update_untrusted_ocall_frame",
"(",
"frame_pointer",
",",
"ocallcontext_tuple",
")",
":",
"if",
"frame_pointer",
"==",
"0",
"or",
"ocallcontext_tuple",
"==",
"0",
":",
"return",
"False",
"# print (\"Trusted ocall context at:{:#x}, rbp:{:#x}, return address:{:#x}\" .form... | [
230,
0
] | [
241,
15
] | python | en | ['en', 'en', 'en'] | True |
oe_debugger_cleanup | () | Remove all loaded enclave symbols | Remove all loaded enclave symbols | def oe_debugger_cleanup():
"""Remove all loaded enclave symbols"""
global g_enclave_list_parsed
for oe_enclave_addr in g_loaded_oe_enclave_addrs:
gdb_cmd = "remove-symbol-file -a %s" % (oe_enclave_addr)
# print (gdb_cmd)
gdb.execute("remove-symbol-file -a %s" % (oe_enclave_addr), Fal... | [
"def",
"oe_debugger_cleanup",
"(",
")",
":",
"global",
"g_enclave_list_parsed",
"for",
"oe_enclave_addr",
"in",
"g_loaded_oe_enclave_addrs",
":",
"gdb_cmd",
"=",
"\"remove-symbol-file -a %s\"",
"%",
"(",
"oe_enclave_addr",
")",
"# print (gdb_cmd)",
"gdb",
".",
"execute",
... | [
353,
0
] | [
362,
10
] | python | en | ['en', 'it', 'en'] | True |
Deserializer | (stream_or_string, **options) |
Deserialize a stream or string of YAML data.
|
Deserialize a stream or string of YAML data.
| def Deserializer(stream_or_string, **options):
"""
Deserialize a stream or string of YAML data.
"""
if isinstance(stream_or_string, bytes):
stream_or_string = stream_or_string.decode('utf-8')
if isinstance(stream_or_string, six.string_types):
stream = StringIO(stream_or_string)
e... | [
"def",
"Deserializer",
"(",
"stream_or_string",
",",
"*",
"*",
"options",
")",
":",
"if",
"isinstance",
"(",
"stream_or_string",
",",
"bytes",
")",
":",
"stream_or_string",
"=",
"stream_or_string",
".",
"decode",
"(",
"'utf-8'",
")",
"if",
"isinstance",
"(",
... | [
67,
0
] | [
84,
85
] | python | en | ['en', 'error', 'th'] | False |
TestApacheBenchExecutor.test_iter | (self) | Ensures that executor doesn't fail with minimal configuration. | Ensures that executor doesn't fail with minimal configuration. | def test_iter(self):
"Ensures that executor doesn't fail with minimal configuration."
self.configure({"execution": {
"scenario": {
"requests": ["http://blazedemo.com"]}}})
self.obj.prepare()
self.obj.get_widget()
try:
self.obj.startup()
... | [
"def",
"test_iter",
"(",
"self",
")",
":",
"self",
".",
"configure",
"(",
"{",
"\"execution\"",
":",
"{",
"\"scenario\"",
":",
"{",
"\"requests\"",
":",
"[",
"\"http://blazedemo.com\"",
"]",
"}",
"}",
"}",
")",
"self",
".",
"obj",
".",
"prepare",
"(",
... | [
21,
4
] | [
35,
52
] | python | en | ['en', 'en', 'en'] | True |
TestApacheBenchExecutor.test_no_request_exception | (self) | Checks that executor.startup fails if there's no request specified. | Checks that executor.startup fails if there's no request specified. | def test_no_request_exception(self):
"Checks that executor.startup fails if there's no request specified."
self.configure({"execution": {"scenario": {}}})
self.obj.prepare()
self.assertRaises(TaurusConfigError, self.obj.startup) | [
"def",
"test_no_request_exception",
"(",
"self",
")",
":",
"self",
".",
"configure",
"(",
"{",
"\"execution\"",
":",
"{",
"\"scenario\"",
":",
"{",
"}",
"}",
"}",
")",
"self",
".",
"obj",
".",
"prepare",
"(",
")",
"self",
".",
"assertRaises",
"(",
"Tau... | [
37,
4
] | [
41,
62
] | python | en | ['en', 'en', 'en'] | True |
TestApacheBenchExecutor.test_non_get_request_exception | (self) |
Checks that executor.startup fails if
request with non-GET method is specified.
|
Checks that executor.startup fails if
request with non-GET method is specified.
| def test_non_get_request_exception(self):
"""
Checks that executor.startup fails if
request with non-GET method is specified.
"""
self.obj.execution.merge({
"scenario": {
"requests": [{
"url": "http://blazedemo.com",
... | [
"def",
"test_non_get_request_exception",
"(",
"self",
")",
":",
"self",
".",
"obj",
".",
"execution",
".",
"merge",
"(",
"{",
"\"scenario\"",
":",
"{",
"\"requests\"",
":",
"[",
"{",
"\"url\"",
":",
"\"http://blazedemo.com\"",
",",
"\"method\"",
":",
"\"POST\"... | [
43,
4
] | [
54,
62
] | python | en | ['en', 'error', 'th'] | False |
TestApacheBenchExecutor.test_no_apache_benchmark | (self) | Checks that prepare() fails if ApacheBenchmark is not installed. | Checks that prepare() fails if ApacheBenchmark is not installed. | def test_no_apache_benchmark(self):
"Checks that prepare() fails if ApacheBenchmark is not installed."
self.obj.settings.merge({"path": "*"})
self.obj.execution.merge({
"scenario": {
"requests": ["http://blazedemo.com"]}})
self.assertRaises(ToolError, self.obj... | [
"def",
"test_no_apache_benchmark",
"(",
"self",
")",
":",
"self",
".",
"obj",
".",
"settings",
".",
"merge",
"(",
"{",
"\"path\"",
":",
"\"*\"",
"}",
")",
"self",
".",
"obj",
".",
"execution",
".",
"merge",
"(",
"{",
"\"scenario\"",
":",
"{",
"\"reques... | [
56,
4
] | [
62,
54
] | python | en | ['en', 'en', 'en'] | True |
create_package_set_from_installed | (**kwargs) | Converts a list of distributions into a PackageSet.
| Converts a list of distributions into a PackageSet.
| def create_package_set_from_installed(**kwargs):
# type: (**Any) -> Tuple[PackageSet, bool]
"""Converts a list of distributions into a PackageSet.
"""
# Default to using all packages installed on the system
if kwargs == {}:
kwargs = {"local_only": False, "skip": ()}
package_set = {}
... | [
"def",
"create_package_set_from_installed",
"(",
"*",
"*",
"kwargs",
")",
":",
"# type: (**Any) -> Tuple[PackageSet, bool]",
"# Default to using all packages installed on the system",
"if",
"kwargs",
"==",
"{",
"}",
":",
"kwargs",
"=",
"{",
"\"local_only\"",
":",
"False",
... | [
33,
0
] | [
51,
32
] | python | en | ['en', 'en', 'en'] | True |
check_package_set | (package_set, should_ignore=None) | Check if a package set is consistent
If should_ignore is passed, it should be a callable that takes a
package name and returns a boolean.
| Check if a package set is consistent | def check_package_set(package_set, should_ignore=None):
# type: (PackageSet, Optional[Callable[[str], bool]]) -> CheckResult
"""Check if a package set is consistent
If should_ignore is passed, it should be a callable that takes a
package name and returns a boolean.
"""
missing = {}
conflic... | [
"def",
"check_package_set",
"(",
"package_set",
",",
"should_ignore",
"=",
"None",
")",
":",
"# type: (PackageSet, Optional[Callable[[str], bool]]) -> CheckResult",
"missing",
"=",
"{",
"}",
"conflicting",
"=",
"{",
"}",
"for",
"package_name",
"in",
"package_set",
":",
... | [
54,
0
] | [
95,
31
] | python | en | ['en', 'en', 'en'] | True |
check_install_conflicts | (to_install) | For checking if the dependency graph would be consistent after \
installing given requirements
| For checking if the dependency graph would be consistent after \
installing given requirements
| def check_install_conflicts(to_install):
# type: (List[InstallRequirement]) -> ConflictDetails
"""For checking if the dependency graph would be consistent after \
installing given requirements
"""
# Start from the current state
package_set, _ = create_package_set_from_installed()
# Install p... | [
"def",
"check_install_conflicts",
"(",
"to_install",
")",
":",
"# type: (List[InstallRequirement]) -> ConflictDetails",
"# Start from the current state",
"package_set",
",",
"_",
"=",
"create_package_set_from_installed",
"(",
")",
"# Install packages",
"would_be_installed",
"=",
... | [
98,
0
] | [
116,
5
] | python | en | ['en', 'en', 'en'] | True |
_simulate_installation_of | (to_install, package_set) | Computes the version of packages after installing to_install.
| Computes the version of packages after installing to_install.
| def _simulate_installation_of(to_install, package_set):
# type: (List[InstallRequirement], PackageSet) -> Set[str]
"""Computes the version of packages after installing to_install.
"""
# Keep track of packages that were installed
installed = set()
# Modify it as installing requirement_set would... | [
"def",
"_simulate_installation_of",
"(",
"to_install",
",",
"package_set",
")",
":",
"# type: (List[InstallRequirement], PackageSet) -> Set[str]",
"# Keep track of packages that were installed",
"installed",
"=",
"set",
"(",
")",
"# Modify it as installing requirement_set would (assumi... | [
119,
0
] | [
138,
20
] | python | en | ['en', 'en', 'en'] | True |
var_helper | (N) | Correct for the fact the rms noise is computed from a clipped
distribution.
That noise will always be lower than the noise from the complete
distribution. The correction factor is a function of the computed
rms noise only.
| Correct for the fact the rms noise is computed from a clipped
distribution. | def var_helper(N):
"""Correct for the fact the rms noise is computed from a clipped
distribution.
That noise will always be lower than the noise from the complete
distribution. The correction factor is a function of the computed
rms noise only.
"""
term1 = numpy.sqrt(2. * numpy.pi) * erf(N... | [
"def",
"var_helper",
"(",
"N",
")",
":",
"term1",
"=",
"numpy",
".",
"sqrt",
"(",
"2.",
"*",
"numpy",
".",
"pi",
")",
"*",
"erf",
"(",
"N",
"/",
"numpy",
".",
"sqrt",
"(",
"2.",
")",
")",
"term2",
"=",
"2.",
"*",
"N",
"*",
"numpy",
".",
"ex... | [
14,
0
] | [
24,
34
] | python | en | ['en', 'en', 'en'] | True |
unbiased_sigma | (N_indep) | Calculate an unbiased sigma for using in sigma clipping.
The formula below for cliplim is pretty subtle. Kappa, sigma
clipping should be such that the noise is not biased by
it. Consequently, the clipping boundaries should be such that
exactly half an independent pixel should exceed it if the map were
... | Calculate an unbiased sigma for using in sigma clipping. | def unbiased_sigma(N_indep):
"""Calculate an unbiased sigma for using in sigma clipping.
The formula below for cliplim is pretty subtle. Kappa, sigma
clipping should be such that the noise is not biased by
it. Consequently, the clipping boundaries should be such that
exactly half an independent pix... | [
"def",
"unbiased_sigma",
"(",
"N_indep",
")",
":",
"return",
"1.4142135623730951",
"*",
"erfcinv",
"(",
"0.5",
"/",
"N_indep",
")"
] | [
34,
0
] | [
54,
54
] | python | en | ['en', 'en', 'en'] | True |
sigma_clip | (data, beam, sigma=unbiased_sigma, max_iter=100,
centref=numpy.median, distf=numpy.var, my_iterations=0,
corr_clip=1.) | Iterative clipping
By default, this performs clipping of the standard deviation about the
median of the data. But by tweaking centref/distf, it could be much
more general.
max_iter sets the maximum number of iterations used.
my_iterations is a counter for recursive operation of the code; leave it... | Iterative clipping | def sigma_clip(data, beam, sigma=unbiased_sigma, max_iter=100,
centref=numpy.median, distf=numpy.var, my_iterations=0,
corr_clip=1.):
"""Iterative clipping
By default, this performs clipping of the standard deviation about the
median of the data. But by tweaking centref/distf,... | [
"def",
"sigma_clip",
"(",
"data",
",",
"beam",
",",
"sigma",
"=",
"unbiased_sigma",
",",
"max_iter",
"=",
"100",
",",
"centref",
"=",
"numpy",
".",
"median",
",",
"distf",
"=",
"numpy",
".",
"var",
",",
"my_iterations",
"=",
"0",
",",
"corr_clip",
"=",... | [
57,
0
] | [
126,
59
] | python | en | ['en', 'en', 'en'] | False |
write_index | () | This is to write the docs for the index automatically. | This is to write the docs for the index automatically. | def write_index():
"""This is to write the docs for the index automatically."""
here = os.path.dirname(__file__)
filename = os.path.join(here, '_generated', 'version_text.txt')
try:
os.makedirs(os.path.dirname(filename))
except FileExistsError:
pass
text = text_version if '+' ... | [
"def",
"write_index",
"(",
")",
":",
"here",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"here",
",",
"'_generated'",
",",
"'version_text.txt'",
")",
"try",
":",
"os",
".",
"make... | [
430,
0
] | [
444,
21
] | python | en | ['en', 'en', 'en'] | True |
write_gdir_doc | () | This is to write the docs for glacierdir automatically. | This is to write the docs for glacierdir automatically. | def write_gdir_doc():
"""This is to write the docs for glacierdir automatically."""
here = os.path.dirname(__file__)
origfile = os.path.join(here, '_templates', 'basenames.txt')
filename = os.path.join(here, '_generated', 'basenames.txt')
try:
os.makedirs(os.path.dirname(filename))
exc... | [
"def",
"write_gdir_doc",
"(",
")",
":",
"here",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"origfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"here",
",",
"'_templates'",
",",
"'basenames.txt'",
")",
"filename",
"=",
"os",
".",
... | [
447,
0
] | [
472,
20
] | python | en | ['en', 'en', 'en'] | True |
iDRACJobs.delete_job | (self, jobid) |
Delete a job
:param jobid: Job ID
:type jobid: str
:return: success/failure response
:rtype: JSON
.. code-block:: python
:caption: Examples
:name: Examples
# Delete a job
jo... |
Delete a job
:param jobid: Job ID
:type jobid: str
:return: success/failure response
:rtype: JSON
.. code-block:: python
:caption: Examples
:name: Examples
# Delete a job
jo... | def delete_job(self, jobid):
"""
Delete a job
:param jobid: Job ID
:type jobid: str
:return: success/failure response
:rtype: JSON
.. code-block:: python
:caption: Examples
:name: Examples
... | [
"def",
"delete_job",
"(",
"self",
",",
"jobid",
")",
":",
"if",
"self",
".",
"entity",
".",
"use_redfish",
":",
"rjson",
"=",
"self",
".",
"entity",
".",
"_delete_job_redfish",
"(",
"job_id",
"=",
"jobid",
")",
"return",
"rjson",
"return",
"self",
".",
... | [
66,
4
] | [
86,
52
] | python | en | ['en', 'ja', 'th'] | False |
iDRACJobs.delete_all_jobs | (self) |
Delete all jobs
:return: success/failure response
:rtype: JSON
.. code-block:: python
:caption: Examples
:name: Examples
# Delete all jobs
job_status = idrac.job_mgr.delete_all_jobs()
|
Delete all jobs
:return: success/failure response
:rtype: JSON
.. code-block:: python
:caption: Examples
:name: Examples
# Delete all jobs
job_status = idrac.job_mgr.delete_all_jobs()
| def delete_all_jobs(self):
"""
Delete all jobs
:return: success/failure response
:rtype: JSON
.. code-block:: python
:caption: Examples
:name: Examples
# Delete all jobs
job_status = idrac.jo... | [
"def",
"delete_all_jobs",
"(",
"self",
")",
":",
"return",
"self",
".",
"entity",
".",
"_jobq_delete",
"(",
"jobid",
"=",
"\"JID_CLEARALL\"",
")"
] | [
88,
4
] | [
103,
61
] | python | en | ['en', 'ja', 'th'] | False |
iDRACJobs.get_job_status | (self, jobid) |
Get the job status
:param jobid: Job ID
:type jobid: str
:return: success/failure response
:rtype: JSON
.. code-block:: python
:caption: Examples
:name: Examples
# Get Job Status
... |
Get the job status
:param jobid: Job ID
:type jobid: str
:return: success/failure response
:rtype: JSON
.. code-block:: python
:caption: Examples
:name: Examples
# Get Job Status
... | def get_job_status(self, jobid):
"""
Get the job status
:param jobid: Job ID
:type jobid: str
:return: success/failure response
:rtype: JSON
.. code-block:: python
:caption: Examples
:name: Exa... | [
"def",
"get_job_status",
"(",
"self",
",",
"jobid",
")",
":",
"if",
"self",
".",
"entity",
".",
"use_redfish",
":",
"return",
"self",
".",
"get_job_status_redfish",
"(",
"jobid",
")",
"jobs",
"=",
"{",
"}",
"jobret",
"=",
"{",
"\"Status\"",
":",
"TypeHel... | [
126,
4
] | [
187,
17
] | python | en | ['en', 'ja', 'th'] | False |
iDRACJobs.job_wait | (self, jobid, track_jobid=True, show_progress=False,
wait_for=2 * 60 * 60) | Wait for the job to finish(fail/success)
:param jobid: id of the job.
:param path: str. .
:returns: returns a json/dict containing job details
| Wait for the job to finish(fail/success)
:param jobid: id of the job.
:param path: str. .
:returns: returns a json/dict containing job details
| def job_wait(self, jobid, track_jobid=True, show_progress=False,
wait_for=2 * 60 * 60): # wait for a 2 hours (longgg time)
"""Wait for the job to finish(fail/success)
:param jobid: id of the job.
:param path: str. .
:returns: returns a json/dict containin... | [
"def",
"job_wait",
"(",
"self",
",",
"jobid",
",",
"track_jobid",
"=",
"True",
",",
"show_progress",
"=",
"False",
",",
"wait_for",
"=",
"2",
"*",
"60",
"*",
"60",
")",
":",
"# wait for a 2 hours (longgg time)\r",
"logger",
".",
"info",
"(",
"self",
".",
... | [
224,
4
] | [
292,
23
] | python | en | ['en', 'en', 'en'] | True |
iDRACJobs.get_job_details_redfish | (self, jobid) | Gets Details of the job
:param jobid: id of the job.
:param path: str. .
:returns: returns a json/dict containing job details
| Gets Details of the job
:param jobid: id of the job.
:param path: str. .
:returns: returns a json/dict containing job details
| def get_job_details_redfish(self, jobid):
"""Gets Details of the job
:param jobid: id of the job.
:param path: str. .
:returns: returns a json/dict containing job details
"""
detail = None
try:
detail = self.entity._get_idracjobdeat... | [
"def",
"get_job_details_redfish",
"(",
"self",
",",
"jobid",
")",
":",
"detail",
"=",
"None",
"try",
":",
"detail",
"=",
"self",
".",
"entity",
".",
"_get_idracjobdeatilbyid_redfish",
"(",
"job_id",
"=",
"jobid",
")",
"logger",
".",
"debug",
"(",
"self",
"... | [
295,
4
] | [
328,
21
] | python | en | ['en', 'en', 'en'] | True |
iDRACJobs.get_job_status_redfish | (self, jobid) | Gets status of the job
:param jobid: id of the job.
:param path: str. .
:returns: returns a json/dict containing job status(key in the dict is Status) along with other details
| Gets status of the job
:param jobid: id of the job.
:param path: str. .
:returns: returns a json/dict containing job status(key in the dict is Status) along with other details
| def get_job_status_redfish(self, jobid):
"""Gets status of the job
:param jobid: id of the job.
:param path: str. .
:returns: returns a json/dict containing job status(key in the dict is Status) along with other details
"""
jobdetail = self.get_job_detai... | [
"def",
"get_job_status_redfish",
"(",
"self",
",",
"jobid",
")",
":",
"jobdetail",
"=",
"self",
".",
"get_job_details_redfish",
"(",
"jobid",
")",
"if",
"jobdetail",
"[",
"'Status'",
"]",
"==",
"'Failed'",
":",
"return",
"jobdetail",
"jobdetail_data",
"=",
"jo... | [
338,
4
] | [
361,
29
] | python | en | ['en', 'en', 'en'] | True |
csrf_failure | (request, reason="", template_name=CSRF_FAILURE_TEMPLATE_NAME) |
Default view used when request fails CSRF protection
|
Default view used when request fails CSRF protection
| def csrf_failure(request, reason="", template_name=CSRF_FAILURE_TEMPLATE_NAME):
"""
Default view used when request fails CSRF protection
"""
from django.middleware.csrf import REASON_NO_REFERER, REASON_NO_CSRF_COOKIE
c = {
'title': _("Forbidden"),
'main': _("CSRF verification failed.... | [
"def",
"csrf_failure",
"(",
"request",
",",
"reason",
"=",
"\"\"",
",",
"template_name",
"=",
"CSRF_FAILURE_TEMPLATE_NAME",
")",
":",
"from",
"django",
".",
"middleware",
".",
"csrf",
"import",
"REASON_NO_REFERER",
",",
"REASON_NO_CSRF_COOKIE",
"c",
"=",
"{",
"'... | [
102,
0
] | [
145,
71
] | python | en | ['en', 'error', 'th'] | False |
getInnerText | (node) |
Get all the inner text of a DOM node (recursively).
|
Get all the inner text of a DOM node (recursively).
| def getInnerText(node):
"""
Get all the inner text of a DOM node (recursively).
"""
# inspired by http://mail.python.org/pipermail/xml-sig/2005-March/011022.html
inner_text = []
for child in node.childNodes:
if child.nodeType == child.TEXT_NODE or child.nodeType == child.CDATA_SECTION_NO... | [
"def",
"getInnerText",
"(",
"node",
")",
":",
"# inspired by http://mail.python.org/pipermail/xml-sig/2005-March/011022.html",
"inner_text",
"=",
"[",
"]",
"for",
"child",
"in",
"node",
".",
"childNodes",
":",
"if",
"child",
".",
"nodeType",
"==",
"child",
".",
"TEX... | [
298,
0
] | [
311,
30
] | python | en | ['en', 'error', 'th'] | False |
Serializer.start_serialization | (self) |
Start serialization -- open the XML document and the root element.
|
Start serialization -- open the XML document and the root element.
| def start_serialization(self):
"""
Start serialization -- open the XML document and the root element.
"""
self.xml = SimplerXMLGenerator(self.stream, self.options.get("encoding", settings.DEFAULT_CHARSET))
self.xml.startDocument()
self.xml.startElement("django-objects", {... | [
"def",
"start_serialization",
"(",
"self",
")",
":",
"self",
".",
"xml",
"=",
"SimplerXMLGenerator",
"(",
"self",
".",
"stream",
",",
"self",
".",
"options",
".",
"get",
"(",
"\"encoding\"",
",",
"settings",
".",
"DEFAULT_CHARSET",
")",
")",
"self",
".",
... | [
30,
4
] | [
36,
67
] | python | en | ['en', 'error', 'th'] | False |
Serializer.end_serialization | (self) |
End serialization -- end the document.
|
End serialization -- end the document.
| def end_serialization(self):
"""
End serialization -- end the document.
"""
self.indent(0)
self.xml.endElement("django-objects")
self.xml.endDocument() | [
"def",
"end_serialization",
"(",
"self",
")",
":",
"self",
".",
"indent",
"(",
"0",
")",
"self",
".",
"xml",
".",
"endElement",
"(",
"\"django-objects\"",
")",
"self",
".",
"xml",
".",
"endDocument",
"(",
")"
] | [
38,
4
] | [
44,
30
] | python | en | ['en', 'error', 'th'] | False |
Serializer.start_object | (self, obj) |
Called as each object is handled.
|
Called as each object is handled.
| def start_object(self, obj):
"""
Called as each object is handled.
"""
if not hasattr(obj, "_meta"):
raise base.SerializationError("Non-model object (%s) encountered during serialization" % type(obj))
self.indent(1)
attrs = OrderedDict([("model", force_text(o... | [
"def",
"start_object",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"\"_meta\"",
")",
":",
"raise",
"base",
".",
"SerializationError",
"(",
"\"Non-model object (%s) encountered during serialization\"",
"%",
"type",
"(",
"obj",
")",... | [
46,
4
] | [
60,
46
] | python | en | ['en', 'error', 'th'] | False |
Serializer.end_object | (self, obj) |
Called after handling all fields for an object.
|
Called after handling all fields for an object.
| def end_object(self, obj):
"""
Called after handling all fields for an object.
"""
self.indent(1)
self.xml.endElement("object") | [
"def",
"end_object",
"(",
"self",
",",
"obj",
")",
":",
"self",
".",
"indent",
"(",
"1",
")",
"self",
".",
"xml",
".",
"endElement",
"(",
"\"object\"",
")"
] | [
62,
4
] | [
67,
37
] | python | en | ['en', 'error', 'th'] | False |
Serializer.handle_field | (self, obj, field) |
Called to handle each field on an object (except for ForeignKeys and
ManyToManyFields)
|
Called to handle each field on an object (except for ForeignKeys and
ManyToManyFields)
| def handle_field(self, obj, field):
"""
Called to handle each field on an object (except for ForeignKeys and
ManyToManyFields)
"""
self.indent(2)
self.xml.startElement("field", OrderedDict([
("name", field.name),
("type", field.get_internal_type())... | [
"def",
"handle_field",
"(",
"self",
",",
"obj",
",",
"field",
")",
":",
"self",
".",
"indent",
"(",
"2",
")",
"self",
".",
"xml",
".",
"startElement",
"(",
"\"field\"",
",",
"OrderedDict",
"(",
"[",
"(",
"\"name\"",
",",
"field",
".",
"name",
")",
... | [
69,
4
] | [
90,
36
] | python | en | ['en', 'error', 'th'] | False |
Serializer.handle_fk_field | (self, obj, field) |
Called to handle a ForeignKey (we need to treat them slightly
differently from regular fields).
|
Called to handle a ForeignKey (we need to treat them slightly
differently from regular fields).
| def handle_fk_field(self, obj, field):
"""
Called to handle a ForeignKey (we need to treat them slightly
differently from regular fields).
"""
self._start_relational_field(field)
related_att = getattr(obj, field.get_attname())
if related_att is not None:
... | [
"def",
"handle_fk_field",
"(",
"self",
",",
"obj",
",",
"field",
")",
":",
"self",
".",
"_start_relational_field",
"(",
"field",
")",
"related_att",
"=",
"getattr",
"(",
"obj",
",",
"field",
".",
"get_attname",
"(",
")",
")",
"if",
"related_att",
"is",
"... | [
92,
4
] | [
113,
36
] | python | en | ['en', 'error', 'th'] | False |
Serializer.handle_m2m_field | (self, obj, field) |
Called to handle a ManyToManyField. Related objects are only
serialized as references to the object's PK (i.e. the related *data*
is not dumped, just the relation).
|
Called to handle a ManyToManyField. Related objects are only
serialized as references to the object's PK (i.e. the related *data*
is not dumped, just the relation).
| def handle_m2m_field(self, obj, field):
"""
Called to handle a ManyToManyField. Related objects are only
serialized as references to the object's PK (i.e. the related *data*
is not dumped, just the relation).
"""
if field.remote_field.through._meta.auto_created:
... | [
"def",
"handle_m2m_field",
"(",
"self",
",",
"obj",
",",
"field",
")",
":",
"if",
"field",
".",
"remote_field",
".",
"through",
".",
"_meta",
".",
"auto_created",
":",
"self",
".",
"_start_relational_field",
"(",
"field",
")",
"if",
"self",
".",
"use_natur... | [
115,
4
] | [
142,
40
] | python | en | ['en', 'error', 'th'] | False |
Serializer._start_relational_field | (self, field) |
Helper to output the <field> element for relational fields
|
Helper to output the <field> element for relational fields
| def _start_relational_field(self, field):
"""
Helper to output the <field> element for relational fields
"""
self.indent(2)
self.xml.startElement("field", OrderedDict([
("name", field.name),
("rel", field.remote_field.__class__.__name__),
("to"... | [
"def",
"_start_relational_field",
"(",
"self",
",",
"field",
")",
":",
"self",
".",
"indent",
"(",
"2",
")",
"self",
".",
"xml",
".",
"startElement",
"(",
"\"field\"",
",",
"OrderedDict",
"(",
"[",
"(",
"\"name\"",
",",
"field",
".",
"name",
")",
",",
... | [
144,
4
] | [
153,
11
] | python | en | ['en', 'error', 'th'] | False |
Deserializer._make_parser | (self) | Create a hardened XML parser (no custom/external entities). | Create a hardened XML parser (no custom/external entities). | def _make_parser(self):
"""Create a hardened XML parser (no custom/external entities)."""
return DefusedExpatParser() | [
"def",
"_make_parser",
"(",
"self",
")",
":",
"return",
"DefusedExpatParser",
"(",
")"
] | [
167,
4
] | [
169,
35
] | python | en | ['en', 'af', 'en'] | True |
Deserializer._handle_object | (self, node) |
Convert an <object> node to a DeserializedObject.
|
Convert an <object> node to a DeserializedObject.
| def _handle_object(self, node):
"""
Convert an <object> node to a DeserializedObject.
"""
# Look up the model using the model loading mechanism. If this fails,
# bail.
Model = self._get_model_from_node(node, "model")
# Start building a data dictionary from the ob... | [
"def",
"_handle_object",
"(",
"self",
",",
"node",
")",
":",
"# Look up the model using the model loading mechanism. If this fails,",
"# bail.",
"Model",
"=",
"self",
".",
"_get_model_from_node",
"(",
"node",
",",
"\"model\"",
")",
"# Start building a data dictionary from the... | [
178,
4
] | [
227,
53
] | python | en | ['en', 'error', 'th'] | False |
Deserializer._handle_fk_field_node | (self, node, field) |
Handle a <field> node for a ForeignKey
|
Handle a <field> node for a ForeignKey
| def _handle_fk_field_node(self, node, field):
"""
Handle a <field> node for a ForeignKey
"""
# Check if there is a child node named 'None', returning None if so.
if node.getElementsByTagName('None'):
return None
else:
model = field.remote_field.mod... | [
"def",
"_handle_fk_field_node",
"(",
"self",
",",
"node",
",",
"field",
")",
":",
"# Check if there is a child node named 'None', returning None if so.",
"if",
"node",
".",
"getElementsByTagName",
"(",
"'None'",
")",
":",
"return",
"None",
"else",
":",
"model",
"=",
... | [
229,
4
] | [
256,
98
] | python | en | ['en', 'error', 'th'] | False |
Deserializer._handle_m2m_field_node | (self, node, field) |
Handle a <field> node for a ManyToManyField.
|
Handle a <field> node for a ManyToManyField.
| def _handle_m2m_field_node(self, node, field):
"""
Handle a <field> node for a ManyToManyField.
"""
model = field.remote_field.model
default_manager = model._default_manager
if hasattr(default_manager, 'get_by_natural_key'):
def m2m_convert(n):
... | [
"def",
"_handle_m2m_field_node",
"(",
"self",
",",
"node",
",",
"field",
")",
":",
"model",
"=",
"field",
".",
"remote_field",
".",
"model",
"default_manager",
"=",
"model",
".",
"_default_manager",
"if",
"hasattr",
"(",
"default_manager",
",",
"'get_by_natural_... | [
258,
4
] | [
278,
76
] | python | en | ['en', 'error', 'th'] | False |
Deserializer._get_model_from_node | (self, node, attr) |
Helper to look up a model from a <object model=...> or a <field
rel=... to=...> node.
|
Helper to look up a model from a <object model=...> or a <field
rel=... to=...> node.
| def _get_model_from_node(self, node, attr):
"""
Helper to look up a model from a <object model=...> or a <field
rel=... to=...> node.
"""
model_identifier = node.getAttribute(attr)
if not model_identifier:
raise base.DeserializationError(
"<%s>... | [
"def",
"_get_model_from_node",
"(",
"self",
",",
"node",
",",
"attr",
")",
":",
"model_identifier",
"=",
"node",
".",
"getAttribute",
"(",
"attr",
")",
"if",
"not",
"model_identifier",
":",
"raise",
"base",
".",
"DeserializationError",
"(",
"\"<%s> node is missi... | [
280,
4
] | [
295,
52
] | python | en | ['en', 'error', 'th'] | False |
JsonHookTests.test_json_github_push__1_commit_message | (self) |
Tests if json github push 1 commit is handled correctly
|
Tests if json github push 1 commit is handled correctly
| def test_json_github_push__1_commit_message(self) -> None:
"""
Tests if json github push 1 commit is handled correctly
"""
with open("zerver/webhooks/json/fixtures/json_github_push__1_commit.json") as f:
original_fixture = json.load(f)
expected_topic = "JSON"
... | [
"def",
"test_json_github_push__1_commit_message",
"(",
"self",
")",
"->",
"None",
":",
"with",
"open",
"(",
"\"zerver/webhooks/json/fixtures/json_github_push__1_commit.json\"",
")",
"as",
"f",
":",
"original_fixture",
"=",
"json",
".",
"load",
"(",
"f",
")",
"expected... | [
10,
4
] | [
23,
90
] | python | en | ['en', 'error', 'th'] | False |
JsonHookTests.test_json_pingdom_http_up_to_down_message | (self) |
Tests if json pingdom http up to down is handled correctly
|
Tests if json pingdom http up to down is handled correctly
| def test_json_pingdom_http_up_to_down_message(self) -> None:
"""
Tests if json pingdom http up to down is handled correctly
"""
with open("zerver/webhooks/json/fixtures/json_pingdom_http_up_to_down.json") as f:
original_fixture = json.load(f)
expected_topic = "JSON"
... | [
"def",
"test_json_pingdom_http_up_to_down_message",
"(",
"self",
")",
"->",
"None",
":",
"with",
"open",
"(",
"\"zerver/webhooks/json/fixtures/json_pingdom_http_up_to_down.json\"",
")",
"as",
"f",
":",
"original_fixture",
"=",
"json",
".",
"load",
"(",
"f",
")",
"expe... | [
25,
4
] | [
38,
92
] | python | en | ['en', 'error', 'th'] | False |
JsonHookTests.test_json_sentry_event_for_exception_js_message | (self) |
Tests if json sentry event for exception js is handled correctly
|
Tests if json sentry event for exception js is handled correctly
| def test_json_sentry_event_for_exception_js_message(self) -> None:
"""
Tests if json sentry event for exception js is handled correctly
"""
with open("zerver/webhooks/json/fixtures/json_sentry_event_for_exception_js.json") as f:
original_fixture = json.load(f)
expect... | [
"def",
"test_json_sentry_event_for_exception_js_message",
"(",
"self",
")",
"->",
"None",
":",
"with",
"open",
"(",
"\"zerver/webhooks/json/fixtures/json_sentry_event_for_exception_js.json\"",
")",
"as",
"f",
":",
"original_fixture",
"=",
"json",
".",
"load",
"(",
"f",
... | [
40,
4
] | [
53,
98
] | python | en | ['en', 'error', 'th'] | False |
generate_saml_response | (
self, email: str, name: str, extra_attributes: Mapping[str, List[str]] = {}
) |
The samlresponse.txt fixture has a pre-generated SAMLResponse,
with {email}, {first_name}, {last_name} placeholders, that can
be filled out with the data we want.
|
The samlresponse.txt fixture has a pre-generated SAMLResponse,
with {email}, {first_name}, {last_name} placeholders, that can
be filled out with the data we want.
| def generate_saml_response(
self, email: str, name: str, extra_attributes: Mapping[str, List[str]] = {}
) -> str:
"""
The samlresponse.txt fixture has a pre-generated SAMLResponse,
with {email}, {first_name}, {last_name} placeholders, that can
be filled out with the data we w... | [
"def",
"generate_saml_response",
"(",
"self",
",",
"email",
":",
"str",
",",
"name",
":",
"str",
",",
"extra_attributes",
":",
"Mapping",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
"=",
"{",
"}",
")",
"->",
"str",
":",
"name_parts",
"=",
"name",
... | [
1839,
4
] | [
1874,
28
] | python | en | ['en', 'error', 'th'] | False |
test_social_auth_no_key | (self) |
Since in the case of SAML there isn't a direct equivalent of CLIENT_KEY_SETTING,
we override this test, to test for the case where the obligatory
SOCIAL_AUTH_SAML_ENABLED_IDPS isn't configured.
|
Since in the case of SAML there isn't a direct equivalent of CLIENT_KEY_SETTING,
we override this test, to test for the case where the obligatory
SOCIAL_AUTH_SAML_ENABLED_IDPS isn't configured.
| def test_social_auth_no_key(self) -> None:
"""
Since in the case of SAML there isn't a direct equivalent of CLIENT_KEY_SETTING,
we override this test, to test for the case where the obligatory
SOCIAL_AUTH_SAML_ENABLED_IDPS isn't configured.
"""
account_data_dict = self.ge... | [
"def",
"test_social_auth_no_key",
"(",
"self",
")",
"->",
"None",
":",
"account_data_dict",
"=",
"self",
".",
"get_account_data_dict",
"(",
"email",
"=",
"self",
".",
"email",
",",
"name",
"=",
"self",
".",
"name",
")",
"with",
"self",
".",
"settings",
"("... | [
1879,
4
] | [
1896,
99
] | python | en | ['en', 'error', 'th'] | False |
test_social_auth_complete_valid_get_idp_bad_samlresponse | (self) |
This tests for a hypothetical scenario where our basic parsing of the SAMLResponse
successfully returns the issuing IdP, but it fails further down the line, during proper
validation in the underlying libraries.
|
This tests for a hypothetical scenario where our basic parsing of the SAMLResponse
successfully returns the issuing IdP, but it fails further down the line, during proper
validation in the underlying libraries.
| def test_social_auth_complete_valid_get_idp_bad_samlresponse(self) -> None:
"""
This tests for a hypothetical scenario where our basic parsing of the SAMLResponse
successfully returns the issuing IdP, but it fails further down the line, during proper
validation in the underlying librarie... | [
"def",
"test_social_auth_complete_valid_get_idp_bad_samlresponse",
"(",
"self",
")",
"->",
"None",
":",
"with",
"self",
".",
"assertLogs",
"(",
"self",
".",
"logger_string",
",",
"level",
"=",
"\"INFO\"",
")",
"as",
"m",
",",
"mock",
".",
"patch",
".",
"object... | [
2086,
4
] | [
2109,
39
] | python | en | ['en', 'error', 'th'] | False |
test_social_auth_invalid_email | (self) |
This test needs an override from the original class. For security reasons,
the 'next' and 'mobile_flow_otp' params don't get passed on in the session
if the authentication attempt failed. See SAMLAuthBackend.auth_complete for details.
|
This test needs an override from the original class. For security reasons,
the 'next' and 'mobile_flow_otp' params don't get passed on in the session
if the authentication attempt failed. See SAMLAuthBackend.auth_complete for details.
| def test_social_auth_invalid_email(self) -> None:
"""
This test needs an override from the original class. For security reasons,
the 'next' and 'mobile_flow_otp' params don't get passed on in the session
if the authentication attempt failed. See SAMLAuthBackend.auth_complete for details.... | [
"def",
"test_social_auth_invalid_email",
"(",
"self",
")",
"->",
"None",
":",
"account_data_dict",
"=",
"self",
".",
"get_account_data_dict",
"(",
"email",
"=",
"\"invalid\"",
",",
"name",
"=",
"self",
".",
"name",
")",
"with",
"self",
".",
"assertLogs",
"(",
... | [
2138,
4
] | [
2156,
47
] | python | en | ['en', 'error', 'th'] | False |
SocialAuthBase.social_auth_test | (
self,
account_data_dict: Dict[str, str],
*,
subdomain: str,
mobile_flow_otp: Optional[str] = None,
desktop_flow_otp: Optional[str] = None,
is_signup: bool = False,
next: str = "",
multiuse_object_key: str = "",
expect_choose_email_screen:... | Main entrypoint for all social authentication tests.
* account_data_dict: Dictionary containing the name/email data
that should be returned by the social auth backend.
* subdomain: Which organization's login page is being accessed.
* desktop_flow_otp / mobile_flow_otp: Token to be use... | Main entrypoint for all social authentication tests. | def social_auth_test(
self,
account_data_dict: Dict[str, str],
*,
subdomain: str,
mobile_flow_otp: Optional[str] = None,
desktop_flow_otp: Optional[str] = None,
is_signup: bool = False,
next: str = "",
multiuse_object_key: str = "",
expect_... | [
"def",
"social_auth_test",
"(",
"self",
",",
"account_data_dict",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
",",
"*",
",",
"subdomain",
":",
"str",
",",
"mobile_flow_otp",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"desktop_flow_otp",
":",
"Opti... | [
908,
4
] | [
1001,
21
] | python | en | ['en', 'en', 'en'] | True |
SocialAuthBase.test_social_auth_registration_existing_account | (self) | If the user already exists, signup flow just logs them in | If the user already exists, signup flow just logs them in | def test_social_auth_registration_existing_account(self) -> None:
"""If the user already exists, signup flow just logs them in"""
email = "hamlet@zulip.com"
name = "Full Name"
account_data_dict = self.get_account_data_dict(email=email, name=name)
result = self.social_auth_test(
... | [
"def",
"test_social_auth_registration_existing_account",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"\"hamlet@zulip.com\"",
"name",
"=",
"\"Full Name\"",
"account_data_dict",
"=",
"self",
".",
"get_account_data_dict",
"(",
"email",
"=",
"email",
",",
"name",
... | [
1262,
4
] | [
1281,
57
] | python | en | ['en', 'en', 'en'] | True |
SocialAuthBase.test_social_auth_registration | (self) | If the user doesn't exist yet, social auth can be used to register an account | If the user doesn't exist yet, social auth can be used to register an account | def test_social_auth_registration(self) -> None:
"""If the user doesn't exist yet, social auth can be used to register an account"""
email = "newuser@zulip.com"
name = "Full Name"
subdomain = "zulip"
realm = get_realm("zulip")
account_data_dict = self.get_account_data_dic... | [
"def",
"test_social_auth_registration",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"\"newuser@zulip.com\"",
"name",
"=",
"\"Full Name\"",
"subdomain",
"=",
"\"zulip\"",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"account_data_dict",
"=",
"self",
"."... | [
1366,
4
] | [
1378,
9
] | python | en | ['en', 'en', 'en'] | True |
SocialAuthBase.test_social_auth_registration_invitation_exists | (self) |
This tests the registration flow in the case where an invitation for the user
was generated.
|
This tests the registration flow in the case where an invitation for the user
was generated.
| def test_social_auth_registration_invitation_exists(self) -> None:
"""
This tests the registration flow in the case where an invitation for the user
was generated.
"""
email = "newuser@zulip.com"
name = "Full Name"
subdomain = "zulip"
realm = get_realm("zu... | [
"def",
"test_social_auth_registration_invitation_exists",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"\"newuser@zulip.com\"",
"name",
"=",
"\"Full Name\"",
"subdomain",
"=",
"\"zulip\"",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"iago",
"=",
"self",
... | [
1435,
4
] | [
1454,
9
] | python | en | ['en', 'error', 'th'] | False |
SocialAuthBase.test_social_auth_registration_using_multiuse_invite | (self) | If the user doesn't exist yet, social auth can be used to register an account | If the user doesn't exist yet, social auth can be used to register an account | def test_social_auth_registration_using_multiuse_invite(self) -> None:
"""If the user doesn't exist yet, social auth can be used to register an account"""
email = "newuser@zulip.com"
name = "Full Name"
subdomain = "zulip"
realm = get_realm("zulip")
realm.invite_required =... | [
"def",
"test_social_auth_registration_using_multiuse_invite",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"\"newuser@zulip.com\"",
"name",
"=",
"\"Full Name\"",
"subdomain",
"=",
"\"zulip\"",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"realm",
".",
"in... | [
1478,
4
] | [
1519,
9
] | python | en | ['en', 'en', 'en'] | True |
SocialAuthBase.test_social_auth_registration_without_is_signup | (self) | If `is_signup` is not set then a new account isn't created | If `is_signup` is not set then a new account isn't created | def test_social_auth_registration_without_is_signup(self) -> None:
"""If `is_signup` is not set then a new account isn't created"""
email = "newuser@zulip.com"
name = "Full Name"
account_data_dict = self.get_account_data_dict(email=email, name=name)
result = self.social_auth_test... | [
"def",
"test_social_auth_registration_without_is_signup",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"\"newuser@zulip.com\"",
"name",
"=",
"\"Full Name\"",
"account_data_dict",
"=",
"self",
".",
"get_account_data_dict",
"(",
"email",
"=",
"email",
",",
"name",... | [
1521,
4
] | [
1541,
82
] | python | en | ['en', 'en', 'en'] | True |
SocialAuthBase.test_social_auth_registration_without_is_signup_closed_realm | (self) | If the user doesn't exist yet in closed realm, give an error | If the user doesn't exist yet in closed realm, give an error | def test_social_auth_registration_without_is_signup_closed_realm(self) -> None:
"""If the user doesn't exist yet in closed realm, give an error"""
realm = get_realm("zulip")
do_set_realm_property(realm, "emails_restricted_to_domains", True, acting_user=None)
email = "nonexisting@phantom.... | [
"def",
"test_social_auth_registration_without_is_signup_closed_realm",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"do_set_realm_property",
"(",
"realm",
",",
"\"emails_restricted_to_domains\"",
",",
"True",
",",
"acting_user",
... | [
1543,
4
] | [
1571,
9
] | python | en | ['en', 'en', 'en'] | True |
SocialAuthBase.test_social_auth_with_ldap_auth_registration_from_confirmation | (self) |
This test checks that in configurations that use the LDAP authentication backend
and a social backend, it is possible to create non-LDAP users via the social backend.
|
This test checks that in configurations that use the LDAP authentication backend
and a social backend, it is possible to create non-LDAP users via the social backend.
| def test_social_auth_with_ldap_auth_registration_from_confirmation(self) -> None:
"""
This test checks that in configurations that use the LDAP authentication backend
and a social backend, it is possible to create non-LDAP users via the social backend.
"""
self.init_default_ldap_... | [
"def",
"test_social_auth_with_ldap_auth_registration_from_confirmation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"init_default_ldap_database",
"(",
")",
"email",
"=",
"self",
".",
"nonreg_email",
"(",
"\"alice\"",
")",
"name",
"=",
"\"Alice Social\"",
"realm... | [
1637,
4
] | [
1689,
9
] | python | en | ['en', 'error', 'th'] | False |
json_response_from_error | (exception: JsonableError) |
This should only be needed in middleware; in app code, just raise.
When app code raises a JsonableError, the JsonErrorHandler
middleware takes care of transforming it into a response by
calling this function.
|
This should only be needed in middleware; in app code, just raise. | def json_response_from_error(exception: JsonableError) -> HttpResponse:
"""
This should only be needed in middleware; in app code, just raise.
When app code raises a JsonableError, the JsonErrorHandler
middleware takes care of transforming it into a response by
calling this function.
"""
re... | [
"def",
"json_response_from_error",
"(",
"exception",
":",
"JsonableError",
")",
"->",
"HttpResponse",
":",
"response",
"=",
"json_response",
"(",
"\"error\"",
",",
"msg",
"=",
"exception",
".",
"msg",
",",
"data",
"=",
"exception",
".",
"data",
",",
"status",
... | [
66,
0
] | [
81,
19
] | python | en | ['en', 'error', 'th'] | False |
PostGISIntrospection.get_postgis_types | (self) |
Returns a dictionary with keys that are the PostgreSQL object
identification integers for the PostGIS geometry and/or
geography types (if supported).
|
Returns a dictionary with keys that are the PostgreSQL object
identification integers for the PostGIS geometry and/or
geography types (if supported).
| def get_postgis_types(self):
"""
Returns a dictionary with keys that are the PostgreSQL object
identification integers for the PostGIS geometry and/or
geography types (if supported).
"""
field_types = [
('geometry', 'GeometryField'),
# The value fo... | [
"def",
"get_postgis_types",
"(",
"self",
")",
":",
"field_types",
"=",
"[",
"(",
"'geometry'",
",",
"'GeometryField'",
")",
",",
"# The value for the geography type is actually a tuple",
"# to pass in the `geography=True` keyword to the field",
"# definition.",
"(",
"'geography... | [
41,
4
] | [
70,
28
] | python | en | ['en', 'error', 'th'] | False |
PostGISIntrospection.get_geometry_type | (self, table_name, geo_col) |
The geometry type OID used by PostGIS does not indicate the particular
type of field that a geometry column is (e.g., whether it's a
PointField or a PolygonField). Thus, this routine queries the PostGIS
metadata tables to determine the geometry type,
|
The geometry type OID used by PostGIS does not indicate the particular
type of field that a geometry column is (e.g., whether it's a
PointField or a PolygonField). Thus, this routine queries the PostGIS
metadata tables to determine the geometry type,
| def get_geometry_type(self, table_name, geo_col):
"""
The geometry type OID used by PostGIS does not indicate the particular
type of field that a geometry column is (e.g., whether it's a
PointField or a PolygonField). Thus, this routine queries the PostGIS
metadata tables to det... | [
"def",
"get_geometry_type",
"(",
"self",
",",
"table_name",
",",
"geo_col",
")",
":",
"cursor",
"=",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"try",
":",
"try",
":",
"# First seeing if this geometry column is in the `geometry_columns`",
"cursor",
".",
"... | [
83,
4
] | [
127,
39
] | python | en | ['en', 'error', 'th'] | False |
TestIdealisedCases.test_min_slope | (self) | Check what is the min slope a flowline model can produce
| Check what is the min slope a flowline model can produce
| def test_min_slope(self):
""" Check what is the min slope a flowline model can produce
"""
models = [KarthausModel, FluxBasedModel, MUSCLSuperBeeModel]
kwargs = [{'fixed_dt': 3 * SEC_IN_DAY}, {}, {}]
lens = []
surface_h = []
volume = []
min_slope = []
... | [
"def",
"test_min_slope",
"(",
"self",
")",
":",
"models",
"=",
"[",
"KarthausModel",
",",
"FluxBasedModel",
",",
"MUSCLSuperBeeModel",
"]",
"kwargs",
"=",
"[",
"{",
"'fixed_dt'",
":",
"3",
"*",
"SEC_IN_DAY",
"}",
",",
"{",
"}",
",",
"{",
"}",
"]",
"len... | [
234,
4
] | [
315,
22
] | python | en | ['en', 'en', 'en'] | True |
TestIdealisedCases.test_cliff | (self) | a test case for mass conservation in the flowline models
the idea is to introduce a cliff in the sloping bed and see
what the models do when the cliff height is changed
| a test case for mass conservation in the flowline models
the idea is to introduce a cliff in the sloping bed and see
what the models do when the cliff height is changed
| def test_cliff(self):
""" a test case for mass conservation in the flowline models
the idea is to introduce a cliff in the sloping bed and see
what the models do when the cliff height is changed
"""
models = [KarthausModel, FluxBasedModel, MUSCLSuperBeeModel]
le... | [
"def",
"test_cliff",
"(",
"self",
")",
":",
"models",
"=",
"[",
"KarthausModel",
",",
"FluxBasedModel",
",",
"MUSCLSuperBeeModel",
"]",
"lens",
"=",
"[",
"]",
"surface_h",
"=",
"[",
"]",
"volume",
"=",
"[",
"]",
"yrs",
"=",
"np",
".",
"arange",
"(",
... | [
318,
4
] | [
400,
63
] | python | en | ['en', 'en', 'en'] | True |
TestIdealisedCases.test_varying_width | (self) | This test is for a flowline glacier of varying width, i.e with an
accumulation area twice as wide as the tongue. | This test is for a flowline glacier of varying width, i.e with an
accumulation area twice as wide as the tongue. | def test_varying_width(self):
"""This test is for a flowline glacier of varying width, i.e with an
accumulation area twice as wide as the tongue."""
# set do_plot = True to see the plots
models = [KarthausModel, FluxBasedModel, MUSCLSuperBeeModel]
steps = [15 * SEC_IN_DAY, None... | [
"def",
"test_varying_width",
"(",
"self",
")",
":",
"# set do_plot = True to see the plots",
"models",
"=",
"[",
"KarthausModel",
",",
"FluxBasedModel",
",",
"MUSCLSuperBeeModel",
"]",
"steps",
"=",
"[",
"15",
"*",
"SEC_IN_DAY",
",",
"None",
",",
"None",
"]",
"l... | [
672,
4
] | [
737,
42
] | python | en | ['en', 'en', 'en'] | True |
_update_m2m_from_expression | (user, related, expr, remove=True) |
Helper function to update m2m relationship based on user matching one or
more expressions.
|
Helper function to update m2m relationship based on user matching one or
more expressions.
| def _update_m2m_from_expression(user, related, expr, remove=True):
"""
Helper function to update m2m relationship based on user matching one or
more expressions.
"""
should_add = False
if expr is None:
return
elif not expr:
pass
elif expr is True:
should_add = Tru... | [
"def",
"_update_m2m_from_expression",
"(",
"user",
",",
"related",
",",
"expr",
",",
"remove",
"=",
"True",
")",
":",
"should_add",
"=",
"False",
"if",
"expr",
"is",
"None",
":",
"return",
"elif",
"not",
"expr",
":",
"pass",
"elif",
"expr",
"is",
"True",... | [
51,
0
] | [
76,
28
] | python | en | ['en', 'error', 'th'] | False |
update_user_orgs | (backend, details, user=None, *args, **kwargs) |
Update organization memberships for the given user based on mapping rules
defined in settings.
|
Update organization memberships for the given user based on mapping rules
defined in settings.
| def update_user_orgs(backend, details, user=None, *args, **kwargs):
"""
Update organization memberships for the given user based on mapping rules
defined in settings.
"""
if not user:
return
from awx.main.models import Organization
org_map = backend.setting('ORGANIZATION_MAP') or {}... | [
"def",
"update_user_orgs",
"(",
"backend",
",",
"details",
",",
"user",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"user",
":",
"return",
"from",
"awx",
".",
"main",
".",
"models",
"import",
"Organization",
"org_map"... | [
108,
0
] | [
131,
92
] | python | en | ['en', 'error', 'th'] | False |
update_user_teams | (backend, details, user=None, *args, **kwargs) |
Update team memberships for the given user based on mapping rules defined
in settings.
|
Update team memberships for the given user based on mapping rules defined
in settings.
| def update_user_teams(backend, details, user=None, *args, **kwargs):
"""
Update team memberships for the given user based on mapping rules defined
in settings.
"""
if not user:
return
from awx.main.models import Organization, Team
team_map = backend.setting('TEAM_MAP') or {}
for... | [
"def",
"update_user_teams",
"(",
"backend",
",",
"details",
",",
"user",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"user",
":",
"return",
"from",
"awx",
".",
"main",
".",
"models",
"import",
"Organization",
",",
"... | [
134,
0
] | [
155,
87
] | python | en | ['en', 'error', 'th'] | False |
is_fp_closed | (obj) |
Checks whether a given file-like object is closed.
:param obj:
The file-like object to check.
|
Checks whether a given file-like object is closed. | def is_fp_closed(obj):
"""
Checks whether a given file-like object is closed.
:param obj:
The file-like object to check.
"""
try:
# Check `isclosed()` first, in case Python3 doesn't set `closed`.
# GH Issue #928
return obj.isclosed()
except AttributeError:
... | [
"def",
"is_fp_closed",
"(",
"obj",
")",
":",
"try",
":",
"# Check `isclosed()` first, in case Python3 doesn't set `closed`.",
"# GH Issue #928",
"return",
"obj",
".",
"isclosed",
"(",
")",
"except",
"AttributeError",
":",
"pass",
"try",
":",
"# Check via the official file... | [
8,
0
] | [
36,
65
] | python | en | ['en', 'error', 'th'] | False |
assert_header_parsing | (headers) |
Asserts whether all headers have been successfully parsed.
Extracts encountered errors from the result of parsing headers.
Only works on Python 3.
:param http.client.HTTPMessage headers: Headers to verify.
:raises urllib3.exceptions.HeaderParsingError:
If parsing errors are found.
|
Asserts whether all headers have been successfully parsed.
Extracts encountered errors from the result of parsing headers. | def assert_header_parsing(headers):
"""
Asserts whether all headers have been successfully parsed.
Extracts encountered errors from the result of parsing headers.
Only works on Python 3.
:param http.client.HTTPMessage headers: Headers to verify.
:raises urllib3.exceptions.HeaderParsingError:
... | [
"def",
"assert_header_parsing",
"(",
"headers",
")",
":",
"# This will fail silently if we pass in the wrong kind of parameter.",
"# To make debugging easier add an explicit check.",
"if",
"not",
"isinstance",
"(",
"headers",
",",
"httplib",
".",
"HTTPMessage",
")",
":",
"raise... | [
39,
0
] | [
90,
78
] | python | en | ['en', 'error', 'th'] | False |
is_response_to_head | (response) |
Checks whether the request of a response has been a HEAD-request.
Handles the quirks of AppEngine.
:param http.client.HTTPResponse response:
Response to check if the originating request
used 'HEAD' as a method.
|
Checks whether the request of a response has been a HEAD-request.
Handles the quirks of AppEngine. | def is_response_to_head(response):
"""
Checks whether the request of a response has been a HEAD-request.
Handles the quirks of AppEngine.
:param http.client.HTTPResponse response:
Response to check if the originating request
used 'HEAD' as a method.
"""
# FIXME: Can we do this s... | [
"def",
"is_response_to_head",
"(",
"response",
")",
":",
"# FIXME: Can we do this somehow without accessing private httplib _method?",
"method",
"=",
"response",
".",
"_method",
"if",
"isinstance",
"(",
"method",
",",
"int",
")",
":",
"# Platform-specific: Appengine",
"retu... | [
93,
0
] | [
106,
35
] | python | en | ['en', 'error', 'th'] | False |
BackendTests.assertUnsortedListEqual | (self, a, b) |
Checks two results lists are equal while not taking into account the ordering.
Note: This is different to assertSetEqual in that duplicate results are taken
into account.
|
Checks two results lists are equal while not taking into account the ordering. | def assertUnsortedListEqual(self, a, b):
"""
Checks two results lists are equal while not taking into account the ordering.
Note: This is different to assertSetEqual in that duplicate results are taken
into account.
"""
self.assertListEqual(list(sorted(a)), list(sorted(b... | [
"def",
"assertUnsortedListEqual",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"self",
".",
"assertListEqual",
"(",
"list",
"(",
"sorted",
"(",
"a",
")",
")",
",",
"list",
"(",
"sorted",
"(",
"b",
")",
")",
")"
] | [
41,
4
] | [
48,
62
] | python | en | ['en', 'error', 'th'] | False |
RedisStorage.__init__ | (self, redis_object) | Uses specified redis object for storage. | Uses specified redis object for storage. | def __init__(self, redis_object):
""" Uses specified redis object for storage. """
self.redis_object = redis_object | [
"def",
"__init__",
"(",
"self",
",",
"redis_object",
")",
":",
"self",
".",
"redis_object",
"=",
"redis_object"
] | [
44,
4
] | [
46,
40
] | python | en | ['en', 'en', 'en'] | True |
RedisStorage.store_vector | (self, hash_name, bucket_key, v, data) |
Stores vector and JSON-serializable data in bucket with specified key.
|
Stores vector and JSON-serializable data in bucket with specified key.
| def store_vector(self, hash_name, bucket_key, v, data):
"""
Stores vector and JSON-serializable data in bucket with specified key.
"""
self._add_vector(hash_name, bucket_key, v, data, self.redis_object) | [
"def",
"store_vector",
"(",
"self",
",",
"hash_name",
",",
"bucket_key",
",",
"v",
",",
"data",
")",
":",
"self",
".",
"_add_vector",
"(",
"hash_name",
",",
"bucket_key",
",",
"v",
",",
"data",
",",
"self",
".",
"redis_object",
")"
] | [
48,
4
] | [
52,
75
] | python | en | ['en', 'error', 'th'] | False |
RedisStorage.store_many_vectors | (self, hash_name, bucket_keys, vs, data) |
Store a batch of vectors in Redis.
Stores vector and JSON-serializable data in bucket with specified key.
|
Store a batch of vectors in Redis.
Stores vector and JSON-serializable data in bucket with specified key.
| def store_many_vectors(self, hash_name, bucket_keys, vs, data):
"""
Store a batch of vectors in Redis.
Stores vector and JSON-serializable data in bucket with specified key.
"""
with self.redis_object.pipeline() as pipeline:
if data is None:
data = [No... | [
"def",
"store_many_vectors",
"(",
"self",
",",
"hash_name",
",",
"bucket_keys",
",",
"vs",
",",
"data",
")",
":",
"with",
"self",
".",
"redis_object",
".",
"pipeline",
"(",
")",
"as",
"pipeline",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"[",
... | [
54,
4
] | [
64,
30
] | python | en | ['en', 'error', 'th'] | False |
RedisStorage._add_vector | (self, hash_name, bucket_key, v, data, redis_object) |
Store vector and JSON-serializable data in bucket with specified key.
|
Store vector and JSON-serializable data in bucket with specified key.
| def _add_vector(self, hash_name, bucket_key, v, data, redis_object):
'''
Store vector and JSON-serializable data in bucket with specified key.
'''
redis_key = self._format_redis_key(hash_name, bucket_key)
val_dict = {}
# Depending on type (sparse or not) fill value dict... | [
"def",
"_add_vector",
"(",
"self",
",",
"hash_name",
",",
"bucket_key",
",",
"v",
",",
"data",
",",
"redis_object",
")",
":",
"redis_key",
"=",
"self",
".",
"_format_redis_key",
"(",
"hash_name",
",",
"bucket_key",
")",
"val_dict",
"=",
"{",
"}",
"# Depend... | [
66,
4
] | [
104,
78
] | python | en | ['en', 'error', 'th'] | False |
RedisStorage.delete_vector | (self, hash_name, bucket_keys, data) |
Deletes vector and JSON-serializable data in buckets with specified keys.
|
Deletes vector and JSON-serializable data in buckets with specified keys.
| def delete_vector(self, hash_name, bucket_keys, data):
"""
Deletes vector and JSON-serializable data in buckets with specified keys.
"""
with self.redis_object.pipeline() as pipeline:
for key in bucket_keys:
redis_key = self._format_redis_key(hash_name, key)
... | [
"def",
"delete_vector",
"(",
"self",
",",
"hash_name",
",",
"bucket_keys",
",",
"data",
")",
":",
"with",
"self",
".",
"redis_object",
".",
"pipeline",
"(",
")",
"as",
"pipeline",
":",
"for",
"key",
"in",
"bucket_keys",
":",
"redis_key",
"=",
"self",
"."... | [
125,
4
] | [
143,
30
] | python | en | ['en', 'error', 'th'] | False |
RedisStorage.get_bucket | (self, hash_name, bucket_key) |
Returns bucket content as list of tuples (vector, data).
|
Returns bucket content as list of tuples (vector, data).
| def get_bucket(self, hash_name, bucket_key):
"""
Returns bucket content as list of tuples (vector, data).
"""
results = []
for row in self._get_bucket_rows(hash_name, bucket_key):
val_dict = pickle.loads(row)
# Depending on type (sparse or not) reconstruct... | [
"def",
"get_bucket",
"(",
"self",
",",
"hash_name",
",",
"bucket_key",
")",
":",
"results",
"=",
"[",
"]",
"for",
"row",
"in",
"self",
".",
"_get_bucket_rows",
"(",
"hash_name",
",",
"bucket_key",
")",
":",
"val_dict",
"=",
"pickle",
".",
"loads",
"(",
... | [
145,
4
] | [
181,
22
] | python | en | ['en', 'error', 'th'] | False |
RedisStorage.clean_buckets | (self, hash_name) |
Removes all buckets and their content for specified hash.
|
Removes all buckets and their content for specified hash.
| def clean_buckets(self, hash_name):
"""
Removes all buckets and their content for specified hash.
"""
bucket_keys = self._iter_bucket_keys(hash_name)
self.redis_object.delete(*bucket_keys) | [
"def",
"clean_buckets",
"(",
"self",
",",
"hash_name",
")",
":",
"bucket_keys",
"=",
"self",
".",
"_iter_bucket_keys",
"(",
"hash_name",
")",
"self",
".",
"redis_object",
".",
"delete",
"(",
"*",
"bucket_keys",
")"
] | [
183,
4
] | [
188,
46
] | python | en | ['en', 'error', 'th'] | False |
RedisStorage.clean_all_buckets | (self) |
Removes all buckets from all hashes and their content.
|
Removes all buckets from all hashes and their content.
| def clean_all_buckets(self):
"""
Removes all buckets from all hashes and their content.
"""
bucket_keys = self.redis_object.keys(pattern='nearpy_*')
if len(bucket_keys) > 0:
self.redis_object.delete(*bucket_keys) | [
"def",
"clean_all_buckets",
"(",
"self",
")",
":",
"bucket_keys",
"=",
"self",
".",
"redis_object",
".",
"keys",
"(",
"pattern",
"=",
"'nearpy_*'",
")",
"if",
"len",
"(",
"bucket_keys",
")",
">",
"0",
":",
"self",
".",
"redis_object",
".",
"delete",
"(",... | [
190,
4
] | [
196,
50
] | python | en | ['en', 'error', 'th'] | False |
RedisStorage.store_hash_configuration | (self, lshash) |
Stores hash configuration
|
Stores hash configuration
| def store_hash_configuration(self, lshash):
"""
Stores hash configuration
"""
self.redis_object.set(lshash.hash_name+'_conf', pickle.dumps(lshash.get_config())) | [
"def",
"store_hash_configuration",
"(",
"self",
",",
"lshash",
")",
":",
"self",
".",
"redis_object",
".",
"set",
"(",
"lshash",
".",
"hash_name",
"+",
"'_conf'",
",",
"pickle",
".",
"dumps",
"(",
"lshash",
".",
"get_config",
"(",
")",
")",
")"
] | [
198,
4
] | [
202,
90
] | python | en | ['en', 'error', 'th'] | False |
RedisStorage.load_hash_configuration | (self, hash_name) |
Loads and returns hash configuration
|
Loads and returns hash configuration
| def load_hash_configuration(self, hash_name):
"""
Loads and returns hash configuration
"""
conf = self.redis_object.get(hash_name+'_conf')
return pickle.loads(conf) if conf is not None else None | [
"def",
"load_hash_configuration",
"(",
"self",
",",
"hash_name",
")",
":",
"conf",
"=",
"self",
".",
"redis_object",
".",
"get",
"(",
"hash_name",
"+",
"'_conf'",
")",
"return",
"pickle",
".",
"loads",
"(",
"conf",
")",
"if",
"conf",
"is",
"not",
"None",... | [
204,
4
] | [
210,
63
] | python | en | ['en', 'error', 'th'] | False |
get_license | () | Return a dictionary representing the active license on this instance. | Return a dictionary representing the active license on this instance. | def get_license():
"""Return a dictionary representing the active license on this instance."""
return _get_validated_license_data() | [
"def",
"get_license",
"(",
")",
":",
"return",
"_get_validated_license_data",
"(",
")"
] | [
12,
0
] | [
14,
40
] | python | en | ['en', 'en', 'en'] | True |
WalletNode._sync | (self) |
Wallet has fallen far behind (or is starting up for the first time), and must be synced
up to the LCA of the blockchain.
|
Wallet has fallen far behind (or is starting up for the first time), and must be synced
up to the LCA of the blockchain.
| async def _sync(self) -> None:
"""
Wallet has fallen far behind (or is starting up for the first time), and must be synced
up to the LCA of the blockchain.
"""
if self.wallet_state_manager is None or self.backup_initialized is False or self.server is None:
return None... | [
"async",
"def",
"_sync",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"wallet_state_manager",
"is",
"None",
"or",
"self",
".",
"backup_initialized",
"is",
"False",
"or",
"self",
".",
"server",
"is",
"None",
":",
"return",
"None",
"highest_weight... | [
525,
4
] | [
622,
17
] | python | en | ['en', 'error', 'th'] | False |
WalletNode.fetch_blocks_and_validate | (
self,
peer: WSKaleConnection,
height_start: uint32,
height_end: uint32,
fork_point_with_peak: Optional[uint32],
) |
Returns whether the blocks validated, and whether the peak was advanced
|
Returns whether the blocks validated, and whether the peak was advanced | async def fetch_blocks_and_validate(
self,
peer: WSKaleConnection,
height_start: uint32,
height_end: uint32,
fork_point_with_peak: Optional[uint32],
) -> Tuple[bool, bool]:
"""
Returns whether the blocks validated, and whether the peak was advanced
""... | [
"async",
"def",
"fetch_blocks_and_validate",
"(",
"self",
",",
"peer",
":",
"WSKaleConnection",
",",
"height_start",
":",
"uint32",
",",
"height_end",
":",
"uint32",
",",
"fork_point_with_peak",
":",
"Optional",
"[",
"uint32",
"]",
",",
")",
"->",
"Tuple",
"["... | [
624,
4
] | [
709,
34
] | python | en | ['en', 'error', 'th'] | False |
HTMLTokenizer.__iter__ | (self) | This is where the magic happens.
We do our usually processing through the states and when we have a token
to return we yield the token which pauses processing until the next token
is requested.
| This is where the magic happens. | def __iter__(self):
""" This is where the magic happens.
We do our usually processing through the states and when we have a token
to return we yield the token which pauses processing until the next token
is requested.
"""
self.tokenQueue = deque([])
# Start proce... | [
"def",
"__iter__",
"(",
"self",
")",
":",
"self",
".",
"tokenQueue",
"=",
"deque",
"(",
"[",
"]",
")",
"# Start processing. When EOF is reached self.state will return False",
"# instead of True and the loop will terminate.",
"while",
"self",
".",
"state",
"(",
")",
":",... | [
54,
4
] | [
68,
47
] | python | en | ['en', 'en', 'en'] | True |
HTMLTokenizer.consumeNumberEntity | (self, isHex) | This function returns either U+FFFD or the character based on the
decimal or hexadecimal representation. It also discards ";" if present.
If not present self.tokenQueue.append({"type": tokenTypes["ParseError"]}) is invoked.
| This function returns either U+FFFD or the character based on the
decimal or hexadecimal representation. It also discards ";" if present.
If not present self.tokenQueue.append({"type": tokenTypes["ParseError"]}) is invoked.
| def consumeNumberEntity(self, isHex):
"""This function returns either U+FFFD or the character based on the
decimal or hexadecimal representation. It also discards ";" if present.
If not present self.tokenQueue.append({"type": tokenTypes["ParseError"]}) is invoked.
"""
allowed = ... | [
"def",
"consumeNumberEntity",
"(",
"self",
",",
"isHex",
")",
":",
"allowed",
"=",
"digits",
"radix",
"=",
"10",
"if",
"isHex",
":",
"allowed",
"=",
"hexDigits",
"radix",
"=",
"16",
"charStack",
"=",
"[",
"]",
"# Consume all the characters that are in range whil... | [
70,
4
] | [
140,
19
] | python | en | ['en', 'en', 'en'] | True |
HTMLTokenizer.processEntityInAttribute | (self, allowedChar) | This method replaces the need for "entityInAttributeValueState".
| This method replaces the need for "entityInAttributeValueState".
| def processEntityInAttribute(self, allowedChar):
"""This method replaces the need for "entityInAttributeValueState".
"""
self.consumeEntity(allowedChar=allowedChar, fromAttribute=True) | [
"def",
"processEntityInAttribute",
"(",
"self",
",",
"allowedChar",
")",
":",
"self",
".",
"consumeEntity",
"(",
"allowedChar",
"=",
"allowedChar",
",",
"fromAttribute",
"=",
"True",
")"
] | [
222,
4
] | [
225,
71
] | python | en | ['en', 'en', 'en'] | True |
HTMLTokenizer.emitCurrentToken | (self) | This method is a generic handler for emitting the tags. It also sets
the state to "data" because that's what's needed after a token has been
emitted.
| This method is a generic handler for emitting the tags. It also sets
the state to "data" because that's what's needed after a token has been
emitted.
| def emitCurrentToken(self):
"""This method is a generic handler for emitting the tags. It also sets
the state to "data" because that's what's needed after a token has been
emitted.
"""
token = self.currentToken
# Add token to the queue to be yielded
if (token["typ... | [
"def",
"emitCurrentToken",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"currentToken",
"# Add token to the queue to be yielded",
"if",
"(",
"token",
"[",
"\"type\"",
"]",
"in",
"tagTokenTypes",
")",
":",
"token",
"[",
"\"name\"",
"]",
"=",
"token",
"[",
... | [
227,
4
] | [
252,
35
] | python | en | ['en', 'en', 'en'] | True |
openapi_param_value_generator | (
endpoints: List[str],
) | This decorator is used to register OpenAPI param value genarator functions
with endpoints. Example usage:
@openapi_param_value_generator(["/messages/render:post"])
def ...
| This decorator is used to register OpenAPI param value genarator functions
with endpoints. Example usage: | def openapi_param_value_generator(
endpoints: List[str],
) -> Callable[[Callable[[], Dict[str, object]]], Callable[[], Dict[str, object]]]:
"""This decorator is used to register OpenAPI param value genarator functions
with endpoints. Example usage:
@openapi_param_value_generator(["/messages/render:post... | [
"def",
"openapi_param_value_generator",
"(",
"endpoints",
":",
"List",
"[",
"str",
"]",
",",
")",
"->",
"Callable",
"[",
"[",
"Callable",
"[",
"[",
"]",
",",
"Dict",
"[",
"str",
",",
"object",
"]",
"]",
"]",
",",
"Callable",
"[",
"[",
"]",
",",
"Di... | [
35,
0
] | [
57,
18
] | python | en | ['en', 'en', 'en'] | True |
assert_all_helper_functions_called | () | Throws an exception if any registered helpers were not called by tests | Throws an exception if any registered helpers were not called by tests | def assert_all_helper_functions_called() -> None:
"""Throws an exception if any registered helpers were not called by tests"""
if REGISTERED_GENERATOR_FUNCTIONS == CALLED_GENERATOR_FUNCTIONS:
return
uncalled_functions = str(REGISTERED_GENERATOR_FUNCTIONS - CALLED_GENERATOR_FUNCTIONS)
raise Exc... | [
"def",
"assert_all_helper_functions_called",
"(",
")",
"->",
"None",
":",
"if",
"REGISTERED_GENERATOR_FUNCTIONS",
"==",
"CALLED_GENERATOR_FUNCTIONS",
":",
"return",
"uncalled_functions",
"=",
"str",
"(",
"REGISTERED_GENERATOR_FUNCTIONS",
"-",
"CALLED_GENERATOR_FUNCTIONS",
")"... | [
60,
0
] | [
67,
92
] | python | en | ['en', 'en', 'en'] | True |
SiteMiddleware.process_request | (self, request) |
Set request.site to contain the Site object responsible for handling this request,
according to hostname matching rules
|
Set request.site to contain the Site object responsible for handling this request,
according to hostname matching rules
| def process_request(self, request):
"""
Set request.site to contain the Site object responsible for handling this request,
according to hostname matching rules
"""
try:
request.site = Site.find_for_request(request)
except Site.DoesNotExist:
request... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"request",
".",
"site",
"=",
"Site",
".",
"find_for_request",
"(",
"request",
")",
"except",
"Site",
".",
"DoesNotExist",
":",
"request",
".",
"site",
"=",
"None"
] | [
6,
4
] | [
14,
31
] | python | en | ['en', 'error', 'th'] | False |
WalletRpcApi._state_changed | (self, *args) |
Called by the WalletNode or WalletStateManager when something has changed in the wallet. This
gives us an opportunity to send notifications to all connected clients via WebSocket.
|
Called by the WalletNode or WalletStateManager when something has changed in the wallet. This
gives us an opportunity to send notifications to all connected clients via WebSocket.
| async def _state_changed(self, *args) -> List[WsRpcMessage]:
"""
Called by the WalletNode or WalletStateManager when something has changed in the wallet. This
gives us an opportunity to send notifications to all connected clients via WebSocket.
"""
if len(args) < 2:
r... | [
"async",
"def",
"_state_changed",
"(",
"self",
",",
"*",
"args",
")",
"->",
"List",
"[",
"WsRpcMessage",
"]",
":",
"if",
"len",
"(",
"args",
")",
"<",
"2",
":",
"return",
"[",
"]",
"data",
"=",
"{",
"\"state\"",
":",
"args",
"[",
"0",
"]",
",",
... | [
102,
4
] | [
117,
87
] | python | en | ['en', 'error', 'th'] | False |
WalletRpcApi._stop_wallet | (self) |
Stops a currently running wallet/key, which allows starting the wallet with a new key.
Each key has it's own wallet database.
|
Stops a currently running wallet/key, which allows starting the wallet with a new key.
Each key has it's own wallet database.
| async def _stop_wallet(self):
"""
Stops a currently running wallet/key, which allows starting the wallet with a new key.
Each key has it's own wallet database.
"""
if self.service is not None:
self.service._close()
await self.service._await_closed() | [
"async",
"def",
"_stop_wallet",
"(",
"self",
")",
":",
"if",
"self",
".",
"service",
"is",
"not",
"None",
":",
"self",
".",
"service",
".",
"_close",
"(",
")",
"await",
"self",
".",
"service",
".",
"_await_closed",
"(",
")"
] | [
119,
4
] | [
126,
46
] | 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.