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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
JMXasDict._get_boundary_extractors | (self, element) |
extract-boundary option
:param element:
:return:
|
extract-boundary option
:param element:
:return:
| def _get_boundary_extractors(self, element):
"""
extract-boundary option
:param element:
:return:
"""
boundary_extractors = {}
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
extractor_elements = [element fo... | [
"def",
"_get_boundary_extractors",
"(",
"self",
",",
"element",
")",
":",
"boundary_extractors",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
... | [
724,
4
] | [
790,
34
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_html_extractors | (self, element) |
extract-css-jquery option
:param element:
:return:
|
extract-css-jquery option
:param element:
:return:
| def _get_html_extractors(self, element):
"""
extract-css-jquery option
:param element:
:return:
"""
html_extractors = {}
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
extractor_elements = [element for ele... | [
"def",
"_get_html_extractors",
"(",
"self",
",",
"element",
")",
":",
"html_extractors",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
... | [
792,
4
] | [
845,
30
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_json_path_extractors | (self, element) |
extract-jsonpath option
:param element:
:return:
|
extract-jsonpath option
:param element:
:return:
| def _get_json_path_extractors(self, element):
"""
extract-jsonpath option
:param element:
:return:
"""
json_path_extractors = {}
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
plugins_extractor_pattern = ... | [
"def",
"_get_json_path_extractors",
"(",
"self",
",",
"element",
")",
":",
"json_path_extractors",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\""... | [
847,
4
] | [
912,
35
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_xpath_extractors | (self, element) |
extract-xpath option
:param element:
:return:
|
extract-xpath option
:param element:
:return:
| def _get_xpath_extractors(self, element):
"""
extract-xpath option
:param element:
:return:
"""
extractors = {}
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
elements = [element for element in hashtree.i... | [
"def",
"_get_xpath_extractors",
"(",
"self",
",",
"element",
")",
":",
"extractors",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
"el... | [
914,
4
] | [
963,
25
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_assertions | (self, element) |
assertions:
assert, assert-jsonpath, assert-xpath
:param element:
:return:
|
assertions:
assert, assert-jsonpath, assert-xpath
:param element:
:return:
| def _get_assertions(self, element):
"""
assertions:
assert, assert-jsonpath, assert-xpath
:param element:
:return:
"""
assertions = {}
simple_assertions = self._get_response_assertions(element)
if simple_assertions:
assertions.update({"... | [
"def",
"_get_assertions",
"(",
"self",
",",
"element",
")",
":",
"assertions",
"=",
"{",
"}",
"simple_assertions",
"=",
"self",
".",
"_get_response_assertions",
"(",
"element",
")",
"if",
"simple_assertions",
":",
"assertions",
".",
"update",
"(",
"{",
"\"asse... | [
965,
4
] | [
983,
25
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_response_assertion | (self, jmx_element) |
Convert JMeter Response Assertion to Taurus config format
|
Convert JMeter Response Assertion to Taurus config format | def _get_response_assertion(self, jmx_element):
"""
Convert JMeter Response Assertion to Taurus config format
"""
assertion = {}
assertion_strings = self._extract_test_strings(jmx_element)
if not assertion_strings:
return
assertion["contains"] = asse... | [
"def",
"_get_response_assertion",
"(",
"self",
",",
"jmx_element",
")",
":",
"assertion",
"=",
"{",
"}",
"assertion_strings",
"=",
"self",
".",
"_extract_test_strings",
"(",
"jmx_element",
")",
"if",
"not",
"assertion_strings",
":",
"return",
"assertion",
"[",
"... | [
1069,
4
] | [
1111,
24
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_response_assertions | (self, element) |
:param element:
:return: list of dicts
|
:param element:
:return: list of dicts
| def _get_response_assertions(self, element):
"""
:param element:
:return: list of dicts
"""
response_assertions = []
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
response_assertion_elements = [element for eleme... | [
"def",
"_get_response_assertions",
"(",
"self",
",",
"element",
")",
":",
"response_assertions",
"=",
"[",
"]",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
... | [
1113,
4
] | [
1132,
34
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_jsonpath_assertions | (self, element) |
assert-jsonpath option
:param element:
:return: list of dicts
|
assert-jsonpath option
:param element:
:return: list of dicts
| def _get_jsonpath_assertions(self, element):
"""
assert-jsonpath option
:param element:
:return: list of dicts
"""
json_path_assertions = []
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
pattern = "com.at... | [
"def",
"_get_jsonpath_assertions",
"(",
"self",
",",
"element",
")",
":",
"json_path_assertions",
"=",
"[",
"]",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",... | [
1134,
4
] | [
1172,
35
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_xpath_assertions | (self, element) |
assert-xpath option
:param element:
:return: list of dicts
|
assert-xpath option
:param element:
:return: list of dicts
| def _get_xpath_assertions(self, element):
"""
assert-xpath option
:param element:
:return: list of dicts
"""
assertions = []
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
assertion_elements = [element for... | [
"def",
"_get_xpath_assertions",
"(",
"self",
",",
"element",
")",
":",
"assertions",
"=",
"[",
"]",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
"as... | [
1174,
4
] | [
1206,
25
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_variables | (self, element) |
:param element:
:return:
|
:param element:
:return:
| def _get_variables(self, element):
"""
:param element:
:return:
"""
variables = {}
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
arguments = [element for element in hashtree.iterchildren() if element.tag == "Argu... | [
"def",
"_get_variables",
"(",
"self",
",",
"element",
")",
":",
"variables",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
"arguments"... | [
1208,
4
] | [
1221,
60
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_jsr223_processors | (self, element) |
jsr223 option
:param element:
:return:
|
jsr223 option
:param element:
:return:
| def _get_jsr223_processors(self, element):
"""
jsr223 option
:param element:
:return:
"""
extensions = {
'javascript': '.js',
'beanshell': '.bsh',
'bsh': '.bsh',
'ecmascript': '.js',
'groovy': '.groovy',
... | [
"def",
"_get_jsr223_processors",
"(",
"self",
",",
"element",
")",
":",
"extensions",
"=",
"{",
"'javascript'",
":",
"'.js'",
",",
"'beanshell'",
":",
"'.bsh'",
",",
"'bsh'",
":",
"'.bsh'",
",",
"'ecmascript'",
":",
"'.js'",
",",
"'groovy'",
":",
"'.groovy'"... | [
1230,
4
] | [
1285,
21
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict.process_tg | (self, tg_etree_element) |
Get execution and scenario settings for TG
:param tg_etree_element:
:return: dict
|
Get execution and scenario settings for TG
:param tg_etree_element:
:return: dict
| def process_tg(self, tg_etree_element):
"""
Get execution and scenario settings for TG
:param tg_etree_element:
:return: dict
"""
self.log.debug("Processing thread group... %s", tg_etree_element.get("testname"))
tg_scenario_settings = self._get_tg_scenario_setting... | [
"def",
"process_tg",
"(",
"self",
",",
"tg_etree_element",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Processing thread group... %s\"",
",",
"tg_etree_element",
".",
"get",
"(",
"\"testname\"",
")",
")",
"tg_scenario_settings",
"=",
"self",
".",
"_get_t... | [
1296,
4
] | [
1350,
51
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_request_settings | (self, request_element) |
Gets all possible request settings
:param request_element:
:return: dict
|
Gets all possible request settings
:param request_element:
:return: dict
| def _get_request_settings(self, request_element):
"""
Gets all possible request settings
:param request_element:
:return: dict
"""
request_config = {}
request_config.update(self._get_request_base(request_element))
request_config.update(self._get_request_bo... | [
"def",
"_get_request_settings",
"(",
"self",
",",
"request_element",
")",
":",
"request_config",
"=",
"{",
"}",
"request_config",
".",
"update",
"(",
"self",
".",
"_get_request_base",
"(",
"request_element",
")",
")",
"request_config",
".",
"update",
"(",
"self"... | [
1455,
4
] | [
1472,
29
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_tg_scenario_settings | (self, tg_etree_element) |
Gets all possible tg settings and applies global overrides
:param tg_etree_element:
:return:
|
Gets all possible tg settings and applies global overrides
:param tg_etree_element:
:return:
| def _get_tg_scenario_settings(self, tg_etree_element):
"""
Gets all possible tg settings and applies global overrides
:param tg_etree_element:
:return:
"""
default_tg_settings = {"store-cookie": False, "store-cache": False, "use-dns-cache-mgr": False}
global_tg_se... | [
"def",
"_get_tg_scenario_settings",
"(",
"self",
",",
"tg_etree_element",
")",
":",
"default_tg_settings",
"=",
"{",
"\"store-cookie\"",
":",
"False",
",",
"\"store-cache\"",
":",
"False",
",",
"\"use-dns-cache-mgr\"",
":",
"False",
"}",
"global_tg_settings",
"=",
"... | [
1474,
4
] | [
1498,
26
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_tg_execution_settings | (self, tg_etree_element) |
Gets execution settings
:param tg_etree_element:
:return: dict
|
Gets execution settings
:param tg_etree_element:
:return: dict
| def _get_tg_execution_settings(self, tg_etree_element):
"""
Gets execution settings
:param tg_etree_element:
:return: dict
"""
global_execution_settings = self._get_global_tg_execution()
execution_settings = {
'concurrency': 1,
'iterations'... | [
"def",
"_get_tg_execution_settings",
"(",
"self",
",",
"tg_etree_element",
")",
":",
"global_execution_settings",
"=",
"self",
".",
"_get_global_tg_execution",
"(",
")",
"execution_settings",
"=",
"{",
"'concurrency'",
":",
"1",
",",
"'iterations'",
":",
"1",
",",
... | [
1500,
4
] | [
1525,
33
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_global_objects | (self) |
list of global objects in test plan
:return:
|
list of global objects in test plan
:return:
| def _get_global_objects(self):
"""
list of global objects in test plan
:return:
"""
self.global_objects = []
try:
ht_object = self.tree.find(".//hashTree").find(".//TestPlan").getnext()
except BaseException:
raise TaurusInternalException("B... | [
"def",
"_get_global_objects",
"(",
"self",
")",
":",
"self",
".",
"global_objects",
"=",
"[",
"]",
"try",
":",
"ht_object",
"=",
"self",
".",
"tree",
".",
"find",
"(",
"\".//hashTree\"",
")",
".",
"find",
"(",
"\".//TestPlan\"",
")",
".",
"getnext",
"(",... | [
1527,
4
] | [
1539,
47
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_global_tg_scenario | (self) |
:return: dict
|
:return: dict
| def _get_global_tg_scenario(self):
"""
:return: dict
"""
default_tg_settings = {}
testplan_element = self.tree.find(".//TestPlan")
default_tg_settings.update(self._get_headers(testplan_element))
default_tg_settings.update(self._get_data_sources(testplan_element))
... | [
"def",
"_get_global_tg_scenario",
"(",
"self",
")",
":",
"default_tg_settings",
"=",
"{",
"}",
"testplan_element",
"=",
"self",
".",
"tree",
".",
"find",
"(",
"\".//TestPlan\"",
")",
"default_tg_settings",
".",
"update",
"(",
"self",
".",
"_get_headers",
"(",
... | [
1541,
4
] | [
1557,
34
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_global_tg_execution | (self) |
:return: dict
|
:return: dict
| def _get_global_tg_execution(self):
"""
:return: dict
"""
default_tg_settings = {}
testplan_element = self.tree.find(".//TestPlan")
default_tg_settings.update(self._get_throughput(testplan_element))
return default_tg_settings | [
"def",
"_get_global_tg_execution",
"(",
"self",
")",
":",
"default_tg_settings",
"=",
"{",
"}",
"testplan_element",
"=",
"self",
".",
"tree",
".",
"find",
"(",
"\".//TestPlan\"",
")",
"default_tg_settings",
".",
"update",
"(",
"self",
".",
"_get_throughput",
"("... | [
1559,
4
] | [
1566,
34
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._clean_jmx_tree | (self, element) |
Removes all unknown and disabled elements
:return:
|
Removes all unknown and disabled elements
:return:
| def _clean_jmx_tree(self, element):
"""
Removes all unknown and disabled elements
:return:
"""
for subelement in element.findall('./'):
tag = subelement.tag.lower()
if tag == 'hashtree':
self._clean_jmx_tree(subelement) # look inside
... | [
"def",
"_clean_jmx_tree",
"(",
"self",
",",
"element",
")",
":",
"for",
"subelement",
"in",
"element",
".",
"findall",
"(",
"'./'",
")",
":",
"tag",
"=",
"subelement",
".",
"tag",
".",
"lower",
"(",
")",
"if",
"tag",
"==",
"'hashtree'",
":",
"self",
... | [
1588,
4
] | [
1617,
21
] | python | en | ['en', 'error', 'th'] | False |
Converter.convert | (self, file_to_convert, dump_modified_jmx_to=None) |
Get all thread groups from jmx, convert to dict.
:type dump_modified_jmx_to: str
:type file_to_convert: str
:rtype: dict
|
Get all thread groups from jmx, convert to dict.
:type dump_modified_jmx_to: str
:type file_to_convert: str
:rtype: dict
| def convert(self, file_to_convert, dump_modified_jmx_to=None):
"""
Get all thread groups from jmx, convert to dict.
:type dump_modified_jmx_to: str
:type file_to_convert: str
:rtype: dict
"""
self.dialect.load(file_to_convert)
base_script = {"scenarios": {... | [
"def",
"convert",
"(",
"self",
",",
"file_to_convert",
",",
"dump_modified_jmx_to",
"=",
"None",
")",
":",
"self",
".",
"dialect",
".",
"load",
"(",
"file_to_convert",
")",
"base_script",
"=",
"{",
"\"scenarios\"",
":",
"{",
"}",
",",
"EXEC",
":",
"[",
"... | [
1642,
4
] | [
1671,
84
] | python | en | ['en', 'error', 'th'] | False |
Converter._dump_modified_jmx | (self, dump_jmx) |
Dump modified JMX from dialect object
|
Dump modified JMX from dialect object
| def _dump_modified_jmx(self, dump_jmx):
"""
Dump modified JMX from dialect object
"""
if dump_jmx:
if os.path.exists(dump_jmx):
self.log.warning("%s already exists and will be overwritten", dump_jmx)
self.dialect.save(dump_jmx)
... | [
"def",
"_dump_modified_jmx",
"(",
"self",
",",
"dump_jmx",
")",
":",
"if",
"dump_jmx",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"dump_jmx",
")",
":",
"self",
".",
"log",
".",
"warning",
"(",
"\"%s already exists and will be overwritten\"",
",",
"dum... | [
1673,
4
] | [
1681,
66
] | python | en | ['en', 'error', 'th'] | False |
JMX2YAML.process | (self) |
Process file
:return:
|
Process file
:return:
| def process(self):
"""
Process file
:return:
"""
output_format = Configuration.JSON if self.options.json else Configuration.YAML
self.log.info('Loading jmx file %s', self.src_file)
self.src_file = os.path.abspath(os.path.expanduser(self.src_file))
if not ... | [
"def",
"process",
"(",
"self",
")",
":",
"output_format",
"=",
"Configuration",
".",
"JSON",
"if",
"self",
".",
"options",
".",
"json",
"else",
"Configuration",
".",
"YAML",
"self",
".",
"log",
".",
"info",
"(",
"'Loading jmx file %s'",
",",
"self",
".",
... | [
1702,
4
] | [
1738,
75
] | python | en | ['en', 'error', 'th'] | False |
patch_data_urls | (monkeypatch) | This makes sure we never download the big files with our tests | This makes sure we never download the big files with our tests | def patch_data_urls(monkeypatch):
"""This makes sure we never download the big files with our tests"""
url = 'https://cluster.klima.uni-bremen.de/~oggm/test_climate/'
monkeypatch.setattr(cru, 'CRU_SERVER', url + 'cru/')
monkeypatch.setattr(cru, 'CRU_BASE', 'cru_ts3.23.1901.2014.{}.dat.nc')
monkeypat... | [
"def",
"patch_data_urls",
"(",
"monkeypatch",
")",
":",
"url",
"=",
"'https://cluster.klima.uni-bremen.de/~oggm/test_climate/'",
"monkeypatch",
".",
"setattr",
"(",
"cru",
",",
"'CRU_SERVER'",
",",
"url",
"+",
"'cru/'",
")",
"monkeypatch",
".",
"setattr",
"(",
"cru"... | [
102,
0
] | [
135,
54
] | python | en | ['en', 'en', 'en'] | True |
secure_url_retrieve | (url, *args, **kwargs) | A simple patch to OGGM's download function to make sure we don't
download elsewhere than expected. | A simple patch to OGGM's download function to make sure we don't
download elsewhere than expected. | def secure_url_retrieve(url, *args, **kwargs):
"""A simple patch to OGGM's download function to make sure we don't
download elsewhere than expected."""
assert ('github' in url or
'cluster.klima.uni-bremen.de/~oggm/ref_mb_params' in url or
'cluster.klima.uni-bremen.de/~oggm/test_gdir... | [
"def",
"secure_url_retrieve",
"(",
"url",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"(",
"'github'",
"in",
"url",
"or",
"'cluster.klima.uni-bremen.de/~oggm/ref_mb_params'",
"in",
"url",
"or",
"'cluster.klima.uni-bremen.de/~oggm/test_gdirs/'",
"in"... | [
138,
0
] | [
150,
49
] | python | en | ['en', 'en', 'en'] | True |
test_dir | () | Provides a reference to the test directory for the entire test session.
Named after the current git revision.
As a session-scoped fixture, this will only be created once and
then injected to each test that depends on it.
| Provides a reference to the test directory for the entire test session. | def test_dir():
""" Provides a reference to the test directory for the entire test session.
Named after the current git revision.
As a session-scoped fixture, this will only be created once and
then injected to each test that depends on it.
"""
return get_test_dir() | [
"def",
"test_dir",
"(",
")",
":",
"return",
"get_test_dir",
"(",
")"
] | [
178,
0
] | [
185,
25
] | python | en | ['en', 'en', 'en'] | True |
case_dir | (request, test_dir) | Provides a unique directory for the current test function, a child of
the session test directory (test_dir > case_dir). Named after the
current test function.
As a function-scoped fixture, a new directory is created for
each function that uses this and then cleaned up when the case
... | Provides a unique directory for the current test function, a child of
the session test directory (test_dir > case_dir). Named after the
current test function.
As a function-scoped fixture, a new directory is created for
each function that uses this and then cleaned up when the case
... | def case_dir(request, test_dir):
""" Provides a unique directory for the current test function, a child of
the session test directory (test_dir > case_dir). Named after the
current test function.
As a function-scoped fixture, a new directory is created for
each function that uses thi... | [
"def",
"case_dir",
"(",
"request",
",",
"test_dir",
")",
":",
"cd",
"=",
"_setup_case_dir",
"(",
"request",
".",
"function",
",",
"test_dir",
")",
"yield",
"cd",
"_teardown_case_dir",
"(",
"cd",
")"
] | [
200,
0
] | [
210,
26
] | python | en | ['en', 'en', 'en'] | True |
class_case_dir | (request, test_dir) | Provides a unique directory for the current test class, a child of
the session test directory (test_dir > class_case_dir). Named after
the current test class.
As a class-scoped fixture, a class directory is created once for
the current class and used by each test inside it. It is cleane... | Provides a unique directory for the current test class, a child of
the session test directory (test_dir > class_case_dir). Named after
the current test class.
As a class-scoped fixture, a class directory is created once for
the current class and used by each test inside it. It is cleane... | def class_case_dir(request, test_dir):
""" Provides a unique directory for the current test class, a child of
the session test directory (test_dir > class_case_dir). Named after
the current test class.
As a class-scoped fixture, a class directory is created once for
the current class... | [
"def",
"class_case_dir",
"(",
"request",
",",
"test_dir",
")",
":",
"cd",
"=",
"_setup_case_dir",
"(",
"request",
".",
"cls",
",",
"test_dir",
")",
"yield",
"cd",
"_teardown_case_dir",
"(",
"cd",
")"
] | [
214,
0
] | [
224,
26
] | python | en | ['en', 'en', 'en'] | True |
hef_gdir_base | (request, test_dir) | Provides an initialized Hintereisferner glacier directory.
As a module fixture, the initialization is run only once per test
module that uses it.
IMPORTANT: To preserve a constant starting condition, hef_gdir_base
should almost never be directly injected into a test case. Test cases
... | Provides an initialized Hintereisferner glacier directory.
As a module fixture, the initialization is run only once per test
module that uses it.
IMPORTANT: To preserve a constant starting condition, hef_gdir_base
should almost never be directly injected into a test case. Test cases
... | def hef_gdir_base(request, test_dir):
""" Provides an initialized Hintereisferner glacier directory.
As a module fixture, the initialization is run only once per test
module that uses it.
IMPORTANT: To preserve a constant starting condition, hef_gdir_base
should almost never be direc... | [
"def",
"hef_gdir_base",
"(",
"request",
",",
"test_dir",
")",
":",
"try",
":",
"module",
"=",
"request",
".",
"module",
"border",
"=",
"module",
".",
"DOM_BORDER",
"if",
"module",
".",
"DOM_BORDER",
"is",
"not",
"None",
"else",
"40",
"return",
"init_hef",
... | [
228,
0
] | [
242,
25
] | python | en | ['de', 'en', 'en'] | True |
hef_gdir | (hef_gdir_base, class_case_dir) | Provides a copy of the base Hintereisenferner glacier directory in
a case directory specific to the current test class. All cases in
the test class will use the same copy of this glacier directory.
| Provides a copy of the base Hintereisenferner glacier directory in
a case directory specific to the current test class. All cases in
the test class will use the same copy of this glacier directory.
| def hef_gdir(hef_gdir_base, class_case_dir):
""" Provides a copy of the base Hintereisenferner glacier directory in
a case directory specific to the current test class. All cases in
the test class will use the same copy of this glacier directory.
"""
return tasks.copy_to_basedir(hef_gdir_bas... | [
"def",
"hef_gdir",
"(",
"hef_gdir_base",
",",
"class_case_dir",
")",
":",
"return",
"tasks",
".",
"copy_to_basedir",
"(",
"hef_gdir_base",
",",
"base_dir",
"=",
"class_case_dir",
",",
"setup",
"=",
"'all'",
")"
] | [
246,
0
] | [
252,
45
] | python | en | ['en', 'en', 'en'] | True |
literals | (choices, prefix="", suffix="") |
Create a regex from a space-separated list of literal `choices`.
If provided, `prefix` and `suffix` will be attached to each choice
individually.
|
Create a regex from a space-separated list of literal `choices`. | def literals(choices, prefix="", suffix=""):
"""
Create a regex from a space-separated list of literal `choices`.
If provided, `prefix` and `suffix` will be attached to each choice
individually.
"""
return "|".join(prefix + re.escape(c) + suffix for c in choices.split()) | [
"def",
"literals",
"(",
"choices",
",",
"prefix",
"=",
"\"\"",
",",
"suffix",
"=",
"\"\"",
")",
":",
"return",
"\"|\"",
".",
"join",
"(",
"prefix",
"+",
"re",
".",
"escape",
"(",
"c",
")",
"+",
"suffix",
"for",
"c",
"in",
"choices",
".",
"split",
... | [
21,
0
] | [
28,
76
] | python | en | ['en', 'error', 'th'] | False |
prepare_js_for_gettext | (js) |
Convert the Javascript source `js` into something resembling C for
xgettext.
What actually happens is that all the regex literals are replaced with
"REGEX".
|
Convert the Javascript source `js` into something resembling C for
xgettext. | def prepare_js_for_gettext(js):
"""
Convert the Javascript source `js` into something resembling C for
xgettext.
What actually happens is that all the regex literals are replaced with
"REGEX".
"""
def escape_quotes(m):
"""Used in a regex to properly escape double quotes."""
... | [
"def",
"prepare_js_for_gettext",
"(",
"js",
")",
":",
"def",
"escape_quotes",
"(",
"m",
")",
":",
"\"\"\"Used in a regex to properly escape double quotes.\"\"\"",
"s",
"=",
"m",
".",
"group",
"(",
"0",
")",
"if",
"s",
"==",
"'\"'",
":",
"return",
"r'\\\"'",
"e... | [
186,
0
] | [
221,
21
] | python | en | ['en', 'error', 'th'] | False |
Lexer.lex | (self, text) |
Lexically analyze `text`.
Yields pairs (`name`, `tokentext`).
|
Lexically analyze `text`. | def lex(self, text):
"""
Lexically analyze `text`.
Yields pairs (`name`, `tokentext`).
"""
end = len(text)
state = self.state
regexes = self.regexes
toks = self.toks
start = 0
while start < end:
for match in regexes[state].fin... | [
"def",
"lex",
"(",
"self",
",",
"text",
")",
":",
"end",
"=",
"len",
"(",
"text",
")",
"state",
"=",
"self",
".",
"state",
"regexes",
"=",
"self",
".",
"regexes",
"toks",
"=",
"self",
".",
"toks",
"start",
"=",
"0",
"while",
"start",
"<",
"end",
... | [
50,
4
] | [
74,
26
] | python | en | ['en', 'error', 'th'] | False |
messages | (request) |
Returns a lazy 'messages' context variable.
|
Returns a lazy 'messages' context variable.
| def messages(request):
"""
Returns a lazy 'messages' context variable.
"""
return {
'messages': get_messages(request),
'DEFAULT_MESSAGE_LEVELS': DEFAULT_LEVELS,
} | [
"def",
"messages",
"(",
"request",
")",
":",
"return",
"{",
"'messages'",
":",
"get_messages",
"(",
"request",
")",
",",
"'DEFAULT_MESSAGE_LEVELS'",
":",
"DEFAULT_LEVELS",
",",
"}"
] | [
4,
0
] | [
11,
5
] | python | en | ['en', 'error', 'th'] | False |
FocusLabel.keyboard_on_key_down | (self, window, keycode, text, modifiers) | We call super before doing anything else to enable tab cycling
by FocusBehavior. If we wanted to use tab for ourselves, we could just
not call it, or call it if we didn't need tab.
| We call super before doing anything else to enable tab cycling
by FocusBehavior. If we wanted to use tab for ourselves, we could just
not call it, or call it if we didn't need tab.
| def keyboard_on_key_down(self, window, keycode, text, modifiers):
'''We call super before doing anything else to enable tab cycling
by FocusBehavior. If we wanted to use tab for ourselves, we could just
not call it, or call it if we didn't need tab.
'''
if super(FocusLabel, self)... | [
"def",
"keyboard_on_key_down",
"(",
"self",
",",
"window",
",",
"keycode",
",",
"text",
",",
"modifiers",
")",
":",
"if",
"super",
"(",
"FocusLabel",
",",
"self",
")",
".",
"keyboard_on_key_down",
"(",
"window",
",",
"keycode",
",",
"text",
",",
"modifiers... | [
35,
4
] | [
44,
19
] | python | en | ['en', 'en', 'en'] | True |
run_app_happily | (root, nursery) | This method, which runs Kivy, is run by trio as one of the coroutines.
| This method, which runs Kivy, is run by trio as one of the coroutines.
| async def run_app_happily(root, nursery):
'''This method, which runs Kivy, is run by trio as one of the coroutines.
'''
# trio needs to be set so that it'll be used for the event loop
await async_runTouchApp(root, async_lib='trio') # run Kivy
print('App done')
# now cancel all the other tasks t... | [
"async",
"def",
"run_app_happily",
"(",
"root",
",",
"nursery",
")",
":",
"# trio needs to be set so that it'll be used for the event loop",
"await",
"async_runTouchApp",
"(",
"root",
",",
"async_lib",
"=",
"'trio'",
")",
"# run Kivy",
"print",
"(",
"'App done'",
")",
... | [
20,
0
] | [
27,
33
] | python | en | ['en', 'en', 'en'] | True |
waste_time_freely | () | This method is also run by trio and periodically prints something. | This method is also run by trio and periodically prints something. | async def waste_time_freely():
'''This method is also run by trio and periodically prints something.'''
try:
while True:
print('Sitting on the beach')
await trio.sleep(2)
except trio.Cancelled as e:
print('Wasting time was canceled', e)
finally:
# when can... | [
"async",
"def",
"waste_time_freely",
"(",
")",
":",
"try",
":",
"while",
"True",
":",
"print",
"(",
"'Sitting on the beach'",
")",
"await",
"trio",
".",
"sleep",
"(",
"2",
")",
"except",
"trio",
".",
"Cancelled",
"as",
"e",
":",
"print",
"(",
"'Wasting t... | [
30,
0
] | [
40,
34
] | python | en | ['en', 'en', 'en'] | True |
AccSGD.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... | [
63,
4
] | [
101,
19
] | python | en | ['en', 'en', 'en'] | True |
AllConv.__init__ | (self, args) |
TODO: Write Comment
|
TODO: Write Comment
| def __init__(self, args):
"""
TODO: Write Comment
"""
from tensorflow.keras import optimizers
self.name = 'AllConv'
CifarModel.__init__(self, args)
self.optimizer = optimizers.Adam(lr=1.0e-4) | [
"def",
"__init__",
"(",
"self",
",",
"args",
")",
":",
"from",
"tensorflow",
".",
"keras",
"import",
"optimizers",
"self",
".",
"name",
"=",
"'AllConv'",
"CifarModel",
".",
"__init__",
"(",
"self",
",",
"args",
")",
"self",
".",
"optimizer",
"=",
"optimi... | [
9,
4
] | [
19,
51
] | python | en | ['en', 'error', 'th'] | False |
AllConv.network | (self, img_input) |
TODO: Write Comment
|
TODO: Write Comment
| def network(self, img_input):
"""
TODO: Write Comment
"""
from tensorflow.keras import initializers, layers, regularizers
weight_decay = 0.0001
x = layers.Conv2D(96, (3, 3), kernel_regularizer=regularizers.l2(weight_decay), kernel_initializer=initializers.he_normal(), ... | [
"def",
"network",
"(",
"self",
",",
"img_input",
")",
":",
"from",
"tensorflow",
".",
"keras",
"import",
"initializers",
",",
"layers",
",",
"regularizers",
"weight_decay",
"=",
"0.0001",
"x",
"=",
"layers",
".",
"Conv2D",
"(",
"96",
",",
"(",
"3",
",",
... | [
21,
4
] | [
72,
16
] | python | en | ['en', 'error', 'th'] | False |
AllConv.scheduler | (self, epoch) |
TODO: Write Comment
|
TODO: Write Comment
| def scheduler(self, epoch):
"""
TODO: Write Comment
"""
return 1.0e-4 | [
"def",
"scheduler",
"(",
"self",
",",
"epoch",
")",
":",
"return",
"1.0e-4"
] | [
74,
4
] | [
79,
21
] | python | en | ['en', 'error', 'th'] | False |
message_cache_items | (items_for_remote_cache: Dict[str, Tuple[bytes]], message: Message) |
Note: this code is untested, and the caller has been
commented out for a while.
|
Note: this code is untested, and the caller has been
commented out for a while.
| def message_cache_items(items_for_remote_cache: Dict[str, Tuple[bytes]], message: Message) -> None:
"""
Note: this code is untested, and the caller has been
commented out for a while.
"""
key = to_dict_cache_key_id(message.id)
value = MessageDict.to_dict_uncached([message])[message.id]
items... | [
"def",
"message_cache_items",
"(",
"items_for_remote_cache",
":",
"Dict",
"[",
"str",
",",
"Tuple",
"[",
"bytes",
"]",
"]",
",",
"message",
":",
"Message",
")",
"->",
"None",
":",
"key",
"=",
"to_dict_cache_key_id",
"(",
"message",
".",
"id",
")",
"value",... | [
49,
0
] | [
56,
42
] | python | en | ['en', 'error', 'th'] | False |
get_active_realm_ids | () | For installations like Zulip Cloud hosting a lot of realms, it only makes
sense to do cache-filling work for realms that have any currently
active users/clients. Otherwise, we end up with every single-user
trial organization that has ever been created costing us N streams
worth of cache work (where N i... | For installations like Zulip Cloud hosting a lot of realms, it only makes
sense to do cache-filling work for realms that have any currently
active users/clients. Otherwise, we end up with every single-user
trial organization that has ever been created costing us N streams
worth of cache work (where N i... | def get_active_realm_ids() -> List[int]:
"""For installations like Zulip Cloud hosting a lot of realms, it only makes
sense to do cache-filling work for realms that have any currently
active users/clients. Otherwise, we end up with every single-user
trial organization that has ever been created costing... | [
"def",
"get_active_realm_ids",
"(",
")",
"->",
"List",
"[",
"int",
"]",
":",
"date",
"=",
"timezone_now",
"(",
")",
"-",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"2",
")",
"return",
"(",
"RealmCount",
".",
"objects",
".",
"filter",
"(",
"end_tim... | [
93,
0
] | [
106,
5
] | python | en | ['en', 'en', 'en'] | True |
load_config_cli | (root_path: Path, filename: str, sub_config: Optional[str] = None) |
Loads configuration from the specified filename, in the config directory,
and then overrides any properties using the passed in command line arguments.
Nested properties in the config file can be used in the command line with ".",
for example --farmer_peer.host. Does not support lists.
|
Loads configuration from the specified filename, in the config directory,
and then overrides any properties using the passed in command line arguments.
Nested properties in the config file can be used in the command line with ".",
for example --farmer_peer.host. Does not support lists.
| def load_config_cli(root_path: Path, filename: str, sub_config: Optional[str] = None) -> Dict:
"""
Loads configuration from the specified filename, in the config directory,
and then overrides any properties using the passed in command line arguments.
Nested properties in the config file can be used in t... | [
"def",
"load_config_cli",
"(",
"root_path",
":",
"Path",
",",
"filename",
":",
"str",
",",
"sub_config",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Dict",
":",
"config",
"=",
"load_config",
"(",
"root_path",
",",
"filename",
",",
"sub_con... | [
60,
0
] | [
82,
48
] | python | en | ['en', 'error', 'th'] | False |
columns_from_table | (table, keywords=None, alias=None, where=None,
order=None) | Obtain specific column (keywords) values from 'table', with
kwargs limitations.
A very simple helper function, that builds an SQL query to obtain
the specified columns from 'table', and then executes that
query. Optionally, the WHERE clause can be specified using the
where dictionary. It returns a ... | Obtain specific column (keywords) values from 'table', with
kwargs limitations. | def columns_from_table(table, keywords=None, alias=None, where=None,
order=None):
"""Obtain specific column (keywords) values from 'table', with
kwargs limitations.
A very simple helper function, that builds an SQL query to obtain
the specified columns from 'table', and then exec... | [
"def",
"columns_from_table",
"(",
"table",
",",
"keywords",
"=",
"None",
",",
"alias",
"=",
"None",
",",
"where",
"=",
"None",
",",
"order",
"=",
"None",
")",
":",
"if",
"keywords",
"is",
"None",
":",
"query",
"=",
"\"SELECT * FROM \"",
"+",
"table",
"... | [
11,
0
] | [
78,
23
] | python | en | ['en', 'en', 'en'] | True |
convert_db_rows_to_dicts | (results, cursor_description=None, alias_map=None) | Converts a SQLAlchemy Resultproxy to a list of dicts.
here for backward compatability reasons. A ResultProxy can already be used
as a dict, but for now it is too much work to rewrite all code.
Args:
results: a SQLalchemy ResultProxy or just a list of rows
cursor_description: Not required i... | Converts a SQLAlchemy Resultproxy to a list of dicts. | def convert_db_rows_to_dicts(results, cursor_description=None, alias_map=None):
"""Converts a SQLAlchemy Resultproxy to a list of dicts.
here for backward compatability reasons. A ResultProxy can already be used
as a dict, but for now it is too much work to rewrite all code.
Args:
results: a S... | [
"def",
"convert_db_rows_to_dicts",
"(",
"results",
",",
"cursor_description",
"=",
"None",
",",
"alias_map",
"=",
"None",
")",
":",
"dic_list",
"=",
"[",
"]",
"for",
"row",
"in",
"results",
":",
"if",
"cursor_description",
":",
"dict_row",
"=",
"dict",
"(",
... | [
81,
0
] | [
103,
19
] | python | en | ['en', 'en', 'en'] | True |
get_db_rows_as_dicts | (cursor, alias_map=None) | Grab results of cursor.fetchall(), convert to a list of dictionaries. | Grab results of cursor.fetchall(), convert to a list of dictionaries. | def get_db_rows_as_dicts(cursor, alias_map=None):
"""Grab results of cursor.fetchall(), convert to a list of dictionaries."""
if hasattr(cursor, "description"):
description = [col[0] for col in cursor.description]
else:
description = None
return convert_db_rows_to_dicts(cursor.fetchall(... | [
"def",
"get_db_rows_as_dicts",
"(",
"cursor",
",",
"alias_map",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"cursor",
",",
"\"description\"",
")",
":",
"description",
"=",
"[",
"col",
"[",
"0",
"]",
"for",
"col",
"in",
"cursor",
".",
"description",
"]",... | [
106,
0
] | [
114,
56
] | python | en | ['en', 'en', 'en'] | True |
set_columns_for_table | (table, data=None, where=None) | Set specific columns (keywords) for 'table', with 'where'
limitations.
A simple helper function, that builds an SQL query to update the
specified columns given by data for 'table', and then executes
that query. Optionally, the WHERE clause can be specified using
the 'where' dictionary.
The dat... | Set specific columns (keywords) for 'table', with 'where'
limitations. | def set_columns_for_table(table, data=None, where=None):
"""Set specific columns (keywords) for 'table', with 'where'
limitations.
A simple helper function, that builds an SQL query to update the
specified columns given by data for 'table', and then executes
that query. Optionally, the WHERE clause... | [
"def",
"set_columns_for_table",
"(",
"table",
",",
"data",
"=",
"None",
",",
"where",
"=",
"None",
")",
":",
"query",
"=",
"\"UPDATE \"",
"+",
"table",
"+",
"\" SET \"",
"+",
"\", \"",
".",
"join",
"(",
"[",
"\"%s=%%s\"",
"%",
"key",
"for",
"key",
"in"... | [
118,
0
] | [
139,
59
] | python | en | ['en', 'en', 'en'] | True |
DatabaseSchemaEditor._create_like_index_sql | (self, model, field) |
Return the statement to create an index with varchar operator pattern
when the column type is 'varchar' or 'text', otherwise return None.
|
Return the statement to create an index with varchar operator pattern
when the column type is 'varchar' or 'text', otherwise return None.
| def _create_like_index_sql(self, model, field):
"""
Return the statement to create an index with varchar operator pattern
when the column type is 'varchar' or 'text', otherwise return None.
"""
db_type = field.db_type(connection=self.connection)
if db_type is not None and... | [
"def",
"_create_like_index_sql",
"(",
"self",
",",
"model",
",",
"field",
")",
":",
"db_type",
"=",
"field",
".",
"db_type",
"(",
"connection",
"=",
"self",
".",
"connection",
")",
"if",
"db_type",
"is",
"not",
"None",
"and",
"(",
"field",
".",
"db_index... | [
31,
4
] | [
51,
19
] | python | en | ['en', 'error', 'th'] | False |
DatabaseSchemaEditor._alter_column_type_sql | (self, table, old_field, new_field, new_type) |
Makes ALTER TYPE with SERIAL make sense.
|
Makes ALTER TYPE with SERIAL make sense.
| def _alter_column_type_sql(self, table, old_field, new_field, new_type):
"""
Makes ALTER TYPE with SERIAL make sense.
"""
if new_type.lower() in ("serial", "bigserial"):
column = new_field.column
sequence_name = "%s_%s_seq" % (table, column)
col_type =... | [
"def",
"_alter_column_type_sql",
"(",
"self",
",",
"table",
",",
"old_field",
",",
"new_field",
",",
"new_type",
")",
":",
"if",
"new_type",
".",
"lower",
"(",
")",
"in",
"(",
"\"serial\"",
",",
"\"bigserial\"",
")",
":",
"column",
"=",
"new_field",
".",
... | [
53,
4
] | [
105,
13
] | python | en | ['en', 'error', 'th'] | False |
f | (x) | Noise free objective. | Noise free objective. | def f(x):
"""Noise free objective."""
return np.sin(10 * x) * x * 100 | [
"def",
"f",
"(",
"x",
")",
":",
"return",
"np",
".",
"sin",
"(",
"10",
"*",
"x",
")",
"*",
"x",
"*",
"100"
] | [
29,
0
] | [
32,
35
] | python | en | ['en', 'en', 'en'] | True |
CharDistributionAnalysis.reset | (self) | reset analyser, clear any state | reset analyser, clear any state | def reset(self):
"""reset analyser, clear any state"""
# If this flag is set to True, detection is done and conclusion has
# been made
self._done = False
self._total_chars = 0 # Total characters encountered
# The number of characters whose frequency order is less than 51... | [
"def",
"reset",
"(",
"self",
")",
":",
"# If this flag is set to True, detection is done and conclusion has",
"# been made",
"self",
".",
"_done",
"=",
"False",
"self",
".",
"_total_chars",
"=",
"0",
"# Total characters encountered",
"# The number of characters whose frequency ... | [
60,
4
] | [
67,
28
] | python | en | ['en', 'en', 'en'] | True |
CharDistributionAnalysis.feed | (self, char, char_len) | feed a character with known length | feed a character with known length | def feed(self, char, char_len):
"""feed a character with known length"""
if char_len == 2:
# we only care about 2-bytes character in our distribution analysis
order = self.get_order(char)
else:
order = -1
if order >= 0:
self._total_chars +=... | [
"def",
"feed",
"(",
"self",
",",
"char",
",",
"char_len",
")",
":",
"if",
"char_len",
"==",
"2",
":",
"# we only care about 2-bytes character in our distribution analysis",
"order",
"=",
"self",
".",
"get_order",
"(",
"char",
")",
"else",
":",
"order",
"=",
"-... | [
69,
4
] | [
81,
41
] | python | en | ['en', 'en', 'en'] | True |
CharDistributionAnalysis.get_confidence | (self) | return confidence based on existing data | return confidence based on existing data | def get_confidence(self):
"""return confidence based on existing data"""
# if we didn't receive any character in our consideration range,
# return negative answer
if self._total_chars <= 0 or self._freq_chars <= self.MINIMUM_DATA_THRESHOLD:
return self.SURE_NO
if sel... | [
"def",
"get_confidence",
"(",
"self",
")",
":",
"# if we didn't receive any character in our consideration range,",
"# return negative answer",
"if",
"self",
".",
"_total_chars",
"<=",
"0",
"or",
"self",
".",
"_freq_chars",
"<=",
"self",
".",
"MINIMUM_DATA_THRESHOLD",
":"... | [
83,
4
] | [
97,
28
] | python | en | ['en', 'zu', 'en'] | True |
AlertWordTests.test_default_no_words | (self) |
Users start out with no alert words.
|
Users start out with no alert words.
| def test_default_no_words(self) -> None:
"""
Users start out with no alert words.
"""
user = self.get_user()
words = user_alert_words(user)
self.assertEqual(words, []) | [
"def",
"test_default_no_words",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
")",
"words",
"=",
"user_alert_words",
"(",
"user",
")",
"self",
".",
"assertEqual",
"(",
"words",
",",
"[",
"]",
")"
] | [
34,
4
] | [
40,
35
] | python | en | ['en', 'error', 'th'] | False |
AlertWordTests.test_basics | (self) |
Verifies the basic behavior of modifying alert words.
Also verifies the cache-flushing behavior.
|
Verifies the basic behavior of modifying alert words. | def test_basics(self) -> None:
"""
Verifies the basic behavior of modifying alert words.
Also verifies the cache-flushing behavior.
"""
user = self.get_user()
realm_alert_words = alert_words_in_realm(user.realm)
self.assert_length(realm_alert_words.get(user.id, [... | [
"def",
"test_basics",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
")",
"realm_alert_words",
"=",
"alert_words_in_realm",
"(",
"user",
".",
"realm",
")",
"self",
".",
"assert_length",
"(",
"realm_alert_words",
".",
"get",
... | [
42,
4
] | [
72,
57
] | python | en | ['en', 'error', 'th'] | False |
AlertWordTests.test_remove_word | (self) |
Removing alert words works via do_remove_alert_words, even
for multi-word and non-ascii words.
|
Removing alert words works via do_remove_alert_words, even
for multi-word and non-ascii words.
| def test_remove_word(self) -> None:
"""
Removing alert words works via do_remove_alert_words, even
for multi-word and non-ascii words.
"""
user = self.get_user()
expected_remaining_alerts = set(self.interesting_alert_word_list)
do_add_alert_words(user, self.inter... | [
"def",
"test_remove_word",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
")",
"expected_remaining_alerts",
"=",
"set",
"(",
"self",
".",
"interesting_alert_word_list",
")",
"do_add_alert_words",
"(",
"user",
",",
"self",
".",
... | [
74,
4
] | [
88,
85
] | python | en | ['en', 'error', 'th'] | False |
AlertWordTests.test_realm_words | (self) |
We can gather alert words for an entire realm via
alert_words_in_realm. Alerts added for one user do not impact other
users.
|
We can gather alert words for an entire realm via
alert_words_in_realm. Alerts added for one user do not impact other
users.
| def test_realm_words(self) -> None:
"""
We can gather alert words for an entire realm via
alert_words_in_realm. Alerts added for one user do not impact other
users.
"""
# Clear all the words that we got from populate_db.
AlertWord.objects.all().delete()
... | [
"def",
"test_realm_words",
"(",
"self",
")",
"->",
"None",
":",
"# Clear all the words that we got from populate_db.",
"AlertWord",
".",
"objects",
".",
"all",
"(",
")",
".",
"delete",
"(",
")",
"user1",
"=",
"self",
".",
"get_user",
"(",
")",
"do_add_alert_word... | [
90,
4
] | [
111,
65
] | python | en | ['en', 'error', 'th'] | False |
AlertWordTests.message_does_alert | (self, user: UserProfile, message: str) | Send a bunch of messages as othello, so our user is notified | Send a bunch of messages as othello, so our user is notified | def message_does_alert(self, user: UserProfile, message: str) -> bool:
"""Send a bunch of messages as othello, so our user is notified"""
self.send_stream_message(self.example_user("othello"), "Denmark", message)
user_message = most_recent_usermessage(user)
return "has_alert_word" in use... | [
"def",
"message_does_alert",
"(",
"self",
",",
"user",
":",
"UserProfile",
",",
"message",
":",
"str",
")",
"->",
"bool",
":",
"self",
".",
"send_stream_message",
"(",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
",",
"\"Denmark\"",
",",
"message",
... | [
158,
4
] | [
162,
60
] | python | en | ['en', 'en', 'en'] | True |
get_next_runserver_command | () |
Return the next highest priority "runserver" command class
|
Return the next highest priority "runserver" command class
| def get_next_runserver_command():
"""
Return the next highest priority "runserver" command class
"""
for app_name in get_lower_priority_apps():
module_path = "%s.management.commands.runserver" % app_name
try:
return import_module(module_path).Command
except (ImportErr... | [
"def",
"get_next_runserver_command",
"(",
")",
":",
"for",
"app_name",
"in",
"get_lower_priority_apps",
"(",
")",
":",
"module_path",
"=",
"\"%s.management.commands.runserver\"",
"%",
"app_name",
"try",
":",
"return",
"import_module",
"(",
"module_path",
")",
".",
"... | [
13,
0
] | [
22,
16
] | python | en | ['en', 'error', 'th'] | False |
get_lower_priority_apps | () |
Yield all app module names below the current app in the INSTALLED_APPS list
|
Yield all app module names below the current app in the INSTALLED_APPS list
| def get_lower_priority_apps():
"""
Yield all app module names below the current app in the INSTALLED_APPS list
"""
self_app_name = ".".join(__name__.split(".")[:-3])
reached_self = False
for app_config in apps.get_app_configs():
if app_config.name == self_app_name:
reached_se... | [
"def",
"get_lower_priority_apps",
"(",
")",
":",
"self_app_name",
"=",
"\".\"",
".",
"join",
"(",
"__name__",
".",
"split",
"(",
"\".\"",
")",
"[",
":",
"-",
"3",
"]",
")",
"reached_self",
"=",
"False",
"for",
"app_config",
"in",
"apps",
".",
"get_app_co... | [
25,
0
] | [
36,
23
] | python | en | ['en', 'error', 'th'] | False |
Blockchain.create | (
coin_store: CoinStore,
block_store: BlockStore,
consensus_constants: ConsensusConstants,
) |
Initializes a blockchain with the BlockRecords from disk, assuming they have all been
validated. Uses the genesis block given in override_constants, or as a fallback,
in the consensus constants config.
|
Initializes a blockchain with the BlockRecords from disk, assuming they have all been
validated. Uses the genesis block given in override_constants, or as a fallback,
in the consensus constants config.
| async def create(
coin_store: CoinStore,
block_store: BlockStore,
consensus_constants: ConsensusConstants,
):
"""
Initializes a blockchain with the BlockRecords from disk, assuming they have all been
validated. Uses the genesis block given in override_constants, or as... | [
"async",
"def",
"create",
"(",
"coin_store",
":",
"CoinStore",
",",
"block_store",
":",
"BlockStore",
",",
"consensus_constants",
":",
"ConsensusConstants",
",",
")",
":",
"self",
"=",
"Blockchain",
"(",
")",
"self",
".",
"lock",
"=",
"asyncio",
".",
"Lock",... | [
87,
4
] | [
114,
19
] | python | en | ['en', 'error', 'th'] | False |
Blockchain._load_chain_from_store | (self) |
Initializes the state of the Blockchain class from the database.
|
Initializes the state of the Blockchain class from the database.
| async def _load_chain_from_store(self) -> None:
"""
Initializes the state of the Blockchain class from the database.
"""
height_to_hash, sub_epoch_summaries = await self.block_store.get_peak_height_dicts()
self.__height_to_hash = height_to_hash
self.__sub_epoch_summaries ... | [
"async",
"def",
"_load_chain_from_store",
"(",
"self",
")",
"->",
"None",
":",
"height_to_hash",
",",
"sub_epoch_summaries",
"=",
"await",
"self",
".",
"block_store",
".",
"get_peak_height_dicts",
"(",
")",
"self",
".",
"__height_to_hash",
"=",
"height_to_hash",
"... | [
120,
4
] | [
140,
66
] | python | en | ['en', 'error', 'th'] | False |
Blockchain.get_peak | (self) |
Return the peak of the blockchain
|
Return the peak of the blockchain
| def get_peak(self) -> Optional[BlockRecord]:
"""
Return the peak of the blockchain
"""
if self._peak_height is None:
return None
return self.height_to_block_record(self._peak_height) | [
"def",
"get_peak",
"(",
"self",
")",
"->",
"Optional",
"[",
"BlockRecord",
"]",
":",
"if",
"self",
".",
"_peak_height",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"height_to_block_record",
"(",
"self",
".",
"_peak_height",
")"
] | [
142,
4
] | [
148,
61
] | python | en | ['en', 'error', 'th'] | False |
Blockchain.get_full_peak | (self) | Return list of FullBlocks that are peaks | Return list of FullBlocks that are peaks | async def get_full_peak(self) -> Optional[FullBlock]:
if self._peak_height is None:
return None
""" Return list of FullBlocks that are peaks"""
block = await self.block_store.get_full_block(self.height_to_hash(self._peak_height))
assert block is not None
return block | [
"async",
"def",
"get_full_peak",
"(",
"self",
")",
"->",
"Optional",
"[",
"FullBlock",
"]",
":",
"if",
"self",
".",
"_peak_height",
"is",
"None",
":",
"return",
"None",
"block",
"=",
"await",
"self",
".",
"block_store",
".",
"get_full_block",
"(",
"self",
... | [
150,
4
] | [
156,
20
] | python | en | ['en', 'et', 'en'] | True |
Blockchain.receive_block | (
self,
block: FullBlock,
pre_validation_result: Optional[PreValidationResult] = None,
fork_point_with_peak: Optional[uint32] = None,
summaries_to_check: List[SubEpochSummary] = None, # passed only on long sync
) |
This method must be called under the blockchain lock
Adds a new block into the blockchain, if it's valid and connected to the current
blockchain, regardless of whether it is the child of a head, or another block.
Returns a header if block is added to head. Returns an error if the block ... |
This method must be called under the blockchain lock
Adds a new block into the blockchain, if it's valid and connected to the current
blockchain, regardless of whether it is the child of a head, or another block.
Returns a header if block is added to head. Returns an error if the block ... | async def receive_block(
self,
block: FullBlock,
pre_validation_result: Optional[PreValidationResult] = None,
fork_point_with_peak: Optional[uint32] = None,
summaries_to_check: List[SubEpochSummary] = None, # passed only on long sync
) -> Tuple[ReceiveBlockResult, Optional[E... | [
"async",
"def",
"receive_block",
"(",
"self",
",",
"block",
":",
"FullBlock",
",",
"pre_validation_result",
":",
"Optional",
"[",
"PreValidationResult",
"]",
"=",
"None",
",",
"fork_point_with_peak",
":",
"Optional",
"[",
"uint32",
"]",
"=",
"None",
",",
"summ... | [
161,
4
] | [
284,
65
] | python | en | ['en', 'error', 'th'] | False |
Blockchain._reconsider_peak | (
self,
block_record: BlockRecord,
genesis: bool,
fork_point_with_peak: Optional[uint32],
npc_result: Optional[NPCResult],
) |
When a new block is added, this is called, to check if the new block is the new peak of the chain.
This also handles reorgs by reverting blocks which are not in the heaviest chain.
It returns the height of the fork between the previous chain and the new chain, or returns
None if there w... |
When a new block is added, this is called, to check if the new block is the new peak of the chain.
This also handles reorgs by reverting blocks which are not in the heaviest chain.
It returns the height of the fork between the previous chain and the new chain, or returns
None if there w... | async def _reconsider_peak(
self,
block_record: BlockRecord,
genesis: bool,
fork_point_with_peak: Optional[uint32],
npc_result: Optional[NPCResult],
) -> Tuple[Optional[uint32], Optional[uint32], List[BlockRecord]]:
"""
When a new block is added, this is calle... | [
"async",
"def",
"_reconsider_peak",
"(",
"self",
",",
"block_record",
":",
"BlockRecord",
",",
"genesis",
":",
"bool",
",",
"fork_point_with_peak",
":",
"Optional",
"[",
"uint32",
"]",
",",
"npc_result",
":",
"Optional",
"[",
"NPCResult",
"]",
",",
")",
"->"... | [
286,
4
] | [
368,
29
] | python | en | ['en', 'error', 'th'] | False |
Blockchain.contains_block | (self, header_hash: bytes32) |
True if we have already added this block to the chain. This may return false for orphan blocks
that we have added but no longer keep in memory.
|
True if we have already added this block to the chain. This may return false for orphan blocks
that we have added but no longer keep in memory.
| def contains_block(self, header_hash: bytes32) -> bool:
"""
True if we have already added this block to the chain. This may return false for orphan blocks
that we have added but no longer keep in memory.
"""
return header_hash in self.__block_records | [
"def",
"contains_block",
"(",
"self",
",",
"header_hash",
":",
"bytes32",
")",
"->",
"bool",
":",
"return",
"header_hash",
"in",
"self",
".",
"__block_records"
] | [
559,
4
] | [
564,
50
] | python | en | ['en', 'error', 'th'] | False |
Blockchain.warmup | (self, fork_point: uint32) |
Loads blocks into the cache. The blocks loaded include all blocks from
fork point - BLOCKS_CACHE_SIZE up to and including the fork_point.
Args:
fork_point: the last block height to load in the cache
|
Loads blocks into the cache. The blocks loaded include all blocks from
fork point - BLOCKS_CACHE_SIZE up to and including the fork_point. | async def warmup(self, fork_point: uint32):
"""
Loads blocks into the cache. The blocks loaded include all blocks from
fork point - BLOCKS_CACHE_SIZE up to and including the fork_point.
Args:
fork_point: the last block height to load in the cache
"""
if self... | [
"async",
"def",
"warmup",
"(",
"self",
",",
"fork_point",
":",
"uint32",
")",
":",
"if",
"self",
".",
"_peak_height",
"is",
"None",
":",
"return",
"None",
"block_records",
"=",
"await",
"self",
".",
"block_store",
".",
"get_block_records_in_range",
"(",
"max... | [
588,
4
] | [
603,
47
] | python | en | ['en', 'error', 'th'] | False |
Blockchain.clean_block_record | (self, height: int) |
Clears all block records in the cache which have block_record < height.
Args:
height: Minimum height that we need to keep in the cache
|
Clears all block records in the cache which have block_record < height.
Args:
height: Minimum height that we need to keep in the cache
| def clean_block_record(self, height: int):
"""
Clears all block records in the cache which have block_record < height.
Args:
height: Minimum height that we need to keep in the cache
"""
if height < 0:
return None
blocks_to_remove = self.__heights_i... | [
"def",
"clean_block_record",
"(",
"self",
",",
"height",
":",
"int",
")",
":",
"if",
"height",
"<",
"0",
":",
"return",
"None",
"blocks_to_remove",
"=",
"self",
".",
"__heights_in_cache",
".",
"get",
"(",
"uint32",
"(",
"height",
")",
",",
"None",
")",
... | [
605,
4
] | [
620,
80
] | python | en | ['en', 'error', 'th'] | False |
Blockchain.clean_block_records | (self) |
Cleans the cache so that we only maintain relevant blocks. This removes
block records that have height < peak - BLOCKS_CACHE_SIZE.
These blocks are necessary for calculating future difficulty adjustments.
|
Cleans the cache so that we only maintain relevant blocks. This removes
block records that have height < peak - BLOCKS_CACHE_SIZE.
These blocks are necessary for calculating future difficulty adjustments.
| def clean_block_records(self):
"""
Cleans the cache so that we only maintain relevant blocks. This removes
block records that have height < peak - BLOCKS_CACHE_SIZE.
These blocks are necessary for calculating future difficulty adjustments.
"""
if len(self.__block_records... | [
"def",
"clean_block_records",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"__block_records",
")",
"<",
"self",
".",
"constants",
".",
"BLOCKS_CACHE_SIZE",
":",
"return",
"None",
"peak",
"=",
"self",
".",
"get_peak",
"(",
")",
"assert",
"peak",
... | [
622,
4
] | [
636,
79
] | python | en | ['en', 'error', 'th'] | False |
Blockchain.get_block_records_at | (self, heights: List[uint32], batch_size=900) |
gets block records by height (only blocks that are part of the chain)
|
gets block records by height (only blocks that are part of the chain)
| async def get_block_records_at(self, heights: List[uint32], batch_size=900) -> List[BlockRecord]:
"""
gets block records by height (only blocks that are part of the chain)
"""
records: List[BlockRecord] = []
hashes = []
assert batch_size < 999 # sqlite in python 3.7 has ... | [
"async",
"def",
"get_block_records_at",
"(",
"self",
",",
"heights",
":",
"List",
"[",
"uint32",
"]",
",",
"batch_size",
"=",
"900",
")",
"->",
"List",
"[",
"BlockRecord",
"]",
":",
"records",
":",
"List",
"[",
"BlockRecord",
"]",
"=",
"[",
"]",
"hashe... | [
687,
4
] | [
704,
22
] | python | en | ['en', 'error', 'th'] | False |
Blockchain.add_block_record | (self, block_record: BlockRecord) |
Adds a block record to the cache.
|
Adds a block record to the cache.
| def add_block_record(self, block_record: BlockRecord):
"""
Adds a block record to the cache.
"""
self.__block_records[block_record.header_hash] = block_record
if block_record.height not in self.__heights_in_cache.keys():
self.__heights_in_cache[block_record.height] =... | [
"def",
"add_block_record",
"(",
"self",
",",
"block_record",
":",
"BlockRecord",
")",
":",
"self",
".",
"__block_records",
"[",
"block_record",
".",
"header_hash",
"]",
"=",
"block_record",
"if",
"block_record",
".",
"height",
"not",
"in",
"self",
".",
"__heig... | [
716,
4
] | [
724,
82
] | python | en | ['en', 'error', 'th'] | False |
test_label_access_admin | (organization_factory) | can_change because I am an admin of that org | can_change because I am an admin of that org | def test_label_access_admin(organization_factory):
'''can_change because I am an admin of that org'''
no_members = organization_factory("no_members")
members = organization_factory("has_members", users=['admin'], labels=['test'])
label = members.labels.test
admin = members.users.admin
members.o... | [
"def",
"test_label_access_admin",
"(",
"organization_factory",
")",
":",
"no_members",
"=",
"organization_factory",
"(",
"\"no_members\"",
")",
"members",
"=",
"organization_factory",
"(",
"\"has_members\"",
",",
"users",
"=",
"[",
"'admin'",
"]",
",",
"labels",
"="... | [
48,
0
] | [
62,
35
] | python | en | ['en', 'en', 'en'] | True |
current_umask | () | Get the current umask which involves having to set it temporarily. | Get the current umask which involves having to set it temporarily. | def current_umask() -> int:
"""Get the current umask which involves having to set it temporarily."""
mask = os.umask(0)
os.umask(mask)
return mask | [
"def",
"current_umask",
"(",
")",
"->",
"int",
":",
"mask",
"=",
"os",
".",
"umask",
"(",
"0",
")",
"os",
".",
"umask",
"(",
"mask",
")",
"return",
"mask"
] | [
11,
0
] | [
15,
15
] | python | en | ['en', 'en', 'en'] | True |
set_extracted_file_to_default_mode_plus_executable | (path: str) |
Make file present at path have execute for user/group/world
(chmod +x) is no-op on windows per python docs
|
Make file present at path have execute for user/group/world
(chmod +x) is no-op on windows per python docs
| def set_extracted_file_to_default_mode_plus_executable(path: str) -> None:
"""
Make file present at path have execute for user/group/world
(chmod +x) is no-op on windows per python docs
"""
os.chmod(path, (0o777 & ~current_umask() | 0o111)) | [
"def",
"set_extracted_file_to_default_mode_plus_executable",
"(",
"path",
":",
"str",
")",
"->",
"None",
":",
"os",
".",
"chmod",
"(",
"path",
",",
"(",
"0o777",
"&",
"~",
"current_umask",
"(",
")",
"|",
"0o111",
")",
")"
] | [
18,
0
] | [
23,
54
] | python | en | ['en', 'error', 'th'] | False |
get_dist_info | (wheel_dir: str) | Returns the relative path to the dist-info directory if it exists.
Args:
wheel_dir: The root of the extracted wheel directory.
Returns:
Relative path to the dist-info directory if it exists, else, None.
| Returns the relative path to the dist-info directory if it exists. | def get_dist_info(wheel_dir: str) -> str:
""""Returns the relative path to the dist-info directory if it exists.
Args:
wheel_dir: The root of the extracted wheel directory.
Returns:
Relative path to the dist-info directory if it exists, else, None.
"""
dist_info_dirs = glob.glob(o... | [
"def",
"get_dist_info",
"(",
"wheel_dir",
":",
"str",
")",
"->",
"str",
":",
"dist_info_dirs",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"wheel_dir",
",",
"\"*.dist-info\"",
")",
")",
"if",
"not",
"dist_info_dirs",
":",
"raise",... | [
76,
0
] | [
97,
28
] | python | en | ['en', 'en', 'en'] | True |
get_dot_data_directory | (wheel_dir: str) | Returns the relative path to the data directory if it exists.
See: https://www.python.org/dev/peps/pep-0491/#the-data-directory
Args:
wheel_dir: The root of the extracted wheel directory.
Returns:
Relative path to the data directory if it exists, else, None.
| Returns the relative path to the data directory if it exists. | def get_dot_data_directory(wheel_dir: str) -> Optional[str]:
"""Returns the relative path to the data directory if it exists.
See: https://www.python.org/dev/peps/pep-0491/#the-data-directory
Args:
wheel_dir: The root of the extracted wheel directory.
Returns:
Relative path to the da... | [
"def",
"get_dot_data_directory",
"(",
"wheel_dir",
":",
"str",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"dot_data_dirs",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"wheel_dir",
",",
"\"*.data\"",
")",
")",
"if",
"not",
"dot... | [
100,
0
] | [
121,
27
] | python | en | ['en', 'en', 'en'] | True |
parse_wheel_meta_file | (wheel_dir: str) | Parses the given WHEEL file into a dictionary.
Args:
wheel_dir: The file path of the WHEEL metadata file in dist-info.
Returns:
The WHEEL file mapped into a dictionary.
| Parses the given WHEEL file into a dictionary. | def parse_wheel_meta_file(wheel_dir: str) -> Dict[str, str]:
"""Parses the given WHEEL file into a dictionary.
Args:
wheel_dir: The file path of the WHEEL metadata file in dist-info.
Returns:
The WHEEL file mapped into a dictionary.
"""
contents = {}
with open(wheel_dir, "r") ... | [
"def",
"parse_wheel_meta_file",
"(",
"wheel_dir",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"contents",
"=",
"{",
"}",
"with",
"open",
"(",
"wheel_dir",
",",
"\"r\"",
")",
"as",
"wheel_file",
":",
"for",
"line",
"in",
"wheel_file... | [
124,
0
] | [
146,
19
] | python | en | ['en', 'en', 'en'] | True |
test_organization_copy_to_jobs | () |
All unified job types should infer their organization from their template organization
|
All unified job types should infer their organization from their template organization
| def test_organization_copy_to_jobs():
"""
All unified job types should infer their organization from their template organization
"""
for cls in UnifiedJobTemplate.__subclasses__():
if cls is WorkflowApprovalTemplate:
continue # these do not track organization
assert 'organiz... | [
"def",
"test_organization_copy_to_jobs",
"(",
")",
":",
"for",
"cls",
"in",
"UnifiedJobTemplate",
".",
"__subclasses__",
"(",
")",
":",
"if",
"cls",
"is",
"WorkflowApprovalTemplate",
":",
"continue",
"# these do not track organization",
"assert",
"'organization'",
"in",... | [
57,
0
] | [
64,
72
] | python | en | ['en', 'error', 'th'] | False |
test_log_representation | () |
Common representation used inside of log messages
|
Common representation used inside of log messages
| def test_log_representation():
"""
Common representation used inside of log messages
"""
uj = UnifiedJob(status='running', id=4)
job = Job(status='running', id=4)
assert job.log_format == 'job 4 (running)'
assert uj.log_format == 'unified_job 4 (running)' | [
"def",
"test_log_representation",
"(",
")",
":",
"uj",
"=",
"UnifiedJob",
"(",
"status",
"=",
"'running'",
",",
"id",
"=",
"4",
")",
"job",
"=",
"Job",
"(",
"status",
"=",
"'running'",
",",
"id",
"=",
"4",
")",
"assert",
"job",
".",
"log_format",
"==... | [
67,
0
] | [
74,
53
] | python | en | ['en', 'error', 'th'] | False |
Custom.__init__ | (self, args) |
TODO: Write Comment
|
TODO: Write Comment
| def __init__(self, args):
"""
TODO: Write Comment
"""
self.name = args.custom_name
CifarModel.__init__(self, args) | [
"def",
"__init__",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"name",
"=",
"args",
".",
"custom_name",
"CifarModel",
".",
"__init__",
"(",
"self",
",",
"args",
")"
] | [
10,
4
] | [
16,
39
] | python | en | ['en', 'error', 'th'] | False |
Custom.load | (self) |
TODO: Write Comment
|
TODO: Write Comment
| def load(self):
"""
TODO: Write Comment
"""
if self.args.verbose: print(f"Loading Model...")
self._model = self.load_model(f"{self.log_filepath}model.h5")
self._model.load_weights(f"{self.log_filepath}model_weights.h5") | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"self",
".",
"args",
".",
"verbose",
":",
"print",
"(",
"f\"Loading Model...\"",
")",
"self",
".",
"_model",
"=",
"self",
".",
"load_model",
"(",
"f\"{self.log_filepath}model.h5\"",
")",
"self",
".",
"_model",
".... | [
18,
4
] | [
26,
72
] | python | en | ['en', 'error', 'th'] | False |
PSDraw.begin_document | (self, id=None) | Set up printing of a document. (Write PostScript DSC header.) | Set up printing of a document. (Write PostScript DSC header.) | def begin_document(self, id=None):
"""Set up printing of a document. (Write PostScript DSC header.)"""
# FIXME: incomplete
self._fp_write(
"%!PS-Adobe-3.0\n"
"save\n"
"/showpage { } def\n"
"%%EndComments\n"
"%%BeginDocument\n"
)... | [
"def",
"begin_document",
"(",
"self",
",",
"id",
"=",
"None",
")",
":",
"# FIXME: incomplete",
"self",
".",
"_fp_write",
"(",
"\"%!PS-Adobe-3.0\\n\"",
"\"save\\n\"",
"\"/showpage { } def\\n\"",
"\"%%EndComments\\n\"",
"\"%%BeginDocument\\n\"",
")",
"# self._fp_write(ERROR_P... | [
42,
4
] | [
56,
25
] | python | en | ['en', 'lb', 'en'] | True |
PSDraw.end_document | (self) | Ends printing. (Write PostScript DSC footer.) | Ends printing. (Write PostScript DSC footer.) | def end_document(self):
"""Ends printing. (Write PostScript DSC footer.)"""
self._fp_write("%%EndDocument\nrestore showpage\n%%End\n")
if hasattr(self.fp, "flush"):
self.fp.flush() | [
"def",
"end_document",
"(",
"self",
")",
":",
"self",
".",
"_fp_write",
"(",
"\"%%EndDocument\\nrestore showpage\\n%%End\\n\"",
")",
"if",
"hasattr",
"(",
"self",
".",
"fp",
",",
"\"flush\"",
")",
":",
"self",
".",
"fp",
".",
"flush",
"(",
")"
] | [
58,
4
] | [
62,
27
] | python | en | ['en', 'en', 'en'] | True |
PSDraw.setfont | (self, font, size) |
Selects which font to use.
:param font: A PostScript font name
:param size: Size in points.
|
Selects which font to use. | def setfont(self, font, size):
"""
Selects which font to use.
:param font: A PostScript font name
:param size: Size in points.
"""
if font not in self.isofont:
# reencode font
self._fp_write(f"/PSDraw-{font} ISOLatin1Encoding /{font} E\n")
... | [
"def",
"setfont",
"(",
"self",
",",
"font",
",",
"size",
")",
":",
"if",
"font",
"not",
"in",
"self",
".",
"isofont",
":",
"# reencode font",
"self",
".",
"_fp_write",
"(",
"f\"/PSDraw-{font} ISOLatin1Encoding /{font} E\\n\"",
")",
"self",
".",
"isofont",
"[",... | [
64,
4
] | [
76,
56
] | python | en | ['en', 'error', 'th'] | False |
PSDraw.line | (self, xy0, xy1) |
Draws a line between the two points. Coordinates are given in
PostScript point coordinates (72 points per inch, (0, 0) is the lower
left corner of the page).
|
Draws a line between the two points. Coordinates are given in
PostScript point coordinates (72 points per inch, (0, 0) is the lower
left corner of the page).
| def line(self, xy0, xy1):
"""
Draws a line between the two points. Coordinates are given in
PostScript point coordinates (72 points per inch, (0, 0) is the lower
left corner of the page).
"""
self._fp_write("%d %d %d %d Vl\n" % (*xy0, *xy1)) | [
"def",
"line",
"(",
"self",
",",
"xy0",
",",
"xy1",
")",
":",
"self",
".",
"_fp_write",
"(",
"\"%d %d %d %d Vl\\n\"",
"%",
"(",
"*",
"xy0",
",",
"*",
"xy1",
")",
")"
] | [
78,
4
] | [
84,
57
] | python | en | ['en', 'error', 'th'] | False |
PSDraw.rectangle | (self, box) |
Draws a rectangle.
:param box: A 4-tuple of integers whose order and function is currently
undocumented.
Hint: the tuple is passed into this format string:
.. code-block:: python
%d %d M %d %d 0 Vr\n
|
Draws a rectangle. | def rectangle(self, box):
"""
Draws a rectangle.
:param box: A 4-tuple of integers whose order and function is currently
undocumented.
Hint: the tuple is passed into this format string:
.. code-block:: python
... | [
"def",
"rectangle",
"(",
"self",
",",
"box",
")",
":",
"self",
".",
"_fp_write",
"(",
"\"%d %d M %d %d 0 Vr\\n\"",
"%",
"box",
")"
] | [
86,
4
] | [
99,
52
] | python | en | ['en', 'error', 'th'] | False |
PSDraw.text | (self, xy, text) |
Draws text at the given position. You must use
:py:meth:`~PIL.PSDraw.PSDraw.setfont` before calling this method.
|
Draws text at the given position. You must use
:py:meth:`~PIL.PSDraw.PSDraw.setfont` before calling this method.
| def text(self, xy, text):
"""
Draws text at the given position. You must use
:py:meth:`~PIL.PSDraw.PSDraw.setfont` before calling this method.
"""
text = "\\(".join(text.split("("))
text = "\\)".join(text.split(")"))
self._fp_write(f"{xy[0]} {xy[1]} M ({text}) S\n... | [
"def",
"text",
"(",
"self",
",",
"xy",
",",
"text",
")",
":",
"text",
"=",
"\"\\\\(\"",
".",
"join",
"(",
"text",
".",
"split",
"(",
"\"(\"",
")",
")",
"text",
"=",
"\"\\\\)\"",
".",
"join",
"(",
"text",
".",
"split",
"(",
"\")\"",
")",
")",
"s... | [
101,
4
] | [
108,
57
] | python | en | ['en', 'error', 'th'] | False |
PSDraw.image | (self, box, im, dpi=None) | Draw a PIL image, centered in the given box. | Draw a PIL image, centered in the given box. | def image(self, box, im, dpi=None):
"""Draw a PIL image, centered in the given box."""
# default resolution depends on mode
if not dpi:
if im.mode == "1":
dpi = 200 # fax
else:
dpi = 100 # greyscale
# image size (on paper)
... | [
"def",
"image",
"(",
"self",
",",
"box",
",",
"im",
",",
"dpi",
"=",
"None",
")",
":",
"# default resolution depends on mode",
"if",
"not",
"dpi",
":",
"if",
"im",
".",
"mode",
"==",
"\"1\"",
":",
"dpi",
"=",
"200",
"# fax",
"else",
":",
"dpi",
"=",
... | [
110,
4
] | [
139,
38
] | python | en | ['en', 'en', 'en'] | True |
addScriptOptions | (parser, pos_args, kw_args) | add script-specific script options | add script-specific script options | def addScriptOptions(parser, pos_args, kw_args):
""" add script-specific script options """
script_options_group = parser.add_argument_group('Options')
hlpstr = "Output 3' ends soft-clipped sequence? Output sequences " \
"are written from nearest ase upstream/downstream of the " ... | [
"def",
"addScriptOptions",
"(",
"parser",
",",
"pos_args",
",",
"kw_args",
")",
":",
"script_options_group",
"=",
"parser",
".",
"add_argument_group",
"(",
"'Options'",
")",
"hlpstr",
"=",
"\"Output 3' ends soft-clipped sequence? Output sequences \"",
"\"are written from ne... | [
113,
0
] | [
274,
37
] | python | en | ['en', 'it', 'en'] | True |
getRegionPadSeqs | (thisbam, region=None, minlength=0, region_pad=20, LOG_EVERY_N=1000,
logger=None) | parses a bam file gathering statistics
Returns a dictionary of various gathered statistics. | parses a bam file gathering statistics
Returns a dictionary of various gathered statistics. | def getRegionPadSeqs(thisbam, region=None, minlength=0, region_pad=20, LOG_EVERY_N=1000,
logger=None):
"""parses a bam file gathering statistics
Returns a dictionary of various gathered statistics."""
def readEndsInRegion(read, region, pad=20):
if str(read.referen... | [
"def",
"getRegionPadSeqs",
"(",
"thisbam",
",",
"region",
"=",
"None",
",",
"minlength",
"=",
"0",
",",
"region_pad",
"=",
"20",
",",
"LOG_EVERY_N",
"=",
"1000",
",",
"logger",
"=",
"None",
")",
":",
"def",
"readEndsInRegion",
"(",
"read",
",",
"region",... | [
276,
0
] | [
380,
42
] | python | en | ['en', 'en', 'en'] | True |
buildStartAndEndWigData | (thisbam, LOG_EVERY_N=1000, logger=None) | parses a bam file for 3' and 5' ends and builds these into wig-track data
Returns a dictionary of various gathered statistics. | parses a bam file for 3' and 5' ends and builds these into wig-track data
Returns a dictionary of various gathered statistics. | def buildStartAndEndWigData(thisbam, LOG_EVERY_N=1000, logger=None):
"""parses a bam file for 3' and 5' ends and builds these into wig-track data
Returns a dictionary of various gathered statistics."""
def formatToWig(wigdata):
""" take in the read position data and output in... | [
"def",
"buildStartAndEndWigData",
"(",
"thisbam",
",",
"LOG_EVERY_N",
"=",
"1000",
",",
"logger",
"=",
"None",
")",
":",
"def",
"formatToWig",
"(",
"wigdata",
")",
":",
"\"\"\" take in the read position data and output in wigTrack format\"\"\"",
"this_wigTracks",
"=",
"... | [
382,
0
] | [
461,
35
] | python | en | ['en', 'en', 'en'] | True |
get_object_from_data | (field, Model, data, obj=None) |
Utility method to obtain related object in data according to fallbacks:
- if data contains key with pointer to Django object, return that
- if contains integer, get object from database
- if this does not work, raise exception
|
Utility method to obtain related object in data according to fallbacks:
- if data contains key with pointer to Django object, return that
- if contains integer, get object from database
- if this does not work, raise exception
| def get_object_from_data(field, Model, data, obj=None):
"""
Utility method to obtain related object in data according to fallbacks:
- if data contains key with pointer to Django object, return that
- if contains integer, get object from database
- if this does not work, raise exception
"""
... | [
"def",
"get_object_from_data",
"(",
"field",
",",
"Model",
",",
"data",
",",
"obj",
"=",
"None",
")",
":",
"try",
":",
"raw_value",
"=",
"data",
"[",
"field",
"]",
"except",
"KeyError",
":",
"# Calling method needs to deal with non-existence of key",
"raise",
"P... | [
93,
0
] | [
120,
74
] | python | en | ['en', 'error', 'th'] | False |
vars_are_encrypted | (vars) | Returns True if any of the values in the dictionary vars contains
content which is encrypted by the AWX encryption algorithm
| Returns True if any of the values in the dictionary vars contains
content which is encrypted by the AWX encryption algorithm
| def vars_are_encrypted(vars):
"""Returns True if any of the values in the dictionary vars contains
content which is encrypted by the AWX encryption algorithm
"""
for value in vars.values():
if isinstance(value, str):
if value.startswith('$encrypted$'):
return True
... | [
"def",
"vars_are_encrypted",
"(",
"vars",
")",
":",
"for",
"value",
"in",
"vars",
".",
"values",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"if",
"value",
".",
"startswith",
"(",
"'$encrypted$'",
")",
":",
"return",
"True",
... | [
123,
0
] | [
131,
16
] | python | en | ['en', 'en', 'en'] | True |
get_user_queryset | (user, model_class) |
Return a queryset for the given model_class containing only the instances
that should be visible to the given user.
|
Return a queryset for the given model_class containing only the instances
that should be visible to the given user.
| def get_user_queryset(user, model_class):
"""
Return a queryset for the given model_class containing only the instances
that should be visible to the given user.
"""
access_class = access_registry[model_class]
access_instance = access_class(user)
return access_instance.get_queryset() | [
"def",
"get_user_queryset",
"(",
"user",
",",
"model_class",
")",
":",
"access_class",
"=",
"access_registry",
"[",
"model_class",
"]",
"access_instance",
"=",
"access_class",
"(",
"user",
")",
"return",
"access_instance",
".",
"get_queryset",
"(",
")"
] | [
142,
0
] | [
149,
41
] | python | en | ['en', 'error', 'th'] | False |
check_user_access | (user, model_class, action, *args, **kwargs) |
Return True if user can perform action against model_class with the
provided parameters.
|
Return True if user can perform action against model_class with the
provided parameters.
| def check_user_access(user, model_class, action, *args, **kwargs):
"""
Return True if user can perform action against model_class with the
provided parameters.
"""
access_class = access_registry[model_class]
access_instance = access_class(user)
access_method = getattr(access_instance, 'can_%... | [
"def",
"check_user_access",
"(",
"user",
",",
"model_class",
",",
"action",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"access_class",
"=",
"access_registry",
"[",
"model_class",
"]",
"access_instance",
"=",
"access_class",
"(",
"user",
")",
"acces... | [
152,
0
] | [
162,
17
] | python | en | ['en', 'error', 'th'] | False |
check_user_access_with_errors | (user, model_class, action, *args, **kwargs) |
Return T/F permission and summary of problems with the action.
|
Return T/F permission and summary of problems with the action.
| def check_user_access_with_errors(user, model_class, action, *args, **kwargs):
"""
Return T/F permission and summary of problems with the action.
"""
access_class = access_registry[model_class]
access_instance = access_class(user, save_messages=True)
access_method = getattr(access_instance, 'can... | [
"def",
"check_user_access_with_errors",
"(",
"user",
",",
"model_class",
",",
"action",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"access_class",
"=",
"access_registry",
"[",
"model_class",
"]",
"access_instance",
"=",
"access_class",
"(",
"user",
"... | [
165,
0
] | [
174,
45
] | python | en | ['en', 'error', 'th'] | False |
get_user_capabilities | (user, instance, **kwargs) |
Returns a dictionary of capabilities the user has on the particular
instance. *NOTE* This is not a direct mapping of can_* methods into this
dictionary, it is intended to munge some queries in a way that is
convenient for the user interface to consume and hide or show various
actions in the interf... |
Returns a dictionary of capabilities the user has on the particular
instance. *NOTE* This is not a direct mapping of can_* methods into this
dictionary, it is intended to munge some queries in a way that is
convenient for the user interface to consume and hide or show various
actions in the interf... | def get_user_capabilities(user, instance, **kwargs):
"""
Returns a dictionary of capabilities the user has on the particular
instance. *NOTE* This is not a direct mapping of can_* methods into this
dictionary, it is intended to munge some queries in a way that is
convenient for the user interface t... | [
"def",
"get_user_capabilities",
"(",
"user",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"access_class",
"=",
"access_registry",
"[",
"instance",
".",
"__class__",
"]",
"return",
"access_class",
"(",
"user",
")",
".",
"get_user_capabilities",
"(",
"ins... | [
177,
0
] | [
186,
71
] | python | en | ['en', 'error', 'th'] | False |
check_superuser | (func) |
check_superuser is a decorator that provides a simple short circuit
for access checks. If the User object is a superuser, return True, otherwise
execute the logic of the can_access method.
|
check_superuser is a decorator that provides a simple short circuit
for access checks. If the User object is a superuser, return True, otherwise
execute the logic of the can_access method.
| def check_superuser(func):
"""
check_superuser is a decorator that provides a simple short circuit
for access checks. If the User object is a superuser, return True, otherwise
execute the logic of the can_access method.
"""
def wrapper(self, *args, **kwargs):
if self.user.is_superuser:
... | [
"def",
"check_superuser",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"user",
".",
"is_superuser",
":",
"return",
"True",
"return",
"func",
"(",
"self",
",",
"*",
"ar... | [
189,
0
] | [
201,
18
] | python | en | ['en', 'error', 'th'] | False |
consumer_access | (group_name) |
consumer_access returns the proper Access class based on group_name
for a channels consumer.
|
consumer_access returns the proper Access class based on group_name
for a channels consumer.
| def consumer_access(group_name):
"""
consumer_access returns the proper Access class based on group_name
for a channels consumer.
"""
class_map = {'job_events': JobAccess, 'workflow_events': WorkflowJobAccess, 'ad_hoc_command_events': AdHocCommandAccess}
return class_map.get(group_name) | [
"def",
"consumer_access",
"(",
"group_name",
")",
":",
"class_map",
"=",
"{",
"'job_events'",
":",
"JobAccess",
",",
"'workflow_events'",
":",
"WorkflowJobAccess",
",",
"'ad_hoc_command_events'",
":",
"AdHocCommandAccess",
"}",
"return",
"class_map",
".",
"get",
"("... | [
204,
0
] | [
210,
36
] | 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.