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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
merge_hooks | (request_hooks, session_hooks, dict_class=OrderedDict) | Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
| Properly merges both requests and session hooks. | def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
"""Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
"""
if session_hooks is None or session_hooks.get('response') == []:
... | [
"def",
"merge_hooks",
"(",
"request_hooks",
",",
"session_hooks",
",",
"dict_class",
"=",
"OrderedDict",
")",
":",
"if",
"session_hooks",
"is",
"None",
"or",
"session_hooks",
".",
"get",
"(",
"'response'",
")",
"==",
"[",
"]",
":",
"return",
"request_hooks",
... | [
80,
0
] | [
92,
66
] | python | en | ['en', 'en', 'en'] | True |
session | () |
Returns a :class:`Session` for context-management.
.. deprecated:: 1.0.0
This method has been deprecated since version 1.0.0 and is only kept for
backwards compatibility. New code should use :class:`~requests.sessions.Session`
to create a session. This may be removed at a future date.... |
Returns a :class:`Session` for context-management. | def session():
"""
Returns a :class:`Session` for context-management.
.. deprecated:: 1.0.0
This method has been deprecated since version 1.0.0 and is only kept for
backwards compatibility. New code should use :class:`~requests.sessions.Session`
to create a session. This may be rem... | [
"def",
"session",
"(",
")",
":",
"return",
"Session",
"(",
")"
] | [
756,
0
] | [
768,
20
] | python | en | ['en', 'error', 'th'] | False |
SessionRedirectMixin.get_redirect_target | (self, resp) | Receives a Response. Returns a redirect URI or ``None`` | Receives a Response. Returns a redirect URI or ``None`` | def get_redirect_target(self, resp):
"""Receives a Response. Returns a redirect URI or ``None``"""
# Due to the nature of how requests processes redirects this method will
# be called at least once upon the original response and at least twice
# on each subsequent redirect response (if a... | [
"def",
"get_redirect_target",
"(",
"self",
",",
"resp",
")",
":",
"# Due to the nature of how requests processes redirects this method will",
"# be called at least once upon the original response and at least twice",
"# on each subsequent redirect response (if any).",
"# If a custom mixin is u... | [
97,
4
] | [
116,
19
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.should_strip_auth | (self, old_url, new_url) | Decide whether Authorization header should be removed when redirecting | Decide whether Authorization header should be removed when redirecting | def should_strip_auth(self, old_url, new_url):
"""Decide whether Authorization header should be removed when redirecting"""
old_parsed = urlparse(old_url)
new_parsed = urlparse(new_url)
if old_parsed.hostname != new_parsed.hostname:
return True
# Special case: allow h... | [
"def",
"should_strip_auth",
"(",
"self",
",",
"old_url",
",",
"new_url",
")",
":",
"old_parsed",
"=",
"urlparse",
"(",
"old_url",
")",
"new_parsed",
"=",
"urlparse",
"(",
"new_url",
")",
"if",
"old_parsed",
".",
"hostname",
"!=",
"new_parsed",
".",
"hostname... | [
118,
4
] | [
141,
45
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.resolve_redirects | (self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs) | Receives a Response. Returns a generator of Responses or Requests. | Receives a Response. Returns a generator of Responses or Requests. | def resolve_redirects(self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):
"""Receives a Response. Returns a generator of Responses or Requests."""
hist = [] # keep track of history
url = self.get... | [
"def",
"resolve_redirects",
"(",
"self",
",",
"resp",
",",
"req",
",",
"stream",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"verify",
"=",
"True",
",",
"cert",
"=",
"None",
",",
"proxies",
"=",
"None",
",",
"yield_requests",
"=",
"False",
",",
"... | [
143,
4
] | [
251,
26
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_auth | (self, prepared_request, response) | When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
| When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
| def rebuild_auth(self, prepared_request, response):
"""When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
"""
headers = pr... | [
"def",
"rebuild_auth",
"(",
"self",
",",
"prepared_request",
",",
"response",
")",
":",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
".",
"url",
"if",
"'Authorization'",
"in",
"headers",
"and",
"self",
".",
"should_strip_au... | [
253,
4
] | [
269,
51
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_proxies | (self, prepared_request, proxies) | This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect).
... | This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect). | def rebuild_proxies(self, prepared_request, proxies):
"""This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in c... | [
"def",
"rebuild_proxies",
"(",
"self",
",",
"prepared_request",
",",
"proxies",
")",
":",
"proxies",
"=",
"proxies",
"if",
"proxies",
"is",
"not",
"None",
"else",
"{",
"}",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
"... | [
272,
4
] | [
311,
26
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_method | (self, prepared_request, response) | When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
| When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
| def rebuild_method(self, prepared_request, response):
"""When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
"""
method = prepared_request.method
# https://tools.ietf.org/html/rfc7231#section-6.4.4
if response... | [
"def",
"rebuild_method",
"(",
"self",
",",
"prepared_request",
",",
"response",
")",
":",
"method",
"=",
"prepared_request",
".",
"method",
"# https://tools.ietf.org/html/rfc7231#section-6.4.4",
"if",
"response",
".",
"status_code",
"==",
"codes",
".",
"see_other",
"a... | [
313,
4
] | [
333,
40
] | python | en | ['en', 'en', 'en'] | True |
Session.prepare_request | (self, request) | Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class:`Request` instance to prepare with this
... | Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`. | def prepare_request(self, request):
"""Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class... | [
"def",
"prepare_request",
"(",
"self",
",",
"request",
")",
":",
"cookies",
"=",
"request",
".",
"cookies",
"or",
"{",
"}",
"# Bootstrap CookieJar.",
"if",
"not",
"isinstance",
"(",
"cookies",
",",
"cookielib",
".",
"CookieJar",
")",
":",
"cookies",
"=",
"... | [
422,
4
] | [
460,
16
] | python | en | ['en', 'co', 'en'] | True |
Session.request | (self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None) | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the... | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object. | def request(self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None):
"""Constructs a :class:`Request <Request>`, prepares it and... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"cookies",
"=",
"None",
",",
"files",
"=",
"None",
",",
"auth",
"=",
"None",
",",
"timeout",
"=",
"N... | [
462,
4
] | [
531,
19
] | python | en | ['en', 'en', 'en'] | True |
Session.get | (self, url, **kwargs) | r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a GET request. Returns :class:`Response` object. | def get(self, url, **kwargs):
r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects',... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'GET'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
533,
4
] | [
542,
49
] | python | en | ['en', 'lb', 'en'] | True |
Session.options | (self, url, **kwargs) | r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a OPTIONS request. Returns :class:`Response` object. | def options(self, url, **kwargs):
r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_red... | [
"def",
"options",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'OPTIONS'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
544,
4
] | [
553,
53
] | python | en | ['en', 'en', 'en'] | True |
Session.head | (self, url, **kwargs) | r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a HEAD request. Returns :class:`Response` object. | def head(self, url, **kwargs):
r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects... | [
"def",
"head",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"False",
")",
"return",
"self",
".",
"request",
"(",
"'HEAD'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
555,
4
] | [
564,
50
] | python | en | ['en', 'lb', 'en'] | True |
Session.post | (self, url, data=None, json=None, **kwargs) | r"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json to send in the bo... | r"""Sends a POST request. Returns :class:`Response` object. | def post(self, url, data=None, json=None, **kwargs):
r"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Req... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"json",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'POST'",
",",
"url",
",",
"data",
"=",
"data",
",",
"json",
"=",
"json",
",",... | [
566,
4
] | [
577,
72
] | python | en | ['en', 'lb', 'en'] | True |
Session.put | (self, url, data=None, **kwargs) | r"""Sends a PUT request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``re... | r"""Sends a PUT request. Returns :class:`Response` object. | def put(self, url, data=None, **kwargs):
r"""Sends a PUT request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'PUT'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
579,
4
] | [
589,
60
] | python | en | ['en', 'lb', 'en'] | True |
Session.patch | (self, url, data=None, **kwargs) | r"""Sends a PATCH request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``... | r"""Sends a PATCH request. Returns :class:`Response` object. | def patch(self, url, data=None, **kwargs):
r"""Sends a PATCH request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
... | [
"def",
"patch",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'PATCH'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
591,
4
] | [
601,
62
] | python | en | ['en', 'en', 'en'] | True |
Session.delete | (self, url, **kwargs) | r"""Sends a DELETE request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a DELETE request. Returns :class:`Response` object. | def delete(self, url, **kwargs):
r"""Sends a DELETE request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
return self.request('DELETE', ... | [
"def",
"delete",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'DELETE'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
603,
4
] | [
611,
52
] | python | en | ['en', 'en', 'en'] | True |
Session.send | (self, request, **kwargs) | Send a given PreparedRequest.
:rtype: requests.Response
| Send a given PreparedRequest. | def send(self, request, **kwargs):
"""Send a given PreparedRequest.
:rtype: requests.Response
"""
# Set defaults that the hooks can utilize to ensure they always have
# the correct parameters to reproduce the previous request.
kwargs.setdefault('stream', self.stream)
... | [
"def",
"send",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set defaults that the hooks can utilize to ensure they always have",
"# the correct parameters to reproduce the previous request.",
"kwargs",
".",
"setdefault",
"(",
"'stream'",
",",
"self",
"... | [
613,
4
] | [
686,
16
] | python | en | ['en', 'co', 'en'] | True |
Session.merge_environment_settings | (self, url, proxies, stream, verify, cert) |
Check the environment and merge it with some settings.
:rtype: dict
|
Check the environment and merge it with some settings. | def merge_environment_settings(self, url, proxies, stream, verify, cert):
"""
Check the environment and merge it with some settings.
:rtype: dict
"""
# Gather clues from the surrounding environment.
if self.trust_env:
# Set environment's proxies.
... | [
"def",
"merge_environment_settings",
"(",
"self",
",",
"url",
",",
"proxies",
",",
"stream",
",",
"verify",
",",
"cert",
")",
":",
"# Gather clues from the surrounding environment.",
"if",
"self",
".",
"trust_env",
":",
"# Set environment's proxies.",
"no_proxy",
"=",... | [
688,
4
] | [
715,
29
] | python | en | ['en', 'error', 'th'] | False |
Session.get_adapter | (self, url) |
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
|
Returns the appropriate connection adapter for the given URL. | def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
... | [
"def",
"get_adapter",
"(",
"self",
",",
"url",
")",
":",
"for",
"(",
"prefix",
",",
"adapter",
")",
"in",
"self",
".",
"adapters",
".",
"items",
"(",
")",
":",
"if",
"url",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"prefix",
".",
"lower",
"... | [
717,
4
] | [
729,
85
] | python | en | ['en', 'error', 'th'] | False |
Session.close | (self) | Closes all adapters and as such the session | Closes all adapters and as such the session | def close(self):
"""Closes all adapters and as such the session"""
for v in self.adapters.values():
v.close() | [
"def",
"close",
"(",
"self",
")",
":",
"for",
"v",
"in",
"self",
".",
"adapters",
".",
"values",
"(",
")",
":",
"v",
".",
"close",
"(",
")"
] | [
731,
4
] | [
734,
21
] | python | en | ['en', 'en', 'en'] | True |
Session.mount | (self, prefix, adapter) | Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
| Registers a connection adapter to a prefix. | def mount(self, prefix, adapter):
"""Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
"""
self.adapters[prefix] = adapter
keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]
for key in keys_to_move:
... | [
"def",
"mount",
"(",
"self",
",",
"prefix",
",",
"adapter",
")",
":",
"self",
".",
"adapters",
"[",
"prefix",
"]",
"=",
"adapter",
"keys_to_move",
"=",
"[",
"k",
"for",
"k",
"in",
"self",
".",
"adapters",
"if",
"len",
"(",
"k",
")",
"<",
"len",
"... | [
736,
4
] | [
745,
55
] | python | en | ['en', 'en', 'en'] | True |
Create | (env=None) | Returns a new `Runfiles` instance.
The returned object is either:
- manifest-based, meaning it looks up runfile paths from a manifest file, or
- directory-based, meaning it looks up runfile paths under a given directory
path
If `env` contains "RUNFILES_MANIFEST_FILE" with non-empty value, this method
re... | Returns a new `Runfiles` instance. | def Create(env=None):
"""Returns a new `Runfiles` instance.
The returned object is either:
- manifest-based, meaning it looks up runfile paths from a manifest file, or
- directory-based, meaning it looks up runfile paths under a given directory
path
If `env` contains "RUNFILES_MANIFEST_FILE" with non-em... | [
"def",
"Create",
"(",
"env",
"=",
"None",
")",
":",
"env_map",
"=",
"os",
".",
"environ",
"if",
"env",
"is",
"None",
"else",
"env",
"manifest",
"=",
"env_map",
".",
"get",
"(",
"\"RUNFILES_MANIFEST_FILE\"",
")",
"if",
"manifest",
":",
"return",
"CreateMa... | [
79,
0
] | [
112,
13
] | python | en | ['en', 'lb', 'en'] | True |
_PathsFrom | (argv0, runfiles_mf, runfiles_dir, is_runfiles_manifest,
is_runfiles_directory) | Discover runfiles manifest and runfiles directory paths.
Args:
argv0: string; the value of sys.argv[0]
runfiles_mf: string; the value of the RUNFILES_MANIFEST_FILE environment
variable
runfiles_dir: string; the value of the RUNFILES_DIR environment variable
is_runfiles_manifest: lambda(string):... | Discover runfiles manifest and runfiles directory paths. | def _PathsFrom(argv0, runfiles_mf, runfiles_dir, is_runfiles_manifest,
is_runfiles_directory):
"""Discover runfiles manifest and runfiles directory paths.
Args:
argv0: string; the value of sys.argv[0]
runfiles_mf: string; the value of the RUNFILES_MANIFEST_FILE environment
variable
... | [
"def",
"_PathsFrom",
"(",
"argv0",
",",
"runfiles_mf",
",",
"runfiles_dir",
",",
"is_runfiles_manifest",
",",
"is_runfiles_directory",
")",
":",
"mf_alid",
"=",
"is_runfiles_manifest",
"(",
"runfiles_mf",
")",
"dir_valid",
"=",
"is_runfiles_directory",
"(",
"runfiles_... | [
244,
0
] | [
292,
76
] | python | en | ['en', 'en', 'en'] | True |
_Runfiles.Rlocation | (self, path) | Returns the runtime path of a runfile.
Runfiles are data-dependencies of Bazel-built binaries and tests.
The returned path may not be valid. The caller should check the path's
validity and that the path exists.
The function may return None. In that case the caller can be sure that the
rule does n... | Returns the runtime path of a runfile. | def Rlocation(self, path):
"""Returns the runtime path of a runfile.
Runfiles are data-dependencies of Bazel-built binaries and tests.
The returned path may not be valid. The caller should check the path's
validity and that the path exists.
The function may return None. In that case the caller ca... | [
"def",
"Rlocation",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
")",
"if",
"not",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
")",
"if",
"(",
"path",
".",
"startswith",
"... | [
124,
2
] | [
155,
48
] | python | en | ['en', 'en', 'en'] | True |
_Runfiles.EnvVars | (self) | Returns environment variables for subprocesses.
The caller should set the returned key-value pairs in the environment of
subprocesses in case those subprocesses are also Bazel-built binaries that
need to use runfiles.
Returns:
{string: string}; a dict; keys are environment variable names, values... | Returns environment variables for subprocesses. | def EnvVars(self):
"""Returns environment variables for subprocesses.
The caller should set the returned key-value pairs in the environment of
subprocesses in case those subprocesses are also Bazel-built binaries that
need to use runfiles.
Returns:
{string: string}; a dict; keys are environm... | [
"def",
"EnvVars",
"(",
"self",
")",
":",
"return",
"self",
".",
"_strategy",
".",
"EnvVars",
"(",
")"
] | [
157,
2
] | [
168,
35
] | python | en | ['en', 'en', 'en'] | True |
_ManifestBased._LoadRunfiles | (path) | Loads the runfiles manifest. | Loads the runfiles manifest. | def _LoadRunfiles(path):
"""Loads the runfiles manifest."""
result = {}
with open(path, "r") as f:
for line in f:
line = line.strip()
if line:
tokens = line.split(" ", 1)
if len(tokens) == 1:
result[line] = line
else:
result[tokens[... | [
"def",
"_LoadRunfiles",
"(",
"path",
")",
":",
"result",
"=",
"{",
"}",
"with",
"open",
"(",
"path",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
":",
"tokens",
"="... | [
186,
2
] | [
198,
17
] | python | en | ['en', 'co', 'en'] | True |
OpenAPIArgumentsTest.convert_regex_to_url_pattern | (self, regex_pattern: str) | Convert regular expressions style URL patterns to their
corresponding OpenAPI style formats. All patterns are
expected to start with ^ and end with $.
Examples:
1. /messages/{message_id} <-> r'^messages/(?P<message_id>[0-9]+)$'
2. /events <-> r'^events$'
3. '/... | Convert regular expressions style URL patterns to their
corresponding OpenAPI style formats. All patterns are
expected to start with ^ and end with $.
Examples:
1. /messages/{message_id} <-> r'^messages/(?P<message_id>[0-9]+)$'
2. /events <-> r'^events$'
3. '/... | def convert_regex_to_url_pattern(self, regex_pattern: str) -> str:
"""Convert regular expressions style URL patterns to their
corresponding OpenAPI style formats. All patterns are
expected to start with ^ and end with $.
Examples:
1. /messages/{message_id} <-> r'^messages/(?P... | [
"def",
"convert_regex_to_url_pattern",
"(",
"self",
",",
"regex_pattern",
":",
"str",
")",
"->",
"str",
":",
"# Handle the presence-email code which has a non-slashes syntax.",
"regex_pattern",
"=",
"regex_pattern",
".",
"replace",
"(",
"\"[^/]*\"",
",",
"\".*\"",
")",
... | [
305,
4
] | [
323,
26
] | python | en | ['en', 'en', 'en'] | True |
OpenAPIArgumentsTest.check_for_non_existant_openapi_endpoints | (self) | Here, we check to see if every endpoint documented in the OpenAPI
documentation actually exists in urls.py and thus in actual code.
Note: We define this as a helper called at the end of
test_openapi_arguments instead of as a separate test to ensure that
this test is only executed after t... | Here, we check to see if every endpoint documented in the OpenAPI
documentation actually exists in urls.py and thus in actual code.
Note: We define this as a helper called at the end of
test_openapi_arguments instead of as a separate test to ensure that
this test is only executed after t... | def check_for_non_existant_openapi_endpoints(self) -> None:
"""Here, we check to see if every endpoint documented in the OpenAPI
documentation actually exists in urls.py and thus in actual code.
Note: We define this as a helper called at the end of
test_openapi_arguments instead of as a ... | [
"def",
"check_for_non_existant_openapi_endpoints",
"(",
"self",
")",
"->",
"None",
":",
"openapi_paths",
"=",
"set",
"(",
"get_openapi_paths",
"(",
")",
")",
"undocumented_paths",
"=",
"openapi_paths",
"-",
"self",
".",
"checked_endpoints",
"undocumented_paths",
"-=",... | [
339,
4
] | [
356,
37
] | python | en | ['en', 'en', 'en'] | True |
OpenAPIArgumentsTest.get_standardized_argument_type | (self, t: Any) | Given a type from the typing module such as List[str] or Union[str, int],
convert it into a corresponding Python type. Unions are mapped to a canonical
choice among the options.
E.g. typing.Union[typing.List[typing.Dict[str, typing.Any]], NoneType]
needs to be mapped to list. | Given a type from the typing module such as List[str] or Union[str, int],
convert it into a corresponding Python type. Unions are mapped to a canonical
choice among the options.
E.g. typing.Union[typing.List[typing.Dict[str, typing.Any]], NoneType]
needs to be mapped to list. | def get_standardized_argument_type(self, t: Any) -> Union[type, Tuple[type, object]]:
"""Given a type from the typing module such as List[str] or Union[str, int],
convert it into a corresponding Python type. Unions are mapped to a canonical
choice among the options.
E.g. typing.Union[typ... | [
"def",
"get_standardized_argument_type",
"(",
"self",
",",
"t",
":",
"Any",
")",
"->",
"Union",
"[",
"type",
",",
"Tuple",
"[",
"type",
",",
"object",
"]",
"]",
":",
"origin",
"=",
"getattr",
"(",
"t",
",",
"\"__origin__\"",
",",
"None",
")",
"if",
"... | [
372,
4
] | [
404,
56
] | python | en | ['en', 'en', 'en'] | True |
OpenAPIArgumentsTest.render_openapi_type_exception | (
self,
function: Callable[..., HttpResponse],
openapi_params: Set[Tuple[str, Union[type, Tuple[type, object]]]],
function_params: Set[Tuple[str, Union[type, Tuple[type, object]]]],
diff: Set[Tuple[str, Union[type, Tuple[type, object]]]],
) | Print a *VERY* clear and verbose error message for when the types
(between the OpenAPI documentation and the function declaration) don't match. | Print a *VERY* clear and verbose error message for when the types
(between the OpenAPI documentation and the function declaration) don't match. | def render_openapi_type_exception(
self,
function: Callable[..., HttpResponse],
openapi_params: Set[Tuple[str, Union[type, Tuple[type, object]]]],
function_params: Set[Tuple[str, Union[type, Tuple[type, object]]]],
diff: Set[Tuple[str, Union[type, Tuple[type, object]]]],
) ->... | [
"def",
"render_openapi_type_exception",
"(",
"self",
",",
"function",
":",
"Callable",
"[",
"...",
",",
"HttpResponse",
"]",
",",
"openapi_params",
":",
"Set",
"[",
"Tuple",
"[",
"str",
",",
"Union",
"[",
"type",
",",
"Tuple",
"[",
"type",
",",
"object",
... | [
406,
4
] | [
437,
33
] | python | en | ['en', 'en', 'en'] | True |
OpenAPIArgumentsTest.check_argument_types | (
self, function: Callable[..., HttpResponse], openapi_parameters: List[Dict[str, Any]]
) | We construct for both the OpenAPI data and the function's definition a set of
tuples of the form (var_name, type) and then compare those sets to see if the
OpenAPI data defines a different type than that actually accepted by the function.
Otherwise, we print out the exact differences for conveni... | We construct for both the OpenAPI data and the function's definition a set of
tuples of the form (var_name, type) and then compare those sets to see if the
OpenAPI data defines a different type than that actually accepted by the function.
Otherwise, we print out the exact differences for conveni... | def check_argument_types(
self, function: Callable[..., HttpResponse], openapi_parameters: List[Dict[str, Any]]
) -> None:
"""We construct for both the OpenAPI data and the function's definition a set of
tuples of the form (var_name, type) and then compare those sets to see if the
Op... | [
"def",
"check_argument_types",
"(",
"self",
",",
"function",
":",
"Callable",
"[",
"...",
",",
"HttpResponse",
"]",
",",
"openapi_parameters",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
")",
"->",
"None",
":",
"openapi_params",
":",
"Set... | [
439,
4
] | [
529,
95
] | python | en | ['en', 'en', 'en'] | True |
OpenAPIArgumentsTest.test_openapi_arguments | (self) | This end-to-end API documentation test compares the arguments
defined in the actual code using @has_request_variables and
REQ(), with the arguments declared in our API documentation
for every API endpoint in Zulip.
First, we import the fancy-Django version of zproject/urls.py
by... | This end-to-end API documentation test compares the arguments
defined in the actual code using @has_request_variables and
REQ(), with the arguments declared in our API documentation
for every API endpoint in Zulip. | def test_openapi_arguments(self) -> None:
"""This end-to-end API documentation test compares the arguments
defined in the actual code using @has_request_variables and
REQ(), with the arguments declared in our API documentation
for every API endpoint in Zulip.
First, we import th... | [
"def",
"test_openapi_arguments",
"(",
"self",
")",
"->",
"None",
":",
"from",
"zproject",
"import",
"urls",
"as",
"urlconf",
"# We loop through all the API patterns, looking in particular",
"# for those using the rest_dispatch decorator; we then parse",
"# its mapping of (HTTP_METHOD... | [
531,
4
] | [
657,
55
] | python | en | ['en', 'en', 'en'] | True |
OpenAPIAttributesTest.test_attributes | (self) |
Checks:
* All endpoints have `operationId` and `tag` attributes.
* All example responses match their schema.
* That no opaque object exists.
|
Checks:
* All endpoints have `operationId` and `tag` attributes.
* All example responses match their schema.
* That no opaque object exists.
| def test_attributes(self) -> None:
"""
Checks:
* All endpoints have `operationId` and `tag` attributes.
* All example responses match their schema.
* That no opaque object exists.
"""
EXCLUDE = ["/real-time"]
VALID_TAGS = [
"users",
... | [
"def",
"test_attributes",
"(",
"self",
")",
"->",
"None",
":",
"EXCLUDE",
"=",
"[",
"\"/real-time\"",
"]",
"VALID_TAGS",
"=",
"[",
"\"users\"",
",",
"\"server_and_organizations\"",
",",
"\"authentication\"",
",",
"\"real_time_events\"",
",",
"\"streams\"",
",",
"\... | [
1005,
4
] | [
1048,
21
] | python | en | ['en', 'error', 'th'] | False |
OpenAPIRegexTest.test_regex | (self) |
Calls a few documented and undocumented endpoints and checks whether they
find a match or not.
|
Calls a few documented and undocumented endpoints and checks whether they
find a match or not.
| def test_regex(self) -> None:
"""
Calls a few documented and undocumented endpoints and checks whether they
find a match or not.
"""
# Some of the undocumentd endpoints which are very similar to
# some of the documented endpoints.
assert find_openapi_endpoint("/u... | [
"def",
"test_regex",
"(",
"self",
")",
"->",
"None",
":",
"# Some of the undocumentd endpoints which are very similar to",
"# some of the documented endpoints.",
"assert",
"find_openapi_endpoint",
"(",
"\"/users/me/presence\"",
")",
"is",
"None",
"assert",
"find_openapi_endpoint"... | [
1052,
4
] | [
1074,
97
] | python | en | ['en', 'error', 'th'] | False |
OpenAPIRequestValidatorTest.test_validator | (self) |
Test to make sure the request validator works properly
The tests cover both cases such as catching valid requests marked
as invalid and making sure invalid requests are markded properly
|
Test to make sure the request validator works properly
The tests cover both cases such as catching valid requests marked
as invalid and making sure invalid requests are markded properly
| def test_validator(self) -> None:
"""
Test to make sure the request validator works properly
The tests cover both cases such as catching valid requests marked
as invalid and making sure invalid requests are markded properly
"""
# `/users/me/subscriptions` doesn't require ... | [
"def",
"test_validator",
"(",
"self",
")",
"->",
"None",
":",
"# `/users/me/subscriptions` doesn't require any parameters",
"validate_request",
"(",
"\"/users/me/subscriptions\"",
",",
"\"get\"",
",",
"{",
"}",
",",
"{",
"}",
",",
"False",
",",
"\"200\"",
")",
"with... | [
1078,
4
] | [
1095,
9
] | python | en | ['en', 'error', 'th'] | False |
WhiteNoiseMiddleware.immutable_file_test | (self, path, url) |
Determine whether given URL represents an immutable file (i.e. a
file with a hash of its contents as part of its name) which can
therefore be cached forever
|
Determine whether given URL represents an immutable file (i.e. a
file with a hash of its contents as part of its name) which can
therefore be cached forever
| def immutable_file_test(self, path, url):
"""
Determine whether given URL represents an immutable file (i.e. a
file with a hash of its contents as part of its name) which can
therefore be cached forever
"""
if not url.startswith(self.static_prefix):
return Fal... | [
"def",
"immutable_file_test",
"(",
"self",
",",
"path",
",",
"url",
")",
":",
"if",
"not",
"url",
".",
"startswith",
"(",
"self",
".",
"static_prefix",
")",
":",
"return",
"False",
"name",
"=",
"url",
"[",
"len",
"(",
"self",
".",
"static_prefix",
")",... | [
131,
4
] | [
149,
20
] | python | en | ['en', 'error', 'th'] | False |
WhiteNoiseMiddleware.get_name_without_hash | (self, filename) |
Removes the version hash from a filename e.g, transforms
'css/application.f3ea4bcc2.css' into 'css/application.css'
Note: this is specific to the naming scheme used by Django's
CachedStaticFilesStorage. You may have to override this if
you are using a different static files ver... |
Removes the version hash from a filename e.g, transforms
'css/application.f3ea4bcc2.css' into 'css/application.css' | def get_name_without_hash(self, filename):
"""
Removes the version hash from a filename e.g, transforms
'css/application.f3ea4bcc2.css' into 'css/application.css'
Note: this is specific to the naming scheme used by Django's
CachedStaticFilesStorage. You may have to override this... | [
"def",
"get_name_without_hash",
"(",
"self",
",",
"filename",
")",
":",
"name_with_hash",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"name",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"name_with_hash",
")",
"[",
"0",
... | [
151,
4
] | [
162,
25
] | python | en | ['en', 'error', 'th'] | False |
FunctionalTestCase.test_lazy_base_class | (self) | Test that lazy also finds base class methods in the proxy object | Test that lazy also finds base class methods in the proxy object | def test_lazy_base_class(self):
"""Test that lazy also finds base class methods in the proxy object"""
class Base(object):
def base_method(self):
pass
class Klazz(Base):
pass
t = lazy(lambda: Klazz(), Klazz)()
self.assertTrue('base_metho... | [
"def",
"test_lazy_base_class",
"(",
"self",
")",
":",
"class",
"Base",
"(",
"object",
")",
":",
"def",
"base_method",
"(",
"self",
")",
":",
"pass",
"class",
"Klazz",
"(",
"Base",
")",
":",
"pass",
"t",
"=",
"lazy",
"(",
"lambda",
":",
"Klazz",
"(",
... | [
11,
4
] | [
22,
48
] | python | en | ['en', 'en', 'en'] | True |
FunctionalTestCase.test_cached_property | (self) |
Test that cached_property caches its value,
and that it behaves like a property
|
Test that cached_property caches its value,
and that it behaves like a property
| def test_cached_property(self):
"""
Test that cached_property caches its value,
and that it behaves like a property
"""
class A(object):
@cached_property
def value(self):
return 1, object()
def other_value(self):
... | [
"def",
"test_cached_property",
"(",
"self",
")",
":",
"class",
"A",
"(",
"object",
")",
":",
"@",
"cached_property",
"def",
"value",
"(",
"self",
")",
":",
"return",
"1",
",",
"object",
"(",
")",
"def",
"other_value",
"(",
"self",
")",
":",
"return",
... | [
42,
4
] | [
76,
48
] | python | en | ['en', 'error', 'th'] | False |
FunctionalTestCase.test_lazy_equality | (self) |
Tests that == and != work correctly for Promises.
|
Tests that == and != work correctly for Promises.
| def test_lazy_equality(self):
"""
Tests that == and != work correctly for Promises.
"""
lazy_a = lazy(lambda: 4, int)
lazy_b = lazy(lambda: 4, int)
lazy_c = lazy(lambda: 5, int)
self.assertEqual(lazy_a(), lazy_b())
self.assertNotEqual(lazy_b(), lazy_c()) | [
"def",
"test_lazy_equality",
"(",
"self",
")",
":",
"lazy_a",
"=",
"lazy",
"(",
"lambda",
":",
"4",
",",
"int",
")",
"lazy_b",
"=",
"lazy",
"(",
"lambda",
":",
"4",
",",
"int",
")",
"lazy_c",
"=",
"lazy",
"(",
"lambda",
":",
"5",
",",
"int",
")",... | [
78,
4
] | [
88,
47
] | python | en | ['en', 'error', 'th'] | False |
_py_func_with_gradient | (func, inp, Tout, stateful=True, name=None, grad_func=None) |
PyFunc defined as given by Tensorflow
:param func: Custom Function
:param inp: Function Inputs
:param Tout: Ouput Type of out Custom Function
:param stateful: Calculate Gradients when stateful is True
:param name: Name of the PyFunction
:param grad: Custom Gradient Function
:return:
... |
PyFunc defined as given by Tensorflow
:param func: Custom Function
:param inp: Function Inputs
:param Tout: Ouput Type of out Custom Function
:param stateful: Calculate Gradients when stateful is True
:param name: Name of the PyFunction
:param grad: Custom Gradient Function
:return:
... | def _py_func_with_gradient(func, inp, Tout, stateful=True, name=None, grad_func=None):
"""
PyFunc defined as given by Tensorflow
:param func: Custom Function
:param inp: Function Inputs
:param Tout: Ouput Type of out Custom Function
:param stateful: Calculate Gradients when stateful is True
... | [
"def",
"_py_func_with_gradient",
"(",
"func",
",",
"inp",
",",
"Tout",
",",
"stateful",
"=",
"True",
",",
"name",
"=",
"None",
",",
"grad_func",
"=",
"None",
")",
":",
"# Generate random name in order to avoid conflicts with inbuilt names",
"rnd_name",
"=",
"\"PyFun... | [
13,
0
] | [
35,
72
] | python | en | ['en', 'error', 'th'] | False |
convert_pytorch_model_to_tf | (model, out_dims=None) |
Convert a pytorch model into a tensorflow op that allows backprop
:param model: A pytorch nn.Module object
:param out_dims: The number of output dimensions (classes) for the model
:return: A model function that maps an input (tf.Tensor) to the
output of the model (tf.Tensor)
|
Convert a pytorch model into a tensorflow op that allows backprop
:param model: A pytorch nn.Module object
:param out_dims: The number of output dimensions (classes) for the model
:return: A model function that maps an input (tf.Tensor) to the
output of the model (tf.Tensor)
| def convert_pytorch_model_to_tf(model, out_dims=None):
"""
Convert a pytorch model into a tensorflow op that allows backprop
:param model: A pytorch nn.Module object
:param out_dims: The number of output dimensions (classes) for the model
:return: A model function that maps an input (tf.Tensor) to t... | [
"def",
"convert_pytorch_model_to_tf",
"(",
"model",
",",
"out_dims",
"=",
"None",
")",
":",
"warnings",
".",
"warn",
"(",
"\"convert_pytorch_model_to_tf is deprecated, switch to\"",
"+",
"\" dedicated PyTorch support provided by CleverHans v4.\"",
")",
"torch_state",
"=",
"{"... | [
38,
0
] | [
96,
22
] | python | en | ['en', 'error', 'th'] | False |
diag | (diag_elements) | Function to create tensorflow diagonal matrix with input diagonal entries.
Args:
diag_elements: tensor with diagonal elements
Returns:
tf matrix with diagonal entries as diag_elements
| Function to create tensorflow diagonal matrix with input diagonal entries. | def diag(diag_elements):
"""Function to create tensorflow diagonal matrix with input diagonal entries.
Args:
diag_elements: tensor with diagonal elements
Returns:
tf matrix with diagonal entries as diag_elements
"""
return tf.diag(tf.reshape(diag_elements, [-1])) | [
"def",
"diag",
"(",
"diag_elements",
")",
":",
"return",
"tf",
".",
"diag",
"(",
"tf",
".",
"reshape",
"(",
"diag_elements",
",",
"[",
"-",
"1",
"]",
")",
")"
] | [
10,
0
] | [
19,
51
] | python | en | ['en', 'el-Latn', 'en'] | True |
initialize_dual | (
neural_net_params_object,
init_dual_file=None,
random_init_variance=0.01,
init_nu=200.0,
) | Function to initialize the dual variables of the class.
Args:
neural_net_params_object: Object with the neural net weights, biases
and types
init_dual_file: Path to file containing dual variables, if the path
is empty, perform random initialization
Expects numpy dictionary with
... | Function to initialize the dual variables of the class. | def initialize_dual(
neural_net_params_object,
init_dual_file=None,
random_init_variance=0.01,
init_nu=200.0,
):
"""Function to initialize the dual variables of the class.
Args:
neural_net_params_object: Object with the neural net weights, biases
and types
init_dual_file: Pa... | [
"def",
"initialize_dual",
"(",
"neural_net_params_object",
",",
"init_dual_file",
"=",
"None",
",",
"random_init_variance",
"=",
"0.01",
",",
"init_nu",
"=",
"200.0",
",",
")",
":",
"lambda_pos",
"=",
"[",
"]",
"lambda_neg",
"=",
"[",
"]",
"lambda_quad",
"=",
... | [
22,
0
] | [
134,
19
] | python | en | ['en', 'en', 'en'] | True |
eig_one_step | (current_vector, learning_rate, vector_prod_fn) | Function that performs one step of gd (variant) for min eigen value.
Args:
current_vector: current estimate of the eigen vector with minimum eigen
value.
learning_rate: learning rate.
vector_prod_fn: function which returns product H*x, where H is a matrix for
which we computing ei... | Function that performs one step of gd (variant) for min eigen value. | def eig_one_step(current_vector, learning_rate, vector_prod_fn):
"""Function that performs one step of gd (variant) for min eigen value.
Args:
current_vector: current estimate of the eigen vector with minimum eigen
value.
learning_rate: learning rate.
vector_prod_fn: function which re... | [
"def",
"eig_one_step",
"(",
"current_vector",
",",
"learning_rate",
",",
"vector_prod_fn",
")",
":",
"grad",
"=",
"2",
"*",
"vector_prod_fn",
"(",
"current_vector",
")",
"# Current objective = (1/2)*v^T (2*M*v); v = current_vector",
"# grad = 2*M*v",
"current_objective",
"=... | [
137,
0
] | [
202,
45
] | python | en | ['en', 'en', 'en'] | True |
minimum_eigen_vector | (x, num_steps, learning_rate, vector_prod_fn) | Computes eigenvector which corresponds to minimum eigenvalue.
Args:
x: initial value of eigenvector.
num_steps: number of optimization steps.
learning_rate: learning rate.
vector_prod_fn: function which takes x and returns product H*x.
Returns:
approximate value of eigenvector.
... | Computes eigenvector which corresponds to minimum eigenvalue. | def minimum_eigen_vector(x, num_steps, learning_rate, vector_prod_fn):
"""Computes eigenvector which corresponds to minimum eigenvalue.
Args:
x: initial value of eigenvector.
num_steps: number of optimization steps.
learning_rate: learning rate.
vector_prod_fn: function which takes x an... | [
"def",
"minimum_eigen_vector",
"(",
"x",
",",
"num_steps",
",",
"learning_rate",
",",
"vector_prod_fn",
")",
":",
"x",
"=",
"tf",
".",
"nn",
".",
"l2_normalize",
"(",
"x",
")",
"for",
"_",
"in",
"range",
"(",
"num_steps",
")",
":",
"x",
"=",
"eig_one_s... | [
205,
0
] | [
224,
12
] | python | de | ['en', 'de', 'nl'] | False |
tf_lanczos_smallest_eigval | (
vector_prod_fn,
matrix_dim,
initial_vector,
num_iter=1000,
max_iter=1000,
collapse_tol=1e-9,
dtype=tf.float32,
) | Computes smallest eigenvector and eigenvalue using Lanczos in pure TF.
This function computes smallest eigenvector and eigenvalue of the matrix
which is implicitly specified by `vector_prod_fn`.
`vector_prod_fn` is a function which takes `x` and returns a product of matrix
in consideration and `x`.
... | Computes smallest eigenvector and eigenvalue using Lanczos in pure TF. | def tf_lanczos_smallest_eigval(
vector_prod_fn,
matrix_dim,
initial_vector,
num_iter=1000,
max_iter=1000,
collapse_tol=1e-9,
dtype=tf.float32,
):
"""Computes smallest eigenvector and eigenvalue using Lanczos in pure TF.
This function computes smallest eigenvector and eigenvalue of t... | [
"def",
"tf_lanczos_smallest_eigval",
"(",
"vector_prod_fn",
",",
"matrix_dim",
",",
"initial_vector",
",",
"num_iter",
"=",
"1000",
",",
"max_iter",
"=",
"1000",
",",
"collapse_tol",
"=",
"1e-9",
",",
"dtype",
"=",
"tf",
".",
"float32",
",",
")",
":",
"# alp... | [
227,
0
] | [
325,
43
] | python | en | ['de', 'en', 'en'] | True |
sorted_walk | (dir) | Do os.walk in a reproducible way,
independent of indeterministic filesystem readdir order
| Do os.walk in a reproducible way,
independent of indeterministic filesystem readdir order
| def sorted_walk(dir):
"""Do os.walk in a reproducible way,
independent of indeterministic filesystem readdir order
"""
for base, dirs, files in os.walk(dir):
dirs.sort()
files.sort()
yield base, dirs, files | [
"def",
"sorted_walk",
"(",
"dir",
")",
":",
"for",
"base",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"dir",
")",
":",
"dirs",
".",
"sort",
"(",
")",
"files",
".",
"sort",
"(",
")",
"yield",
"base",
",",
"dirs",
",",
"files"
] | [
43,
0
] | [
50,
31
] | python | en | ['en', 'gl', 'en'] | True |
walk_egg | (egg_dir) | Walk an unpacked egg's contents, skipping the metadata directory | Walk an unpacked egg's contents, skipping the metadata directory | def walk_egg(egg_dir):
"""Walk an unpacked egg's contents, skipping the metadata directory"""
walker = sorted_walk(egg_dir)
base, dirs, files = next(walker)
if 'EGG-INFO' in dirs:
dirs.remove('EGG-INFO')
yield base, dirs, files
for bdf in walker:
yield bdf | [
"def",
"walk_egg",
"(",
"egg_dir",
")",
":",
"walker",
"=",
"sorted_walk",
"(",
"egg_dir",
")",
"base",
",",
"dirs",
",",
"files",
"=",
"next",
"(",
"walker",
")",
"if",
"'EGG-INFO'",
"in",
"dirs",
":",
"dirs",
".",
"remove",
"(",
"'EGG-INFO'",
")",
... | [
365,
0
] | [
373,
17
] | python | en | ['en', 'en', 'en'] | True |
scan_module | (egg_dir, base, name, stubs) | Check whether module possibly uses unsafe-for-zipfile stuff | Check whether module possibly uses unsafe-for-zipfile stuff | def scan_module(egg_dir, base, name, stubs):
"""Check whether module possibly uses unsafe-for-zipfile stuff"""
filename = os.path.join(base, name)
if filename[:-1] in stubs:
return True # Extension module
pkg = base[len(egg_dir) + 1:].replace(os.sep, '.')
module = pkg + (pkg and '.' or '')... | [
"def",
"scan_module",
"(",
"egg_dir",
",",
"base",
",",
"name",
",",
"stubs",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base",
",",
"name",
")",
"if",
"filename",
"[",
":",
"-",
"1",
"]",
"in",
"stubs",
":",
"return",
"True... | [
413,
0
] | [
446,
15
] | python | en | ['en', 'en', 'en'] | True |
iter_symbols | (code) | Yield names and strings used by `code` and its nested code objects | Yield names and strings used by `code` and its nested code objects | def iter_symbols(code):
"""Yield names and strings used by `code` and its nested code objects"""
for name in code.co_names:
yield name
for const in code.co_consts:
if isinstance(const, six.string_types):
yield const
elif isinstance(const, CodeType):
for name i... | [
"def",
"iter_symbols",
"(",
"code",
")",
":",
"for",
"name",
"in",
"code",
".",
"co_names",
":",
"yield",
"name",
"for",
"const",
"in",
"code",
".",
"co_consts",
":",
"if",
"isinstance",
"(",
"const",
",",
"six",
".",
"string_types",
")",
":",
"yield",... | [
449,
0
] | [
458,
26
] | python | en | ['en', 'en', 'en'] | True |
make_zipfile | (zip_filename, base_dir, verbose=0, dry_run=0, compress=True,
mode='w') | Create a zip file from all the files under 'base_dir'. The output
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile"
Python module (if available) or the InfoZIP "zip" utility (if installed
and found on the default search path). If neither tool is available,
raises DistutilsExecErro... | Create a zip file from all the files under 'base_dir'. The output
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile"
Python module (if available) or the InfoZIP "zip" utility (if installed
and found on the default search path). If neither tool is available,
raises DistutilsExecErro... | def make_zipfile(zip_filename, base_dir, verbose=0, dry_run=0, compress=True,
mode='w'):
"""Create a zip file from all the files under 'base_dir'. The output
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile"
Python module (if available) or the InfoZIP "zip" utility (if... | [
"def",
"make_zipfile",
"(",
"zip_filename",
",",
"base_dir",
",",
"verbose",
"=",
"0",
",",
"dry_run",
"=",
"0",
",",
"compress",
"=",
"True",
",",
"mode",
"=",
"'w'",
")",
":",
"import",
"zipfile",
"mkpath",
"(",
"os",
".",
"path",
".",
"dirname",
"... | [
478,
0
] | [
509,
23
] | python | en | ['en', 'en', 'en'] | True |
bdist_egg.call_command | (self, cmdname, **kw) | Invoke reinitialized command `cmdname` with keyword args | Invoke reinitialized command `cmdname` with keyword args | def call_command(self, cmdname, **kw):
"""Invoke reinitialized command `cmdname` with keyword args"""
for dirname in INSTALL_DIRECTORY_ATTRS:
kw.setdefault(dirname, self.bdist_dir)
kw.setdefault('skip_build', self.skip_build)
kw.setdefault('dry_run', self.dry_run)
cmd... | [
"def",
"call_command",
"(",
"self",
",",
"cmdname",
",",
"*",
"*",
"kw",
")",
":",
"for",
"dirname",
"in",
"INSTALL_DIRECTORY_ATTRS",
":",
"kw",
".",
"setdefault",
"(",
"dirname",
",",
"self",
".",
"bdist_dir",
")",
"kw",
".",
"setdefault",
"(",
"'skip_b... | [
152,
4
] | [
160,
18
] | python | en | ['en', 'en', 'en'] | True |
bdist_egg.copy_metadata_to | (self, target_dir) | Copy metadata (egg info) to the target_dir | Copy metadata (egg info) to the target_dir | def copy_metadata_to(self, target_dir):
"Copy metadata (egg info) to the target_dir"
# normalize the path (so that a forward-slash in egg_info will
# match using startswith below)
norm_egg_info = os.path.normpath(self.egg_info)
prefix = os.path.join(norm_egg_info, '')
for... | [
"def",
"copy_metadata_to",
"(",
"self",
",",
"target_dir",
")",
":",
"# normalize the path (so that a forward-slash in egg_info will",
"# match using startswith below)",
"norm_egg_info",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"self",
".",
"egg_info",
")",
"prefix",... | [
321,
4
] | [
331,
44
] | python | en | ['en', 'pt', 'en'] | True |
bdist_egg.get_ext_outputs | (self) | Get a list of relative paths to C extensions in the output distro | Get a list of relative paths to C extensions in the output distro | def get_ext_outputs(self):
"""Get a list of relative paths to C extensions in the output distro"""
all_outputs = []
ext_outputs = []
paths = {self.bdist_dir: ''}
for base, dirs, files in sorted_walk(self.bdist_dir):
for filename in files:
if os.path.... | [
"def",
"get_ext_outputs",
"(",
"self",
")",
":",
"all_outputs",
"=",
"[",
"]",
"ext_outputs",
"=",
"[",
"]",
"paths",
"=",
"{",
"self",
".",
"bdist_dir",
":",
"''",
"}",
"for",
"base",
",",
"dirs",
",",
"files",
"in",
"sorted_walk",
"(",
"self",
".",... | [
333,
4
] | [
359,
39
] | python | en | ['en', 'en', 'en'] | True |
RelatedObjectUnicodeTests.test_m2m_with_unicode_reference | (self) |
Regression test for #6045: references to other models can be unicode
strings, providing they are directly convertible to ASCII.
|
Regression test for #6045: references to other models can be unicode
strings, providing they are directly convertible to ASCII.
| def test_m2m_with_unicode_reference(self):
"""
Regression test for #6045: references to other models can be unicode
strings, providing they are directly convertible to ASCII.
"""
m1 = UnicodeReferenceModel.objects.create()
m2 = UnicodeReferenceModel.objects.create()
... | [
"def",
"test_m2m_with_unicode_reference",
"(",
"self",
")",
":",
"m1",
"=",
"UnicodeReferenceModel",
".",
"objects",
".",
"create",
"(",
")",
"m2",
"=",
"UnicodeReferenceModel",
".",
"objects",
".",
"create",
"(",
")",
"m2",
".",
"others",
".",
"add",
"(",
... | [
78,
4
] | [
87,
29
] | python | en | ['en', 'error', 'th'] | False |
request | (method, url, **kwargs) | Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to se... | Constructs and sends a :class:`Request <Request>`. | def request(method, url, **kwargs):
"""Constructs and sends a :class:`Request <Request>`.
:param method: method for the new :class:`Request` object: ``GET``, ``OPTIONS``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
:param url: URL for the new :class:`Request` object.
:param params: (optional... | [
"def",
"request",
"(",
"method",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"# By using the 'with' statement we are sure the session is closed, thus we",
"# avoid leaving sockets open which can trigger a ResourceWarning in some",
"# cases, and look like a memory leak in others.",
"... | [
15,
0
] | [
60,
64
] | python | en | ['en', 'en', 'en'] | True |
get | (url, params=None, **kwargs) | r"""Sends a GET request.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` o... | r"""Sends a GET request. | def get(url, params=None, **kwargs):
r"""Sends a GET request.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
... | [
"def",
"get",
"(",
"url",
",",
"params",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"request",
"(",
"'get'",
",",
"url",
",",
"params",
"=",
"params",
",",
"*",
... | [
63,
0
] | [
75,
55
] | python | en | ['en', 'co', 'en'] | True |
options | (url, **kwargs) | r"""Sends an OPTIONS request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
| r"""Sends an OPTIONS request. | def options(url, **kwargs):
r"""Sends an OPTIONS request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects', True)... | [
"def",
"options",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"request",
"(",
"'options'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
78,
0
] | [
88,
44
] | python | en | ['en', 'en', 'en'] | True |
head | (url, **kwargs) | r"""Sends a HEAD request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes. If
`allow_redirects` is not provided, it will be set to `False` (as
opposed to the default :meth:`request` behavior).
:return: :class:`Response <Respo... | r"""Sends a HEAD request. | def head(url, **kwargs):
r"""Sends a HEAD request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes. If
`allow_redirects` is not provided, it will be set to `False` (as
opposed to the default :meth:`request` behavior).
:re... | [
"def",
"head",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"False",
")",
"return",
"request",
"(",
"'head'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
91,
0
] | [
103,
41
] | python | en | ['en', 'co', 'en'] | True |
post | (url, data=None, json=None, **kwargs) | r"""Sends a POST request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kw... | r"""Sends a POST request. | def post(url, data=None, json=None, **kwargs):
r"""Sends a POST request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in ... | [
"def",
"post",
"(",
"url",
",",
"data",
"=",
"None",
",",
"json",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"request",
"(",
"'post'",
",",
"url",
",",
"data",
"=",
"data",
",",
"json",
"=",
"json",
",",
"*",
"*",
"kwargs",
")"
] | [
106,
0
] | [
118,
63
] | python | en | ['en', 'en', 'en'] | True |
put | (url, data=None, **kwargs) | r"""Sends a PUT request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kwa... | r"""Sends a PUT request. | def put(url, data=None, **kwargs):
r"""Sends a PUT request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of t... | [
"def",
"put",
"(",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"request",
"(",
"'put'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
121,
0
] | [
133,
51
] | python | en | ['en', 'co', 'en'] | True |
patch | (url, data=None, **kwargs) | r"""Sends a PATCH request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*k... | r"""Sends a PATCH request. | def patch(url, data=None, **kwargs):
r"""Sends a PATCH request.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body ... | [
"def",
"patch",
"(",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"request",
"(",
"'patch'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
136,
0
] | [
148,
53
] | python | en | ['en', 'co', 'en'] | True |
delete | (url, **kwargs) | r"""Sends a DELETE request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
| r"""Sends a DELETE request. | def delete(url, **kwargs):
r"""Sends a DELETE request.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
return request('delete', url, **kwargs) | [
"def",
"delete",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"request",
"(",
"'delete'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
151,
0
] | [
160,
43
] | python | en | ['en', 'it', 'en'] | True |
fill_edit_history_entries | (message_history: List[Dict[str, Any]], message: Message) | This fills out the message edit history entries from the database,
which are designed to have the minimum data possible, to instead
have the current topic + content as of that time, plus data on
whatever changed. This makes it much simpler to do future
processing.
Note that this mutates what is pa... | This fills out the message edit history entries from the database,
which are designed to have the minimum data possible, to instead
have the current topic + content as of that time, plus data on
whatever changed. This makes it much simpler to do future
processing. | def fill_edit_history_entries(message_history: List[Dict[str, Any]], message: Message) -> None:
"""This fills out the message edit history entries from the database,
which are designed to have the minimum data possible, to instead
have the current topic + content as of that time, plus data on
whatever c... | [
"def",
"fill_edit_history_entries",
"(",
"message_history",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"message",
":",
"Message",
")",
"->",
"None",
":",
"prev_content",
"=",
"message",
".",
"content",
"prev_rendered_content",
"=",
"mes... | [
29,
0
] | [
74,
5
] | python | en | ['en', 'en', 'en'] | True |
two_hour_reservation | (resource_in_unit, user) | A two-hour reservation fixture with actual datetime objects | A two-hour reservation fixture with actual datetime objects | def two_hour_reservation(resource_in_unit, user):
"""A two-hour reservation fixture with actual datetime objects"""
return Reservation.objects.create(
resource=resource_in_unit,
begin=datetime.datetime(2119, 5, 5, 10, 0, 0, tzinfo=UTC),
end=datetime.datetime(2119, 5, 5, 12, 0, 0, tzinfo=... | [
"def",
"two_hour_reservation",
"(",
"resource_in_unit",
",",
"user",
")",
":",
"return",
"Reservation",
".",
"objects",
".",
"create",
"(",
"resource",
"=",
"resource_in_unit",
",",
"begin",
"=",
"datetime",
".",
"datetime",
"(",
"2119",
",",
"5",
",",
"5",
... | [
19,
0
] | [
36,
5
] | python | en | ['en', 'en', 'en'] | True |
Feed.feed_extra_kwargs | (self, obj) |
Returns an extra keyword arguments dictionary that is used when
initializing the feed generator.
|
Returns an extra keyword arguments dictionary that is used when
initializing the feed generator.
| def feed_extra_kwargs(self, obj):
"""
Returns an extra keyword arguments dictionary that is used when
initializing the feed generator.
"""
return {} | [
"def",
"feed_extra_kwargs",
"(",
"self",
",",
"obj",
")",
":",
"return",
"{",
"}"
] | [
88,
4
] | [
93,
17
] | python | en | ['en', 'error', 'th'] | False |
Feed.item_extra_kwargs | (self, item) |
Returns an extra keyword arguments dictionary that is used with
the `add_item` call of the feed generator.
|
Returns an extra keyword arguments dictionary that is used with
the `add_item` call of the feed generator.
| def item_extra_kwargs(self, item):
"""
Returns an extra keyword arguments dictionary that is used with
the `add_item` call of the feed generator.
"""
return {} | [
"def",
"item_extra_kwargs",
"(",
"self",
",",
"item",
")",
":",
"return",
"{",
"}"
] | [
95,
4
] | [
100,
17
] | python | en | ['en', 'error', 'th'] | False |
Feed.get_context_data | (self, **kwargs) |
Returns a dictionary to use as extra context if either
``self.description_template`` or ``self.item_template`` are used.
Default implementation preserves the old behavior
of using {'obj': item, 'site': current_site} as the context.
|
Returns a dictionary to use as extra context if either
``self.description_template`` or ``self.item_template`` are used. | def get_context_data(self, **kwargs):
"""
Returns a dictionary to use as extra context if either
``self.description_template`` or ``self.item_template`` are used.
Default implementation preserves the old behavior
of using {'obj': item, 'site': current_site} as the context.
... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"{",
"'obj'",
":",
"kwargs",
".",
"get",
"(",
"'item'",
")",
",",
"'site'",
":",
"kwargs",
".",
"get",
"(",
"'site'",
")",
"}"
] | [
105,
4
] | [
113,
70
] | python | en | ['en', 'error', 'th'] | False |
Feed.get_feed | (self, obj, request) |
Returns a feedgenerator.DefaultFeed object, fully populated, for
this feed. Raises FeedDoesNotExist for invalid parameters.
|
Returns a feedgenerator.DefaultFeed object, fully populated, for
this feed. Raises FeedDoesNotExist for invalid parameters.
| def get_feed(self, obj, request):
"""
Returns a feedgenerator.DefaultFeed object, fully populated, for
this feed. Raises FeedDoesNotExist for invalid parameters.
"""
current_site = get_current_site(request)
link = self.__get_dynamic_attr('link', obj)
link = add_d... | [
"def",
"get_feed",
"(",
"self",
",",
"obj",
",",
"request",
")",
":",
"current_site",
"=",
"get_current_site",
"(",
"request",
")",
"link",
"=",
"self",
".",
"__get_dynamic_attr",
"(",
"'link'",
",",
"obj",
")",
"link",
"=",
"add_domain",
"(",
"current_sit... | [
115,
4
] | [
218,
19
] | python | en | ['en', 'error', 'th'] | False |
CodeshipHookTests.test_codeship_build_in_testing_status_message | (self) |
Tests if codeship testing status is mapped correctly
|
Tests if codeship testing status is mapped correctly
| def test_codeship_build_in_testing_status_message(self) -> None:
"""
Tests if codeship testing status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started."
self.check_webhook("t... | [
"def",
"test_codeship_build_in_testing_status_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started.\"",
"self",
".",
"check_webhook",
"(",
"\"testing_bui... | [
9,
4
] | [
14,
73
] | python | en | ['en', 'error', 'th'] | False |
CodeshipHookTests.test_codeship_build_in_error_status_message | (self) |
Tests if codeship error status is mapped correctly
|
Tests if codeship error status is mapped correctly
| def test_codeship_build_in_error_status_message(self) -> None:
"""
Tests if codeship error status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed."
self.check_webhook("error_... | [
"def",
"test_codeship_build_in_error_status_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed.\"",
"self",
".",
"check_webhook",
"(",
"\"error_build\""... | [
16,
4
] | [
21,
71
] | python | en | ['en', 'error', 'th'] | False |
CodeshipHookTests.test_codeship_build_in_success_status_message | (self) |
Tests if codeship success status is mapped correctly
|
Tests if codeship success status is mapped correctly
| def test_codeship_build_in_success_status_message(self) -> None:
"""
Tests if codeship success status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded."
self.check_webhook(... | [
"def",
"test_codeship_build_in_success_status_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded.\"",
"self",
".",
"check_webhook",
"(",
"\"success_b... | [
23,
4
] | [
28,
73
] | python | en | ['en', 'error', 'th'] | False |
CodeshipHookTests.test_codeship_build_in_other_status_status_message | (self) |
Tests if codeship other status is mapped correctly
|
Tests if codeship other status is mapped correctly
| def test_codeship_build_in_other_status_status_message(self) -> None:
"""
Tests if codeship other status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status."
... | [
"def",
"test_codeship_build_in_other_status_status_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status.\"",
"self",
".",
"check_webhook... | [
30,
4
] | [
35,
78
] | python | en | ['en', 'error', 'th'] | False |
DatabaseCreation.sql_for_pending_references | (self, model, style, pending_references) | SQLite3 doesn't support constraints | SQLite3 doesn't support constraints | def sql_for_pending_references(self, model, style, pending_references):
"SQLite3 doesn't support constraints"
return [] | [
"def",
"sql_for_pending_references",
"(",
"self",
",",
"model",
",",
"style",
",",
"pending_references",
")",
":",
"return",
"[",
"]"
] | [
41,
4
] | [
43,
17
] | python | en | ['en', 'en', 'en'] | True |
DatabaseCreation.sql_remove_table_constraints | (self, model, references_to_delete, style) | SQLite3 doesn't support constraints | SQLite3 doesn't support constraints | def sql_remove_table_constraints(self, model, references_to_delete, style):
"SQLite3 doesn't support constraints"
return [] | [
"def",
"sql_remove_table_constraints",
"(",
"self",
",",
"model",
",",
"references_to_delete",
",",
"style",
")",
":",
"return",
"[",
"]"
] | [
45,
4
] | [
47,
17
] | python | en | ['en', 'en', 'en'] | True |
DatabaseCreation.test_db_signature | (self) |
Returns a tuple that uniquely identifies a test database.
This takes into account the special cases of ":memory:" and "" for
SQLite since the databases will be distinct despite having the same
TEST NAME. See http://www.sqlite.org/inmemorydb.html
|
Returns a tuple that uniquely identifies a test database. | def test_db_signature(self):
"""
Returns a tuple that uniquely identifies a test database.
This takes into account the special cases of ":memory:" and "" for
SQLite since the databases will be distinct despite having the same
TEST NAME. See http://www.sqlite.org/inmemorydb.html
... | [
"def",
"test_db_signature",
"(",
"self",
")",
":",
"test_dbname",
"=",
"self",
".",
"_get_test_db_name",
"(",
")",
"sig",
"=",
"[",
"self",
".",
"connection",
".",
"settings_dict",
"[",
"'NAME'",
"]",
"]",
"if",
"test_dbname",
"==",
"':memory:'",
":",
"sig... | [
85,
4
] | [
97,
25
] | python | en | ['en', 'error', 'th'] | False |
register_json | (conn_or_curs=None, globally=False, loads=None,
oid=None, array_oid=None, name='json') | Create and register typecasters converting :sql:`json` type to Python objects.
:param conn_or_curs: a connection or cursor used to find the :sql:`json`
and :sql:`json[]` oids; the typecasters are registered in a scope
limited to this object, unless *globally* is set to `!True`. It can be
`!... | Create and register typecasters converting :sql:`json` type to Python objects. | def register_json(conn_or_curs=None, globally=False, loads=None,
oid=None, array_oid=None, name='json'):
"""Create and register typecasters converting :sql:`json` type to Python objects.
:param conn_or_curs: a connection or cursor used to find the :sql:`json`
and :sql:`json[]` oids; t... | [
"def",
"register_json",
"(",
"conn_or_curs",
"=",
"None",
",",
"globally",
"=",
"False",
",",
"loads",
"=",
"None",
",",
"oid",
"=",
"None",
",",
"array_oid",
"=",
"None",
",",
"name",
"=",
"'json'",
")",
":",
"if",
"oid",
"is",
"None",
":",
"oid",
... | [
93,
0
] | [
129,
26
] | python | en | ['en', 'en', 'en'] | True |
register_default_json | (conn_or_curs=None, globally=False, loads=None) |
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following.
Since PostgreSQL 9.2 :sql:`json` is a builtin type, hence its oid is known
and fixed. This function allows specifying a customized *loads* function
for the default :sql:`json` type without querying the database.
All the ... |
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following. | def register_default_json(conn_or_curs=None, globally=False, loads=None):
"""
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following.
Since PostgreSQL 9.2 :sql:`json` is a builtin type, hence its oid is known
and fixed. This function allows specifying a customized *loads* function... | [
"def",
"register_default_json",
"(",
"conn_or_curs",
"=",
"None",
",",
"globally",
"=",
"False",
",",
"loads",
"=",
"None",
")",
":",
"return",
"register_json",
"(",
"conn_or_curs",
"=",
"conn_or_curs",
",",
"globally",
"=",
"globally",
",",
"loads",
"=",
"l... | [
132,
0
] | [
142,
59
] | python | en | ['en', 'error', 'th'] | False |
register_default_jsonb | (conn_or_curs=None, globally=False, loads=None) |
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following.
As in `register_default_json()`, the function allows to register a
customized *loads* function for the :sql:`jsonb` type at its known oid for
PostgreSQL 9.4 and following versions. All the parameters have the same
mean... |
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following. | def register_default_jsonb(conn_or_curs=None, globally=False, loads=None):
"""
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following.
As in `register_default_json()`, the function allows to register a
customized *loads* function for the :sql:`jsonb` type at its known oid for
... | [
"def",
"register_default_jsonb",
"(",
"conn_or_curs",
"=",
"None",
",",
"globally",
"=",
"False",
",",
"loads",
"=",
"None",
")",
":",
"return",
"register_json",
"(",
"conn_or_curs",
"=",
"conn_or_curs",
",",
"globally",
"=",
"globally",
",",
"loads",
"=",
"... | [
145,
0
] | [
155,
75
] | python | en | ['en', 'error', 'th'] | False |
_create_json_typecasters | (oid, array_oid, loads=None, name='JSON') | Create typecasters for json data type. | Create typecasters for json data type. | def _create_json_typecasters(oid, array_oid, loads=None, name='JSON'):
"""Create typecasters for json data type."""
if loads is None:
loads = json.loads
def typecast_json(s, cur):
if s is None:
return None
return loads(s)
JSON = new_type((oid, ), name, typecast_json... | [
"def",
"_create_json_typecasters",
"(",
"oid",
",",
"array_oid",
",",
"loads",
"=",
"None",
",",
"name",
"=",
"'JSON'",
")",
":",
"if",
"loads",
"is",
"None",
":",
"loads",
"=",
"json",
".",
"loads",
"def",
"typecast_json",
"(",
"s",
",",
"cur",
")",
... | [
158,
0
] | [
174,
26
] | python | en | ['en', 'en', 'en'] | True |
Json.dumps | (self, obj) | Serialize *obj* in JSON format.
The default is to call `!json.dumps()` or the *dumps* function
provided in the constructor. You can override this method to create a
customized JSON wrapper.
| Serialize *obj* in JSON format. | def dumps(self, obj):
"""Serialize *obj* in JSON format.
The default is to call `!json.dumps()` or the *dumps* function
provided in the constructor. You can override this method to create a
customized JSON wrapper.
"""
return self._dumps(obj) | [
"def",
"dumps",
"(",
"self",
",",
"obj",
")",
":",
"return",
"self",
".",
"_dumps",
"(",
"obj",
")"
] | [
65,
4
] | [
72,
31
] | python | en | ['en', 'fy', 'it'] | False |
CharSetProber.filter_international_words | (buf) |
We define three types of bytes:
alphabet: english alphabets [a-zA-Z]
international: international characters [\x80-\xFF]
marker: everything else [^a-zA-Z\x80-\xFF]
The input buffer can be thought to contain a series of words delimited
by markers. This function works to ... |
We define three types of bytes:
alphabet: english alphabets [a-zA-Z]
international: international characters [\x80-\xFF]
marker: everything else [^a-zA-Z\x80-\xFF] | def filter_international_words(buf):
"""
We define three types of bytes:
alphabet: english alphabets [a-zA-Z]
international: international characters [\x80-\xFF]
marker: everything else [^a-zA-Z\x80-\xFF]
The input buffer can be thought to contain a series of words delim... | [
"def",
"filter_international_words",
"(",
"buf",
")",
":",
"filtered",
"=",
"bytearray",
"(",
")",
"# This regex expression filters out only words that have at-least one",
"# international character. The word may include one marker character at",
"# the end.",
"words",
"=",
"re",
"... | [
66,
4
] | [
100,
23
] | python | en | ['en', 'error', 'th'] | False |
CharSetProber.filter_with_english_letters | (buf) |
Returns a copy of ``buf`` that retains only the sequences of English
alphabet and high byte characters that are not between <> characters.
Also retains English alphabet and high byte characters immediately
before occurrences of >.
This filter can be applied to all scripts which... |
Returns a copy of ``buf`` that retains only the sequences of English
alphabet and high byte characters that are not between <> characters.
Also retains English alphabet and high byte characters immediately
before occurrences of >. | def filter_with_english_letters(buf):
"""
Returns a copy of ``buf`` that retains only the sequences of English
alphabet and high byte characters that are not between <> characters.
Also retains English alphabet and high byte characters immediately
before occurrences of >.
... | [
"def",
"filter_with_english_letters",
"(",
"buf",
")",
":",
"filtered",
"=",
"bytearray",
"(",
")",
"in_tag",
"=",
"False",
"prev",
"=",
"0",
"for",
"curr",
"in",
"range",
"(",
"len",
"(",
"buf",
")",
")",
":",
"# Slice here to get bytes instead of an int with... | [
103,
4
] | [
144,
23
] | python | en | ['en', 'error', 'th'] | False |
ProjectedGradientDescent.__init__ | (
self, model, sess=None, dtypestr="float32", default_rand_init=True, **kwargs
) |
Create a ProjectedGradientDescent instance.
Note: the model parameter should be an instance of the
cleverhans.model.Model abstraction provided by CleverHans.
|
Create a ProjectedGradientDescent instance.
Note: the model parameter should be an instance of the
cleverhans.model.Model abstraction provided by CleverHans.
| def __init__(
self, model, sess=None, dtypestr="float32", default_rand_init=True, **kwargs
):
"""
Create a ProjectedGradientDescent instance.
Note: the model parameter should be an instance of the
cleverhans.model.Model abstraction provided by CleverHans.
"""
... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"sess",
"=",
"None",
",",
"dtypestr",
"=",
"\"float32\"",
",",
"default_rand_init",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"ProjectedGradientDescent",
",",
"self",
")",
".",
"__ini... | [
33,
4
] | [
61,
50
] | python | en | ['en', 'error', 'th'] | False |
ProjectedGradientDescent.generate | (self, x, **kwargs) |
Generate symbolic graph for adversarial examples and return.
:param x: The model's symbolic inputs.
:param kwargs: See `parse_params`
|
Generate symbolic graph for adversarial examples and return. | def generate(self, x, **kwargs):
"""
Generate symbolic graph for adversarial examples and return.
:param x: The model's symbolic inputs.
:param kwargs: See `parse_params`
"""
# Parse and save attack-specific parameters
assert self.parse_params(**kwargs)
... | [
"def",
"generate",
"(",
"self",
",",
"x",
",",
"*",
"*",
"kwargs",
")",
":",
"# Parse and save attack-specific parameters",
"assert",
"self",
".",
"parse_params",
"(",
"*",
"*",
"kwargs",
")",
"asserts",
"=",
"[",
"]",
"# If a data range was specified, check that ... | [
63,
4
] | [
199,
20
] | python | en | ['en', 'error', 'th'] | False |
ProjectedGradientDescent.parse_params | (
self,
eps=0.3,
eps_iter=0.05,
nb_iter=10,
y=None,
ord=np.inf,
loss_fn=softmax_cross_entropy_with_logits,
clip_min=None,
clip_max=None,
y_target=None,
rand_init=None,
rand_init_eps=None,
clip_grad=False,
san... |
Take in a dictionary of parameters and applies attack-specific checks
before saving them as attributes.
Attack-specific parameters:
:param eps: (optional float) maximum distortion of adversarial example
compared to original input
:param eps_iter: (optional ... |
Take in a dictionary of parameters and applies attack-specific checks
before saving them as attributes. | def parse_params(
self,
eps=0.3,
eps_iter=0.05,
nb_iter=10,
y=None,
ord=np.inf,
loss_fn=softmax_cross_entropy_with_logits,
clip_min=None,
clip_max=None,
y_target=None,
rand_init=None,
rand_init_eps=None,
clip_grad=Fa... | [
"def",
"parse_params",
"(",
"self",
",",
"eps",
"=",
"0.3",
",",
"eps_iter",
"=",
"0.05",
",",
"nb_iter",
"=",
"10",
",",
"y",
"=",
"None",
",",
"ord",
"=",
"np",
".",
"inf",
",",
"loss_fn",
"=",
"softmax_cross_entropy_with_logits",
",",
"clip_min",
"=... | [
201,
4
] | [
290,
19
] | python | en | ['en', 'error', 'th'] | False |
SkippingTestCase.test_skip_unless_db_feature | (self) |
Testing the django.test.skipUnlessDBFeature decorator.
|
Testing the django.test.skipUnlessDBFeature decorator.
| def test_skip_unless_db_feature(self):
"""
Testing the django.test.skipUnlessDBFeature decorator.
"""
# Total hack, but it works, just want an attribute that's always true.
@skipUnlessDBFeature("__class__")
def test_func():
raise ValueError
@skipUnles... | [
"def",
"test_skip_unless_db_feature",
"(",
"self",
")",
":",
"# Total hack, but it works, just want an attribute that's always true.",
"@",
"skipUnlessDBFeature",
"(",
"\"__class__\"",
")",
"def",
"test_func",
"(",
")",
":",
"raise",
"ValueError",
"@",
"skipUnlessDBFeature",
... | [
32,
4
] | [
56,
60
] | python | en | ['en', 'error', 'th'] | False |
SkippingTestCase.test_skip_if_db_feature | (self) |
Testing the django.test.skipIfDBFeature decorator.
|
Testing the django.test.skipIfDBFeature decorator.
| def test_skip_if_db_feature(self):
"""
Testing the django.test.skipIfDBFeature decorator.
"""
@skipIfDBFeature("__class__")
def test_func():
raise ValueError
@skipIfDBFeature("notprovided")
def test_func2():
raise ValueError
@skip... | [
"def",
"test_skip_if_db_feature",
"(",
"self",
")",
":",
"@",
"skipIfDBFeature",
"(",
"\"__class__\"",
")",
"def",
"test_func",
"(",
")",
":",
"raise",
"ValueError",
"@",
"skipIfDBFeature",
"(",
"\"notprovided\"",
")",
"def",
"test_func2",
"(",
")",
":",
"rais... | [
58,
4
] | [
86,
53
] | python | en | ['en', 'error', 'th'] | False |
AssertQuerysetEqualTests.test_repeated_values | (self) |
Test that assertQuerysetEqual checks the number of appearance of each item
when used with option ordered=False.
|
Test that assertQuerysetEqual checks the number of appearance of each item
when used with option ordered=False.
| def test_repeated_values(self):
"""
Test that assertQuerysetEqual checks the number of appearance of each item
when used with option ordered=False.
"""
batmobile = Car.objects.create(name='Batmobile')
k2000 = Car.objects.create(name='K 2000')
PossessedCar.objects.... | [
"def",
"test_repeated_values",
"(",
"self",
")",
":",
"batmobile",
"=",
"Car",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'Batmobile'",
")",
"k2000",
"=",
"Car",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'K 2000'",
")",
"PossessedCar",
"."... | [
181,
4
] | [
206,
9
] | python | en | ['en', 'error', 'th'] | False |
AssertRaisesMsgTest.test_special_re_chars | (self) | assertRaisesMessage shouldn't interpret RE special chars. | assertRaisesMessage shouldn't interpret RE special chars. | def test_special_re_chars(self):
"""assertRaisesMessage shouldn't interpret RE special chars."""
def func1():
raise ValueError("[.*x+]y?")
self.assertRaisesMessage(ValueError, "[.*x+]y?", func1) | [
"def",
"test_special_re_chars",
"(",
"self",
")",
":",
"def",
"func1",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"[.*x+]y?\"",
")",
"self",
".",
"assertRaisesMessage",
"(",
"ValueError",
",",
"\"[.*x+]y?\"",
",",
"func1",
")"
] | [
731,
4
] | [
735,
63
] | python | en | ['en', 'lb', 'en'] | True |
OverrideSettingsTests.test_override_media_root | (self) |
Overriding the MEDIA_ROOT setting should be reflected in the
base_location attribute of django.core.files.storage.default_storage.
|
Overriding the MEDIA_ROOT setting should be reflected in the
base_location attribute of django.core.files.storage.default_storage.
| def test_override_media_root(self):
"""
Overriding the MEDIA_ROOT setting should be reflected in the
base_location attribute of django.core.files.storage.default_storage.
"""
self.assertEqual(default_storage.base_location, '')
with self.settings(MEDIA_ROOT='test_value'):
... | [
"def",
"test_override_media_root",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"default_storage",
".",
"base_location",
",",
"''",
")",
"with",
"self",
".",
"settings",
"(",
"MEDIA_ROOT",
"=",
"'test_value'",
")",
":",
"self",
".",
"assertEqual",
... | [
795,
4
] | [
802,
73
] | python | en | ['en', 'error', 'th'] | False |
OverrideSettingsTests.test_override_media_url | (self) |
Overriding the MEDIA_URL setting should be reflected in the
base_url attribute of django.core.files.storage.default_storage.
|
Overriding the MEDIA_URL setting should be reflected in the
base_url attribute of django.core.files.storage.default_storage.
| def test_override_media_url(self):
"""
Overriding the MEDIA_URL setting should be reflected in the
base_url attribute of django.core.files.storage.default_storage.
"""
self.assertEqual(default_storage.base_location, '')
with self.settings(MEDIA_URL='/test_value/'):
... | [
"def",
"test_override_media_url",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"default_storage",
".",
"base_location",
",",
"''",
")",
"with",
"self",
".",
"settings",
"(",
"MEDIA_URL",
"=",
"'/test_value/'",
")",
":",
"self",
".",
"assertEqual",
... | [
804,
4
] | [
811,
70
] | python | en | ['en', 'error', 'th'] | False |
OverrideSettingsTests.test_override_file_upload_permissions | (self) |
Overriding the FILE_UPLOAD_PERMISSIONS setting should be reflected in
the file_permissions_mode attribute of
django.core.files.storage.default_storage.
|
Overriding the FILE_UPLOAD_PERMISSIONS setting should be reflected in
the file_permissions_mode attribute of
django.core.files.storage.default_storage.
| def test_override_file_upload_permissions(self):
"""
Overriding the FILE_UPLOAD_PERMISSIONS setting should be reflected in
the file_permissions_mode attribute of
django.core.files.storage.default_storage.
"""
self.assertIsNone(default_storage.file_permissions_mode)
... | [
"def",
"test_override_file_upload_permissions",
"(",
"self",
")",
":",
"self",
".",
"assertIsNone",
"(",
"default_storage",
".",
"file_permissions_mode",
")",
"with",
"self",
".",
"settings",
"(",
"FILE_UPLOAD_PERMISSIONS",
"=",
"0o777",
")",
":",
"self",
".",
"as... | [
813,
4
] | [
821,
74
] | python | en | ['en', 'error', 'th'] | False |
OverrideSettingsTests.test_override_file_upload_directory_permissions | (self) |
Overriding the FILE_UPLOAD_DIRECTORY_PERMISSIONS setting should be
reflected in the directory_permissions_mode attribute of
django.core.files.storage.default_storage.
|
Overriding the FILE_UPLOAD_DIRECTORY_PERMISSIONS setting should be
reflected in the directory_permissions_mode attribute of
django.core.files.storage.default_storage.
| def test_override_file_upload_directory_permissions(self):
"""
Overriding the FILE_UPLOAD_DIRECTORY_PERMISSIONS setting should be
reflected in the directory_permissions_mode attribute of
django.core.files.storage.default_storage.
"""
self.assertIsNone(default_storage.dire... | [
"def",
"test_override_file_upload_directory_permissions",
"(",
"self",
")",
":",
"self",
".",
"assertIsNone",
"(",
"default_storage",
".",
"directory_permissions_mode",
")",
"with",
"self",
".",
"settings",
"(",
"FILE_UPLOAD_DIRECTORY_PERMISSIONS",
"=",
"0o777",
")",
":... | [
823,
4
] | [
831,
79
] | python | en | ['en', 'error', 'th'] | False |
Console.size | (self) | Get the size of the console. | Get the size of the console. | def size(self):
"""Get the size of the console."""
return (self.width, self.height) | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"width",
",",
"self",
".",
"height",
")"
] | [
17,
4
] | [
19,
40
] | python | en | ['en', 'en', 'en'] | True |
Console.print | (self, *objects: tuple, sep=" ", end="\n", style=None) | Prints the given styled strings and other positional arguments to stdout. | Prints the given styled strings and other positional arguments to stdout. | def print(self, *objects: tuple, sep=" ", end="\n", style=None):
"""Prints the given styled strings and other positional arguments to stdout."""
if not objects:
print(sep=sep, end=end)
strs = [self.style(obj) for obj in objects]
print(*strs, sep=sep, end=end) | [
"def",
"print",
"(",
"self",
",",
"*",
"objects",
":",
"tuple",
",",
"sep",
"=",
"\" \"",
",",
"end",
"=",
"\"\\n\"",
",",
"style",
"=",
"None",
")",
":",
"if",
"not",
"objects",
":",
"print",
"(",
"sep",
"=",
"sep",
",",
"end",
"=",
"end",
")"... | [
21,
4
] | [
27,
38
] | python | en | ['en', 'en', 'en'] | True |
Console.style | (self, obj) | Wrapper function to determine whether an object has styling and process it accordingly. | Wrapper function to determine whether an object has styling and process it accordingly. | def style(self, obj) -> str:
"""Wrapper function to determine whether an object has styling and process it accordingly."""
if isinstance(obj, str):
return self.parse(obj)
return str(obj) | [
"def",
"style",
"(",
"self",
",",
"obj",
")",
"->",
"str",
":",
"if",
"isinstance",
"(",
"obj",
",",
"str",
")",
":",
"return",
"self",
".",
"parse",
"(",
"obj",
")",
"return",
"str",
"(",
"obj",
")"
] | [
29,
4
] | [
33,
23
] | python | en | ['en', 'en', 'en'] | True |
Console.parse | (self, s: str) | Parses a string containing possible styles and variable injections and returns the styled string. | Parses a string containing possible styles and variable injections and returns the styled string. | def parse(self, s: str) -> str:
"""Parses a string containing possible styles and variable injections and returns the styled string."""
ptr = 0
stop = len(s)
buffer = ""
while ptr < stop:
_next = ""
if s[ptr] == "\\" and (s[ptr + 1] == "[" or s[ptr + 1] ==... | [
"def",
"parse",
"(",
"self",
",",
"s",
":",
"str",
")",
"->",
"str",
":",
"ptr",
"=",
"0",
"stop",
"=",
"len",
"(",
"s",
")",
"buffer",
"=",
"\"\"",
"while",
"ptr",
"<",
"stop",
":",
"_next",
"=",
"\"\"",
"if",
"s",
"[",
"ptr",
"]",
"==",
"... | [
35,
4
] | [
75,
21
] | 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.