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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Schema.dereference | (self) |
Instruct all children to perform dereferencing.
|
Instruct all children to perform dereferencing.
| def dereference(self):
"""
Instruct all children to perform dereferencing.
"""
all = []
indexes = {}
for child in self.children:
child.content(all)
deplist = DepList()
for x in all:
x.qualify()
midx, deps = x.dependencie... | [
"def",
"dereference",
"(",
"self",
")",
":",
"all",
"=",
"[",
"]",
"indexes",
"=",
"{",
"}",
"for",
"child",
"in",
"self",
".",
"children",
":",
"child",
".",
"content",
"(",
"all",
")",
"deplist",
"=",
"DepList",
"(",
")",
"for",
"x",
"in",
"all... | [
311,
4
] | [
331,
22
] | python | en | ['en', 'error', 'th'] | False |
Schema.locate | (self, ns) |
Find a schema by namespace. Only the URI portion of
the namespace is compared to each schema's I{targetNamespace}.
The request is passed to the container.
@param ns: A namespace.
@type ns: (prefix,URI)
@return: The schema matching the namesapce, else None.
@rtyp... |
Find a schema by namespace. Only the URI portion of
the namespace is compared to each schema's I{targetNamespace}.
The request is passed to the container.
| def locate(self, ns):
"""
Find a schema by namespace. Only the URI portion of
the namespace is compared to each schema's I{targetNamespace}.
The request is passed to the container.
@param ns: A namespace.
@type ns: (prefix,URI)
@return: The schema matching the na... | [
"def",
"locate",
"(",
"self",
",",
"ns",
")",
":",
"if",
"self",
".",
"container",
"is",
"not",
"None",
":",
"return",
"self",
".",
"container",
".",
"locate",
"(",
"ns",
")",
"else",
":",
"return",
"None"
] | [
333,
4
] | [
346,
23
] | python | en | ['en', 'error', 'th'] | False |
Schema.custom | (self, ref, context=None) |
Get whether the specified reference is B{not} an (xs) builtin.
@param ref: A str or qref.
@type ref: (str|qref)
@return: True if B{not} a builtin, else False.
@rtype: bool
|
Get whether the specified reference is B{not} an (xs) builtin.
| def custom(self, ref, context=None):
"""
Get whether the specified reference is B{not} an (xs) builtin.
@param ref: A str or qref.
@type ref: (str|qref)
@return: True if B{not} a builtin, else False.
@rtype: bool
"""
if ref is None:
return Tru... | [
"def",
"custom",
"(",
"self",
",",
"ref",
",",
"context",
"=",
"None",
")",
":",
"if",
"ref",
"is",
"None",
":",
"return",
"True",
"else",
":",
"return",
"(",
"not",
"self",
".",
"builtin",
"(",
"ref",
",",
"context",
")",
")"
] | [
348,
4
] | [
359,
53
] | python | en | ['en', 'error', 'th'] | False |
Schema.builtin | (self, ref, context=None) |
Get whether the specified reference is an (xs) builtin.
@param ref: A str or qref.
@type ref: (str|qref)
@return: True if builtin, else False.
@rtype: bool
|
Get whether the specified reference is an (xs) builtin.
| def builtin(self, ref, context=None):
"""
Get whether the specified reference is an (xs) builtin.
@param ref: A str or qref.
@type ref: (str|qref)
@return: True if builtin, else False.
@rtype: bool
"""
w3 = 'http://www.w3.org'
try:
if ... | [
"def",
"builtin",
"(",
"self",
",",
"ref",
",",
"context",
"=",
"None",
")",
":",
"w3",
"=",
"'http://www.w3.org'",
"try",
":",
"if",
"isqref",
"(",
"ref",
")",
":",
"ns",
"=",
"ref",
"[",
"1",
"]",
"return",
"(",
"ref",
"[",
"0",
"]",
"in",
"F... | [
361,
4
] | [
380,
24
] | python | en | ['en', 'error', 'th'] | False |
Schema.instance | (self, root, baseurl, options) |
Create and return an new schema object using the
specified I{root} and I{url}.
@param root: A schema root node.
@type root: L{sax.element.Element}
@param baseurl: A base URL.
@type baseurl: str
@param options: An options dictionary.
@type options: L{optio... |
Create and return an new schema object using the
specified I{root} and I{url}.
| def instance(self, root, baseurl, options):
"""
Create and return an new schema object using the
specified I{root} and I{url}.
@param root: A schema root node.
@type root: L{sax.element.Element}
@param baseurl: A base URL.
@type baseurl: str
@param options... | [
"def",
"instance",
"(",
"self",
",",
"root",
",",
"baseurl",
",",
"options",
")",
":",
"return",
"Schema",
"(",
"root",
",",
"baseurl",
",",
"options",
")"
] | [
382,
4
] | [
396,
45
] | python | en | ['en', 'error', 'th'] | False |
hide_file | (path) |
Set the hidden attribute on a file or directory.
From http://stackoverflow.com/questions/19622133/
`path` must be text.
|
Set the hidden attribute on a file or directory. | def hide_file(path):
"""
Set the hidden attribute on a file or directory.
From http://stackoverflow.com/questions/19622133/
`path` must be text.
"""
__import__('ctypes.wintypes')
SetFileAttributes = ctypes.windll.kernel32.SetFileAttributesW
SetFileAttributes.argtypes = ctypes.wintypes.... | [
"def",
"hide_file",
"(",
"path",
")",
":",
"__import__",
"(",
"'ctypes.wintypes'",
")",
"SetFileAttributes",
"=",
"ctypes",
".",
"windll",
".",
"kernel32",
".",
"SetFileAttributesW",
"SetFileAttributes",
".",
"argtypes",
"=",
"ctypes",
".",
"wintypes",
".",
"LPW... | [
11,
0
] | [
28,
31
] | python | en | ['en', 'error', 'th'] | False |
send_to_push_bouncer | (
method: str,
endpoint: str,
post_data: Union[bytes, Mapping[str, Union[str, bytes]]],
extra_headers: Mapping[str, str] = {},
) | While it does actually send the notice, this function has a lot of
code and comments around error handling for the push notifications
bouncer. There are several classes of failures, each with its own
potential solution:
* Network errors with requests.request. We raise an exception to signal
it ... | While it does actually send the notice, this function has a lot of
code and comments around error handling for the push notifications
bouncer. There are several classes of failures, each with its own
potential solution: | def send_to_push_bouncer(
method: str,
endpoint: str,
post_data: Union[bytes, Mapping[str, Union[str, bytes]]],
extra_headers: Mapping[str, str] = {},
) -> Dict[str, object]:
"""While it does actually send the notice, this function has a lot of
code and comments around error handling for the pus... | [
"def",
"send_to_push_bouncer",
"(",
"method",
":",
"str",
",",
"endpoint",
":",
"str",
",",
"post_data",
":",
"Union",
"[",
"bytes",
",",
"Mapping",
"[",
"str",
",",
"Union",
"[",
"str",
",",
"bytes",
"]",
"]",
"]",
",",
"extra_headers",
":",
"Mapping"... | [
25,
0
] | [
99,
36
] | python | en | ['en', 'en', 'en'] | True |
server_ssl_context | () |
Returns an SSL context for the mock RT server to use, with a self signed
certificate.
|
Returns an SSL context for the mock RT server to use, with a self signed
certificate.
| def server_ssl_context():
"""
Returns an SSL context for the mock RT server to use, with a self signed
certificate.
"""
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS)
ssl_context.load_cert_chain(
path_to_test_resource("dummy_cert"),
keyfile=path_to_test_resource("dummy_key"),
... | [
"def",
"server_ssl_context",
"(",
")",
":",
"ssl_context",
"=",
"ssl",
".",
"SSLContext",
"(",
"ssl",
".",
"PROTOCOL_TLS",
")",
"ssl_context",
".",
"load_cert_chain",
"(",
"path_to_test_resource",
"(",
"\"dummy_cert\"",
")",
",",
"keyfile",
"=",
"path_to_test_reso... | [
10,
0
] | [
21,
22
] | python | en | ['en', 'error', 'th'] | False |
mock_server | () |
Fixture for creating a mock RT server. The server is designed
to behave very similarly to the actual RT server, but returns
dummy responses to most messages.
The server runs in a background thread and is cleaned up as part of the
fixture's tear-down step.
Yields:
tests.mock_rt_server.... |
Fixture for creating a mock RT server. The server is designed
to behave very similarly to the actual RT server, but returns
dummy responses to most messages. | def mock_server():
"""
Fixture for creating a mock RT server. The server is designed
to behave very similarly to the actual RT server, but returns
dummy responses to most messages.
The server runs in a background thread and is cleaned up as part of the
fixture's tear-down step.
Yields:
... | [
"def",
"mock_server",
"(",
")",
":",
"logbook",
"=",
"MockRealtimeLogbook",
"(",
")",
"logbook",
".",
"url",
"=",
"\"wss://127.0.0.1:8765/v2\"",
"MockRealtimeServer",
".",
"logbook",
"=",
"logbook",
"server",
"=",
"SimpleSSLWebSocketServer",
"(",
"\"127.0.0.1\"",
",... | [
25,
0
] | [
60,
5
] | 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 |
get_openapi_fixture | (endpoint: str, method: str, status_code: str = "200") | Fetch a fixture from the full spec object. | Fetch a fixture from the full spec object. | def get_openapi_fixture(endpoint: str, method: str, status_code: str = "200") -> Dict[str, Any]:
"""Fetch a fixture from the full spec object."""
return get_schema(endpoint, method, status_code)["example"] | [
"def",
"get_openapi_fixture",
"(",
"endpoint",
":",
"str",
",",
"method",
":",
"str",
",",
"status_code",
":",
"str",
"=",
"\"200\"",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"get_schema",
"(",
"endpoint",
",",
"method",
",",
"sta... | [
205,
0
] | [
207,
63
] | python | en | ['en', 'en', 'en'] | True |
get_openapi_description | (endpoint: str, method: str) | Fetch a description from the full spec object. | Fetch a description from the full spec object. | def get_openapi_description(endpoint: str, method: str) -> str:
"""Fetch a description from the full spec object."""
return openapi_spec.openapi()["paths"][endpoint][method.lower()]["description"] | [
"def",
"get_openapi_description",
"(",
"endpoint",
":",
"str",
",",
"method",
":",
"str",
")",
"->",
"str",
":",
"return",
"openapi_spec",
".",
"openapi",
"(",
")",
"[",
"\"paths\"",
"]",
"[",
"endpoint",
"]",
"[",
"method",
".",
"lower",
"(",
")",
"]"... | [
210,
0
] | [
212,
83
] | python | en | ['en', 'en', 'en'] | True |
fix_events | (content: Dict[str, Any]) | Remove undocumented events from events array. This is a makeshift
function so that further documentation of `/events` can happen with
only zulip.yaml changes and minimal other changes. It should be removed
as soon as `/events` documentation is complete.
| Remove undocumented events from events array. This is a makeshift
function so that further documentation of `/events` can happen with
only zulip.yaml changes and minimal other changes. It should be removed
as soon as `/events` documentation is complete.
| def fix_events(content: Dict[str, Any]) -> None:
"""Remove undocumented events from events array. This is a makeshift
function so that further documentation of `/events` can happen with
only zulip.yaml changes and minimal other changes. It should be removed
as soon as `/events` documentation is complete... | [
"def",
"fix_events",
"(",
"content",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"# 'user' is deprecated so remove its occurrences from the events array",
"for",
"event",
"in",
"content",
"[",
"\"events\"",
"]",
":",
"event",
".",
"pop",
"(... | [
255,
0
] | [
263,
31
] | python | en | ['en', 'en', 'en'] | True |
validate_against_openapi_schema | (
content: Dict[str, Any],
path: str,
method: str,
status_code: str,
display_brief_error: bool = False,
) | Compare a "content" dict with the defined schema for a specific method
in an endpoint. Return true if validated and false if skipped.
| Compare a "content" dict with the defined schema for a specific method
in an endpoint. Return true if validated and false if skipped.
| def validate_against_openapi_schema(
content: Dict[str, Any],
path: str,
method: str,
status_code: str,
display_brief_error: bool = False,
) -> bool:
"""Compare a "content" dict with the defined schema for a specific method
in an endpoint. Return true if validated and false if skipped.
"... | [
"def",
"validate_against_openapi_schema",
"(",
"content",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"path",
":",
"str",
",",
"method",
":",
"str",
",",
"status_code",
":",
"str",
",",
"display_brief_error",
":",
"bool",
"=",
"False",
",",
")",
"->",... | [
266,
0
] | [
353,
15
] | python | en | ['en', 'en', 'en'] | True |
validate_schema | (schema: Dict[str, Any]) | Check if opaque objects are present in the OpenAPI spec; this is an
important part of our policy for ensuring every detail of Zulip's
API responses is correct.
This is done by checking for the presence of the
`additionalProperties` attribute for all objects (dictionaries).
| Check if opaque objects are present in the OpenAPI spec; this is an
important part of our policy for ensuring every detail of Zulip's
API responses is correct. | def validate_schema(schema: Dict[str, Any]) -> None:
"""Check if opaque objects are present in the OpenAPI spec; this is an
important part of our policy for ensuring every detail of Zulip's
API responses is correct.
This is done by checking for the presence of the
`additionalProperties` attribute f... | [
"def",
"validate_schema",
"(",
"schema",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"if",
"\"oneOf\"",
"in",
"schema",
":",
"for",
"subschema",
"in",
"schema",
"[",
"\"oneOf\"",
"]",
":",
"validate_schema",
"(",
"subschema",
")",
... | [
356,
0
] | [
378,
59
] | python | en | ['en', 'en', 'en'] | True |
to_python_type | (py_type: str) | Transform an OpenAPI-like type to a Python one.
https://swagger.io/docs/specification/data-models/data-types
| Transform an OpenAPI-like type to a Python one.
https://swagger.io/docs/specification/data-models/data-types
| def to_python_type(py_type: str) -> type:
"""Transform an OpenAPI-like type to a Python one.
https://swagger.io/docs/specification/data-models/data-types
"""
TYPES = {
"string": str,
"number": float,
"integer": int,
"boolean": bool,
"array": list,
"object"... | [
"def",
"to_python_type",
"(",
"py_type",
":",
"str",
")",
"->",
"type",
":",
"TYPES",
"=",
"{",
"\"string\"",
":",
"str",
",",
"\"number\"",
":",
"float",
",",
"\"integer\"",
":",
"int",
",",
"\"boolean\"",
":",
"bool",
",",
"\"array\"",
":",
"list",
"... | [
381,
0
] | [
394,
25
] | python | en | ['en', 'haw', 'en'] | True |
OpenAPISpec.openapi | (self) | Reload the OpenAPI file if it has been modified after the last time
it was read, and then return the parsed data.
| Reload the OpenAPI file if it has been modified after the last time
it was read, and then return the parsed data.
| def openapi(self) -> Dict[str, Any]:
"""Reload the OpenAPI file if it has been modified after the last time
it was read, and then return the parsed data.
"""
self.check_reload()
assert len(self._openapi) > 0
return self._openapi | [
"def",
"openapi",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"self",
".",
"check_reload",
"(",
")",
"assert",
"len",
"(",
"self",
".",
"_openapi",
")",
">",
"0",
"return",
"self",
".",
"_openapi"
] | [
148,
4
] | [
154,
28
] | python | en | ['en', 'en', 'en'] | True |
OpenAPISpec.endpoints_dict | (self) | Reload the OpenAPI file if it has been modified after the last time
it was read, and then return the parsed data.
| Reload the OpenAPI file if it has been modified after the last time
it was read, and then return the parsed data.
| def endpoints_dict(self) -> Dict[str, str]:
"""Reload the OpenAPI file if it has been modified after the last time
it was read, and then return the parsed data.
"""
self.check_reload()
assert len(self._endpoints_dict) > 0
return self._endpoints_dict | [
"def",
"endpoints_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"self",
".",
"check_reload",
"(",
")",
"assert",
"len",
"(",
"self",
".",
"_endpoints_dict",
")",
">",
"0",
"return",
"self",
".",
"_endpoints_dict"
] | [
156,
4
] | [
162,
35
] | python | en | ['en', 'en', 'en'] | True |
OpenAPISpec.request_validator | (self) | Reload the OpenAPI file if it has been modified after the last time
it was read, and then return the openapi_core validator object. Similar
to preceding functions. Used for proper access to OpenAPI objects.
| Reload the OpenAPI file if it has been modified after the last time
it was read, and then return the openapi_core validator object. Similar
to preceding functions. Used for proper access to OpenAPI objects.
| def request_validator(self) -> RequestValidator:
"""Reload the OpenAPI file if it has been modified after the last time
it was read, and then return the openapi_core validator object. Similar
to preceding functions. Used for proper access to OpenAPI objects.
"""
self.check_reload... | [
"def",
"request_validator",
"(",
"self",
")",
"->",
"RequestValidator",
":",
"self",
".",
"check_reload",
"(",
")",
"assert",
"self",
".",
"_request_validator",
"is",
"not",
"None",
"return",
"self",
".",
"_request_validator"
] | [
164,
4
] | [
171,
38
] | python | en | ['en', 'en', 'en'] | True |
Basic.process | (self, node) |
Process an object graph representation of the xml I{node}.
@param node: An XML tree.
@type node: L{sax.element.Element}
@return: A suds object.
@rtype: L{Object}
|
Process an object graph representation of the xml I{node}.
| def process(self, node):
"""
Process an object graph representation of the xml I{node}.
@param node: An XML tree.
@type node: L{sax.element.Element}
@return: A suds object.
@rtype: L{Object}
"""
content = Content(node)
return Core.process(self, con... | [
"def",
"process",
"(",
"self",
",",
"node",
")",
":",
"content",
"=",
"Content",
"(",
"node",
")",
"return",
"Core",
".",
"process",
"(",
"self",
",",
"content",
")"
] | [
31,
4
] | [
40,
42
] | python | en | ['en', 'error', 'th'] | False |
print_symbol | (symbol) |
Prints a single symbol to standard error.
:param symbol: The symbol to print.
:type symbol: str
|
Prints a single symbol to standard error. | def print_symbol(symbol):
"""
Prints a single symbol to standard error.
:param symbol: The symbol to print.
:type symbol: str
"""
print(symbol, end="", file=sys.stderr, flush=True) | [
"def",
"print_symbol",
"(",
"symbol",
")",
":",
"print",
"(",
"symbol",
",",
"end",
"=",
"\"\"",
",",
"file",
"=",
"sys",
".",
"stderr",
",",
"flush",
"=",
"True",
")"
] | [
27,
0
] | [
34,
54
] | python | en | ['en', 'error', 'th'] | False |
parse_additional_vocab | (additional_vocab_filepath) |
Parses an additional vocab list from a file.
:param additional_vocab_filepath: Path to the additional vocab file.
:type additional_vocab_filepath: str
:return: A list of objects or strings which are the additional
vocab items.
:rtype: List[Union[dict, str]]
:raises SystemExit: If the... |
Parses an additional vocab list from a file. | def parse_additional_vocab(additional_vocab_filepath):
"""
Parses an additional vocab list from a file.
:param additional_vocab_filepath: Path to the additional vocab file.
:type additional_vocab_filepath: str
:return: A list of objects or strings which are the additional
vocab items.
... | [
"def",
"parse_additional_vocab",
"(",
"additional_vocab_filepath",
")",
":",
"additional_vocab",
"=",
"[",
"]",
"with",
"open",
"(",
"additional_vocab_filepath",
")",
"as",
"additional_vocab_file",
":",
"try",
":",
"additional_vocab",
"=",
"json",
".",
"load",
"(",
... | [
37,
0
] | [
74,
27
] | python | en | ['en', 'error', 'th'] | False |
additional_vocab_item | (to_parse) |
Parses a single item of additional vocab. Used in conjunction with the
additional vocab command line argument.
:param to_parse: The item to parse.
:type to_parse: str
:return: Either a dictionary or a string depending on the form of the
additional vocab item.
:rtype: Union[dict, str]
... |
Parses a single item of additional vocab. Used in conjunction with the
additional vocab command line argument. | def additional_vocab_item(to_parse):
"""
Parses a single item of additional vocab. Used in conjunction with the
additional vocab command line argument.
:param to_parse: The item to parse.
:type to_parse: str
:return: Either a dictionary or a string depending on the form of the
addition... | [
"def",
"additional_vocab_item",
"(",
"to_parse",
")",
":",
"to_parse",
"=",
"str",
"(",
"to_parse",
")",
"parts",
"=",
"to_parse",
".",
"split",
"(",
"\":\"",
")",
"if",
"len",
"(",
"parts",
")",
">",
"2",
":",
"raise",
"argparse",
".",
"ArgumentTypeErro... | [
77,
0
] | [
119,
27
] | python | en | ['en', 'error', 'th'] | False |
get_log_level | (verbosity) |
Returns the appropriate log level given a verbosity level.
:param verbosity: Verbosity level.
:type verbosity: int
:return: The logging level (eg. logging.INFO).
:rtype: int
:raises SystemExit: If the given verbosity level is invalid.
|
Returns the appropriate log level given a verbosity level. | def get_log_level(verbosity):
"""
Returns the appropriate log level given a verbosity level.
:param verbosity: Verbosity level.
:type verbosity: int
:return: The logging level (eg. logging.INFO).
:rtype: int
:raises SystemExit: If the given verbosity level is invalid.
"""
try:
... | [
"def",
"get_log_level",
"(",
"verbosity",
")",
":",
"try",
":",
"log_level",
"=",
"{",
"0",
":",
"logging",
".",
"WARNING",
",",
"1",
":",
"logging",
".",
"INFO",
",",
"2",
":",
"logging",
".",
"DEBUG",
"}",
"[",
"verbosity",
"]",
"return",
"log_leve... | [
122,
0
] | [
146,
20
] | python | en | ['en', 'error', 'th'] | False |
get_connection_settings | (args) |
Helper function which returns a ConnectionSettings object based on the
command line options given to the program.
:param args: Keyword arguments, typically from the command line.
:type args: dict
:return: Settings for the WebSocket connection.
:rtype: speechmatics.models.ConnectionSettings
... |
Helper function which returns a ConnectionSettings object based on the
command line options given to the program. | def get_connection_settings(args):
"""
Helper function which returns a ConnectionSettings object based on the
command line options given to the program.
:param args: Keyword arguments, typically from the command line.
:type args: dict
:return: Settings for the WebSocket connection.
:rtype:... | [
"def",
"get_connection_settings",
"(",
"args",
")",
":",
"settings",
"=",
"ConnectionSettings",
"(",
"url",
"=",
"args",
"[",
"\"url\"",
"]",
",",
"message_buffer_size",
"=",
"args",
"[",
"\"buffer_size\"",
"]",
")",
"if",
"args",
"[",
"\"ssl_mode\"",
"]",
"... | [
155,
0
] | [
177,
19
] | python | en | ['en', 'error', 'th'] | False |
get_transcription_config | (args) |
Helper function which returns a TranscriptionConfig object based on the
command line options given to the program.
:param args: Keyword arguments probably from the command line.
:type args: dict
:return: Settings for the ASR engine.
:rtype: speechmatics.models.TranscriptionConfig
|
Helper function which returns a TranscriptionConfig object based on the
command line options given to the program. | def get_transcription_config(args):
"""
Helper function which returns a TranscriptionConfig object based on the
command line options given to the program.
:param args: Keyword arguments probably from the command line.
:type args: dict
:return: Settings for the ASR engine.
:rtype: speechmat... | [
"def",
"get_transcription_config",
"(",
"args",
")",
":",
"config",
"=",
"TranscriptionConfig",
"(",
"args",
"[",
"\"lang\"",
"]",
",",
"enable_partials",
"=",
"True",
"if",
"args",
"[",
"\"enable_partials\"",
"]",
"else",
"None",
",",
"output_locale",
"=",
"a... | [
180,
0
] | [
232,
17
] | python | en | ['en', 'error', 'th'] | False |
get_audio_settings | (args) |
Helper function which returns an AudioSettings object based on the command
line options given to the program.
Args:
args (dict): Keyword arguments, typically from the command line.
Returns:
speechmatics.models.TranscriptionConfig: Settings for the audio stream
in the conne... |
Helper function which returns an AudioSettings object based on the command
line options given to the program. | def get_audio_settings(args):
"""
Helper function which returns an AudioSettings object based on the command
line options given to the program.
Args:
args (dict): Keyword arguments, typically from the command line.
Returns:
speechmatics.models.TranscriptionConfig: Settings for the ... | [
"def",
"get_audio_settings",
"(",
"args",
")",
":",
"settings",
"=",
"AudioSettings",
"(",
"sample_rate",
"=",
"args",
"[",
"\"sample_rate\"",
"]",
",",
"chunk_size",
"=",
"args",
"[",
"\"chunk_size\"",
"]",
",",
"encoding",
"=",
"args",
"[",
"\"raw\"",
"]",... | [
235,
0
] | [
252,
19
] | python | en | ['en', 'error', 'th'] | False |
add_printing_handlers | (
api, transcripts, enable_partials=False, debug_handlers_too=False,
speaker_change_token=False, language="en") |
Adds a set of handlers to the websocket client which print out transcripts
as they are received. This includes partials if they are enabled.
Args:
api (speechmatics.client.WebsocketClient): Client instance.
transcripts (Transcripts): Allows the transcripts to be concatenated to
... |
Adds a set of handlers to the websocket client which print out transcripts
as they are received. This includes partials if they are enabled. | def add_printing_handlers(
api, transcripts, enable_partials=False, debug_handlers_too=False,
speaker_change_token=False, language="en"):
"""
Adds a set of handlers to the websocket client which print out transcripts
as they are received. This includes partials if they are enabled.
Args... | [
"def",
"add_printing_handlers",
"(",
"api",
",",
"transcripts",
",",
"enable_partials",
"=",
"False",
",",
"debug_handlers_too",
"=",
"False",
",",
"speaker_change_token",
"=",
"False",
",",
"language",
"=",
"\"en\"",
")",
":",
"if",
"debug_handlers_too",
":",
"... | [
256,
0
] | [
332,
69
] | python | en | ['en', 'error', 'th'] | False |
join_words | (words, language="en") |
Joins a list of words with a language specific separator. Because not all
languages use the standard English white-space between words.
:param words: List of words
:type words: List[str]
:param language: Language code
:type language: str
:return: Words joined with a language-specific sep... |
Joins a list of words with a language specific separator. Because not all
languages use the standard English white-space between words. | def join_words(words, language="en"):
"""
Joins a list of words with a language specific separator. Because not all
languages use the standard English white-space between words.
:param words: List of words
:type words: List[str]
:param language: Language code
:type language: str
:retu... | [
"def",
"join_words",
"(",
"words",
",",
"language",
"=",
"\"en\"",
")",
":",
"if",
"language",
"in",
"{",
"\"ja\"",
",",
"\"cmn\"",
"}",
":",
"separator",
"=",
"\"\"",
"else",
":",
"separator",
"=",
"\" \"",
"return",
"separator",
".",
"join",
"(",
"wo... | [
335,
0
] | [
353,
32
] | python | en | ['en', 'error', 'th'] | False |
main | (args=None) |
Main entrypoint.
:param args: command-line arguments; defaults to None in which
case arguments will retrieved from `sys.argv` (this is useful
mainly for unit tests).
:type args: List[str]
|
Main entrypoint. | def main(args=None):
"""
Main entrypoint.
:param args: command-line arguments; defaults to None in which
case arguments will retrieved from `sys.argv` (this is useful
mainly for unit tests).
:type args: List[str]
"""
if not args:
args = vars(parse_args())
lo... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"if",
"not",
"args",
":",
"args",
"=",
"vars",
"(",
"parse_args",
"(",
")",
")",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"get_log_level",
"(",
"args",
"[",
"\"verbose\"",
"]",
")",
")",
"... | [
356,
0
] | [
412,
31
] | python | en | ['en', 'error', 'th'] | False |
parse_args | (args=None) |
Parses command-line arguments.
:param args: List of arguments to parse.
:type args: (List[str], optional)
:return: The set of arguments provided along with their values.
:rtype: Namespace
|
Parses command-line arguments. | def parse_args(args=None):
"""
Parses command-line arguments.
:param args: List of arguments to parse.
:type args: (List[str], optional)
:return: The set of arguments provided along with their values.
:rtype: Namespace
"""
parser = argparse.ArgumentParser(
description="CLI for ... | [
"def",
"parse_args",
"(",
"args",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"CLI for Speechmatics products.\"",
")",
"parser",
".",
"add_argument",
"(",
"\"-v\"",
",",
"dest",
"=",
"\"verbose\"",
",",
"... | [
415,
0
] | [
583,
39
] | python | en | ['en', 'error', 'th'] | False |
get_project_name | (project_id, projects) | Retrieves project name for given project id
Args:
projects: List of projects
project_id: project id
Returns: Project name or None if there is no match
| Retrieves project name for given project id | def get_project_name(project_id, projects):
"""Retrieves project name for given project id
Args:
projects: List of projects
project_id: project id
Returns: Project name or None if there is no match
"""
for project in projects:
if project_id == project.id:
return... | [
"def",
"get_project_name",
"(",
"project_id",
",",
"projects",
")",
":",
"for",
"project",
"in",
"projects",
":",
"if",
"project_id",
"==",
"project",
".",
"id",
":",
"return",
"project",
".",
"name"
] | [
114,
0
] | [
125,
31
] | python | en | ['da', 'en', 'en'] | True |
get_domain_id_for_operation | (request) | Get the ID of the domain in which the current operation should happen.
If the user has a domain context set, use that, otherwise use the user's
effective domain.
| Get the ID of the domain in which the current operation should happen. | def get_domain_id_for_operation(request):
"""Get the ID of the domain in which the current operation should happen.
If the user has a domain context set, use that, otherwise use the user's
effective domain.
"""
domain_context = request.session.get('domain_context')
if domain_context:
r... | [
"def",
"get_domain_id_for_operation",
"(",
"request",
")",
":",
"domain_context",
"=",
"request",
".",
"session",
".",
"get",
"(",
"'domain_context'",
")",
"if",
"domain_context",
":",
"return",
"domain_context",
"return",
"api",
".",
"keystone",
".",
"get_effecti... | [
17,
0
] | [
27,
56
] | python | en | ['en', 'en', 'en'] | True |
__newobj_ex__ | (cls, args, kwargs) | Used by pickle protocol 4, instead of __newobj__ to allow classes with
keyword-only arguments to be pickled correctly.
| Used by pickle protocol 4, instead of __newobj__ to allow classes with
keyword-only arguments to be pickled correctly.
| def __newobj_ex__(cls, args, kwargs):
"""Used by pickle protocol 4, instead of __newobj__ to allow classes with
keyword-only arguments to be pickled correctly.
"""
return cls.__new__(cls, *args, **kwargs) | [
"def",
"__newobj_ex__",
"(",
"cls",
",",
"args",
",",
"kwargs",
")",
":",
"return",
"cls",
".",
"__new__",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | [
89,
0
] | [
93,
44
] | python | en | ['en', 'en', 'en'] | True |
_slotnames | (cls) | Return a list of slot names for a given class.
This needs to find slots defined by the class and its bases, so we
can't simply return the __slots__ attribute. We must walk down
the Method Resolution Order and concatenate the __slots__ of each
class found there. (This assumes classes don't modify thei... | Return a list of slot names for a given class. | def _slotnames(cls):
"""Return a list of slot names for a given class.
This needs to find slots defined by the class and its bases, so we
can't simply return the __slots__ attribute. We must walk down
the Method Resolution Order and concatenate the __slots__ of each
class found there. (This assum... | [
"def",
"_slotnames",
"(",
"cls",
")",
":",
"# Get the value from a cache in the class if possible",
"names",
"=",
"cls",
".",
"__dict__",
".",
"get",
"(",
"\"__slotnames__\"",
")",
"if",
"names",
"is",
"not",
"None",
":",
"return",
"names",
"# Not cached -- calculat... | [
95,
0
] | [
144,
16
] | python | en | ['en', 'en', 'en'] | True |
add_extension | (module, name, code) | Register an extension code. | Register an extension code. | def add_extension(module, name, code):
"""Register an extension code."""
code = int(code)
if not 1 <= code <= 0x7fffffff:
raise ValueError("code out of range")
key = (module, name)
if (_extension_registry.get(key) == code and
_inverted_registry.get(code) == key):
return # Red... | [
"def",
"add_extension",
"(",
"module",
",",
"name",
",",
"code",
")",
":",
"code",
"=",
"int",
"(",
"code",
")",
"if",
"not",
"1",
"<=",
"code",
"<=",
"0x7fffffff",
":",
"raise",
"ValueError",
"(",
"\"code out of range\"",
")",
"key",
"=",
"(",
"module... | [
161,
0
] | [
177,
34
] | python | en | ['en', 'lb', 'en'] | True |
remove_extension | (module, name, code) | Unregister an extension code. For testing only. | Unregister an extension code. For testing only. | def remove_extension(module, name, code):
"""Unregister an extension code. For testing only."""
key = (module, name)
if (_extension_registry.get(key) != code or
_inverted_registry.get(code) != key):
raise ValueError("key %s is not registered with code %s" %
(key, co... | [
"def",
"remove_extension",
"(",
"module",
",",
"name",
",",
"code",
")",
":",
"key",
"=",
"(",
"module",
",",
"name",
")",
"if",
"(",
"_extension_registry",
".",
"get",
"(",
"key",
")",
"!=",
"code",
"or",
"_inverted_registry",
".",
"get",
"(",
"code",... | [
179,
0
] | [
189,
34
] | python | en | ['en', 'en', 'en'] | True |
DatabasePerfContext.__init__ | (self, perf_context_ts, stats_freq_sec, cumulative) |
perf_context_ts is expected to be in the following format:
Dict[metric, Dict[timestamp, value]], where for
each (metric, timestamp) pair, the value is database-wide (i.e.
summed over all the threads involved)
if stats_freq_sec == 0, per-metric only one value is reported
|
perf_context_ts is expected to be in the following format:
Dict[metric, Dict[timestamp, value]], where for
each (metric, timestamp) pair, the value is database-wide (i.e.
summed over all the threads involved)
if stats_freq_sec == 0, per-metric only one value is reported
| def __init__(self, perf_context_ts, stats_freq_sec, cumulative):
'''
perf_context_ts is expected to be in the following format:
Dict[metric, Dict[timestamp, value]], where for
each (metric, timestamp) pair, the value is database-wide (i.e.
summed over all the threads involved)
... | [
"def",
"__init__",
"(",
"self",
",",
"perf_context_ts",
",",
"stats_freq_sec",
",",
"cumulative",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"stats_freq_sec",
"=",
"stats_freq_sec",
"self",
".",
"keys_ts",
"=",
"{",
"NO_ENTITY",
"... | [
124,
4
] | [
136,
39
] | python | en | ['en', 'error', 'th'] | False |
generate_metadata | (build_env, backend) | Generate metadata using mechanisms described in PEP 517.
Returns the generated metadata directory.
| Generate metadata using mechanisms described in PEP 517. | def generate_metadata(build_env, backend):
# type: (BuildEnvironment, Pep517HookCaller) -> str
"""Generate metadata using mechanisms described in PEP 517.
Returns the generated metadata directory.
"""
metadata_tmpdir = TempDirectory(
kind="modern-metadata", globally_managed=True
)
... | [
"def",
"generate_metadata",
"(",
"build_env",
",",
"backend",
")",
":",
"# type: (BuildEnvironment, Pep517HookCaller) -> str",
"metadata_tmpdir",
"=",
"TempDirectory",
"(",
"kind",
"=",
"\"modern-metadata\"",
",",
"globally_managed",
"=",
"True",
")",
"metadata_dir",
"=",... | [
14,
0
] | [
36,
51
] | python | en | ['en', 'nl', 'en'] | True |
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 |
EmailLogBackEnd.log_email | (email: EmailMultiAlternatives) | Used in development to record sent emails in a nice HTML log | Used in development to record sent emails in a nice HTML log | def log_email(email: EmailMultiAlternatives) -> None:
"""Used in development to record sent emails in a nice HTML log"""
html_message = "Missing HTML message"
if len(email.alternatives) > 0:
html_message = email.alternatives[0][0]
context = {
"subject": email.sub... | [
"def",
"log_email",
"(",
"email",
":",
"EmailMultiAlternatives",
")",
"->",
"None",
":",
"html_message",
"=",
"\"Missing HTML message\"",
"if",
"len",
"(",
"email",
".",
"alternatives",
")",
">",
"0",
":",
"html_message",
"=",
"email",
".",
"alternatives",
"["... | [
34,
4
] | [
61,
48
] | python | en | ['en', 'en', 'en'] | True |
SecurityGroupsFilterAction.filter | (self, table, security_groups, filter_string) | Naive case-insensitive search. | Naive case-insensitive search. | def filter(self, table, security_groups, filter_string):
"""Naive case-insensitive search."""
query = filter_string.lower()
return [security_group for security_group in security_groups
if query in security_group.name.lower()] | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"security_groups",
",",
"filter_string",
")",
":",
"query",
"=",
"filter_string",
".",
"lower",
"(",
")",
"return",
"[",
"security_group",
"for",
"security_group",
"in",
"security_groups",
"if",
"query",
"in",
... | [
104,
4
] | [
108,
56
] | python | en | ['en', 'it', 'en'] | True |
parse | (doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs) | Parse an HTML document as a string or file-like object into a tree
:arg doc: the document to parse as a string or file-like object
:arg treebuilder: the treebuilder to use when parsing
:arg namespaceHTMLElements: whether or not to namespace HTML elements
:returns: parsed tree
Example:
>>> ... | Parse an HTML document as a string or file-like object into a tree | def parse(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs):
"""Parse an HTML document as a string or file-like object into a tree
:arg doc: the document to parse as a string or file-like object
:arg treebuilder: the treebuilder to use when parsing
:arg namespaceHTMLElements: whether or... | [
"def",
"parse",
"(",
"doc",
",",
"treebuilder",
"=",
"\"etree\"",
",",
"namespaceHTMLElements",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"tb",
"=",
"treebuilders",
".",
"getTreeBuilder",
"(",
"treebuilder",
")",
"p",
"=",
"HTMLParser",
"(",
"tb",
... | [
25,
0
] | [
45,
33
] | python | en | ['en', 'en', 'en'] | True |
parseFragment | (doc, container="div", treebuilder="etree", namespaceHTMLElements=True, **kwargs) | Parse an HTML fragment as a string or file-like object into a tree
:arg doc: the fragment to parse as a string or file-like object
:arg container: the container context to parse the fragment in
:arg treebuilder: the treebuilder to use when parsing
:arg namespaceHTMLElements: whether or not to namesp... | Parse an HTML fragment as a string or file-like object into a tree | def parseFragment(doc, container="div", treebuilder="etree", namespaceHTMLElements=True, **kwargs):
"""Parse an HTML fragment as a string or file-like object into a tree
:arg doc: the fragment to parse as a string or file-like object
:arg container: the container context to parse the fragment in
:arg... | [
"def",
"parseFragment",
"(",
"doc",
",",
"container",
"=",
"\"div\"",
",",
"treebuilder",
"=",
"\"etree\"",
",",
"namespaceHTMLElements",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"tb",
"=",
"treebuilders",
".",
"getTreeBuilder",
"(",
"treebuilder",
")... | [
48,
0
] | [
70,
62
] | python | en | ['en', 'en', 'en'] | True |
log | (function) | Logger that records which phase processes each token | Logger that records which phase processes each token | def log(function):
"""Logger that records which phase processes each token"""
type_names = {value: key for key, value in tokenTypes.items()}
def wrapped(self, *args, **kwargs):
if function.__name__.startswith("process") and len(args) > 0:
token = args[0]
... | [
"def",
"log",
"(",
"function",
")",
":",
"type_names",
"=",
"{",
"value",
":",
"key",
"for",
"key",
",",
"value",
"in",
"tokenTypes",
".",
"items",
"(",
")",
"}",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",... | [
397,
4
] | [
416,
22
] | python | en | ['en', 'en', 'en'] | True |
HTMLParser.__init__ | (self, tree=None, strict=False, namespaceHTMLElements=True, debug=False) |
:arg tree: a treebuilder class controlling the type of tree that will be
returned. Built in treebuilders can be accessed through
html5lib.treebuilders.getTreeBuilder(treeType)
:arg strict: raise an exception when a parse error is encountered
:arg namespaceHTMLElements:... |
:arg tree: a treebuilder class controlling the type of tree that will be
returned. Built in treebuilders can be accessed through
html5lib.treebuilders.getTreeBuilder(treeType) | def __init__(self, tree=None, strict=False, namespaceHTMLElements=True, debug=False):
"""
:arg tree: a treebuilder class controlling the type of tree that will be
returned. Built in treebuilders can be accessed through
html5lib.treebuilders.getTreeBuilder(treeType)
:arg ... | [
"def",
"__init__",
"(",
"self",
",",
"tree",
"=",
"None",
",",
"strict",
"=",
"False",
",",
"namespaceHTMLElements",
"=",
"True",
",",
"debug",
"=",
"False",
")",
":",
"# Raise an exception on the first error encountered",
"self",
".",
"strict",
"=",
"strict",
... | [
92,
4
] | [
121,
48
] | python | en | ['en', 'error', 'th'] | False |
HTMLParser.documentEncoding | (self) | Name of the character encoding that was used to decode the input stream, or
:obj:`None` if that is not determined yet
| Name of the character encoding that was used to decode the input stream, or
:obj:`None` if that is not determined yet | def documentEncoding(self):
"""Name of the character encoding that was used to decode the input stream, or
:obj:`None` if that is not determined yet
"""
if not hasattr(self, 'tokenizer'):
return None
return self.tokenizer.stream.charEncoding[0].name | [
"def",
"documentEncoding",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'tokenizer'",
")",
":",
"return",
"None",
"return",
"self",
".",
"tokenizer",
".",
"stream",
".",
"charEncoding",
"[",
"0",
"]",
".",
"name"
] | [
172,
4
] | [
179,
57
] | python | en | ['en', 'en', 'en'] | True |
HTMLParser.parse | (self, stream, *args, **kwargs) | Parse a HTML document into a well-formed tree
:arg stream: a file-like object or string containing the HTML to be parsed
The optional encoding parameter must be a string that indicates
the encoding. If specified, that encoding will be used,
regardless of any BOM or later d... | Parse a HTML document into a well-formed tree | def parse(self, stream, *args, **kwargs):
"""Parse a HTML document into a well-formed tree
:arg stream: a file-like object or string containing the HTML to be parsed
The optional encoding parameter must be a string that indicates
the encoding. If specified, that encoding will ... | [
"def",
"parse",
"(",
"self",
",",
"stream",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_parse",
"(",
"stream",
",",
"False",
",",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"tree",
"."... | [
261,
4
] | [
284,
38
] | python | en | ['en', 'en', 'en'] | True |
HTMLParser.parseFragment | (self, stream, *args, **kwargs) | Parse a HTML fragment into a well-formed tree fragment
:arg container: name of the element we're setting the innerHTML
property if set to None, default to 'div'
:arg stream: a file-like object or string containing the HTML to be parsed
The optional encoding parameter must be a... | Parse a HTML fragment into a well-formed tree fragment | def parseFragment(self, stream, *args, **kwargs):
"""Parse a HTML fragment into a well-formed tree fragment
:arg container: name of the element we're setting the innerHTML
property if set to None, default to 'div'
:arg stream: a file-like object or string containing the HTML to be ... | [
"def",
"parseFragment",
"(",
"self",
",",
"stream",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_parse",
"(",
"stream",
",",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"tree",
".",
"getFr... | [
286,
4
] | [
312,
38
] | python | en | ['en', 'en', 'en'] | True |
InBodyPhase.startTagRawtext | (self, token) | iframe, noembed noframes, noscript(if scripting enabled) | iframe, noembed noframes, noscript(if scripting enabled) | def startTagRawtext(self, token):
"""iframe, noembed noframes, noscript(if scripting enabled)"""
self.parser.parseRCDataRawtext(token, "RAWTEXT") | [
"def",
"startTagRawtext",
"(",
"self",
",",
"token",
")",
":",
"self",
".",
"parser",
".",
"parseRCDataRawtext",
"(",
"token",
",",
"\"RAWTEXT\"",
")"
] | [
1239,
8
] | [
1241,
60
] | python | en | ['en', 'en', 'nl'] | True |
InBodyPhase.startTagMisplaced | (self, token) | Elements that should be children of other elements that have a
different insertion mode; here they are ignored
"caption", "col", "colgroup", "frame", "frameset", "head",
"option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
"tr", "noscript"
| Elements that should be children of other elements that have a
different insertion mode; here they are ignored
"caption", "col", "colgroup", "frame", "frameset", "head",
"option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
"tr", "noscript"
| def startTagMisplaced(self, token):
""" Elements that should be children of other elements that have a
different insertion mode; here they are ignored
"caption", "col", "colgroup", "frame", "frameset", "head",
"option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
... | [
"def",
"startTagMisplaced",
"(",
"self",
",",
"token",
")",
":",
"self",
".",
"parser",
".",
"parseError",
"(",
"\"unexpected-start-tag-ignored\"",
",",
"{",
"\"name\"",
":",
"token",
"[",
"\"name\"",
"]",
"}",
")"
] | [
1294,
8
] | [
1301,
91
] | python | en | ['en', 'en', 'en'] | True |
InBodyPhase.endTagFormatting | (self, token) | The much-feared adoption agency algorithm | The much-feared adoption agency algorithm | def endTagFormatting(self, token):
"""The much-feared adoption agency algorithm"""
# http://svn.whatwg.org/webapps/complete.html#adoptionAgency revision 7867
# XXX Better parseError messages appreciated.
# Step 1
outerLoopCounter = 0
# Step 2
... | [
"def",
"endTagFormatting",
"(",
"self",
",",
"token",
")",
":",
"# http://svn.whatwg.org/webapps/complete.html#adoptionAgency revision 7867",
"# XXX Better parseError messages appreciated.",
"# Step 1",
"outerLoopCounter",
"=",
"0",
"# Step 2",
"while",
"outerLoopCounter",
"<",
"... | [
1403,
8
] | [
1564,
75
] | python | en | ['en', 'en', 'en'] | True |
PopulateRepoIdMixin.get_repo_id | (self) |
Get the project's GitHub repo id, looking it up based on the owner and name
if not already populated.
Authentication is via the Metecho GitHub app,
so it must already be installed for this repository.
|
Get the project's GitHub repo id, looking it up based on the owner and name
if not already populated. | def get_repo_id(self):
"""
Get the project's GitHub repo id, looking it up based on the owner and name
if not already populated.
Authentication is via the Metecho GitHub app,
so it must already be installed for this repository.
"""
if self.repo_id:
r... | [
"def",
"get_repo_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"repo_id",
":",
"return",
"self",
".",
"repo_id",
"repo",
"=",
"get_repo_info",
"(",
"user",
"=",
"None",
",",
"repo_owner",
"=",
"self",
".",
"repo_owner",
",",
"repo_name",
"=",
"self",
... | [
30,
4
] | [
47,
27
] | python | en | ['en', 'error', 'th'] | False |
PushMixin._push_message | (self, type_, message, for_list=False) |
type_:
str indicating frontend Redux action.
message:
{
"originating_user_id": str,
Optional["message"]: str // error or other message
}
|
type_:
str indicating frontend Redux action.
message:
{
"originating_user_id": str,
Optional["message"]: str // error or other message
}
| def _push_message(self, type_, message, for_list=False):
"""
type_:
str indicating frontend Redux action.
message:
{
"originating_user_id": str,
Optional["message"]: str // error or other message
}
"""
async_to_... | [
"def",
"_push_message",
"(",
"self",
",",
"type_",
",",
"message",
",",
"for_list",
"=",
"False",
")",
":",
"async_to_sync",
"(",
"push",
".",
"push_message_about_instance",
")",
"(",
"self",
",",
"{",
"\"type\"",
":",
"type_",
",",
"\"payload\"",
":",
"me... | [
63,
4
] | [
77,
9
] | python | en | ['en', 'error', 'th'] | False |
PushMixin.notify_scratch_org_error | (
self, *, error, type_, originating_user_id, message=None
) |
This is only used in the ScratchOrg model currently, but it
follows the pattern enough that I wanted to move it into this
mixin.
|
This is only used in the ScratchOrg model currently, but it
follows the pattern enough that I wanted to move it into this
mixin.
| def notify_scratch_org_error(
self, *, error, type_, originating_user_id, message=None
):
"""
This is only used in the ScratchOrg model currently, but it
follows the pattern enough that I wanted to move it into this
mixin.
"""
async_to_sync(push.report_scratch... | [
"def",
"notify_scratch_org_error",
"(",
"self",
",",
"*",
",",
"error",
",",
"type_",
",",
"originating_user_id",
",",
"message",
"=",
"None",
")",
":",
"async_to_sync",
"(",
"push",
".",
"report_scratch_org_error",
")",
"(",
"self",
",",
"error",
"=",
"erro... | [
101,
4
] | [
115,
9
] | python | en | ['en', 'error', 'th'] | False |
musicxml_to_sequence_proto | (musicxml_document) | Convert MusicXML file contents to a NoteSequence proto.
Converts a MusicXML file encoded as a string into a NoteSequence proto.
Args:
musicxml_document: A parsed MusicXML file. This file has been parsed by
class MusicXMLDocument
Returns:
A NoteSequence proto.
Raises:
MusicXMLConversionErro... | Convert MusicXML file contents to a NoteSequence proto. | def musicxml_to_sequence_proto(musicxml_document):
"""Convert MusicXML file contents to a NoteSequence proto.
Converts a MusicXML file encoded as a string into a NoteSequence proto.
Args:
musicxml_document: A parsed MusicXML file. This file has been parsed by
class MusicXMLDocument
Returns:
A N... | [
"def",
"musicxml_to_sequence_proto",
"(",
"musicxml_document",
")",
":",
"sequence",
"=",
"music_pb2",
".",
"NoteSequence",
"(",
")",
"# Standard MusicXML fields.",
"sequence",
".",
"source_info",
".",
"source_type",
"=",
"(",
"music_pb2",
".",
"NoteSequence",
".",
... | [
31,
0
] | [
125,
17
] | python | en | ['en', 'en', 'en'] | True |
musicxml_file_to_sequence_proto | (musicxml_file) | Converts a MusicXML file to a NoteSequence proto.
Args:
musicxml_file: A string path to a MusicXML file.
Returns:
A NoteSequence proto.
Raises:
MusicXMLConversionError: Invalid musicxml_file.
| Converts a MusicXML file to a NoteSequence proto. | def musicxml_file_to_sequence_proto(musicxml_file):
"""Converts a MusicXML file to a NoteSequence proto.
Args:
musicxml_file: A string path to a MusicXML file.
Returns:
A NoteSequence proto.
Raises:
MusicXMLConversionError: Invalid musicxml_file.
"""
try:
musicxml_document = musicxml_pars... | [
"def",
"musicxml_file_to_sequence_proto",
"(",
"musicxml_file",
")",
":",
"try",
":",
"musicxml_document",
"=",
"musicxml_parser",
".",
"MusicXMLDocument",
"(",
"musicxml_file",
")",
"except",
"musicxml_parser",
".",
"MusicXMLParseError",
"as",
"e",
":",
"raise",
"Mus... | [
128,
0
] | [
144,
54
] | python | en | ['en', 'en', 'en'] | True |
serve_file_url_backend | (
request: HttpRequest, user_profile: UserProfile, realm_id_str: str, filename: str
) |
We should return a signed, short-lived URL
that the client can use for native mobile download, rather than serving a redirect.
|
We should return a signed, short-lived URL
that the client can use for native mobile download, rather than serving a redirect.
| def serve_file_url_backend(
request: HttpRequest, user_profile: UserProfile, realm_id_str: str, filename: str
) -> HttpResponse:
"""
We should return a signed, short-lived URL
that the client can use for native mobile download, rather than serving a redirect.
"""
return serve_file(request, user... | [
"def",
"serve_file_url_backend",
"(",
"request",
":",
"HttpRequest",
",",
"user_profile",
":",
"UserProfile",
",",
"realm_id_str",
":",
"str",
",",
"filename",
":",
"str",
")",
"->",
"HttpResponse",
":",
"return",
"serve_file",
"(",
"request",
",",
"user_profile... | [
72,
0
] | [
80,
83
] | python | en | ['en', 'error', 'th'] | False |
EncoderBase.model_to_device | (self, device) | Default implementation, can be overridden in derived classes. | Default implementation, can be overridden in derived classes. | def model_to_device(self, device):
"""Default implementation, can be overridden in derived classes."""
self.to(device) | [
"def",
"model_to_device",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"to",
"(",
"device",
")"
] | [
112,
4
] | [
114,
23
] | python | en | ['en', 'en', 'en'] | True |
EncoderBase.device_and_type_for_input_tensor | (self, _) | Default implementation, can be overridden in derived classes. | Default implementation, can be overridden in derived classes. | def device_and_type_for_input_tensor(self, _):
"""Default implementation, can be overridden in derived classes."""
return self.model_device(), torch.float32 | [
"def",
"device_and_type_for_input_tensor",
"(",
"self",
",",
"_",
")",
":",
"return",
"self",
".",
"model_device",
"(",
")",
",",
"torch",
".",
"float32"
] | [
116,
4
] | [
118,
49
] | python | en | ['en', 'en', 'en'] | True |
ActionParameterizationDefault.forward | (self, actor_core_output) | Just forward the FC layer and generate the distribution object. | Just forward the FC layer and generate the distribution object. | def forward(self, actor_core_output):
"""Just forward the FC layer and generate the distribution object."""
action_distribution_params = self.distribution_linear(actor_core_output)
action_distribution = get_action_distribution(self.action_space, raw_logits=action_distribution_params)
ret... | [
"def",
"forward",
"(",
"self",
",",
"actor_core_output",
")",
":",
"action_distribution_params",
"=",
"self",
".",
"distribution_linear",
"(",
"actor_core_output",
")",
"action_distribution",
"=",
"get_action_distribution",
"(",
"self",
".",
"action_space",
",",
"raw_... | [
388,
4
] | [
392,
62
] | python | en | ['en', 'en', 'en'] | True |
DeactivatedRealmTest.test_send_deactivated_realm | (self) |
rest_dispatch rejects requests in a deactivated realm, both /json and api
|
rest_dispatch rejects requests in a deactivated realm, both /json and api | def test_send_deactivated_realm(self) -> None:
"""
rest_dispatch rejects requests in a deactivated realm, both /json and api
"""
realm = get_realm("zulip")
do_deactivate_realm(get_realm("zulip"), acting_user=None)
result = self.client_post(
"/json/messages",... | [
"def",
"test_send_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"do_deactivate_realm",
"(",
"get_realm",
"(",
"\"zulip\"",
")",
",",
"acting_user",
"=",
"None",
")",
"result",
"=",
"self",
".",
"cl... | [
1041,
4
] | [
1092,
9
] | python | en | ['en', 'error', 'th'] | False |
DeactivatedRealmTest.test_fetch_api_key_deactivated_realm | (self) |
authenticated_json_view views fail in a deactivated realm
|
authenticated_json_view views fail in a deactivated realm | def test_fetch_api_key_deactivated_realm(self) -> None:
"""
authenticated_json_view views fail in a deactivated realm
"""
realm = get_realm("zulip")
user_profile = self.example_user("hamlet")
test_password = "abcd1234"
user_profile.set_password(test_password)
... | [
"def",
"test_fetch_api_key_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"test_password",
"=",
"\"abcd1234\"",
"user_profile",
".... | [
1094,
4
] | [
1110,
9
] | python | en | ['en', 'error', 'th'] | False |
DeactivatedRealmTest.test_webhook_deactivated_realm | (self) |
Using a webhook while in a deactivated realm fails
|
Using a webhook while in a deactivated realm fails | def test_webhook_deactivated_realm(self) -> None:
"""
Using a webhook while in a deactivated realm fails
"""
do_deactivate_realm(get_realm("zulip"), acting_user=None)
user_profile = self.example_user("hamlet")
api_key = get_api_key(user_profile)
url = f"/api/v1/e... | [
"def",
"test_webhook_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"do_deactivate_realm",
"(",
"get_realm",
"(",
"\"zulip\"",
")",
",",
"acting_user",
"=",
"None",
")",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"api_key... | [
1112,
4
] | [
1125,
9
] | python | en | ['en', 'error', 'th'] | False |
LoginRequiredTest.test_login_required | (self) |
Verifies the zulip_login_required decorator blocks deactivated users.
|
Verifies the zulip_login_required decorator blocks deactivated users.
| def test_login_required(self) -> None:
"""
Verifies the zulip_login_required decorator blocks deactivated users.
"""
user_profile = self.example_user("hamlet")
# Verify fails if logged-out
result = self.client_get("/accounts/accept_terms/")
self.assertEqual(resul... | [
"def",
"test_login_required",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"# Verify fails if logged-out",
"result",
"=",
"self",
".",
"client_get",
"(",
"\"/accounts/accept_terms/\"",
")",
"self",
... | [
1129,
4
] | [
1159,
49
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_send_deactivated_user | (self) |
rest_dispatch rejects requests from deactivated users, both /json and api
|
rest_dispatch rejects requests from deactivated users, both /json and api | def test_send_deactivated_user(self) -> None:
"""
rest_dispatch rejects requests from deactivated users, both /json and api
"""
user_profile = self.example_user("hamlet")
self.login_user(user_profile)
do_deactivate_user(user_profile, acting_user=None)
result = s... | [
"def",
"test_send_deactivated_user",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"user_profile",
")",
"do_deactivate_user",
"(",
"user_profile",
",",
"acting_user",
... | [
1193,
4
] | [
1239,
90
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_fetch_api_key_deactivated_user | (self) |
authenticated_json_view views fail with a deactivated user
|
authenticated_json_view views fail with a deactivated user | def test_fetch_api_key_deactivated_user(self) -> None:
"""
authenticated_json_view views fail with a deactivated user
"""
user_profile = self.example_user("hamlet")
email = user_profile.delivery_email
test_password = "abcd1234"
user_profile.set_password(test_pass... | [
"def",
"test_fetch_api_key_deactivated_user",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"email",
"=",
"user_profile",
".",
"delivery_email",
"test_password",
"=",
"\"abcd1234\"",
"user_profile",
".... | [
1241,
4
] | [
1256,
90
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_login_deactivated_user | (self) |
logging in fails with an inactive user
|
logging in fails with an inactive user | def test_login_deactivated_user(self) -> None:
"""
logging in fails with an inactive user
"""
user_profile = self.example_user("hamlet")
do_deactivate_user(user_profile, acting_user=None)
result = self.login_with_return(self.example_email("hamlet"))
self.assert_... | [
"def",
"test_login_deactivated_user",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"do_deactivate_user",
"(",
"user_profile",
",",
"acting_user",
"=",
"None",
")",
"result",
"=",
"self",
".",
"l... | [
1258,
4
] | [
1267,
76
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_login_deactivated_mirror_dummy | (self) |
logging in fails with an inactive user
|
logging in fails with an inactive user | def test_login_deactivated_mirror_dummy(self) -> None:
"""
logging in fails with an inactive user
"""
user_profile = self.example_user("hamlet")
user_profile.is_mirror_dummy = True
user_profile.save()
password = initial_password(user_profile.delivery_email)
... | [
"def",
"test_login_deactivated_mirror_dummy",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"user_profile",
".",
"is_mirror_dummy",
"=",
"True",
"user_profile",
".",
"save",
"(",
")",
"password",
"... | [
1269,
4
] | [
1308,
79
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_webhook_deactivated_user | (self) |
Deactivated users can't use webhooks
|
Deactivated users can't use webhooks | def test_webhook_deactivated_user(self) -> None:
"""
Deactivated users can't use webhooks
"""
user_profile = self.example_user("hamlet")
do_deactivate_user(user_profile, acting_user=None)
api_key = get_api_key(user_profile)
url = f"/api/v1/external/jira?api_key=... | [
"def",
"test_webhook_deactivated_user",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"do_deactivate_user",
"(",
"user_profile",
",",
"acting_user",
"=",
"None",
")",
"api_key",
"=",
"get_api_key",
... | [
1310,
4
] | [
1322,
90
] | python | en | ['en', 'error', 'th'] | False |
TestUserAgentParsing.test_user_agent_parsing | (self) | Test for our user agent parsing logic, using a large data set. | Test for our user agent parsing logic, using a large data set. | def test_user_agent_parsing(self) -> None:
"""Test for our user agent parsing logic, using a large data set."""
user_agents_parsed: Dict[str, int] = defaultdict(int)
user_agents_path = os.path.join(
settings.DEPLOY_ROOT, "zerver/tests/fixtures/user_agents_unique"
)
wi... | [
"def",
"test_user_agent_parsing",
"(",
"self",
")",
"->",
"None",
":",
"user_agents_parsed",
":",
"Dict",
"[",
"str",
",",
"int",
"]",
"=",
"defaultdict",
"(",
"int",
")",
"user_agents_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"settings",
".",
"DE... | [
1966,
4
] | [
1981,
61
] | python | en | ['en', 'en', 'en'] | True |
Hashes.__init__ | (self, hashes=None) |
:param hashes: A dict of algorithm names pointing to lists of allowed
hex digests
|
:param hashes: A dict of algorithm names pointing to lists of allowed
hex digests
| def __init__(self, hashes=None):
# type: (Dict[str, List[str]]) -> None
"""
:param hashes: A dict of algorithm names pointing to lists of allowed
hex digests
"""
self._allowed = {} if hashes is None else hashes | [
"def",
"__init__",
"(",
"self",
",",
"hashes",
"=",
"None",
")",
":",
"# type: (Dict[str, List[str]]) -> None",
"self",
".",
"_allowed",
"=",
"{",
"}",
"if",
"hashes",
"is",
"None",
"else",
"hashes"
] | [
40,
4
] | [
46,
56
] | python | en | ['en', 'error', 'th'] | False |
Hashes.is_hash_allowed | (
self,
hash_name, # type: str
hex_digest, # type: str
) | Return whether the given hex digest is allowed. | Return whether the given hex digest is allowed. | def is_hash_allowed(
self,
hash_name, # type: str
hex_digest, # type: str
):
# type: (...) -> bool
"""Return whether the given hex digest is allowed."""
return hex_digest in self._allowed.get(hash_name, []) | [
"def",
"is_hash_allowed",
"(",
"self",
",",
"hash_name",
",",
"# type: str",
"hex_digest",
",",
"# type: str",
")",
":",
"# type: (...) -> bool",
"return",
"hex_digest",
"in",
"self",
".",
"_allowed",
".",
"get",
"(",
"hash_name",
",",
"[",
"]",
")"
] | [
65,
4
] | [
72,
61
] | python | en | ['en', 'en', 'en'] | True |
Hashes.check_against_chunks | (self, chunks) | Check good hashes against ones built from iterable of chunks of
data.
Raise HashMismatch if none match.
| Check good hashes against ones built from iterable of chunks of
data. | def check_against_chunks(self, chunks):
# type: (Iterator[bytes]) -> None
"""Check good hashes against ones built from iterable of chunks of
data.
Raise HashMismatch if none match.
"""
gots = {}
for hash_name in iterkeys(self._allowed):
try:
... | [
"def",
"check_against_chunks",
"(",
"self",
",",
"chunks",
")",
":",
"# type: (Iterator[bytes]) -> None",
"gots",
"=",
"{",
"}",
"for",
"hash_name",
"in",
"iterkeys",
"(",
"self",
".",
"_allowed",
")",
":",
"try",
":",
"gots",
"[",
"hash_name",
"]",
"=",
"... | [
74,
4
] | [
98,
25
] | python | en | ['en', 'en', 'en'] | True |
Hashes.check_against_file | (self, file) | Check good hashes against a file-like object
Raise HashMismatch if none match.
| Check good hashes against a file-like object | def check_against_file(self, file):
# type: (BinaryIO) -> None
"""Check good hashes against a file-like object
Raise HashMismatch if none match.
"""
return self.check_against_chunks(read_chunks(file)) | [
"def",
"check_against_file",
"(",
"self",
",",
"file",
")",
":",
"# type: (BinaryIO) -> None",
"return",
"self",
".",
"check_against_chunks",
"(",
"read_chunks",
"(",
"file",
")",
")"
] | [
104,
4
] | [
111,
59
] | python | en | ['en', 'en', 'en'] | True |
Hashes.__nonzero__ | (self) | Return whether I know any known-good hashes. | Return whether I know any known-good hashes. | def __nonzero__(self):
# type: () -> bool
"""Return whether I know any known-good hashes."""
return bool(self._allowed) | [
"def",
"__nonzero__",
"(",
"self",
")",
":",
"# type: () -> bool",
"return",
"bool",
"(",
"self",
".",
"_allowed",
")"
] | [
118,
4
] | [
121,
34
] | python | en | ['en', 'en', 'en'] | True |
MissingHashes.__init__ | (self) | Don't offer the ``hashes`` kwarg. | Don't offer the ``hashes`` kwarg. | def __init__(self):
# type: () -> None
"""Don't offer the ``hashes`` kwarg."""
# Pass our favorite hash in to generate a "gotten hash". With the
# empty list, it will never match, so an error will always raise.
super(MissingHashes, self).__init__(hashes={FAVORITE_HASH: []}) | [
"def",
"__init__",
"(",
"self",
")",
":",
"# type: () -> None",
"# Pass our favorite hash in to generate a \"gotten hash\". With the",
"# empty list, it will never match, so an error will always raise.",
"super",
"(",
"MissingHashes",
",",
"self",
")",
".",
"__init__",
"(",
"hash... | [
135,
4
] | [
140,
71
] | python | en | ['en', 'en', 'sw'] | True |
setup_realm_internal_bots | (realm: Realm) | Create this realm's internal bots.
This function is idempotent; it does nothing for a bot that
already exists.
| Create this realm's internal bots. | def setup_realm_internal_bots(realm: Realm) -> None:
"""Create this realm's internal bots.
This function is idempotent; it does nothing for a bot that
already exists.
"""
internal_bots = [
(bot["name"], bot["email_template"] % (settings.INTERNAL_BOT_DOMAIN,))
for bot in settings.REA... | [
"def",
"setup_realm_internal_bots",
"(",
"realm",
":",
"Realm",
")",
"->",
"None",
":",
"internal_bots",
"=",
"[",
"(",
"bot",
"[",
"\"name\"",
"]",
",",
"bot",
"[",
"\"email_template\"",
"]",
"%",
"(",
"settings",
".",
"INTERNAL_BOT_DOMAIN",
",",
")",
")"... | [
30,
0
] | [
48,
18
] | python | en | ['en', 'en', 'en'] | True |
create_if_missing_realm_internal_bots | () | This checks if there is any realm internal bot missing.
If that is the case, it creates the missing realm internal bots.
| This checks if there is any realm internal bot missing. | def create_if_missing_realm_internal_bots() -> None:
"""This checks if there is any realm internal bot missing.
If that is the case, it creates the missing realm internal bots.
"""
if missing_any_realm_internal_bots():
for realm in Realm.objects.all():
setup_realm_internal_bots(real... | [
"def",
"create_if_missing_realm_internal_bots",
"(",
")",
"->",
"None",
":",
"if",
"missing_any_realm_internal_bots",
"(",
")",
":",
"for",
"realm",
"in",
"Realm",
".",
"objects",
".",
"all",
"(",
")",
":",
"setup_realm_internal_bots",
"(",
"realm",
")"
] | [
51,
0
] | [
58,
44
] | python | en | ['en', 'en', 'en'] | True |
ascii_lower | (string) | r"""Transform (only) ASCII letters to lower case: A-Z is mapped to a-z.
:param string: An Unicode string.
:returns: A new Unicode string.
This is used for `ASCII case-insensitive
<http://encoding.spec.whatwg.org/#ascii-case-insensitive>`_
matching of encoding labels.
The same matching is also ... | r"""Transform (only) ASCII letters to lower case: A-Z is mapped to a-z. | def ascii_lower(string):
r"""Transform (only) ASCII letters to lower case: A-Z is mapped to a-z.
:param string: An Unicode string.
:returns: A new Unicode string.
This is used for `ASCII case-insensitive
<http://encoding.spec.whatwg.org/#ascii-case-insensitive>`_
matching of encoding labels.
... | [
"def",
"ascii_lower",
"(",
"string",
")",
":",
"# This turns out to be faster than unicode.translate()",
"return",
"string",
".",
"encode",
"(",
"'utf8'",
")",
".",
"lower",
"(",
")",
".",
"decode",
"(",
"'utf8'",
")"
] | [
34,
0
] | [
57,
55
] | python | en | ['en', 'en', 'en'] | True |
lookup | (label) |
Look for an encoding by its label.
This is the spec’s `get an encoding
<http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm.
Supported labels are listed there.
:param label: A string.
:returns:
An :class:`Encoding` object, or :obj:`None` for an unknown label.
|
Look for an encoding by its label.
This is the spec’s `get an encoding
<http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm.
Supported labels are listed there. | def lookup(label):
"""
Look for an encoding by its label.
This is the spec’s `get an encoding
<http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm.
Supported labels are listed there.
:param label: A string.
:returns:
An :class:`Encoding` object, or :obj:`None` for an ... | [
"def",
"lookup",
"(",
"label",
")",
":",
"# Only strip ASCII whitespace: U+0009, U+000A, U+000C, U+000D, and U+0020.",
"label",
"=",
"ascii_lower",
"(",
"label",
".",
"strip",
"(",
"'\\t\\n\\f\\r '",
")",
")",
"name",
"=",
"LABELS",
".",
"get",
"(",
"label",
")",
... | [
60,
0
] | [
87,
19
] | python | en | ['en', 'error', 'th'] | False |
_get_encoding | (encoding_or_label) |
Accept either an encoding object or label.
:param encoding: An :class:`Encoding` object or a label string.
:returns: An :class:`Encoding` object.
:raises: :exc:`~exceptions.LookupError` for an unknown label.
|
Accept either an encoding object or label. | def _get_encoding(encoding_or_label):
"""
Accept either an encoding object or label.
:param encoding: An :class:`Encoding` object or a label string.
:returns: An :class:`Encoding` object.
:raises: :exc:`~exceptions.LookupError` for an unknown label.
"""
if hasattr(encoding_or_label, 'codec... | [
"def",
"_get_encoding",
"(",
"encoding_or_label",
")",
":",
"if",
"hasattr",
"(",
"encoding_or_label",
",",
"'codec_info'",
")",
":",
"return",
"encoding_or_label",
"encoding",
"=",
"lookup",
"(",
"encoding_or_label",
")",
"if",
"encoding",
"is",
"None",
":",
"r... | [
90,
0
] | [
105,
19
] | python | en | ['en', 'error', 'th'] | False |
decode | (input, fallback_encoding, errors='replace') |
Decode a single string.
:param input: A byte string
:param fallback_encoding:
An :class:`Encoding` object or a label string.
The encoding to use if :obj:`input` does note have a BOM.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.Look... |
Decode a single string. | def decode(input, fallback_encoding, errors='replace'):
"""
Decode a single string.
:param input: A byte string
:param fallback_encoding:
An :class:`Encoding` object or a label string.
The encoding to use if :obj:`input` does note have a BOM.
:param errors: Type of error handling. S... | [
"def",
"decode",
"(",
"input",
",",
"fallback_encoding",
",",
"errors",
"=",
"'replace'",
")",
":",
"# Fail early if `encoding` is an invalid label.",
"fallback_encoding",
"=",
"_get_encoding",
"(",
"fallback_encoding",
")",
"bom_encoding",
",",
"input",
"=",
"_detect_b... | [
138,
0
] | [
157,
65
] | python | en | ['en', 'error', 'th'] | False |
_detect_bom | (input) | Return (bom_encoding, input), with any BOM removed from the input. | Return (bom_encoding, input), with any BOM removed from the input. | def _detect_bom(input):
"""Return (bom_encoding, input), with any BOM removed from the input."""
if input.startswith(b'\xFF\xFE'):
return _UTF16LE, input[2:]
if input.startswith(b'\xFE\xFF'):
return _UTF16BE, input[2:]
if input.startswith(b'\xEF\xBB\xBF'):
return UTF8, input[3:]
... | [
"def",
"_detect_bom",
"(",
"input",
")",
":",
"if",
"input",
".",
"startswith",
"(",
"b'\\xFF\\xFE'",
")",
":",
"return",
"_UTF16LE",
",",
"input",
"[",
"2",
":",
"]",
"if",
"input",
".",
"startswith",
"(",
"b'\\xFE\\xFF'",
")",
":",
"return",
"_UTF16BE"... | [
160,
0
] | [
168,
22
] | python | en | ['en', 'en', 'en'] | True |
encode | (input, encoding=UTF8, errors='strict') |
Encode a single string.
:param input: An Unicode string.
:param encoding: An :class:`Encoding` object or a label string.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unknown encoding label.
:return: A byte string.
|
Encode a single string. | def encode(input, encoding=UTF8, errors='strict'):
"""
Encode a single string.
:param input: An Unicode string.
:param encoding: An :class:`Encoding` object or a label string.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unkn... | [
"def",
"encode",
"(",
"input",
",",
"encoding",
"=",
"UTF8",
",",
"errors",
"=",
"'strict'",
")",
":",
"return",
"_get_encoding",
"(",
"encoding",
")",
".",
"codec_info",
".",
"encode",
"(",
"input",
",",
"errors",
")",
"[",
"0",
"]"
] | [
171,
0
] | [
182,
70
] | python | en | ['en', 'error', 'th'] | False |
iter_decode | (input, fallback_encoding, errors='replace') |
"Pull"-based decoder.
:param input:
An iterable of byte strings.
The input is first consumed just enough to determine the encoding
based on the precense of a BOM,
then consumed on demand when the return value is.
:param fallback_encoding:
An :class:`Encoding` objec... |
"Pull"-based decoder. | def iter_decode(input, fallback_encoding, errors='replace'):
"""
"Pull"-based decoder.
:param input:
An iterable of byte strings.
The input is first consumed just enough to determine the encoding
based on the precense of a BOM,
then consumed on demand when the return value ... | [
"def",
"iter_decode",
"(",
"input",
",",
"fallback_encoding",
",",
"errors",
"=",
"'replace'",
")",
":",
"decoder",
"=",
"IncrementalDecoder",
"(",
"fallback_encoding",
",",
"errors",
")",
"generator",
"=",
"_iter_decode_generator",
"(",
"input",
",",
"decoder",
... | [
185,
0
] | [
210,
30
] | python | en | ['en', 'error', 'th'] | False |
_iter_decode_generator | (input, decoder) | Return a generator that first yields the :obj:`Encoding`,
then yields output chukns as Unicode strings.
| Return a generator that first yields the :obj:`Encoding`,
then yields output chukns as Unicode strings. | def _iter_decode_generator(input, decoder):
"""Return a generator that first yields the :obj:`Encoding`,
then yields output chukns as Unicode strings.
"""
decode = decoder.decode
input = iter(input)
for chunck in input:
output = decode(chunck)
if output:
assert decod... | [
"def",
"_iter_decode_generator",
"(",
"input",
",",
"decoder",
")",
":",
"decode",
"=",
"decoder",
".",
"decode",
"input",
"=",
"iter",
"(",
"input",
")",
"for",
"chunck",
"in",
"input",
":",
"output",
"=",
"decode",
"(",
"chunck",
")",
"if",
"output",
... | [
213,
0
] | [
242,
20
] | python | en | ['en', 'en', 'en'] | True |
iter_encode | (input, encoding=UTF8, errors='strict') |
“Pull”-based encoder.
:param input: An iterable of Unicode strings.
:param encoding: An :class:`Encoding` object or a label string.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupError` for an unknown encoding label.
:returns: An iterable o... |
“Pull”-based encoder. | def iter_encode(input, encoding=UTF8, errors='strict'):
"""
“Pull”-based encoder.
:param input: An iterable of Unicode strings.
:param encoding: An :class:`Encoding` object or a label string.
:param errors: Type of error handling. See :func:`codecs.register`.
:raises: :exc:`~exceptions.LookupEr... | [
"def",
"iter_encode",
"(",
"input",
",",
"encoding",
"=",
"UTF8",
",",
"errors",
"=",
"'strict'",
")",
":",
"# Fail early if `encoding` is an invalid label.",
"encode",
"=",
"IncrementalEncoder",
"(",
"encoding",
",",
"errors",
")",
".",
"encode",
"return",
"_iter... | [
245,
0
] | [
258,
48
] | python | en | ['en', 'error', 'th'] | False |
IncrementalDecoder.decode | (self, input, final=False) | Decode one chunk of the input.
:param input: A byte string.
:param final:
Indicate that no more input is available.
Must be :obj:`True` if this is the last call.
:returns: An Unicode string.
| Decode one chunk of the input. | def decode(self, input, final=False):
"""Decode one chunk of the input.
:param input: A byte string.
:param final:
Indicate that no more input is available.
Must be :obj:`True` if this is the last call.
:returns: An Unicode string.
"""
decoder = ... | [
"def",
"decode",
"(",
"self",
",",
"input",
",",
"final",
"=",
"False",
")",
":",
"decoder",
"=",
"self",
".",
"_decoder",
"if",
"decoder",
"is",
"not",
"None",
":",
"return",
"decoder",
"(",
"input",
",",
"final",
")",
"input",
"=",
"self",
".",
"... | [
294,
4
] | [
319,
36
] | python | en | ['en', 'en', 'en'] | True |
target_dir | () | Returns the target directory | Returns the target directory | def target_dir():
'Returns the target directory'
global TARGET_DIR
if TARGET_DIR is None:
cmd = ['cargo', 'metadata', '--format-version=1']
result = sp.run(cmd, stdout=sp.PIPE, check=True)
TARGET_DIR = Path(json.loads(result.stdout)['target_directory'])
return TARGET_DIR | [
"def",
"target_dir",
"(",
")",
":",
"global",
"TARGET_DIR",
"if",
"TARGET_DIR",
"is",
"None",
":",
"cmd",
"=",
"[",
"'cargo'",
",",
"'metadata'",
",",
"'--format-version=1'",
"]",
"result",
"=",
"sp",
".",
"run",
"(",
"cmd",
",",
"stdout",
"=",
"sp",
"... | [
46,
0
] | [
53,
21
] | python | en | ['en', 'en', 'en'] | True |
build_dir | () | Returns the directory where Cargo places the build artifacts | Returns the directory where Cargo places the build artifacts | def build_dir():
'Returns the directory where Cargo places the build artifacts'
return target_dir() / get_target_triple() / SETTINGS['config'] | [
"def",
"build_dir",
"(",
")",
":",
"return",
"target_dir",
"(",
")",
"/",
"get_target_triple",
"(",
")",
"/",
"SETTINGS",
"[",
"'config'",
"]"
] | [
59,
0
] | [
61,
66
] | python | en | ['en', 'en', 'en'] | True |
esp_dir | () | Returns the directory where we will build the emulated UEFI system partition | Returns the directory where we will build the emulated UEFI system partition | def esp_dir():
'Returns the directory where we will build the emulated UEFI system partition'
return build_dir() / 'esp' | [
"def",
"esp_dir",
"(",
")",
":",
"return",
"build_dir",
"(",
")",
"/",
"'esp'"
] | [
63,
0
] | [
65,
30
] | python | en | ['en', 'en', 'en'] | True |
run_tool | (tool, *flags) | Runs cargo-<tool> with certain arguments. | Runs cargo-<tool> with certain arguments. | def run_tool(tool, *flags):
'Runs cargo-<tool> with certain arguments.'
target = get_target_triple()
cmd = ['cargo', tool, '--target', target, *flags]
if SETTINGS['verbose']:
print(' '.join(cmd))
sp.run(cmd, check=True) | [
"def",
"run_tool",
"(",
"tool",
",",
"*",
"flags",
")",
":",
"target",
"=",
"get_target_triple",
"(",
")",
"cmd",
"=",
"[",
"'cargo'",
",",
"tool",
",",
"'--target'",
",",
"target",
",",
"*",
"flags",
"]",
"if",
"SETTINGS",
"[",
"'verbose'",
"]",
":"... | [
67,
0
] | [
76,
27
] | python | en | ['en', 'en', 'en'] | True |
run_build | (*flags) | Runs cargo-build with certain arguments. | Runs cargo-build with certain arguments. | def run_build(*flags):
'Runs cargo-build with certain arguments.'
run_tool('build', *flags) | [
"def",
"run_build",
"(",
"*",
"flags",
")",
":",
"run_tool",
"(",
"'build'",
",",
"*",
"flags",
")"
] | [
78,
0
] | [
80,
29
] | 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.