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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
WalletBlockStore.add_block_record | (self, header_block_record: HeaderBlockRecord, block_record: BlockRecord) |
Adds a block record to the database. This block record is assumed to be connected
to the chain, but it may or may not be in the LCA path.
|
Adds a block record to the database. This block record is assumed to be connected
to the chain, but it may or may not be in the LCA path.
| async def add_block_record(self, header_block_record: HeaderBlockRecord, block_record: BlockRecord):
"""
Adds a block record to the database. This block record is assumed to be connected
to the chain, but it may or may not be in the LCA path.
"""
cached = self.block_cache.get(hea... | [
"async",
"def",
"add_block_record",
"(",
"self",
",",
"header_block_record",
":",
"HeaderBlockRecord",
",",
"block_record",
":",
"BlockRecord",
")",
":",
"cached",
"=",
"self",
".",
"block_cache",
".",
"get",
"(",
"header_block_record",
".",
"header_hash",
")",
... | [
64,
4
] | [
106,
30
] | python | en | ['en', 'error', 'th'] | False |
WalletBlockStore.get_header_block_record | (self, header_hash: bytes32) | Gets a block record from the database, if present | Gets a block record from the database, if present | async def get_header_block_record(self, header_hash: bytes32) -> Optional[HeaderBlockRecord]:
"""Gets a block record from the database, if present"""
cached = self.block_cache.get(header_hash)
if cached is not None:
return cached
cursor = await self.db.execute("SELECT block f... | [
"async",
"def",
"get_header_block_record",
"(",
"self",
",",
"header_hash",
":",
"bytes32",
")",
"->",
"Optional",
"[",
"HeaderBlockRecord",
"]",
":",
"cached",
"=",
"self",
".",
"block_cache",
".",
"get",
"(",
"header_hash",
")",
"if",
"cached",
"is",
"not"... | [
119,
4
] | [
132,
23
] | python | en | ['en', 'en', 'en'] | True |
WalletBlockStore.get_block_records | (
self,
) |
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
|
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
| async def get_block_records(
self,
) -> Tuple[Dict[bytes32, BlockRecord], Optional[bytes32]]:
"""
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
"""
cursor = await self.db.execute("SELECT header_hash, block, is_peak from bloc... | [
"async",
"def",
"get_block_records",
"(",
"self",
",",
")",
"->",
"Tuple",
"[",
"Dict",
"[",
"bytes32",
",",
"BlockRecord",
"]",
",",
"Optional",
"[",
"bytes32",
"]",
"]",
":",
"cursor",
"=",
"await",
"self",
".",
"db",
".",
"execute",
"(",
"\"SELECT h... | [
145,
4
] | [
164,
24
] | python | en | ['en', 'error', 'th'] | False |
WalletBlockStore.get_block_records_close_to_peak | (
self, blocks_n: int
) |
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
|
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
| async def get_block_records_close_to_peak(
self, blocks_n: int
) -> Tuple[Dict[bytes32, BlockRecord], Optional[bytes32]]:
"""
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
"""
res = await self.db.execute("SELECT header_hash... | [
"async",
"def",
"get_block_records_close_to_peak",
"(",
"self",
",",
"blocks_n",
":",
"int",
")",
"->",
"Tuple",
"[",
"Dict",
"[",
"bytes32",
",",
"BlockRecord",
"]",
",",
"Optional",
"[",
"bytes32",
"]",
"]",
":",
"res",
"=",
"await",
"self",
".",
"db",... | [
175,
4
] | [
200,
24
] | python | en | ['en', 'error', 'th'] | False |
WalletBlockStore.get_block_records_in_range | (
self,
start: int,
stop: int,
) |
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
|
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
| async def get_block_records_in_range(
self,
start: int,
stop: int,
) -> Dict[bytes32, BlockRecord]:
"""
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
"""
formatted_str = f"SELECT header_hash, block from bloc... | [
"async",
"def",
"get_block_records_in_range",
"(",
"self",
",",
"start",
":",
"int",
",",
"stop",
":",
"int",
",",
")",
"->",
"Dict",
"[",
"bytes32",
",",
"BlockRecord",
"]",
":",
"formatted_str",
"=",
"f\"SELECT header_hash, block from block_records WHERE height >=... | [
221,
4
] | [
242,
18
] | python | en | ['en', 'error', 'th'] | False |
WalletBlockStore.get_peak_heights_dicts | (self) |
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
|
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
| async def get_peak_heights_dicts(self) -> Tuple[Dict[uint32, bytes32], Dict[uint32, SubEpochSummary]]:
"""
Returns a dictionary with all blocks, as well as the header hash of the peak,
if present.
"""
res = await self.db.execute("SELECT header_hash from block_records WHERE is_pe... | [
"async",
"def",
"get_peak_heights_dicts",
"(",
"self",
")",
"->",
"Tuple",
"[",
"Dict",
"[",
"uint32",
",",
"bytes32",
"]",
",",
"Dict",
"[",
"uint32",
",",
"SubEpochSummary",
"]",
"]",
":",
"res",
"=",
"await",
"self",
".",
"db",
".",
"execute",
"(",
... | [
244,
4
] | [
283,
50
] | python | en | ['en', 'error', 'th'] | False |
AsyncToSync._run_event_loop | (self, loop, coro) |
Runs the given event loop (designed to be called in a thread).
|
Runs the given event loop (designed to be called in a thread).
| def _run_event_loop(self, loop, coro):
"""
Runs the given event loop (designed to be called in a thread).
"""
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(coro)
finally:
try:
# mimic asyncio.run() behavior
... | [
"def",
"_run_event_loop",
"(",
"self",
",",
"loop",
",",
"coro",
")",
":",
"asyncio",
".",
"set_event_loop",
"(",
"loop",
")",
"try",
":",
"loop",
".",
"run_until_complete",
"(",
"coro",
")",
"finally",
":",
"try",
":",
"# mimic asyncio.run() behavior",
"# c... | [
148,
4
] | [
181,
60
] | python | en | ['en', 'error', 'th'] | False |
AsyncToSync.__get__ | (self, parent, objtype) |
Include self for methods
|
Include self for methods
| def __get__(self, parent, objtype):
"""
Include self for methods
"""
func = functools.partial(self.__call__, parent)
return functools.update_wrapper(func, self.awaitable) | [
"def",
"__get__",
"(",
"self",
",",
"parent",
",",
"objtype",
")",
":",
"func",
"=",
"functools",
".",
"partial",
"(",
"self",
".",
"__call__",
",",
"parent",
")",
"return",
"functools",
".",
"update_wrapper",
"(",
"func",
",",
"self",
".",
"awaitable",
... | [
183,
4
] | [
188,
61
] | python | en | ['en', 'error', 'th'] | False |
AsyncToSync.main_wrap | (
self, args, kwargs, call_result, source_thread, exc_info, context
) |
Wraps the awaitable with something that puts the result into the
result/exception future.
|
Wraps the awaitable with something that puts the result into the
result/exception future.
| async def main_wrap(
self, args, kwargs, call_result, source_thread, exc_info, context
):
"""
Wraps the awaitable with something that puts the result into the
result/exception future.
"""
if context is not None:
_restore_context(context[0])
curren... | [
"async",
"def",
"main_wrap",
"(",
"self",
",",
"args",
",",
"kwargs",
",",
"call_result",
",",
"source_thread",
",",
"exc_info",
",",
"context",
")",
":",
"if",
"context",
"is",
"not",
"None",
":",
"_restore_context",
"(",
"context",
"[",
"0",
"]",
")",
... | [
190,
4
] | [
220,
55
] | python | en | ['en', 'error', 'th'] | False |
SyncToAsync.__get__ | (self, parent, objtype) |
Include self for methods
|
Include self for methods
| def __get__(self, parent, objtype):
"""
Include self for methods
"""
return functools.partial(self.__call__, parent) | [
"def",
"__get__",
"(",
"self",
",",
"parent",
",",
"objtype",
")",
":",
"return",
"functools",
".",
"partial",
"(",
"self",
".",
"__call__",
",",
"parent",
")"
] | [
310,
4
] | [
314,
55
] | python | en | ['en', 'error', 'th'] | False |
SyncToAsync.thread_handler | (self, loop, source_task, exc_info, func, *args, **kwargs) |
Wraps the sync application with exception handling.
|
Wraps the sync application with exception handling.
| def thread_handler(self, loop, source_task, exc_info, func, *args, **kwargs):
"""
Wraps the sync application with exception handling.
"""
# Set the threadlocal for AsyncToSync
self.threadlocal.main_event_loop = loop
self.threadlocal.main_event_loop_pid = os.getpid()
... | [
"def",
"thread_handler",
"(",
"self",
",",
"loop",
",",
"source_task",
",",
"exc_info",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set the threadlocal for AsyncToSync",
"self",
".",
"threadlocal",
".",
"main_event_loop",
"=",
"loop",
... | [
316,
4
] | [
347,
51
] | python | en | ['en', 'error', 'th'] | False |
SyncToAsync.get_current_task | () |
Cross-version implementation of asyncio.current_task()
Returns None if there is no task.
|
Cross-version implementation of asyncio.current_task() | def get_current_task():
"""
Cross-version implementation of asyncio.current_task()
Returns None if there is no task.
"""
try:
if hasattr(asyncio, "current_task"):
# Python 3.7 and up
return asyncio.current_task()
else:
... | [
"def",
"get_current_task",
"(",
")",
":",
"try",
":",
"if",
"hasattr",
"(",
"asyncio",
",",
"\"current_task\"",
")",
":",
"# Python 3.7 and up",
"return",
"asyncio",
".",
"current_task",
"(",
")",
"else",
":",
"# Python 3.6",
"return",
"asyncio",
".",
"Task",
... | [
350,
4
] | [
364,
23
] | python | en | ['en', 'error', 'th'] | False |
build_scripts.copy_scripts | (self) | r"""Copy each script listed in 'self.scripts'; if it's marked as a
Python script in the Unix way (first line matches 'first_line_re',
ie. starts with "\#!" and contains "python"), then adjust the first
line to refer to the current Python interpreter as we copy.
| r"""Copy each script listed in 'self.scripts'; if it's marked as a
Python script in the Unix way (first line matches 'first_line_re',
ie. starts with "\#!" and contains "python"), then adjust the first
line to refer to the current Python interpreter as we copy.
| def copy_scripts(self):
r"""Copy each script listed in 'self.scripts'; if it's marked as a
Python script in the Unix way (first line matches 'first_line_re',
ie. starts with "\#!" and contains "python"), then adjust the first
line to refer to the current Python interpreter as we copy.
... | [
"def",
"copy_scripts",
"(",
"self",
")",
":",
"self",
".",
"mkpath",
"(",
"self",
".",
"build_dir",
")",
"outfiles",
"=",
"[",
"]",
"updated_files",
"=",
"[",
"]",
"for",
"script",
"in",
"self",
".",
"scripts",
":",
"adjust",
"=",
"False",
"script",
... | [
52,
4
] | [
151,
38
] | python | en | ['en', 'en', 'en'] | True |
ContextCache.__missing__ | (self, key) |
Make a SiteSetting for a new Site
|
Make a SiteSetting for a new Site
| def __missing__(self, key):
"""
Make a SiteSetting for a new Site
"""
if not(isinstance(key, Site)):
raise TypeError
out = self[key] = SiteSettings(key)
return out | [
"def",
"__missing__",
"(",
"self",
",",
"key",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"key",
",",
"Site",
")",
")",
":",
"raise",
"TypeError",
"out",
"=",
"self",
"[",
"key",
"]",
"=",
"SiteSettings",
"(",
"key",
")",
"return",
"out"
] | [
21,
4
] | [
28,
18
] | python | en | ['en', 'error', 'th'] | False |
SiteSettings.__missing__ | (self, key) |
Get the settings instance for this site, and store it for later
|
Get the settings instance for this site, and store it for later
| def __missing__(self, key):
"""
Get the settings instance for this site, and store it for later
"""
try:
app_label, model_name = key.split('.', 1)
except ValueError:
raise KeyError('Invalid model name: {}'.format(key))
Model = registry.get_by_natur... | [
"def",
"__missing__",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"app_label",
",",
"model_name",
"=",
"key",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
":",
"raise",
"KeyError",
"(",
"'Invalid model name: {}'",
".",
"format",
"(... | [
43,
4
] | [
56,
18
] | python | en | ['en', 'error', 'th'] | False |
_InstallRequirementBackedCandidate.project_name | (self) | The normalised name of the project the candidate refers to | The normalised name of the project the candidate refers to | def project_name(self):
# type: () -> str
"""The normalised name of the project the candidate refers to"""
if self._name is None:
self._name = canonicalize_name(self.dist.project_name)
return self._name | [
"def",
"project_name",
"(",
"self",
")",
":",
"# type: () -> str",
"if",
"self",
".",
"_name",
"is",
"None",
":",
"self",
".",
"_name",
"=",
"canonicalize_name",
"(",
"self",
".",
"dist",
".",
"project_name",
")",
"return",
"self",
".",
"_name"
] | [
177,
4
] | [
182,
25
] | python | en | ['en', 'en', 'en'] | True |
_InstallRequirementBackedCandidate._check_metadata_consistency | (self, dist) | Check for consistency of project name and version of dist. | Check for consistency of project name and version of dist. | def _check_metadata_consistency(self, dist):
# type: (Distribution) -> None
"""Check for consistency of project name and version of dist."""
# TODO: (Longer term) Rather than abort, reject this candidate
# and backtrack. This would need resolvelib support.
name = canonicali... | [
"def",
"_check_metadata_consistency",
"(",
"self",
",",
"dist",
")",
":",
"# type: (Distribution) -> None",
"# TODO: (Longer term) Rather than abort, reject this candidate",
"# and backtrack. This would need resolvelib support.",
"name",
"=",
"canonicalize_name",
"(",
"dist",
"... | [
208,
4
] | [
218,
75
] | python | en | ['en', 'en', 'en'] | True |
ExtrasCandidate.name | (self) | The normalised name of the project the candidate refers to | The normalised name of the project the candidate refers to | def name(self):
# type: () -> str
"""The normalised name of the project the candidate refers to"""
return format_name(self.base.project_name, self.extras) | [
"def",
"name",
"(",
"self",
")",
":",
"# type: () -> str",
"return",
"format_name",
"(",
"self",
".",
"base",
".",
"project_name",
",",
"self",
".",
"extras",
")"
] | [
499,
4
] | [
502,
63
] | python | en | ['en', 'en', 'en'] | True |
TestCheckUrl.test_crafty_disallowed_url_scheme | (self) |
Some URL parsers do not parse 'jav\tascript:' as a valid scheme.
Browsers, however, do. The checker needs to catch these crafty schemes
|
Some URL parsers do not parse 'jav\tascript:' as a valid scheme.
Browsers, however, do. The checker needs to catch these crafty schemes
| def test_crafty_disallowed_url_scheme(self):
"""
Some URL parsers do not parse 'jav\tascript:' as a valid scheme.
Browsers, however, do. The checker needs to catch these crafty schemes
"""
self.assertFalse(bool(check_url("jav\tascript:alert('XSS')"))) | [
"def",
"test_crafty_disallowed_url_scheme",
"(",
"self",
")",
":",
"self",
".",
"assertFalse",
"(",
"bool",
"(",
"check_url",
"(",
"\"jav\\tascript:alert('XSS')\"",
")",
")",
")"
] | [
15,
4
] | [
20,
70
] | python | en | ['en', 'error', 'th'] | False |
TestAttributeRule.test_no_rule_for_attr | (self) |
Test that attribute_rule() drops attributes for
which no rule has been defined.
|
Test that attribute_rule() drops attributes for
which no rule has been defined.
| def test_no_rule_for_attr(self):
"""
Test that attribute_rule() drops attributes for
which no rule has been defined.
"""
tag = self.soup.b
fn = attribute_rule({'snowman': 'barbecue'})
fn(tag)
self.assertEqual(str(tag), '<b>baz</b>') | [
"def",
"test_no_rule_for_attr",
"(",
"self",
")",
":",
"tag",
"=",
"self",
".",
"soup",
".",
"b",
"fn",
"=",
"attribute_rule",
"(",
"{",
"'snowman'",
":",
"'barbecue'",
"}",
")",
"fn",
"(",
"tag",
")",
"self",
".",
"assertEqual",
"(",
"str",
"(",
"ta... | [
27,
4
] | [
35,
48
] | python | en | ['en', 'error', 'th'] | False |
TestAttributeRule.test_rule_true_for_attr | (self) |
Test that attribute_rule() does not change attributes
when the corresponding rule returns True
|
Test that attribute_rule() does not change attributes
when the corresponding rule returns True
| def test_rule_true_for_attr(self):
"""
Test that attribute_rule() does not change attributes
when the corresponding rule returns True
"""
tag = self.soup.b
fn = attribute_rule({'foo': True})
fn(tag)
self.assertEqual(str(tag), '<b foo="bar">baz</b>') | [
"def",
"test_rule_true_for_attr",
"(",
"self",
")",
":",
"tag",
"=",
"self",
".",
"soup",
".",
"b",
"fn",
"=",
"attribute_rule",
"(",
"{",
"'foo'",
":",
"True",
"}",
")",
"fn",
"(",
"tag",
")",
"self",
".",
"assertEqual",
"(",
"str",
"(",
"tag",
")... | [
37,
4
] | [
45,
58
] | python | en | ['en', 'error', 'th'] | False |
TestAttributeRule.test_rule_false_for_attr | (self) |
Test that attribute_rule() drops attributes
when the corresponding rule returns False
|
Test that attribute_rule() drops attributes
when the corresponding rule returns False
| def test_rule_false_for_attr(self):
"""
Test that attribute_rule() drops attributes
when the corresponding rule returns False
"""
tag = self.soup.b
fn = attribute_rule({'foo': False})
fn(tag)
self.assertEqual(str(tag), '<b>baz</b>') | [
"def",
"test_rule_false_for_attr",
"(",
"self",
")",
":",
"tag",
"=",
"self",
".",
"soup",
".",
"b",
"fn",
"=",
"attribute_rule",
"(",
"{",
"'foo'",
":",
"False",
"}",
")",
"fn",
"(",
"tag",
")",
"self",
".",
"assertEqual",
"(",
"str",
"(",
"tag",
... | [
47,
4
] | [
55,
48
] | python | en | ['en', 'error', 'th'] | False |
TestAttributeRule.test_callable_called_on_attr | (self) |
Test that when the rule returns a callable,
attribute_rule() replaces the attribute with
the result of calling the callable on the attribute.
|
Test that when the rule returns a callable,
attribute_rule() replaces the attribute with
the result of calling the callable on the attribute.
| def test_callable_called_on_attr(self):
"""
Test that when the rule returns a callable,
attribute_rule() replaces the attribute with
the result of calling the callable on the attribute.
"""
tag = self.soup.b
fn = attribute_rule({'foo': len})
fn(tag)
... | [
"def",
"test_callable_called_on_attr",
"(",
"self",
")",
":",
"tag",
"=",
"self",
".",
"soup",
".",
"b",
"fn",
"=",
"attribute_rule",
"(",
"{",
"'foo'",
":",
"len",
"}",
")",
"fn",
"(",
"tag",
")",
"self",
".",
"assertEqual",
"(",
"str",
"(",
"tag",
... | [
57,
4
] | [
66,
56
] | python | en | ['en', 'error', 'th'] | False |
TestAttributeRule.test_callable_returns_None | (self) |
Test that when the rule returns a callable,
attribute_rule() replaces the attribute with
the result of calling the callable on the attribute.
|
Test that when the rule returns a callable,
attribute_rule() replaces the attribute with
the result of calling the callable on the attribute.
| def test_callable_returns_None(self):
"""
Test that when the rule returns a callable,
attribute_rule() replaces the attribute with
the result of calling the callable on the attribute.
"""
tag = self.soup.b
fn = attribute_rule({'foo': lambda x: None})
fn(ta... | [
"def",
"test_callable_returns_None",
"(",
"self",
")",
":",
"tag",
"=",
"self",
".",
"soup",
".",
"b",
"fn",
"=",
"attribute_rule",
"(",
"{",
"'foo'",
":",
"lambda",
"x",
":",
"None",
"}",
")",
"fn",
"(",
"tag",
")",
"self",
".",
"assertEqual",
"(",
... | [
68,
4
] | [
77,
48
] | python | en | ['en', 'error', 'th'] | False |
TestAttributeRule.test_allow_without_attributes | (self) |
Test that attribute_rule() with will drop all
attributes.
|
Test that attribute_rule() with will drop all
attributes.
| def test_allow_without_attributes(self):
"""
Test that attribute_rule() with will drop all
attributes.
"""
soup = BeautifulSoup('<b foo="bar" baz="quux" snowman="barbecue"></b>', 'html5lib')
tag = soup.b
allow_without_attributes(tag)
self.assertEqual(str(t... | [
"def",
"test_allow_without_attributes",
"(",
"self",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"'<b foo=\"bar\" baz=\"quux\" snowman=\"barbecue\"></b>'",
",",
"'html5lib'",
")",
"tag",
"=",
"soup",
".",
"b",
"allow_without_attributes",
"(",
"tag",
")",
"self",
".",... | [
79,
4
] | [
87,
45
] | python | en | ['en', 'error', 'th'] | False |
TestWhitelister.test_clean_unknown_node | (self) |
Unknown node should remove a node from the parent document
|
Unknown node should remove a node from the parent document
| def test_clean_unknown_node(self):
"""
Unknown node should remove a node from the parent document
"""
soup = BeautifulSoup('<foo><bar>baz</bar>quux</foo>', 'html5lib')
tag = soup.foo
self.whitelister.clean_unknown_node('', soup.bar)
self.assertEqual(str(tag), '<fo... | [
"def",
"test_clean_unknown_node",
"(",
"self",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"'<foo><bar>baz</bar>quux</foo>'",
",",
"'html5lib'",
")",
"tag",
"=",
"soup",
".",
"foo",
"self",
".",
"whitelister",
".",
"clean_unknown_node",
"(",
"''",
",",
"soup",
... | [
94,
4
] | [
101,
53
] | python | en | ['en', 'error', 'th'] | False |
TestWhitelister.test_clean_tag_node_cleans_nested_recognised_node | (self) |
<b> tags are allowed without attributes. This remains true
when tags are nested.
|
<b> tags are allowed without attributes. This remains true
when tags are nested.
| def test_clean_tag_node_cleans_nested_recognised_node(self):
"""
<b> tags are allowed without attributes. This remains true
when tags are nested.
"""
soup = BeautifulSoup('<b><b class="delete me">foo</b></b>', 'html5lib')
tag = soup.b
self.whitelister.clean_tag_no... | [
"def",
"test_clean_tag_node_cleans_nested_recognised_node",
"(",
"self",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"'<b><b class=\"delete me\">foo</b></b>'",
",",
"'html5lib'",
")",
"tag",
"=",
"soup",
".",
"b",
"self",
".",
"whitelister",
".",
"clean_tag_node",
"(... | [
103,
4
] | [
111,
55
] | python | en | ['en', 'error', 'th'] | False |
TestWhitelister.test_clean_tag_node_disallows_nested_unrecognised_node | (self) |
<foo> tags should be removed, even when nested.
|
<foo> tags should be removed, even when nested.
| def test_clean_tag_node_disallows_nested_unrecognised_node(self):
"""
<foo> tags should be removed, even when nested.
"""
soup = BeautifulSoup('<b><foo>bar</foo></b>', 'html5lib')
tag = soup.b
self.whitelister.clean_tag_node(tag, tag)
self.assertEqual(str(tag), '<... | [
"def",
"test_clean_tag_node_disallows_nested_unrecognised_node",
"(",
"self",
")",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"'<b><foo>bar</foo></b>'",
",",
"'html5lib'",
")",
"tag",
"=",
"soup",
".",
"b",
"self",
".",
"whitelister",
".",
"clean_tag_node",
"(",
"tag",... | [
113,
4
] | [
120,
48
] | python | en | ['en', 'error', 'th'] | False |
TestWhitelister.test_clean | (self) |
Whitelister.clean should remove disallowed tags and attributes from
a string
|
Whitelister.clean should remove disallowed tags and attributes from
a string
| def test_clean(self):
"""
Whitelister.clean should remove disallowed tags and attributes from
a string
"""
string = '<b foo="bar">snowman <barbecue>Yorkshire</barbecue></b>'
cleaned_string = self.whitelister.clean(string)
self.assertEqual(cleaned_string, '<b>snowm... | [
"def",
"test_clean",
"(",
"self",
")",
":",
"string",
"=",
"'<b foo=\"bar\">snowman <barbecue>Yorkshire</barbecue></b>'",
"cleaned_string",
"=",
"self",
".",
"whitelister",
".",
"clean",
"(",
"string",
")",
"self",
".",
"assertEqual",
"(",
"cleaned_string",
",",
"'<... | [
134,
4
] | [
141,
68
] | python | en | ['en', 'error', 'th'] | False |
CredentialType.test | (self, data) | Test the credential type endpoint. | Test the credential type endpoint. | def test(self, data):
"""Test the credential type endpoint."""
response = self.connection.post(urljoin(str(self.url), 'test/'), data)
exception = exception_from_status_code(response.status_code)
exc_str = "%s (%s) received" % (http.responses[response.status_code], response.status_code)
... | [
"def",
"test",
"(",
"self",
",",
"data",
")",
":",
"response",
"=",
"self",
".",
"connection",
".",
"post",
"(",
"urljoin",
"(",
"str",
"(",
"self",
".",
"url",
")",
",",
"'test/'",
")",
",",
"data",
")",
"exception",
"=",
"exception_from_status_code",... | [
166,
4
] | [
175,
23
] | python | en | ['en', 'en', 'en'] | True |
Credential.test | (self, data) | Test the credential endpoint. | Test the credential endpoint. | def test(self, data):
"""Test the credential endpoint."""
response = self.connection.post(urljoin(str(self.url), 'test/'), data)
exception = exception_from_status_code(response.status_code)
exc_str = "%s (%s) received" % (http.responses[response.status_code], response.status_code)
... | [
"def",
"test",
"(",
"self",
",",
"data",
")",
":",
"response",
"=",
"self",
".",
"connection",
".",
"post",
"(",
"urljoin",
"(",
"str",
"(",
"self",
".",
"url",
")",
",",
"'test/'",
")",
",",
"data",
")",
"exception",
"=",
"exception_from_status_code",... | [
265,
4
] | [
274,
23
] | python | en | ['en', 'en', 'en'] | True |
Credential.expected_passwords_needed_to_start | (self) | Return a list of expected passwords needed to start a job using this credential. | Return a list of expected passwords needed to start a job using this credential. | def expected_passwords_needed_to_start(self):
"""Return a list of expected passwords needed to start a job using this credential."""
passwords = []
for field in ('password', 'become_password', 'ssh_key_unlock', 'vault_password'):
if getattr(self.inputs, field, None) == 'ASK':
... | [
"def",
"expected_passwords_needed_to_start",
"(",
"self",
")",
":",
"passwords",
"=",
"[",
"]",
"for",
"field",
"in",
"(",
"'password'",
",",
"'become_password'",
",",
"'ssh_key_unlock'",
",",
"'vault_password'",
")",
":",
"if",
"getattr",
"(",
"self",
".",
"i... | [
277,
4
] | [
286,
24
] | python | en | ['en', 'en', 'en'] | True |
get_app_modules | () |
Generator function that yields a module object for each installed app
yields tuples of (app_name, module)
|
Generator function that yields a module object for each installed app
yields tuples of (app_name, module)
| def get_app_modules():
"""
Generator function that yields a module object for each installed app
yields tuples of (app_name, module)
"""
for app in apps.get_app_configs():
yield app.name, app.module | [
"def",
"get_app_modules",
"(",
")",
":",
"for",
"app",
"in",
"apps",
".",
"get_app_configs",
"(",
")",
":",
"yield",
"app",
".",
"name",
",",
"app",
".",
"module"
] | [
6,
0
] | [
12,
34
] | python | en | ['en', 'error', 'th'] | False |
get_app_submodules | (submodule_name) |
Searches each app module for the specified submodule
yields tuples of (app_name, module)
|
Searches each app module for the specified submodule
yields tuples of (app_name, module)
| def get_app_submodules(submodule_name):
"""
Searches each app module for the specified submodule
yields tuples of (app_name, module)
"""
for name, module in get_app_modules():
if module_has_submodule(module, submodule_name):
yield name, import_module('%s.%s' % (name, submodule_na... | [
"def",
"get_app_submodules",
"(",
"submodule_name",
")",
":",
"for",
"name",
",",
"module",
"in",
"get_app_modules",
"(",
")",
":",
"if",
"module_has_submodule",
"(",
"module",
",",
"submodule_name",
")",
":",
"yield",
"name",
",",
"import_module",
"(",
"'%s.%... | [
15,
0
] | [
22,
71
] | python | en | ['en', 'error', 'th'] | False |
TestFixedSlidingWindow.test_record_same_minute | (self) |
Legend:
- = record()
^ = render()
|---| = 1 minute, 60 seconds
....................
|------------------------------------------------------------|
^^^^^^^^^^^^^^^^^^^^
|
Legend:
- = record()
^ = render()
|---| = 1 minute, 60 seconds | def test_record_same_minute(self):
"""
Legend:
- = record()
^ = render()
|---| = 1 minute, 60 seconds
....................
|------------------------------------------------------------|
^^^^^^^^^^^^^^^^^^^^
"""
f... | [
"def",
"test_record_same_minute",
"(",
"self",
")",
":",
"fsw",
"=",
"FixedSlidingWindow",
"(",
"self",
".",
"ts",
"(",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
")",
"for",
"i",
"in",
"range",
"(",
"20",
")",
... | [
16,
4
] | [
31,
84
] | python | en | ['en', 'error', 'th'] | False |
TestFixedSlidingWindow.test_record_same_minute_render_diff_minute | (self) |
Legend:
- = record()
^ = render()
|---| = 1 minute, 60 seconds
....................
|------------------------------------------------------------|
^^ ^
... |
Legend:
- = record()
^ = render()
|---| = 1 minute, 60 seconds | def test_record_same_minute_render_diff_minute(self):
"""
Legend:
- = record()
^ = render()
|---| = 1 minute, 60 seconds
....................
|------------------------------------------------------------|
^^ ... | [
"def",
"test_record_same_minute_render_diff_minute",
"(",
"self",
")",
":",
"fsw",
"=",
"FixedSlidingWindow",
"(",
"self",
".",
"ts",
"(",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
")",
"for",
"i",
"in",
"range",
"("... | [
33,
4
] | [
60,
130
] | python | en | ['en', 'error', 'th'] | False |
_process_representation_wrappers | (env, representation, channel_dimensions) | Wraps with necessary representation wrappers.
Args:
env: A GFootball gym environment.
representation: See create_environment.representation comment.
channel_dimensions: (width, height) tuple that represents the dimensions of
SMM or pixels representation.
Returns:
Google Research Football env... | Wraps with necessary representation wrappers. | def _process_representation_wrappers(env, representation, channel_dimensions):
"""Wraps with necessary representation wrappers.
Args:
env: A GFootball gym environment.
representation: See create_environment.representation comment.
channel_dimensions: (width, height) tuple that represents the dimensions... | [
"def",
"_process_representation_wrappers",
"(",
"env",
",",
"representation",
",",
"channel_dimensions",
")",
":",
"if",
"representation",
".",
"startswith",
"(",
"'pixels'",
")",
":",
"env",
"=",
"wrappers",
".",
"PixelsStateWrapper",
"(",
"env",
",",
"'gray'",
... | [
33,
0
] | [
57,
12
] | python | en | ['en', 'en', 'en'] | True |
_apply_output_wrappers | (env, rewards, representation, channel_dimensions,
apply_single_agent_wrappers, stacked) | Wraps with necessary wrappers modifying the output of the environment.
Args:
env: A GFootball gym environment.
rewards: What rewards to apply.
representation: See create_environment.representation comment.
channel_dimensions: (width, height) tuple that represents the dimensions of
SMM or pixel... | Wraps with necessary wrappers modifying the output of the environment. | def _apply_output_wrappers(env, rewards, representation, channel_dimensions,
apply_single_agent_wrappers, stacked):
"""Wraps with necessary wrappers modifying the output of the environment.
Args:
env: A GFootball gym environment.
rewards: What rewards to apply.
representation... | [
"def",
"_apply_output_wrappers",
"(",
"env",
",",
"rewards",
",",
"representation",
",",
"channel_dimensions",
",",
"apply_single_agent_wrappers",
",",
"stacked",
")",
":",
"env",
"=",
"_process_reward_wrappers",
"(",
"env",
",",
"rewards",
")",
"env",
"=",
"_proc... | [
60,
0
] | [
85,
12
] | python | en | ['en', 'en', 'en'] | True |
create_environment | (env_name='',
stacked=False,
representation='extracted',
rewards='scoring',
write_goal_dumps=False,
write_full_episode_dumps=False,
render=False,
write_video=F... | Creates a Google Research Football environment.
Args:
env_name: a name of a scenario to run, e.g. "11_vs_11_stochastic".
The list of scenarios can be found in directory "scenarios".
stacked: If True, stack 4 observations, otherwise, only the last
observation is returned by the environment.
... | Creates a Google Research Football environment. | def create_environment(env_name='',
stacked=False,
representation='extracted',
rewards='scoring',
write_goal_dumps=False,
write_full_episode_dumps=False,
render=False,
... | [
"def",
"create_environment",
"(",
"env_name",
"=",
"''",
",",
"stacked",
"=",
"False",
",",
"representation",
"=",
"'extracted'",
",",
"rewards",
"=",
"'scoring'",
",",
"write_goal_dumps",
"=",
"False",
",",
"write_full_episode_dumps",
"=",
"False",
",",
"render... | [
88,
0
] | [
201,
12
] | python | en | ['en', 'gl', 'en'] | True |
create_remote_environment | (
username,
token,
model_name='',
track='',
stacked=False,
representation='raw',
rewards='scoring',
channel_dimensions=(
observation_preprocessing.SMM_WIDTH,
observation_preprocessing.SMM_HEIGHT),
include_rendering=False) | Creates a remote Google Research Football environment.
Args:
username: User name.
token: User token.
model_name: A model identifier to be displayed on the leaderboard.
track: which competition track to connect to.
stacked: If True, stack 4 observations, otherwise, only the last
observation ... | Creates a remote Google Research Football environment. | def create_remote_environment(
username,
token,
model_name='',
track='',
stacked=False,
representation='raw',
rewards='scoring',
channel_dimensions=(
observation_preprocessing.SMM_WIDTH,
observation_preprocessing.SMM_HEIGHT),
include_rendering=False):
"""Creates a r... | [
"def",
"create_remote_environment",
"(",
"username",
",",
"token",
",",
"model_name",
"=",
"''",
",",
"track",
"=",
"''",
",",
"stacked",
"=",
"False",
",",
"representation",
"=",
"'raw'",
",",
"rewards",
"=",
"'scoring'",
",",
"channel_dimensions",
"=",
"("... | [
204,
0
] | [
245,
12
] | python | en | ['en', 'en', 'en'] | True |
make_model_tuple | (model) |
Takes a model or a string of the form "app_label.ModelName" and returns a
corresponding ("app_label", "modelname") tuple. If a tuple is passed in,
it's assumed to be a valid model tuple already and returned unchanged.
|
Takes a model or a string of the form "app_label.ModelName" and returns a
corresponding ("app_label", "modelname") tuple. If a tuple is passed in,
it's assumed to be a valid model tuple already and returned unchanged.
| def make_model_tuple(model):
"""
Takes a model or a string of the form "app_label.ModelName" and returns a
corresponding ("app_label", "modelname") tuple. If a tuple is passed in,
it's assumed to be a valid model tuple already and returned unchanged.
"""
try:
if isinstance(model, tuple):... | [
"def",
"make_model_tuple",
"(",
"model",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"model",
",",
"tuple",
")",
":",
"model_tuple",
"=",
"model",
"elif",
"isinstance",
"(",
"model",
",",
"six",
".",
"string_types",
")",
":",
"app_label",
",",
"model_... | [
3,
0
] | [
23,
9
] | python | en | ['en', 'error', 'th'] | False |
simplegesture | (name, point_list) |
A simple helper function
|
A simple helper function
| def simplegesture(name, point_list):
"""
A simple helper function
"""
g = Gesture()
g.add_stroke(point_list)
g.normalize()
g.name = name
return g | [
"def",
"simplegesture",
"(",
"name",
",",
"point_list",
")",
":",
"g",
"=",
"Gesture",
"(",
")",
"g",
".",
"add_stroke",
"(",
"point_list",
")",
"g",
".",
"normalize",
"(",
")",
"g",
".",
"name",
"=",
"name",
"return",
"g"
] | [
9,
0
] | [
17,
12
] | python | en | ['en', 'error', 'th'] | False |
handle_default_options | (options) |
Include any default options that all commands should accept here
so that ManagementUtility can handle them before searching for
user commands.
|
Include any default options that all commands should accept here
so that ManagementUtility can handle them before searching for
user commands.
| def handle_default_options(options):
"""
Include any default options that all commands should accept here
so that ManagementUtility can handle them before searching for
user commands.
"""
if options.settings:
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
if options.pythonpa... | [
"def",
"handle_default_options",
"(",
"options",
")",
":",
"if",
"options",
".",
"settings",
":",
"os",
".",
"environ",
"[",
"'DJANGO_SETTINGS_MODULE'",
"]",
"=",
"options",
".",
"settings",
"if",
"options",
".",
"pythonpath",
":",
"sys",
".",
"path",
".",
... | [
66,
0
] | [
75,
46
] | python | en | ['en', 'error', 'th'] | False |
BaseCommand.get_version | (self) |
Return the Django version, which should be correct for all built-in
Django commands. User-supplied commands can override this method to
return their own version.
|
Return the Django version, which should be correct for all built-in
Django commands. User-supplied commands can override this method to
return their own version.
| def get_version(self):
"""
Return the Django version, which should be correct for all built-in
Django commands. User-supplied commands can override this method to
return their own version.
"""
return django.get_version() | [
"def",
"get_version",
"(",
"self",
")",
":",
"return",
"django",
".",
"get_version",
"(",
")"
] | [
208,
4
] | [
214,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseCommand.create_parser | (self, prog_name, subcommand) |
Create and return the ``ArgumentParser`` which will be used to
parse the arguments to this command.
|
Create and return the ``ArgumentParser`` which will be used to
parse the arguments to this command.
| def create_parser(self, prog_name, subcommand):
"""
Create and return the ``ArgumentParser`` which will be used to
parse the arguments to this command.
"""
parser = CommandParser(
self, prog="%s %s" % (os.path.basename(prog_name), subcommand),
description=... | [
"def",
"create_parser",
"(",
"self",
",",
"prog_name",
",",
"subcommand",
")",
":",
"parser",
"=",
"CommandParser",
"(",
"self",
",",
"prog",
"=",
"\"%s %s\"",
"%",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"prog_name",
")",
",",
"subcommand",
")",
... | [
216,
4
] | [
249,
21
] | python | en | ['en', 'error', 'th'] | False |
BaseCommand.add_arguments | (self, parser) |
Entry point for subclassed commands to add custom arguments.
|
Entry point for subclassed commands to add custom arguments.
| def add_arguments(self, parser):
"""
Entry point for subclassed commands to add custom arguments.
"""
pass | [
"def",
"add_arguments",
"(",
"self",
",",
"parser",
")",
":",
"pass"
] | [
251,
4
] | [
255,
12
] | python | en | ['en', 'error', 'th'] | False |
BaseCommand.print_help | (self, prog_name, subcommand) |
Print the help message for this command, derived from
``self.usage()``.
|
Print the help message for this command, derived from
``self.usage()``.
| def print_help(self, prog_name, subcommand):
"""
Print the help message for this command, derived from
``self.usage()``.
"""
parser = self.create_parser(prog_name, subcommand)
parser.print_help() | [
"def",
"print_help",
"(",
"self",
",",
"prog_name",
",",
"subcommand",
")",
":",
"parser",
"=",
"self",
".",
"create_parser",
"(",
"prog_name",
",",
"subcommand",
")",
"parser",
".",
"print_help",
"(",
")"
] | [
257,
4
] | [
263,
27
] | python | en | ['en', 'error', 'th'] | False |
BaseCommand.run_from_argv | (self, argv) |
Set up any environment changes requested (e.g., Python path
and Django settings), then run this command. If the
command raises a ``CommandError``, intercept it and print it sensibly
to stderr. If the ``--traceback`` option is present or the raised
``Exception`` is not ``CommandE... |
Set up any environment changes requested (e.g., Python path
and Django settings), then run this command. If the
command raises a ``CommandError``, intercept it and print it sensibly
to stderr. If the ``--traceback`` option is present or the raised
``Exception`` is not ``CommandE... | def run_from_argv(self, argv):
"""
Set up any environment changes requested (e.g., Python path
and Django settings), then run this command. If the
command raises a ``CommandError``, intercept it and print it sensibly
to stderr. If the ``--traceback`` option is present or the rais... | [
"def",
"run_from_argv",
"(",
"self",
",",
"argv",
")",
":",
"self",
".",
"_called_from_command_line",
"=",
"True",
"parser",
"=",
"self",
".",
"create_parser",
"(",
"argv",
"[",
"0",
"]",
",",
"argv",
"[",
"1",
"]",
")",
"options",
"=",
"parser",
".",
... | [
265,
4
] | [
299,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseCommand.execute | (self, *args, **options) |
Try to execute this command, performing system checks if needed (as
controlled by the ``requires_system_checks`` attribute, except if
force-skipped).
|
Try to execute this command, performing system checks if needed (as
controlled by the ``requires_system_checks`` attribute, except if
force-skipped).
| def execute(self, *args, **options):
"""
Try to execute this command, performing system checks if needed (as
controlled by the ``requires_system_checks`` attribute, except if
force-skipped).
"""
if options['no_color']:
self.style = no_style()
self.... | [
"def",
"execute",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"if",
"options",
"[",
"'no_color'",
"]",
":",
"self",
".",
"style",
"=",
"no_style",
"(",
")",
"self",
".",
"stderr",
".",
"style_func",
"=",
"None",
"if",
"option... | [
301,
4
] | [
342,
21
] | python | en | ['en', 'error', 'th'] | False |
BaseCommand.check | (self, app_configs=None, tags=None, display_num_errors=False,
include_deployment_checks=False, fail_level=checks.ERROR) |
Uses the system check framework to validate entire Django project.
Raises CommandError for any serious message (error or critical errors).
If there are only light messages (like warnings), they are printed to
stderr and no exception is raised.
|
Uses the system check framework to validate entire Django project.
Raises CommandError for any serious message (error or critical errors).
If there are only light messages (like warnings), they are printed to
stderr and no exception is raised.
| def check(self, app_configs=None, tags=None, display_num_errors=False,
include_deployment_checks=False, fail_level=checks.ERROR):
"""
Uses the system check framework to validate entire Django project.
Raises CommandError for any serious message (error or critical errors).
I... | [
"def",
"check",
"(",
"self",
",",
"app_configs",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"display_num_errors",
"=",
"False",
",",
"include_deployment_checks",
"=",
"False",
",",
"fail_level",
"=",
"checks",
".",
"ERROR",
")",
":",
"all_issues",
"=",
"s... | [
347,
4
] | [
412,
38
] | python | en | ['en', 'error', 'th'] | False |
BaseCommand.check_migrations | (self) |
Print a warning if the set of migrations on disk don't match the
migrations in the database.
|
Print a warning if the set of migrations on disk don't match the
migrations in the database.
| def check_migrations(self):
"""
Print a warning if the set of migrations on disk don't match the
migrations in the database.
"""
from django.db.migrations.executor import MigrationExecutor
try:
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
... | [
"def",
"check_migrations",
"(",
"self",
")",
":",
"from",
"django",
".",
"db",
".",
"migrations",
".",
"executor",
"import",
"MigrationExecutor",
"try",
":",
"executor",
"=",
"MigrationExecutor",
"(",
"connections",
"[",
"DEFAULT_DB_ALIAS",
"]",
")",
"except",
... | [
414,
4
] | [
444,
99
] | python | en | ['en', 'error', 'th'] | False |
BaseCommand.handle | (self, *args, **options) |
The actual logic of the command. Subclasses must implement
this method.
|
The actual logic of the command. Subclasses must implement
this method.
| def handle(self, *args, **options):
"""
The actual logic of the command. Subclasses must implement
this method.
"""
raise NotImplementedError('subclasses of BaseCommand must provide a handle() method') | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCommand must provide a handle() method'",
")"
] | [
446,
4
] | [
451,
93
] | python | en | ['en', 'error', 'th'] | False |
AppCommand.handle_app_config | (self, app_config, **options) |
Perform the command's actions for app_config, an AppConfig instance
corresponding to an application label given on the command line.
|
Perform the command's actions for app_config, an AppConfig instance
corresponding to an application label given on the command line.
| def handle_app_config(self, app_config, **options):
"""
Perform the command's actions for app_config, an AppConfig instance
corresponding to an application label given on the command line.
"""
raise NotImplementedError(
"Subclasses of AppCommand must provide"
... | [
"def",
"handle_app_config",
"(",
"self",
",",
"app_config",
",",
"*",
"*",
"options",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Subclasses of AppCommand must provide\"",
"\"a handle_app_config() method.\"",
")"
] | [
480,
4
] | [
487,
44
] | python | en | ['en', 'error', 'th'] | False |
LabelCommand.handle_label | (self, label, **options) |
Perform the command's actions for ``label``, which will be the
string as given on the command line.
|
Perform the command's actions for ``label``, which will be the
string as given on the command line.
| def handle_label(self, label, **options):
"""
Perform the command's actions for ``label``, which will be the
string as given on the command line.
"""
raise NotImplementedError('subclasses of LabelCommand must provide a handle_label() method') | [
"def",
"handle_label",
"(",
"self",
",",
"label",
",",
"*",
"*",
"options",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of LabelCommand must provide a handle_label() method'",
")"
] | [
516,
4
] | [
521,
100
] | python | en | ['en', 'error', 'th'] | False |
JSONParser.parse | (self, stream, media_type=None, parser_context=None) |
Parses the incoming bytestream as JSON and returns the resulting data.
|
Parses the incoming bytestream as JSON and returns the resulting data.
| def parse(self, stream, media_type=None, parser_context=None):
"""
Parses the incoming bytestream as JSON and returns the resulting data.
"""
parser_context = parser_context or {}
encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
try:
data =... | [
"def",
"parse",
"(",
"self",
",",
"stream",
",",
"media_type",
"=",
"None",
",",
"parser_context",
"=",
"None",
")",
":",
"parser_context",
"=",
"parser_context",
"or",
"{",
"}",
"encoding",
"=",
"parser_context",
".",
"get",
"(",
"'encoding'",
",",
"setti... | [
19,
4
] | [
35,
100
] | python | en | ['en', 'error', 'th'] | False |
auth | (request) |
Returns context variables required by apps that use Django's authentication
system.
If there is no 'user' attribute in the request, uses AnonymousUser (from
django.contrib.auth).
|
Returns context variables required by apps that use Django's authentication
system. | def auth(request):
"""
Returns context variables required by apps that use Django's authentication
system.
If there is no 'user' attribute in the request, uses AnonymousUser (from
django.contrib.auth).
"""
if hasattr(request, 'user'):
user = request.user
else:
from djang... | [
"def",
"auth",
"(",
"request",
")",
":",
"if",
"hasattr",
"(",
"request",
",",
"'user'",
")",
":",
"user",
"=",
"request",
".",
"user",
"else",
":",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"models",
"import",
"AnonymousUser",
"user",
"=",
... | [
48,
0
] | [
65,
5
] | python | en | ['en', 'error', 'th'] | False |
PermWrapper.__contains__ | (self, perm_name) |
Lookup by "someapp" or "someapp.someperm" in perms.
|
Lookup by "someapp" or "someapp.someperm" in perms.
| def __contains__(self, perm_name):
"""
Lookup by "someapp" or "someapp.someperm" in perms.
"""
if '.' not in perm_name:
# The name refers to module.
return bool(self[perm_name])
app_label, perm_name = perm_name.split('.', 1)
return self[app_label][... | [
"def",
"__contains__",
"(",
"self",
",",
"perm_name",
")",
":",
"if",
"'.'",
"not",
"in",
"perm_name",
":",
"# The name refers to module.",
"return",
"bool",
"(",
"self",
"[",
"perm_name",
"]",
")",
"app_label",
",",
"perm_name",
"=",
"perm_name",
".",
"spli... | [
37,
4
] | [
45,
41
] | python | en | ['en', 'error', 'th'] | False |
paginator_number | (cl, i) |
Generates an individual page index link in a paginated list.
|
Generates an individual page index link in a paginated list.
| def paginator_number(cl, i):
"""
Generates an individual page index link in a paginated list.
"""
if i == DOT:
return '... '
elif i == cl.page_num:
return format_html('<span class="this-page">{}</span> ', i + 1)
else:
return format_html('<a href="{}"{}>{}</a> ',
... | [
"def",
"paginator_number",
"(",
"cl",
",",
"i",
")",
":",
"if",
"i",
"==",
"DOT",
":",
"return",
"'... '",
"elif",
"i",
"==",
"cl",
".",
"page_num",
":",
"return",
"format_html",
"(",
"'<span class=\"this-page\">{}</span> '",
",",
"i",
"+",
"1",
")",
"el... | [
33,
0
] | [
45,
33
] | python | en | ['en', 'error', 'th'] | False |
pagination | (cl) |
Generates the series of links to the pages in a paginated list.
|
Generates the series of links to the pages in a paginated list.
| def pagination(cl):
"""
Generates the series of links to the pages in a paginated list.
"""
paginator, page_num = cl.paginator, cl.page_num
pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page
if not pagination_required:
page_range = []
else:
ON_E... | [
"def",
"pagination",
"(",
"cl",
")",
":",
"paginator",
",",
"page_num",
"=",
"cl",
".",
"paginator",
",",
"cl",
".",
"page_num",
"pagination_required",
"=",
"(",
"not",
"cl",
".",
"show_all",
"or",
"not",
"cl",
".",
"can_show_all",
")",
"and",
"cl",
".... | [
49,
0
] | [
92,
5
] | python | en | ['en', 'error', 'th'] | False |
result_headers | (cl) |
Generates the list column headers.
|
Generates the list column headers.
| def result_headers(cl):
"""
Generates the list column headers.
"""
ordering_field_columns = cl.get_ordering_field_columns()
for i, field_name in enumerate(cl.list_display):
text, attr = label_for_field(
field_name, cl.model,
model_admin=cl.model_admin,
ret... | [
"def",
"result_headers",
"(",
"cl",
")",
":",
"ordering_field_columns",
"=",
"cl",
".",
"get_ordering_field_columns",
"(",
")",
"for",
"i",
",",
"field_name",
"in",
"enumerate",
"(",
"cl",
".",
"list_display",
")",
":",
"text",
",",
"attr",
"=",
"label_for_f... | [
95,
0
] | [
178,
9
] | python | en | ['en', 'error', 'th'] | False |
_coerce_field_name | (field_name, field_index) |
Coerce a field_name (which may be a callable) to a string.
|
Coerce a field_name (which may be a callable) to a string.
| def _coerce_field_name(field_name, field_index):
"""
Coerce a field_name (which may be a callable) to a string.
"""
if callable(field_name):
if field_name.__name__ == '<lambda>':
return 'lambda' + str(field_index)
else:
return field_name.__name__
return field_... | [
"def",
"_coerce_field_name",
"(",
"field_name",
",",
"field_index",
")",
":",
"if",
"callable",
"(",
"field_name",
")",
":",
"if",
"field_name",
".",
"__name__",
"==",
"'<lambda>'",
":",
"return",
"'lambda'",
"+",
"str",
"(",
"field_index",
")",
"else",
":",... | [
187,
0
] | [
196,
21
] | python | en | ['en', 'error', 'th'] | False |
items_for_result | (cl, result, form) |
Generates the actual list of data.
|
Generates the actual list of data.
| def items_for_result(cl, result, form):
"""
Generates the actual list of data.
"""
def link_in_col(is_first, field_name, cl):
if cl.list_display_links is None:
return False
if is_first and not cl.list_display_links:
return True
return field_name in cl.lis... | [
"def",
"items_for_result",
"(",
"cl",
",",
"result",
",",
"form",
")",
":",
"def",
"link_in_col",
"(",
"is_first",
",",
"field_name",
",",
"cl",
")",
":",
"if",
"cl",
".",
"list_display_links",
"is",
"None",
":",
"return",
"False",
"if",
"is_first",
"and... | [
199,
0
] | [
296,
82
] | python | en | ['en', 'error', 'th'] | False |
result_list | (cl) |
Displays the headers and data list together
|
Displays the headers and data list together
| def result_list(cl):
"""
Displays the headers and data list together
"""
headers = list(result_headers(cl))
num_sorted_fields = 0
for h in headers:
if h['sortable'] and h['sorted']:
num_sorted_fields += 1
return {'cl': cl,
'result_hidden_fields': list(result_h... | [
"def",
"result_list",
"(",
"cl",
")",
":",
"headers",
"=",
"list",
"(",
"result_headers",
"(",
"cl",
")",
")",
"num_sorted_fields",
"=",
"0",
"for",
"h",
"in",
"headers",
":",
"if",
"h",
"[",
"'sortable'",
"]",
"and",
"h",
"[",
"'sorted'",
"]",
":",
... | [
326,
0
] | [
339,
41
] | python | en | ['en', 'error', 'th'] | False |
date_hierarchy | (cl) |
Displays the date hierarchy for date drill-down functionality.
|
Displays the date hierarchy for date drill-down functionality.
| def date_hierarchy(cl):
"""
Displays the date hierarchy for date drill-down functionality.
"""
if cl.date_hierarchy:
field_name = cl.date_hierarchy
field = get_fields_from_path(cl.model, field_name)[-1]
dates_or_datetimes = 'datetimes' if isinstance(field, models.DateTimeField) e... | [
"def",
"date_hierarchy",
"(",
"cl",
")",
":",
"if",
"cl",
".",
"date_hierarchy",
":",
"field_name",
"=",
"cl",
".",
"date_hierarchy",
"field",
"=",
"get_fields_from_path",
"(",
"cl",
".",
"model",
",",
"field_name",
")",
"[",
"-",
"1",
"]",
"dates_or_datet... | [
343,
0
] | [
418,
13
] | python | en | ['en', 'error', 'th'] | False |
search_form | (cl) |
Displays a search form for searching the list.
|
Displays a search form for searching the list.
| def search_form(cl):
"""
Displays a search form for searching the list.
"""
return {
'cl': cl,
'show_result_count': cl.result_count != cl.full_result_count,
'search_var': SEARCH_VAR
} | [
"def",
"search_form",
"(",
"cl",
")",
":",
"return",
"{",
"'cl'",
":",
"cl",
",",
"'show_result_count'",
":",
"cl",
".",
"result_count",
"!=",
"cl",
".",
"full_result_count",
",",
"'search_var'",
":",
"SEARCH_VAR",
"}"
] | [
422,
0
] | [
430,
5
] | python | en | ['en', 'error', 'th'] | False |
admin_actions | (context) |
Track the number of times the action field has been rendered on the page,
so we know which value to use.
|
Track the number of times the action field has been rendered on the page,
so we know which value to use.
| def admin_actions(context):
"""
Track the number of times the action field has been rendered on the page,
so we know which value to use.
"""
context['action_index'] = context.get('action_index', -1) + 1
return context | [
"def",
"admin_actions",
"(",
"context",
")",
":",
"context",
"[",
"'action_index'",
"]",
"=",
"context",
".",
"get",
"(",
"'action_index'",
",",
"-",
"1",
")",
"+",
"1",
"return",
"context"
] | [
444,
0
] | [
450,
18
] | python | en | ['en', 'error', 'th'] | False |
is_did_innerpuz | (inner_f: Program) |
You may want to generalize this if different `CC_MOD` templates are supported.
|
You may want to generalize this if different `CC_MOD` templates are supported.
| def is_did_innerpuz(inner_f: Program):
"""
You may want to generalize this if different `CC_MOD` templates are supported.
"""
return inner_f == DID_INNERPUZ_MOD | [
"def",
"is_did_innerpuz",
"(",
"inner_f",
":",
"Program",
")",
":",
"return",
"inner_f",
"==",
"DID_INNERPUZ_MOD"
] | [
35,
0
] | [
39,
38
] | python | en | ['en', 'error', 'th'] | False |
uncurry_innerpuz | (puzzle: Program) |
Take a puzzle and return `None` if it's not a `CC_MOD` cc, or
a triple of `mod_hash, genesis_coin_checker, inner_puzzle` if it is.
|
Take a puzzle and return `None` if it's not a `CC_MOD` cc, or
a triple of `mod_hash, genesis_coin_checker, inner_puzzle` if it is.
| def uncurry_innerpuz(puzzle: Program) -> Optional[Tuple[Program, Program]]:
"""
Take a puzzle and return `None` if it's not a `CC_MOD` cc, or
a triple of `mod_hash, genesis_coin_checker, inner_puzzle` if it is.
"""
r = puzzle.uncurry()
if r is None:
return r
inner_f, args = r
if ... | [
"def",
"uncurry_innerpuz",
"(",
"puzzle",
":",
"Program",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"Program",
",",
"Program",
"]",
"]",
":",
"r",
"=",
"puzzle",
".",
"uncurry",
"(",
")",
"if",
"r",
"is",
"None",
":",
"return",
"r",
"inner_f",
",",
... | [
46,
0
] | [
59,
26
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateOperatorTest.test_missing_parameter | (self) |
Sending typing notification without op parameter fails
|
Sending typing notification without op parameter fails
| def test_missing_parameter(self) -> None:
"""
Sending typing notification without op parameter fails
"""
sender = self.example_user("hamlet")
params = dict(
to=orjson.dumps([sender.id]).decode(),
)
result = self.api_post(sender, "/api/v1/typing", param... | [
"def",
"test_missing_parameter",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"params",
"=",
"dict",
"(",
"to",
"=",
"orjson",
".",
"dumps",
"(",
"[",
"sender",
".",
"id",
"]",
")",
".",
"de... | [
10,
4
] | [
19,
63
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateOperatorTest.test_invalid_parameter_pm | (self) |
Sending typing notification with invalid value for op parameter fails
|
Sending typing notification with invalid value for op parameter fails
| def test_invalid_parameter_pm(self) -> None:
"""
Sending typing notification with invalid value for op parameter fails
"""
sender = self.example_user("hamlet")
params = dict(
to=orjson.dumps([sender.id]).decode(),
op="foo",
)
result = self.... | [
"def",
"test_invalid_parameter_pm",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"params",
"=",
"dict",
"(",
"to",
"=",
"orjson",
".",
"dumps",
"(",
"[",
"sender",
".",
"id",
"]",
")",
".",
... | [
21,
4
] | [
31,
52
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_empty_to_array_pms | (self) |
Sending pms typing notification without recipient fails
|
Sending pms typing notification without recipient fails
| def test_empty_to_array_pms(self) -> None:
"""
Sending pms typing notification without recipient fails
"""
sender = self.example_user("hamlet")
result = self.api_post(sender, "/api/v1/typing", {"op": "start", "to": "[]"})
self.assert_json_error(result, "Empty 'to' list") | [
"def",
"test_empty_to_array_pms",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"",
",",
"{",
"\"op\"",
":",
"\"start\"",... | [
55,
4
] | [
61,
57
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_empty_to_array_stream | (self) |
Sending stream typing notification without recipient fails
|
Sending stream typing notification without recipient fails
| def test_empty_to_array_stream(self) -> None:
"""
Sending stream typing notification without recipient fails
"""
sender = self.example_user("hamlet")
result = self.api_post(
sender, "/api/v1/typing", {"type": "stream", "op": "start", "to": "[]"}
)
self... | [
"def",
"test_empty_to_array_stream",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"",
",",
"{",
"\"type\"",
":",
"\"stre... | [
63,
4
] | [
71,
57
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_missing_recipient | (self) |
Sending typing notification without recipient fails
|
Sending typing notification without recipient fails
| def test_missing_recipient(self) -> None:
"""
Sending typing notification without recipient fails
"""
sender = self.example_user("hamlet")
result = self.api_post(sender, "/api/v1/typing", {"op": "start"})
self.assert_json_error(result, "Missing 'to' argument") | [
"def",
"test_missing_recipient",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"",
",",
"{",
"\"op\"",
":",
"\"start\"",
... | [
73,
4
] | [
79,
63
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_argument_to_is_not_valid_json | (self) |
Sending typing notification to invalid recipient fails
|
Sending typing notification to invalid recipient fails
| def test_argument_to_is_not_valid_json(self) -> None:
"""
Sending typing notification to invalid recipient fails
"""
sender = self.example_user("hamlet")
invalid = "bad email"
result = self.api_post(sender, "/api/v1/typing", {"op": "start", "to": invalid})
self.as... | [
"def",
"test_argument_to_is_not_valid_json",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"invalid",
"=",
"\"bad email\"",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"... | [
81,
4
] | [
88,
74
] | python | en | ['en', 'error', 'th'] | False |
TypingValidateToArgumentsTest.test_bogus_user_id | (self) |
Sending typing notification to invalid recipient fails
|
Sending typing notification to invalid recipient fails
| def test_bogus_user_id(self) -> None:
"""
Sending typing notification to invalid recipient fails
"""
sender = self.example_user("hamlet")
invalid = "[9999999]"
result = self.api_post(sender, "/api/v1/typing", {"op": "start", "to": invalid})
self.assert_json_error(... | [
"def",
"test_bogus_user_id",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"invalid",
"=",
"\"[9999999]\"",
"result",
"=",
"self",
".",
"api_post",
"(",
"sender",
",",
"\"/api/v1/typing\"",
",",
"{",... | [
90,
4
] | [
97,
65
] | python | en | ['en', 'error', 'th'] | False |
TypingHappyPathTestPMs.test_start_to_self | (self) |
Sending typing notification to yourself (using user IDs)
is successful.
|
Sending typing notification to yourself (using user IDs)
is successful.
| def test_start_to_self(self) -> None:
"""
Sending typing notification to yourself (using user IDs)
is successful.
"""
user = self.example_user("hamlet")
email = user.email
expected_recipient_emails = {email}
expected_recipient_ids = {user.id}
event... | [
"def",
"test_start_to_self",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"email",
"=",
"user",
".",
"email",
"expected_recipient_emails",
"=",
"{",
"email",
"}",
"expected_recipient_ids",
"=",
"{",
"... | [
211,
4
] | [
243,
46
] | python | en | ['en', 'error', 'th'] | False |
TypingHappyPathTestPMs.test_start_to_another_user | (self) |
Sending typing notification to another user
is successful.
|
Sending typing notification to another user
is successful.
| def test_start_to_another_user(self) -> None:
"""
Sending typing notification to another user
is successful.
"""
sender = self.example_user("hamlet")
recipient = self.example_user("othello")
expected_recipients = {sender, recipient}
expected_recipient_emai... | [
"def",
"test_start_to_another_user",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"recipient",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"expected_recipients",
"=",
"{",
"sender",
","... | [
245,
4
] | [
278,
46
] | python | en | ['en', 'error', 'th'] | False |
TypingHappyPathTestPMs.test_stop_to_self | (self) |
Sending stopped typing notification to yourself
is successful.
|
Sending stopped typing notification to yourself
is successful.
| def test_stop_to_self(self) -> None:
"""
Sending stopped typing notification to yourself
is successful.
"""
user = self.example_user("hamlet")
email = user.email
expected_recipient_emails = {email}
expected_recipient_ids = {user.id}
events: List[M... | [
"def",
"test_stop_to_self",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"email",
"=",
"user",
".",
"email",
"expected_recipient_emails",
"=",
"{",
"email",
"}",
"expected_recipient_ids",
"=",
"{",
"u... | [
280,
4
] | [
311,
45
] | python | en | ['en', 'error', 'th'] | False |
TypingHappyPathTestPMs.test_stop_to_another_user | (self) |
Sending stopped typing notification to another user
is successful.
|
Sending stopped typing notification to another user
is successful.
| def test_stop_to_another_user(self) -> None:
"""
Sending stopped typing notification to another user
is successful.
"""
sender = self.example_user("hamlet")
recipient = self.example_user("othello")
expected_recipients = {sender, recipient}
expected_recipie... | [
"def",
"test_stop_to_another_user",
"(",
"self",
")",
"->",
"None",
":",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"recipient",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"expected_recipients",
"=",
"{",
"sender",
",",... | [
313,
4
] | [
345,
45
] | python | en | ['en', 'error', 'th'] | False |
listen_fds | (unset_environment=True) |
Get the number of sockets inherited from systemd socket activation.
:param unset_environment: clear systemd environment variables unless False
:type unset_environment: bool
:return: the number of sockets to inherit from systemd socket activation
:rtype: int
Returns zero immediately if $LISTEN... |
Get the number of sockets inherited from systemd socket activation. | def listen_fds(unset_environment=True):
"""
Get the number of sockets inherited from systemd socket activation.
:param unset_environment: clear systemd environment variables unless False
:type unset_environment: bool
:return: the number of sockets to inherit from systemd socket activation
:rtyp... | [
"def",
"listen_fds",
"(",
"unset_environment",
"=",
"True",
")",
":",
"fds",
"=",
"int",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'LISTEN_FDS'",
",",
"0",
")",
")",
"listen_pid",
"=",
"int",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'LISTEN_PI... | [
11,
0
] | [
45,
14
] | python | en | ['en', 'error', 'th'] | False |
sd_notify | (state, logger, unset_environment=False) | Send a notification to systemd. state is a string; see
the man page of sd_notify (http://www.freedesktop.org/software/systemd/man/sd_notify.html)
for a description of the allowable values.
If the unset_environment parameter is True, sd_notify() will unset
the $NOTIFY_SOCKET environment variable before ... | Send a notification to systemd. state is a string; see
the man page of sd_notify (http://www.freedesktop.org/software/systemd/man/sd_notify.html)
for a description of the allowable values. | def sd_notify(state, logger, unset_environment=False):
"""Send a notification to systemd. state is a string; see
the man page of sd_notify (http://www.freedesktop.org/software/systemd/man/sd_notify.html)
for a description of the allowable values.
If the unset_environment parameter is True, sd_notify() ... | [
"def",
"sd_notify",
"(",
"state",
",",
"logger",
",",
"unset_environment",
"=",
"False",
")",
":",
"addr",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'NOTIFY_SOCKET'",
")",
"if",
"addr",
"is",
"None",
":",
"# not run in a service, just a noop",
"return",
"... | [
48,
0
] | [
76,
20
] | python | en | ['en', 'en', 'en'] | True |
serve | (request, path, insecure=False, **kwargs) |
Serve static files below a given point in the directory structure or
from locations inferred from the staticfiles finders.
To use, put a URL pattern such as::
from django.contrib.staticfiles import views
url(r'^(?P<path>.*)$', views.serve)
in your URLconf.
It uses the django.vi... |
Serve static files below a given point in the directory structure or
from locations inferred from the staticfiles finders. | def serve(request, path, insecure=False, **kwargs):
"""
Serve static files below a given point in the directory structure or
from locations inferred from the staticfiles finders.
To use, put a URL pattern such as::
from django.contrib.staticfiles import views
url(r'^(?P<path>.*)$', vi... | [
"def",
"serve",
"(",
"request",
",",
"path",
",",
"insecure",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"settings",
".",
"DEBUG",
"and",
"not",
"insecure",
":",
"raise",
"Http404",
"normalized_path",
"=",
"posixpath",
".",
"normpath",... | [
15,
0
] | [
39,
77
] | python | en | ['en', 'error', 'th'] | False |
get_exception_info | (exception) |
Formats exception information for display on the debug page using the
structure described in the template API documentation.
|
Formats exception information for display on the debug page using the
structure described in the template API documentation.
| def get_exception_info(exception):
"""
Formats exception information for display on the debug page using the
structure described in the template API documentation.
"""
context_lines = 10
lineno = exception.lineno
lines = list(enumerate(exception.source.strip().split("\n"), start=1))
duri... | [
"def",
"get_exception_info",
"(",
"exception",
")",
":",
"context_lines",
"=",
"10",
"lineno",
"=",
"exception",
".",
"lineno",
"lines",
"=",
"list",
"(",
"enumerate",
"(",
"exception",
".",
"source",
".",
"strip",
"(",
")",
".",
"split",
"(",
"\"\\n\"",
... | [
93,
0
] | [
117,
5
] | python | en | ['en', 'error', 'th'] | False |
check_for_valid_ephemeris | (measures) |
Checks whether the ephemeris data in use by ``measures`` is valid.
``measures`` should already have a valid reference frame.
|
Checks whether the ephemeris data in use by ``measures`` is valid.
``measures`` should already have a valid reference frame.
| def check_for_valid_ephemeris(measures):
"""
Checks whether the ephemeris data in use by ``measures`` is valid.
``measures`` should already have a valid reference frame.
"""
# Note that we need to catch and parse the standard error produced by
# casacore: there doesn't seem to be any other way o... | [
"def",
"check_for_valid_ephemeris",
"(",
"measures",
")",
":",
"# Note that we need to catch and parse the standard error produced by",
"# casacore: there doesn't seem to be any other way of figuring this out.",
"casacore_stderr",
"=",
"BytesIO",
"(",
")",
"with",
"redirect_stream",
"(... | [
19,
0
] | [
36,
19
] | python | en | ['en', 'error', 'th'] | False |
is_bright_source_near | (accessor, distance=20) |
Checks if there is any of the bright radio sources defined in targets
near the center of the image.
:param accessor: a TKP accessor
:param distance: maximum allowed distance of a bright source (in degrees)
:returns: False if not bright source is near, description of source if a
brigh... |
Checks if there is any of the bright radio sources defined in targets
near the center of the image. | def is_bright_source_near(accessor, distance=20):
"""
Checks if there is any of the bright radio sources defined in targets
near the center of the image.
:param accessor: a TKP accessor
:param distance: maximum allowed distance of a bright source (in degrees)
:returns: False if not bright sourc... | [
"def",
"is_bright_source_near",
"(",
"accessor",
",",
"distance",
"=",
"20",
")",
":",
"#TODO: this function should be split up and tested more atomically",
"# The measures object is our interface to casacore",
"m",
"=",
"measures",
"(",
")",
"# First, you need to set the reference... | [
38,
0
] | [
80,
16
] | python | en | ['en', 'error', 'th'] | False |
DraftCreationTests.test_missing_timestamps | (self) | If a timestamp is not provided for a draft dict then it should be automatically
filled in. | If a timestamp is not provided for a draft dict then it should be automatically
filled in. | def test_missing_timestamps(self) -> None:
"""If a timestamp is not provided for a draft dict then it should be automatically
filled in."""
hamlet = self.example_user("hamlet")
visible_stream_name = self.get_streams(hamlet)[0]
visible_stream_id = self.get_stream_id(visible_stream... | [
"def",
"test_missing_timestamps",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"visible_stream_name",
"=",
"self",
".",
"get_streams",
"(",
"hamlet",
")",
"[",
"0",
"]",
"visible_stream_id",
"=",
"s... | [
147,
4
] | [
176,
63
] | python | en | ['en', 'en', 'en'] | True |
DraftCreationTests.test_create_non_stream_draft_with_no_recipient | (self) | When "to" is an empty list, the type should become "" as well. | When "to" is an empty list, the type should become "" as well. | def test_create_non_stream_draft_with_no_recipient(self) -> None:
"""When "to" is an empty list, the type should become "" as well."""
draft_dicts = [
{
"type": "private",
"to": [],
"topic": "sync drafts",
"content": "Let's add ... | [
"def",
"test_create_non_stream_draft_with_no_recipient",
"(",
"self",
")",
"->",
"None",
":",
"draft_dicts",
"=",
"[",
"{",
"\"type\"",
":",
"\"private\"",
",",
"\"to\"",
":",
"[",
"]",
",",
"\"topic\"",
":",
"\"sync drafts\"",
",",
"\"content\"",
":",
"\"Let's ... | [
190,
4
] | [
224,
83
] | python | en | ['en', 'en', 'en'] | True |
ScanningLoader.loadTestsFromModule | (self, module, pattern=None) | Return a suite of all tests cases contained in the given module
If the module is a package, load tests from all the modules in it.
If the module has an ``additional_tests`` function, call it and add
the return value to the tests.
| Return a suite of all tests cases contained in the given module | def loadTestsFromModule(self, module, pattern=None):
"""Return a suite of all tests cases contained in the given module
If the module is a package, load tests from all the modules in it.
If the module has an ``additional_tests`` function, call it and add
the return value to the tests.
... | [
"def",
"loadTestsFromModule",
"(",
"self",
",",
"module",
",",
"pattern",
"=",
"None",
")",
":",
"if",
"module",
"in",
"self",
".",
"_visited",
":",
"return",
"None",
"self",
".",
"_visited",
".",
"add",
"(",
"module",
")",
"tests",
"=",
"[",
"]",
"t... | [
23,
4
] | [
54,
27
] | python | en | ['en', 'en', 'en'] | True |
test.with_project_on_sys_path | (self, func) |
Backward compatibility for project_on_sys_path context.
|
Backward compatibility for project_on_sys_path context.
| def with_project_on_sys_path(self, func):
"""
Backward compatibility for project_on_sys_path context.
"""
with self.project_on_sys_path():
func() | [
"def",
"with_project_on_sys_path",
"(",
"self",
",",
"func",
")",
":",
"with",
"self",
".",
"project_on_sys_path",
"(",
")",
":",
"func",
"(",
")"
] | [
117,
4
] | [
122,
18
] | python | en | ['en', 'error', 'th'] | False |
test.paths_on_pythonpath | (paths) |
Add the indicated paths to the head of the PYTHONPATH environment
variable so that subprocesses will also see the packages at
these paths.
Do this in a context that restores the value on exit.
|
Add the indicated paths to the head of the PYTHONPATH environment
variable so that subprocesses will also see the packages at
these paths. | def paths_on_pythonpath(paths):
"""
Add the indicated paths to the head of the PYTHONPATH environment
variable so that subprocesses will also see the packages at
these paths.
Do this in a context that restores the value on exit.
"""
nothing = object()
ori... | [
"def",
"paths_on_pythonpath",
"(",
"paths",
")",
":",
"nothing",
"=",
"object",
"(",
")",
"orig_pythonpath",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PYTHONPATH'",
",",
"nothing",
")",
"current_pythonpath",
"=",
"os",
".",
"environ",
".",
"get",
"(",
... | [
172,
4
] | [
194,
58
] | python | en | ['en', 'error', 'th'] | False |
test.install_dists | (dist) |
Install the requirements indicated by self.distribution and
return an iterable of the dists that were built.
|
Install the requirements indicated by self.distribution and
return an iterable of the dists that were built.
| def install_dists(dist):
"""
Install the requirements indicated by self.distribution and
return an iterable of the dists that were built.
"""
ir_d = dist.fetch_build_eggs(dist.install_requires)
tr_d = dist.fetch_build_eggs(dist.tests_require or [])
er_d = dist.fet... | [
"def",
"install_dists",
"(",
"dist",
")",
":",
"ir_d",
"=",
"dist",
".",
"fetch_build_eggs",
"(",
"dist",
".",
"install_requires",
")",
"tr_d",
"=",
"dist",
".",
"fetch_build_eggs",
"(",
"dist",
".",
"tests_require",
"or",
"[",
"]",
")",
"er_d",
"=",
"di... | [
197,
4
] | [
208,
48
] | python | en | ['en', 'error', 'th'] | False |
test._resolve_as_ep | (val) |
Load the indicated attribute value, called, as a as if it were
specified as an entry point.
|
Load the indicated attribute value, called, as a as if it were
specified as an entry point.
| def _resolve_as_ep(val):
"""
Load the indicated attribute value, called, as a as if it were
specified as an entry point.
"""
if val is None:
return
parsed = EntryPoint.parse("x=" + val)
return parsed.resolve()() | [
"def",
"_resolve_as_ep",
"(",
"val",
")",
":",
"if",
"val",
"is",
"None",
":",
"return",
"parsed",
"=",
"EntryPoint",
".",
"parse",
"(",
"\"x=\"",
"+",
"val",
")",
"return",
"parsed",
".",
"resolve",
"(",
")",
"(",
")"
] | [
265,
4
] | [
273,
33
] | python | en | ['en', 'error', 'th'] | False |
_xml_escape | (data) | Escape &, <, >, ", ', etc. in a string of data. | Escape &, <, >, ", ', etc. in a string of data. | def _xml_escape(data):
"""Escape &, <, >, ", ', etc. in a string of data."""
# ampersand must be replaced first
from_symbols = '&><"\''
to_symbols = ('&'+s+';' for s in "amp gt lt quot apos".split())
for from_,to_ in zip(from_symbols, to_symbols):
data = data.replace(from_, to_)
... | [
"def",
"_xml_escape",
"(",
"data",
")",
":",
"# ampersand must be replaced first\r",
"from_symbols",
"=",
"'&><\"\\''",
"to_symbols",
"=",
"(",
"'&'",
"+",
"s",
"+",
"';'",
"for",
"s",
"in",
"\"amp gt lt quot apos\"",
".",
"split",
"(",
")",
")",
"for",
"from_... | [
184,
0
] | [
192,
15
] | python | en | ['en', 'en', 'en'] | True |
col | (loc,strg) | Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
... | Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
... | def col (loc,strg):
"""Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parseStrin... | [
"def",
"col",
"(",
"loc",
",",
"strg",
")",
":",
"s",
"=",
"strg",
"return",
"1",
"if",
"0",
"<",
"loc",
"<",
"len",
"(",
"s",
")",
"and",
"s",
"[",
"loc",
"-",
"1",
"]",
"==",
"'\\n'",
"else",
"loc",
"-",
"s",
".",
"rfind",
"(",
"\"\\n\"",... | [
967,
0
] | [
978,
82
] | python | en | ['en', 'en', 'en'] | True |
lineno | (loc,strg) | Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
... | Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
... | def lineno(loc,strg):
"""Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parse... | [
"def",
"lineno",
"(",
"loc",
",",
"strg",
")",
":",
"return",
"strg",
".",
"count",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"+",
"1"
] | [
980,
0
] | [
990,
37
] | python | en | ['en', 'en', 'en'] | True |
line | ( loc, strg ) | Returns the line of text containing loc within a string, counting newlines as line separators.
| Returns the line of text containing loc within a string, counting newlines as line separators.
| def line( loc, strg ):
"""Returns the line of text containing loc within a string, counting newlines as line separators.
"""
lastCR = strg.rfind("\n", 0, loc)
nextCR = strg.find("\n", loc)
if nextCR >= 0:
return strg[lastCR+1:nextCR]
else:
return strg[lastCR+1:] | [
"def",
"line",
"(",
"loc",
",",
"strg",
")",
":",
"lastCR",
"=",
"strg",
".",
"rfind",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"nextCR",
"=",
"strg",
".",
"find",
"(",
"\"\\n\"",
",",
"loc",
")",
"if",
"nextCR",
">=",
"0",
":",
"return",
"st... | [
992,
0
] | [
1000,
30
] | python | en | ['en', 'en', 'en'] | True |
nullDebugAction | (*args) | Do-nothing' debug action, to suppress debugging output during parsing. | Do-nothing' debug action, to suppress debugging output during parsing. | def nullDebugAction(*args):
"""'Do-nothing' debug action, to suppress debugging output during parsing."""
pass | [
"def",
"nullDebugAction",
"(",
"*",
"args",
")",
":",
"pass"
] | [
1011,
0
] | [
1013,
8
] | python | en | ['en', 'jv', 'en'] | True |
ParseBaseException._from_exception | (cls, pe) |
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
|
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
| def _from_exception(cls, pe):
"""
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
"""
return cls(pe.pstr, pe.loc, pe.msg, pe.parserElement) | [
"def",
"_from_exception",
"(",
"cls",
",",
"pe",
")",
":",
"return",
"cls",
"(",
"pe",
".",
"pstr",
",",
"pe",
".",
"loc",
",",
"pe",
".",
"msg",
",",
"pe",
".",
"parserElement",
")"
] | [
220,
4
] | [
225,
61
] | python | en | ['en', 'ja', 'th'] | False |
ParseBaseException.__getattr__ | ( self, aname ) | supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| def __getattr__( self, aname ):
"""supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
"""
if( aname ==... | [
"def",
"__getattr__",
"(",
"self",
",",
"aname",
")",
":",
"if",
"(",
"aname",
"==",
"\"lineno\"",
")",
":",
"return",
"lineno",
"(",
"self",
".",
"loc",
",",
"self",
".",
"pstr",
")",
"elif",
"(",
"aname",
"in",
"(",
"\"col\"",
",",
"\"column\"",
... | [
227,
4
] | [
240,
39
] | python | en | ['en', 'en', 'en'] | True |
ParseBaseException.markInputline | ( self, markerString = ">!<" ) | Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| def markInputline( self, markerString = ">!<" ):
"""Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
"""
line_str = self.line
line_column = self.column - 1
if markerString:
line_str = "... | [
"def",
"markInputline",
"(",
"self",
",",
"markerString",
"=",
"\">!<\"",
")",
":",
"line_str",
"=",
"self",
".",
"line",
"line_column",
"=",
"self",
".",
"column",
"-",
"1",
"if",
"markerString",
":",
"line_str",
"=",
"\"\"",
".",
"join",
"(",
"(",
"l... | [
247,
4
] | [
256,
31
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.