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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
HTMLParser.documentEncoding | (self) | Name of the character encoding that was used to decode the input stream, or
:obj:`None` if that is not determined yet
| Name of the character encoding that was used to decode the input stream, or
:obj:`None` if that is not determined yet | def documentEncoding(self):
"""Name of the character encoding that was used to decode the input stream, or
:obj:`None` if that is not determined yet
"""
if not hasattr(self, 'tokenizer'):
return None
return self.tokenizer.stream.charEncoding[0].name | [
"def",
"documentEncoding",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'tokenizer'",
")",
":",
"return",
"None",
"return",
"self",
".",
"tokenizer",
".",
"stream",
".",
"charEncoding",
"[",
"0",
"]",
".",
"name"
] | [
173,
4
] | [
180,
57
] | python | en | ['en', 'en', 'en'] | True |
HTMLParser.parse | (self, stream, *args, **kwargs) | Parse a HTML document into a well-formed tree
:arg stream: a file-like object or string containing the HTML to be parsed
The optional encoding parameter must be a string that indicates
the encoding. If specified, that encoding will be used,
regardless of any BOM or later d... | Parse a HTML document into a well-formed tree | def parse(self, stream, *args, **kwargs):
"""Parse a HTML document into a well-formed tree
:arg stream: a file-like object or string containing the HTML to be parsed
The optional encoding parameter must be a string that indicates
the encoding. If specified, that encoding will ... | [
"def",
"parse",
"(",
"self",
",",
"stream",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_parse",
"(",
"stream",
",",
"False",
",",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"tree",
"."... | [
266,
4
] | [
289,
38
] | python | en | ['en', 'en', 'en'] | True |
HTMLParser.parseFragment | (self, stream, *args, **kwargs) | Parse a HTML fragment into a well-formed tree fragment
:arg container: name of the element we're setting the innerHTML
property if set to None, default to 'div'
:arg stream: a file-like object or string containing the HTML to be parsed
The optional encoding parameter must be a... | Parse a HTML fragment into a well-formed tree fragment | def parseFragment(self, stream, *args, **kwargs):
"""Parse a HTML fragment into a well-formed tree fragment
:arg container: name of the element we're setting the innerHTML
property if set to None, default to 'div'
:arg stream: a file-like object or string containing the HTML to be ... | [
"def",
"parseFragment",
"(",
"self",
",",
"stream",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_parse",
"(",
"stream",
",",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"tree",
".",
"getFr... | [
291,
4
] | [
317,
38
] | python | en | ['en', 'en', 'en'] | True |
InBodyPhase.startTagRawtext | (self, token) | iframe, noembed noframes, noscript(if scripting enabled) | iframe, noembed noframes, noscript(if scripting enabled) | def startTagRawtext(self, token):
"""iframe, noembed noframes, noscript(if scripting enabled)"""
self.parser.parseRCDataRawtext(token, "RAWTEXT") | [
"def",
"startTagRawtext",
"(",
"self",
",",
"token",
")",
":",
"self",
".",
"parser",
".",
"parseRCDataRawtext",
"(",
"token",
",",
"\"RAWTEXT\"",
")"
] | [
1292,
8
] | [
1294,
60
] | python | en | ['en', 'en', 'nl'] | True |
InBodyPhase.startTagMisplaced | (self, token) | Elements that should be children of other elements that have a
different insertion mode; here they are ignored
"caption", "col", "colgroup", "frame", "frameset", "head",
"option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
"tr", "noscript"
| Elements that should be children of other elements that have a
different insertion mode; here they are ignored
"caption", "col", "colgroup", "frame", "frameset", "head",
"option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
"tr", "noscript"
| def startTagMisplaced(self, token):
""" Elements that should be children of other elements that have a
different insertion mode; here they are ignored
"caption", "col", "colgroup", "frame", "frameset", "head",
"option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
... | [
"def",
"startTagMisplaced",
"(",
"self",
",",
"token",
")",
":",
"self",
".",
"parser",
".",
"parseError",
"(",
"\"unexpected-start-tag-ignored\"",
",",
"{",
"\"name\"",
":",
"token",
"[",
"\"name\"",
"]",
"}",
")"
] | [
1347,
8
] | [
1354,
91
] | python | en | ['en', 'en', 'en'] | True |
InBodyPhase.endTagFormatting | (self, token) | The much-feared adoption agency algorithm | The much-feared adoption agency algorithm | def endTagFormatting(self, token):
"""The much-feared adoption agency algorithm"""
# http://svn.whatwg.org/webapps/complete.html#adoptionAgency revision 7867
# XXX Better parseError messages appreciated.
# Step 1
outerLoopCounter = 0
# Step 2
... | [
"def",
"endTagFormatting",
"(",
"self",
",",
"token",
")",
":",
"# http://svn.whatwg.org/webapps/complete.html#adoptionAgency revision 7867",
"# XXX Better parseError messages appreciated.",
"# Step 1",
"outerLoopCounter",
"=",
"0",
"# Step 2",
"while",
"outerLoopCounter",
"<",
"... | [
1456,
8
] | [
1617,
75
] | python | en | ['en', 'en', 'en'] | True |
user_data_dir | (appname=None, appauthor=None, version=None, roaming=False) | r"""Return full path to the user-specific data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific data dir for this application. | def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of ... | [
"def",
"user_data_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"roaming",
"=",
"False",
")",
":",
"if",
"system",
"==",
"\"win32\"",
":",
"if",
"appauthor",
"is",
"None",
":",
"appauthor",
"=",
"ap... | [
44,
0
] | [
96,
15
] | python | en | ['en', 'en', 'en'] | True |
site_data_dir | (appname=None, appauthor=None, version=None, multipath=False) | r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-shared data dir for this application. | def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of ... | [
"def",
"site_data_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"multipath",
"=",
"False",
")",
":",
"if",
"system",
"==",
"\"win32\"",
":",
"if",
"appauthor",
"is",
"None",
":",
"appauthor",
"=",
"... | [
99,
0
] | [
162,
15
] | python | en | ['en', 'en', 'en'] | True |
user_config_dir | (appname=None, appauthor=None, version=None, roaming=False) | r"""Return full path to the user-specific config dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific config dir for this application. | def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific config dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name... | [
"def",
"user_config_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"roaming",
"=",
"False",
")",
":",
"if",
"system",
"in",
"[",
"\"win32\"",
",",
"\"darwin\"",
"]",
":",
"path",
"=",
"user_data_dir",
... | [
165,
0
] | [
202,
15
] | python | en | ['en', 'en', 'en'] | True |
site_config_dir | (appname=None, appauthor=None, version=None, multipath=False) | r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-shared data dir for this application. | def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name o... | [
"def",
"site_config_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"multipath",
"=",
"False",
")",
":",
"if",
"system",
"in",
"[",
"\"win32\"",
",",
"\"darwin\"",
"]",
":",
"path",
"=",
"site_data_dir"... | [
205,
0
] | [
253,
15
] | python | en | ['en', 'en', 'en'] | True |
user_cache_dir | (appname=None, appauthor=None, version=None, opinion=True) | r"""Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific cache dir for this application. | def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
r"""Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of... | [
"def",
"user_cache_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"opinion",
"=",
"True",
")",
":",
"if",
"system",
"==",
"\"win32\"",
":",
"if",
"appauthor",
"is",
"None",
":",
"appauthor",
"=",
"ap... | [
256,
0
] | [
310,
15
] | python | en | ['en', 'en', 'en'] | True |
user_state_dir | (appname=None, appauthor=None, version=None, roaming=False) | r"""Return full path to the user-specific state dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific state dir for this application. | def user_state_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific state dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name o... | [
"def",
"user_state_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"roaming",
"=",
"False",
")",
":",
"if",
"system",
"in",
"[",
"\"win32\"",
",",
"\"darwin\"",
"]",
":",
"path",
"=",
"user_data_dir",
... | [
313,
0
] | [
352,
15
] | python | en | ['en', 'en', 'en'] | True |
user_log_dir | (appname=None, appauthor=None, version=None, opinion=True) | r"""Return full path to the user-specific log dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific log dir for this application. | def user_log_dir(appname=None, appauthor=None, version=None, opinion=True):
r"""Return full path to the user-specific log dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the... | [
"def",
"user_log_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"opinion",
"=",
"True",
")",
":",
"if",
"system",
"==",
"\"darwin\"",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
... | [
355,
0
] | [
403,
15
] | python | en | ['en', 'en', 'en'] | True |
_get_win_folder_from_registry | (csidl_name) | This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
| This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
| def _get_win_folder_from_registry(csidl_name):
"""This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
"""
if PY3:
import winreg as _winreg
else:
import _winreg
shell_folder_name = {
"CS... | [
"def",
"_get_win_folder_from_registry",
"(",
"csidl_name",
")",
":",
"if",
"PY3",
":",
"import",
"winreg",
"as",
"_winreg",
"else",
":",
"import",
"_winreg",
"shell_folder_name",
"=",
"{",
"\"CSIDL_APPDATA\"",
":",
"\"AppData\"",
",",
"\"CSIDL_COMMON_APPDATA\"",
":"... | [
454,
0
] | [
475,
14
] | python | en | ['en', 'en', 'en'] | True |
RequestEncodingMixin.path_url | (self) | Build the path URL to use. | Build the path URL to use. | def path_url(self):
"""Build the path URL to use."""
url = []
p = urlsplit(self.url)
path = p.path
if not path:
path = '/'
url.append(path)
query = p.query
if query:
url.append('?')
url.append(query)
return... | [
"def",
"path_url",
"(",
"self",
")",
":",
"url",
"=",
"[",
"]",
"p",
"=",
"urlsplit",
"(",
"self",
".",
"url",
")",
"path",
"=",
"p",
".",
"path",
"if",
"not",
"path",
":",
"path",
"=",
"'/'",
"url",
".",
"append",
"(",
"path",
")",
"query",
... | [
61,
4
] | [
79,
27
] | python | en | ['en', 'en', 'en'] | True |
RequestEncodingMixin._encode_params | (data) | Encode parameters in a piece of data.
Will successfully encode parameters when passed as a dict or a list of
2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
if parameters are supplied as a dict.
| Encode parameters in a piece of data. | def _encode_params(data):
"""Encode parameters in a piece of data.
Will successfully encode parameters when passed as a dict or a list of
2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
if parameters are supplied as a dict.
"""
if isinstance(data... | [
"def",
"_encode_params",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"(",
"str",
",",
"bytes",
")",
")",
":",
"return",
"data",
"elif",
"hasattr",
"(",
"data",
",",
"'read'",
")",
":",
"return",
"data",
"elif",
"hasattr",
"(",
"data"... | [
82,
4
] | [
106,
23
] | python | en | ['en', 'en', 'en'] | True |
RequestEncodingMixin._encode_files | (files, data) | Build the body for a multipart/form-data request.
Will successfully encode files when passed as a dict or a list of
tuples. Order is retained if data is a list of tuples but arbitrary
if parameters are supplied as a dict.
The tuples may be 2-tuples (filename, fileobj), 3-tuples (filenam... | Build the body for a multipart/form-data request. | def _encode_files(files, data):
"""Build the body for a multipart/form-data request.
Will successfully encode files when passed as a dict or a list of
tuples. Order is retained if data is a list of tuples but arbitrary
if parameters are supplied as a dict.
The tuples may be 2-tu... | [
"def",
"_encode_files",
"(",
"files",
",",
"data",
")",
":",
"if",
"(",
"not",
"files",
")",
":",
"raise",
"ValueError",
"(",
"\"Files must be provided.\"",
")",
"elif",
"isinstance",
"(",
"data",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"\... | [
109,
4
] | [
170,
33
] | python | en | ['en', 'en', 'en'] | True |
RequestHooksMixin.register_hook | (self, event, hook) | Properly register a hook. | Properly register a hook. | def register_hook(self, event, hook):
"""Properly register a hook."""
if event not in self.hooks:
raise ValueError('Unsupported event specified, with event name "%s"' % (event))
if isinstance(hook, Callable):
self.hooks[event].append(hook)
elif hasattr(hook, '__... | [
"def",
"register_hook",
"(",
"self",
",",
"event",
",",
"hook",
")",
":",
"if",
"event",
"not",
"in",
"self",
".",
"hooks",
":",
"raise",
"ValueError",
"(",
"'Unsupported event specified, with event name \"%s\"'",
"%",
"(",
"event",
")",
")",
"if",
"isinstance... | [
174,
4
] | [
183,
80
] | python | en | ['en', 'da', 'en'] | True |
RequestHooksMixin.deregister_hook | (self, event, hook) | Deregister a previously registered hook.
Returns True if the hook existed, False if not.
| Deregister a previously registered hook.
Returns True if the hook existed, False if not.
| def deregister_hook(self, event, hook):
"""Deregister a previously registered hook.
Returns True if the hook existed, False if not.
"""
try:
self.hooks[event].remove(hook)
return True
except ValueError:
return False | [
"def",
"deregister_hook",
"(",
"self",
",",
"event",
",",
"hook",
")",
":",
"try",
":",
"self",
".",
"hooks",
"[",
"event",
"]",
".",
"remove",
"(",
"hook",
")",
"return",
"True",
"except",
"ValueError",
":",
"return",
"False"
] | [
185,
4
] | [
194,
24
] | python | en | ['en', 'da', 'en'] | True |
Request.prepare | (self) | Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it. | Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it. | def prepare(self):
"""Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it."""
p = PreparedRequest()
p.prepare(
method=self.method,
url=self.url,
headers=self.headers,
files=self.files,
data=self.data,... | [
"def",
"prepare",
"(",
"self",
")",
":",
"p",
"=",
"PreparedRequest",
"(",
")",
"p",
".",
"prepare",
"(",
"method",
"=",
"self",
".",
"method",
",",
"url",
"=",
"self",
".",
"url",
",",
"headers",
"=",
"self",
".",
"headers",
",",
"files",
"=",
"... | [
253,
4
] | [
268,
16
] | python | en | ['en', 'co', 'en'] | True |
PreparedRequest.prepare | (self,
method=None, url=None, headers=None, files=None, data=None,
params=None, auth=None, cookies=None, hooks=None, json=None) | Prepares the entire request with the given parameters. | Prepares the entire request with the given parameters. | def prepare(self,
method=None, url=None, headers=None, files=None, data=None,
params=None, auth=None, cookies=None, hooks=None, json=None):
"""Prepares the entire request with the given parameters."""
self.prepare_method(method)
self.prepare_url(url, params)
self... | [
"def",
"prepare",
"(",
"self",
",",
"method",
"=",
"None",
",",
"url",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"files",
"=",
"None",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
",",
"auth",
"=",
"None",
",",
"cookies",
"=",
"None... | [
307,
4
] | [
323,
33
] | python | en | ['en', 'en', 'en'] | True |
PreparedRequest.prepare_method | (self, method) | Prepares the given HTTP method. | Prepares the given HTTP method. | def prepare_method(self, method):
"""Prepares the given HTTP method."""
self.method = method
if self.method is not None:
self.method = to_native_string(self.method.upper()) | [
"def",
"prepare_method",
"(",
"self",
",",
"method",
")",
":",
"self",
".",
"method",
"=",
"method",
"if",
"self",
".",
"method",
"is",
"not",
"None",
":",
"self",
".",
"method",
"=",
"to_native_string",
"(",
"self",
".",
"method",
".",
"upper",
"(",
... | [
339,
4
] | [
343,
63
] | python | en | ['en', 'en', 'en'] | True |
PreparedRequest.prepare_url | (self, url, params) | Prepares the given HTTP URL. | Prepares the given HTTP URL. | def prepare_url(self, url, params):
"""Prepares the given HTTP URL."""
#: Accept objects that have string representations.
#: We're unable to blindly call unicode/str functions
#: as this will include the bytestring indicator (b'')
#: on python 3.x.
#: https://github.com/... | [
"def",
"prepare_url",
"(",
"self",
",",
"url",
",",
"params",
")",
":",
"#: Accept objects that have string representations.",
"#: We're unable to blindly call unicode/str functions",
"#: as this will include the bytestring indicator (b'')",
"#: on python 3.x.",
"#: https://github.com/ps... | [
355,
4
] | [
439,
22
] | python | en | ['en', 'en', 'en'] | True |
PreparedRequest.prepare_headers | (self, headers) | Prepares the given HTTP headers. | Prepares the given HTTP headers. | def prepare_headers(self, headers):
"""Prepares the given HTTP headers."""
self.headers = CaseInsensitiveDict()
if headers:
for header in headers.items():
# Raise exception on invalid header value.
check_header_validity(header)
name, v... | [
"def",
"prepare_headers",
"(",
"self",
",",
"headers",
")",
":",
"self",
".",
"headers",
"=",
"CaseInsensitiveDict",
"(",
")",
"if",
"headers",
":",
"for",
"header",
"in",
"headers",
".",
"items",
"(",
")",
":",
"# Raise exception on invalid header value.",
"c... | [
441,
4
] | [
450,
60
] | python | en | ['en', 'en', 'en'] | True |
PreparedRequest.prepare_body | (self, data, files, json=None) | Prepares the given HTTP body data. | Prepares the given HTTP body data. | def prepare_body(self, data, files, json=None):
"""Prepares the given HTTP body data."""
# Check if file, fo, generator, iterator.
# If not, run through normal process.
# Nottin' on you.
body = None
content_type = None
if not data and json is not None:
... | [
"def",
"prepare_body",
"(",
"self",
",",
"data",
",",
"files",
",",
"json",
"=",
"None",
")",
":",
"# Check if file, fo, generator, iterator.",
"# If not, run through normal process.",
"# Nottin' on you.",
"body",
"=",
"None",
"content_type",
"=",
"None",
"if",
"not",... | [
452,
4
] | [
519,
24
] | python | en | ['en', 'en', 'en'] | True |
PreparedRequest.prepare_content_length | (self, body) | Prepare Content-Length header based on request method and body | Prepare Content-Length header based on request method and body | def prepare_content_length(self, body):
"""Prepare Content-Length header based on request method and body"""
if body is not None:
length = super_len(body)
if length:
# If length exists, set it. Otherwise, we fallback
# to Transfer-Encoding: chunked... | [
"def",
"prepare_content_length",
"(",
"self",
",",
"body",
")",
":",
"if",
"body",
"is",
"not",
"None",
":",
"length",
"=",
"super_len",
"(",
"body",
")",
"if",
"length",
":",
"# If length exists, set it. Otherwise, we fallback",
"# to Transfer-Encoding: chunked.",
... | [
521,
4
] | [
532,
48
] | python | en | ['en', 'en', 'en'] | True |
PreparedRequest.prepare_auth | (self, auth, url='') | Prepares the given HTTP auth data. | Prepares the given HTTP auth data. | def prepare_auth(self, auth, url=''):
"""Prepares the given HTTP auth data."""
# If no Auth is explicitly provided, extract it from the URL first.
if auth is None:
url_auth = get_auth_from_url(self.url)
auth = url_auth if any(url_auth) else None
if auth:
... | [
"def",
"prepare_auth",
"(",
"self",
",",
"auth",
",",
"url",
"=",
"''",
")",
":",
"# If no Auth is explicitly provided, extract it from the URL first.",
"if",
"auth",
"is",
"None",
":",
"url_auth",
"=",
"get_auth_from_url",
"(",
"self",
".",
"url",
")",
"auth",
... | [
534,
4
] | [
554,
50
] | python | en | ['en', 'en', 'en'] | True |
PreparedRequest.prepare_cookies | (self, cookies) | Prepares the given HTTP cookie data.
This function eventually generates a ``Cookie`` header from the
given cookies using cookielib. Due to cookielib's design, the header
will not be regenerated if it already exists, meaning this function
can only be called once for the life of the
... | Prepares the given HTTP cookie data. | def prepare_cookies(self, cookies):
"""Prepares the given HTTP cookie data.
This function eventually generates a ``Cookie`` header from the
given cookies using cookielib. Due to cookielib's design, the header
will not be regenerated if it already exists, meaning this function
ca... | [
"def",
"prepare_cookies",
"(",
"self",
",",
"cookies",
")",
":",
"if",
"isinstance",
"(",
"cookies",
",",
"cookielib",
".",
"CookieJar",
")",
":",
"self",
".",
"_cookies",
"=",
"cookies",
"else",
":",
"self",
".",
"_cookies",
"=",
"cookiejar_from_dict",
"(... | [
556,
4
] | [
574,
50
] | python | en | ['en', 'en', 'en'] | True |
PreparedRequest.prepare_hooks | (self, hooks) | Prepares the given hooks. | Prepares the given hooks. | def prepare_hooks(self, hooks):
"""Prepares the given hooks."""
# hooks can be passed as None to the prepare method and to this
# method. To prevent iterating over None, simply use an empty list
# if hooks is False-y
hooks = hooks or []
for event in hooks:
sel... | [
"def",
"prepare_hooks",
"(",
"self",
",",
"hooks",
")",
":",
"# hooks can be passed as None to the prepare method and to this",
"# method. To prevent iterating over None, simply use an empty list",
"# if hooks is False-y",
"hooks",
"=",
"hooks",
"or",
"[",
"]",
"for",
"event",
... | [
576,
4
] | [
583,
51
] | python | en | ['en', 'en', 'en'] | True |
Response.__bool__ | (self) | Returns True if :attr:`status_code` is less than 400.
This attribute checks if the status code of the response is between
400 and 600 to see if there was a client error or a server error. If
the status code, is between 200 and 400, this will return True. This
is **not** a check to see i... | Returns True if :attr:`status_code` is less than 400. | def __bool__(self):
"""Returns True if :attr:`status_code` is less than 400.
This attribute checks if the status code of the response is between
400 and 600 to see if there was a client error or a server error. If
the status code, is between 200 and 400, this will return True. This
... | [
"def",
"__bool__",
"(",
"self",
")",
":",
"return",
"self",
".",
"ok"
] | [
668,
4
] | [
676,
22
] | python | en | ['en', 'en', 'en'] | True |
Response.__nonzero__ | (self) | Returns True if :attr:`status_code` is less than 400.
This attribute checks if the status code of the response is between
400 and 600 to see if there was a client error or a server error. If
the status code, is between 200 and 400, this will return True. This
is **not** a check to see i... | Returns True if :attr:`status_code` is less than 400. | def __nonzero__(self):
"""Returns True if :attr:`status_code` is less than 400.
This attribute checks if the status code of the response is between
400 and 600 to see if there was a client error or a server error. If
the status code, is between 200 and 400, this will return True. This
... | [
"def",
"__nonzero__",
"(",
"self",
")",
":",
"return",
"self",
".",
"ok"
] | [
678,
4
] | [
686,
22
] | python | en | ['en', 'en', 'en'] | True |
Response.__iter__ | (self) | Allows you to use a response as an iterator. | Allows you to use a response as an iterator. | def __iter__(self):
"""Allows you to use a response as an iterator."""
return self.iter_content(128) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"self",
".",
"iter_content",
"(",
"128",
")"
] | [
688,
4
] | [
690,
37
] | python | en | ['en', 'en', 'en'] | True |
Response.ok | (self) | Returns True if :attr:`status_code` is less than 400, False if not.
This attribute checks if the status code of the response is between
400 and 600 to see if there was a client error or a server error. If
the status code is between 200 and 400, this will return True. This
is **not** a c... | Returns True if :attr:`status_code` is less than 400, False if not. | def ok(self):
"""Returns True if :attr:`status_code` is less than 400, False if not.
This attribute checks if the status code of the response is between
400 and 600 to see if there was a client error or a server error. If
the status code is between 200 and 400, this will return True. Th... | [
"def",
"ok",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"raise_for_status",
"(",
")",
"except",
"HTTPError",
":",
"return",
"False",
"return",
"True"
] | [
693,
4
] | [
705,
19
] | python | en | ['en', 'en', 'en'] | True |
Response.is_redirect | (self) | True if this Response is a well-formed HTTP redirect that could have
been processed automatically (by :meth:`Session.resolve_redirects`).
| True if this Response is a well-formed HTTP redirect that could have
been processed automatically (by :meth:`Session.resolve_redirects`).
| def is_redirect(self):
"""True if this Response is a well-formed HTTP redirect that could have
been processed automatically (by :meth:`Session.resolve_redirects`).
"""
return ('location' in self.headers and self.status_code in REDIRECT_STATI) | [
"def",
"is_redirect",
"(",
"self",
")",
":",
"return",
"(",
"'location'",
"in",
"self",
".",
"headers",
"and",
"self",
".",
"status_code",
"in",
"REDIRECT_STATI",
")"
] | [
708,
4
] | [
712,
82
] | python | en | ['en', 'en', 'en'] | True |
Response.is_permanent_redirect | (self) | True if this Response one of the permanent versions of redirect. | True if this Response one of the permanent versions of redirect. | def is_permanent_redirect(self):
"""True if this Response one of the permanent versions of redirect."""
return ('location' in self.headers and self.status_code in (codes.moved_permanently, codes.permanent_redirect)) | [
"def",
"is_permanent_redirect",
"(",
"self",
")",
":",
"return",
"(",
"'location'",
"in",
"self",
".",
"headers",
"and",
"self",
".",
"status_code",
"in",
"(",
"codes",
".",
"moved_permanently",
",",
"codes",
".",
"permanent_redirect",
")",
")"
] | [
715,
4
] | [
717,
119
] | python | en | ['en', 'en', 'en'] | True |
Response.next | (self) | Returns a PreparedRequest for the next request in a redirect chain, if there is one. | Returns a PreparedRequest for the next request in a redirect chain, if there is one. | def next(self):
"""Returns a PreparedRequest for the next request in a redirect chain, if there is one."""
return self._next | [
"def",
"next",
"(",
"self",
")",
":",
"return",
"self",
".",
"_next"
] | [
720,
4
] | [
722,
25
] | python | en | ['en', 'en', 'en'] | True |
Response.apparent_encoding | (self) | The apparent encoding, provided by the chardet library. | The apparent encoding, provided by the chardet library. | def apparent_encoding(self):
"""The apparent encoding, provided by the chardet library."""
return chardet.detect(self.content)['encoding'] | [
"def",
"apparent_encoding",
"(",
"self",
")",
":",
"return",
"chardet",
".",
"detect",
"(",
"self",
".",
"content",
")",
"[",
"'encoding'",
"]"
] | [
725,
4
] | [
727,
55
] | python | en | ['en', 'en', 'en'] | True |
Response.iter_content | (self, chunk_size=1, decode_unicode=False) | Iterates over the response data. When stream=True is set on the
request, this avoids reading the content at once into memory for
large responses. The chunk size is the number of bytes it should
read into memory. This is not necessarily the length of each item
returned as decoding can ... | Iterates over the response data. When stream=True is set on the
request, this avoids reading the content at once into memory for
large responses. The chunk size is the number of bytes it should
read into memory. This is not necessarily the length of each item
returned as decoding can ... | def iter_content(self, chunk_size=1, decode_unicode=False):
"""Iterates over the response data. When stream=True is set on the
request, this avoids reading the content at once into memory for
large responses. The chunk size is the number of bytes it should
read into memory. This is no... | [
"def",
"iter_content",
"(",
"self",
",",
"chunk_size",
"=",
"1",
",",
"decode_unicode",
"=",
"False",
")",
":",
"def",
"generate",
"(",
")",
":",
"# Special case for urllib3.",
"if",
"hasattr",
"(",
"self",
".",
"raw",
",",
"'stream'",
")",
":",
"try",
"... | [
729,
4
] | [
782,
21
] | python | en | ['en', 'en', 'en'] | True |
Response.iter_lines | (self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=False, delimiter=None) | Iterates over the response data, one line at a time. When
stream=True is set on the request, this avoids reading the
content at once into memory for large responses.
.. note:: This method is not reentrant safe.
| Iterates over the response data, one line at a time. When
stream=True is set on the request, this avoids reading the
content at once into memory for large responses. | def iter_lines(self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=False, delimiter=None):
"""Iterates over the response data, one line at a time. When
stream=True is set on the request, this avoids reading the
content at once into memory for large responses.
.. note:: This method is not ... | [
"def",
"iter_lines",
"(",
"self",
",",
"chunk_size",
"=",
"ITER_CHUNK_SIZE",
",",
"decode_unicode",
"=",
"False",
",",
"delimiter",
"=",
"None",
")",
":",
"pending",
"=",
"None",
"for",
"chunk",
"in",
"self",
".",
"iter_content",
"(",
"chunk_size",
"=",
"c... | [
784,
4
] | [
813,
25
] | python | en | ['en', 'en', 'en'] | True |
Response.content | (self) | Content of the response, in bytes. | Content of the response, in bytes. | def content(self):
"""Content of the response, in bytes."""
if self._content is False:
# Read the contents.
if self._content_consumed:
raise RuntimeError(
'The content for this response was already consumed')
if self.status_code =... | [
"def",
"content",
"(",
"self",
")",
":",
"if",
"self",
".",
"_content",
"is",
"False",
":",
"# Read the contents.",
"if",
"self",
".",
"_content_consumed",
":",
"raise",
"RuntimeError",
"(",
"'The content for this response was already consumed'",
")",
"if",
"self",
... | [
816,
4
] | [
833,
28
] | python | en | ['en', 'en', 'en'] | True |
Response.text | (self) | Content of the response, in unicode.
If Response.encoding is None, encoding will be guessed using
``chardet``.
The encoding of the response content is determined based solely on HTTP
headers, following RFC 2616 to the letter. If you can take advantage of
non-HTTP knowledge to m... | Content of the response, in unicode. | def text(self):
"""Content of the response, in unicode.
If Response.encoding is None, encoding will be guessed using
``chardet``.
The encoding of the response content is determined based solely on HTTP
headers, following RFC 2616 to the letter. If you can take advantage of
... | [
"def",
"text",
"(",
"self",
")",
":",
"# Try charset from content-type",
"content",
"=",
"None",
"encoding",
"=",
"self",
".",
"encoding",
"if",
"not",
"self",
".",
"content",
":",
"return",
"str",
"(",
"''",
")",
"# Fallback to auto-detected encoding.",
"if",
... | [
836,
4
] | [
871,
22
] | python | en | ['en', 'en', 'en'] | True |
Response.json | (self, **kwargs) | r"""Returns the json-encoded content of a response, if any.
:param \*\*kwargs: Optional arguments that ``json.loads`` takes.
:raises ValueError: If the response body does not contain valid json.
| r"""Returns the json-encoded content of a response, if any. | def json(self, **kwargs):
r"""Returns the json-encoded content of a response, if any.
:param \*\*kwargs: Optional arguments that ``json.loads`` takes.
:raises ValueError: If the response body does not contain valid json.
"""
if not self.encoding and self.content and len(self.co... | [
"def",
"json",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"encoding",
"and",
"self",
".",
"content",
"and",
"len",
"(",
"self",
".",
"content",
")",
">",
"3",
":",
"# No encoding set. JSON RFC 4627 section 3 states we should ex... | [
873,
4
] | [
897,
53
] | python | en | ['en', 'en', 'en'] | True |
Response.links | (self) | Returns the parsed header links of the response, if any. | Returns the parsed header links of the response, if any. | def links(self):
"""Returns the parsed header links of the response, if any."""
header = self.headers.get('link')
# l = MultiDict()
l = {}
if header:
links = parse_header_links(header)
for link in links:
key = link.get('rel') or link.ge... | [
"def",
"links",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"headers",
".",
"get",
"(",
"'link'",
")",
"# l = MultiDict()",
"l",
"=",
"{",
"}",
"if",
"header",
":",
"links",
"=",
"parse_header_links",
"(",
"header",
")",
"for",
"link",
"in",
"... | [
900,
4
] | [
915,
16
] | python | en | ['en', 'en', 'en'] | True |
Response.raise_for_status | (self) | Raises :class:`HTTPError`, if one occurred. | Raises :class:`HTTPError`, if one occurred. | def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ''
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8... | [
"def",
"raise_for_status",
"(",
"self",
")",
":",
"http_error_msg",
"=",
"''",
"if",
"isinstance",
"(",
"self",
".",
"reason",
",",
"bytes",
")",
":",
"# We attempt to decode utf-8 first because some servers",
"# choose to localize their reason strings. If the string",
"# i... | [
917,
4
] | [
940,
58
] | python | en | ['en', 'en', 'en'] | True |
Response.close | (self) | Releases the connection back to the pool. Once this method has been
called the underlying ``raw`` object must not be accessed again.
*Note: Should not normally need to be called explicitly.*
| Releases the connection back to the pool. Once this method has been
called the underlying ``raw`` object must not be accessed again. | def close(self):
"""Releases the connection back to the pool. Once this method has been
called the underlying ``raw`` object must not be accessed again.
*Note: Should not normally need to be called explicitly.*
"""
if not self._content_consumed:
self.raw.close()
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_content_consumed",
":",
"self",
".",
"raw",
".",
"close",
"(",
")",
"release_conn",
"=",
"getattr",
"(",
"self",
".",
"raw",
",",
"'release_conn'",
",",
"None",
")",
"if",
"release_conn... | [
942,
4
] | [
953,
26
] | python | en | ['en', 'en', 'en'] | True |
MissedMessageNotificationsTest.test_stream_watchers | (self) |
We used to have a bug with stream_watchers, where we set their flags to
None.
|
We used to have a bug with stream_watchers, where we set their flags to
None.
| def test_stream_watchers(self) -> None:
"""
We used to have a bug with stream_watchers, where we set their flags to
None.
"""
cordelia = self.example_user("cordelia")
hamlet = self.example_user("hamlet")
realm = hamlet.realm
stream_name = "Denmark"
... | [
"def",
"test_stream_watchers",
"(",
"self",
")",
"->",
"None",
":",
"cordelia",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"realm",
"=",
"hamlet",
".",
"realm",
"stream_name... | [
293,
4
] | [
330,
9
] | python | en | ['en', 'error', 'th'] | False |
MissedMessageNotificationsTest.test_end_to_end_missedmessage_hook | (self) | Tests what arguments missedmessage_hook passes into maybe_enqueue_notifications.
Combined with the previous test, this ensures that the missedmessage_hook is correct | Tests what arguments missedmessage_hook passes into maybe_enqueue_notifications.
Combined with the previous test, this ensures that the missedmessage_hook is correct | def test_end_to_end_missedmessage_hook(self) -> None:
"""Tests what arguments missedmessage_hook passes into maybe_enqueue_notifications.
Combined with the previous test, this ensures that the missedmessage_hook is correct"""
user_profile = self.example_user("hamlet")
user_profile.enabl... | [
"def",
"test_end_to_end_missedmessage_hook",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"user_profile",
".",
"enable_online_push_notifications",
"=",
"False",
"user_profile",
".",
"save",
"(",
")",
... | [
332,
4
] | [
774,
9
] | python | en | ['en', 'en', 'en'] | True |
EventQueueTest.test_event_collapsing | (self) |
The update_message_flags events are special, because
they can be collapsed together. Given two umfe's, we:
* use the latest timestamp
* concatenate the messages
|
The update_message_flags events are special, because
they can be collapsed together. Given two umfe's, we:
* use the latest timestamp
* concatenate the messages
| def test_event_collapsing(self) -> None:
client = self.get_client_descriptor()
queue = client.event_queue
"""
The update_message_flags events are special, because
they can be collapsed together. Given two umfe's, we:
* use the latest timestamp
* concaten... | [
"def",
"test_event_collapsing",
"(",
"self",
")",
"->",
"None",
":",
"client",
"=",
"self",
".",
"get_client_descriptor",
"(",
")",
"queue",
"=",
"client",
".",
"event_queue",
"def",
"umfe",
"(",
"timestamp",
":",
"int",
",",
"messages",
":",
"List",
"[",
... | [
888,
4
] | [
974,
9
] | python | en | ['en', 'error', 'th'] | False |
EventQueueTest.test_collapse_event | (self) |
This mostly focues on the internals of
how we store "virtual_events" that we
can collapse if subsequent events are
of the same form. See the code in
EventQueue.push for more context.
|
This mostly focues on the internals of
how we store "virtual_events" that we
can collapse if subsequent events are
of the same form. See the code in
EventQueue.push for more context.
| def test_collapse_event(self) -> None:
"""
This mostly focues on the internals of
how we store "virtual_events" that we
can collapse if subsequent events are
of the same form. See the code in
EventQueue.push for more context.
"""
client = self.get_client_... | [
"def",
"test_collapse_event",
"(",
"self",
")",
"->",
"None",
":",
"client",
"=",
"self",
".",
"get_client_descriptor",
"(",
")",
"queue",
"=",
"client",
".",
"event_queue",
"queue",
".",
"push",
"(",
"{",
"\"type\"",
":",
"\"restart\"",
",",
"\"server_gener... | [
1058,
4
] | [
1100,
46
] | python | en | ['en', 'error', 'th'] | False |
Collector.add | (self, objs, source=None, nullable=False, reverse_dependency=False) |
Add 'objs' to the collection of objects to be deleted. If the call is
the result of a cascade, 'source' should be the model that caused it,
and 'nullable' should be set to True if the relation can be null.
Return a list of all objects that were not already collected.
|
Add 'objs' to the collection of objects to be deleted. If the call is
the result of a cascade, 'source' should be the model that caused it,
and 'nullable' should be set to True if the relation can be null. | def add(self, objs, source=None, nullable=False, reverse_dependency=False):
"""
Add 'objs' to the collection of objects to be deleted. If the call is
the result of a cascade, 'source' should be the model that caused it,
and 'nullable' should be set to True if the relation can be null.
... | [
"def",
"add",
"(",
"self",
",",
"objs",
",",
"source",
"=",
"None",
",",
"nullable",
"=",
"False",
",",
"reverse_dependency",
"=",
"False",
")",
":",
"if",
"not",
"objs",
":",
"return",
"[",
"]",
"new_objs",
"=",
"[",
"]",
"model",
"=",
"objs",
"["... | [
80,
4
] | [
105,
23
] | python | en | ['en', 'error', 'th'] | False |
Collector.add_field_update | (self, field, value, objs) |
Schedule a field update. 'objs' must be a homogeneous iterable
collection of model instances (e.g. a QuerySet).
|
Schedule a field update. 'objs' must be a homogeneous iterable
collection of model instances (e.g. a QuerySet).
| def add_field_update(self, field, value, objs):
"""
Schedule a field update. 'objs' must be a homogeneous iterable
collection of model instances (e.g. a QuerySet).
"""
if not objs:
return
model = objs[0].__class__
self.field_updates.setdefault(
... | [
"def",
"add_field_update",
"(",
"self",
",",
"field",
",",
"value",
",",
"objs",
")",
":",
"if",
"not",
"objs",
":",
"return",
"model",
"=",
"objs",
"[",
"0",
"]",
".",
"__class__",
"self",
".",
"field_updates",
".",
"setdefault",
"(",
"model",
",",
... | [
107,
4
] | [
117,
47
] | python | en | ['en', 'error', 'th'] | False |
Collector.can_fast_delete | (self, objs, from_field=None) |
Determine if the objects in the given queryset-like or single object
can be fast-deleted. This can be done if there are no cascades, no
parents and no signal listeners for the object class.
The 'from_field' tells where we are coming from - we need this to
determine if the objec... |
Determine if the objects in the given queryset-like or single object
can be fast-deleted. This can be done if there are no cascades, no
parents and no signal listeners for the object class. | def can_fast_delete(self, objs, from_field=None):
"""
Determine if the objects in the given queryset-like or single object
can be fast-deleted. This can be done if there are no cascades, no
parents and no signal listeners for the object class.
The 'from_field' tells where we are... | [
"def",
"can_fast_delete",
"(",
"self",
",",
"objs",
",",
"from_field",
"=",
"None",
")",
":",
"if",
"from_field",
"and",
"from_field",
".",
"remote_field",
".",
"on_delete",
"is",
"not",
"CASCADE",
":",
"return",
"False",
"if",
"hasattr",
"(",
"objs",
",",... | [
125,
4
] | [
159,
9
] | python | en | ['en', 'error', 'th'] | False |
Collector.get_del_batches | (self, objs, field) |
Return the objs in suitably sized batches for the used connection.
|
Return the objs in suitably sized batches for the used connection.
| def get_del_batches(self, objs, field):
"""
Return the objs in suitably sized batches for the used connection.
"""
conn_batch_size = max(
connections[self.using].ops.bulk_batch_size([field.name], objs), 1)
if len(objs) > conn_batch_size:
return [objs[i:i +... | [
"def",
"get_del_batches",
"(",
"self",
",",
"objs",
",",
"field",
")",
":",
"conn_batch_size",
"=",
"max",
"(",
"connections",
"[",
"self",
".",
"using",
"]",
".",
"ops",
".",
"bulk_batch_size",
"(",
"[",
"field",
".",
"name",
"]",
",",
"objs",
")",
... | [
161,
4
] | [
171,
25
] | python | en | ['en', 'error', 'th'] | False |
Collector.collect | (self, objs, source=None, nullable=False, collect_related=True,
source_attr=None, reverse_dependency=False, keep_parents=False) |
Add 'objs' to the collection of objects to be deleted as well as all
parent instances. 'objs' must be a homogeneous iterable collection of
model instances (e.g. a QuerySet). If 'collect_related' is True,
related objects will be handled by their respective on_delete handler.
I... |
Add 'objs' to the collection of objects to be deleted as well as all
parent instances. 'objs' must be a homogeneous iterable collection of
model instances (e.g. a QuerySet). If 'collect_related' is True,
related objects will be handled by their respective on_delete handler. | def collect(self, objs, source=None, nullable=False, collect_related=True,
source_attr=None, reverse_dependency=False, keep_parents=False):
"""
Add 'objs' to the collection of objects to be deleted as well as all
parent instances. 'objs' must be a homogeneous iterable collection... | [
"def",
"collect",
"(",
"self",
",",
"objs",
",",
"source",
"=",
"None",
",",
"nullable",
"=",
"False",
",",
"collect_related",
"=",
"True",
",",
"source_attr",
"=",
"None",
",",
"reverse_dependency",
"=",
"False",
",",
"keep_parents",
"=",
"False",
")",
... | [
173,
4
] | [
249,
71
] | python | en | ['en', 'error', 'th'] | False |
Collector.related_objects | (self, related, objs) |
Get a QuerySet of objects related to `objs` via the relation `related`.
|
Get a QuerySet of objects related to `objs` via the relation `related`.
| def related_objects(self, related, objs):
"""
Get a QuerySet of objects related to `objs` via the relation `related`.
"""
return related.related_model._base_manager.using(self.using).filter(
**{"%s__in" % related.field.name: objs}
) | [
"def",
"related_objects",
"(",
"self",
",",
"related",
",",
"objs",
")",
":",
"return",
"related",
".",
"related_model",
".",
"_base_manager",
".",
"using",
"(",
"self",
".",
"using",
")",
".",
"filter",
"(",
"*",
"*",
"{",
"\"%s__in\"",
"%",
"related",
... | [
251,
4
] | [
257,
9
] | python | en | ['en', 'error', 'th'] | False |
NativePythonExecutor.__init__ | (self, neuropod_path) |
Load a python neuropod
:param neuropod_path: The path to a python neuropod package
|
Load a python neuropod | def __init__(self, neuropod_path):
"""
Load a python neuropod
:param neuropod_path: The path to a python neuropod package
"""
self.neuropod_path = neuropod_path
# Load the model config
data_path = os.path.join(neuropod_path, "0", "data")
with open(os.p... | [
"def",
"__init__",
"(",
"self",
",",
"neuropod_path",
")",
":",
"self",
".",
"neuropod_path",
"=",
"neuropod_path",
"# Load the model config",
"data_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"neuropod_path",
",",
"\"0\"",
",",
"\"data\"",
")",
"with",
... | [
61,
4
] | [
145,
79
] | python | en | ['en', 'error', 'th'] | False |
NativePythonExecutor.forward | (self, inputs) |
Run inference using the specifed inputs.
:param inputs: A dict mapping input names to values. This must match the input
spec in the neuropod config for the loaded model.
Ex: {'x1': np.array([5]), 'x2': np.array([6])}
... |
Run inference using the specifed inputs. | def forward(self, inputs):
"""
Run inference using the specifed inputs.
:param inputs: A dict mapping input names to values. This must match the input
spec in the neuropod config for the loaded model.
Ex: {'x1': np.array([5]), 'x2': n... | [
"def",
"forward",
"(",
"self",
",",
"inputs",
")",
":",
"# Convert unicode to string",
"for",
"k",
",",
"v",
"in",
"inputs",
".",
"items",
"(",
")",
":",
"if",
"v",
".",
"dtype",
".",
"type",
"==",
"np",
".",
"unicode_",
":",
"inputs",
"[",
"k",
"]... | [
147,
4
] | [
181,
18
] | python | en | ['en', 'error', 'th'] | False |
get_safe_phrase | (phrase: str) |
Safe phrase is in lower case and doesn't contain characters which can
conflict with split boundaries. All conflicting characters are replaced
with low dash (_).
|
Safe phrase is in lower case and doesn't contain characters which can
conflict with split boundaries. All conflicting characters are replaced
with low dash (_).
| def get_safe_phrase(phrase: str) -> str:
"""
Safe phrase is in lower case and doesn't contain characters which can
conflict with split boundaries. All conflicting characters are replaced
with low dash (_).
"""
phrase = SPLIT_BOUNDARY_REGEX.sub("_", phrase)
return phrase.lower() | [
"def",
"get_safe_phrase",
"(",
"phrase",
":",
"str",
")",
"->",
"str",
":",
"phrase",
"=",
"SPLIT_BOUNDARY_REGEX",
".",
"sub",
"(",
"\"_\"",
",",
"phrase",
")",
"return",
"phrase",
".",
"lower",
"(",
")"
] | [
191,
0
] | [
198,
25
] | python | en | ['en', 'error', 'th'] | False |
replace_with_safe_phrase | (matchobj: Match[str]) |
The idea is to convert IGNORED_PHRASES into safe phrases, see
`get_safe_phrase()` function. The only exception is when the
IGNORED_PHRASE is at the start of the text or after a split
boundary; in this case, we change the first letter of the phrase
to upper case.
|
The idea is to convert IGNORED_PHRASES into safe phrases, see
`get_safe_phrase()` function. The only exception is when the
IGNORED_PHRASE is at the start of the text or after a split
boundary; in this case, we change the first letter of the phrase
to upper case.
| def replace_with_safe_phrase(matchobj: Match[str]) -> str:
"""
The idea is to convert IGNORED_PHRASES into safe phrases, see
`get_safe_phrase()` function. The only exception is when the
IGNORED_PHRASE is at the start of the text or after a split
boundary; in this case, we change the first letter of ... | [
"def",
"replace_with_safe_phrase",
"(",
"matchobj",
":",
"Match",
"[",
"str",
"]",
")",
"->",
"str",
":",
"ignored_phrase",
"=",
"matchobj",
".",
"group",
"(",
"0",
")",
"safe_string",
"=",
"get_safe_phrase",
"(",
"ignored_phrase",
")",
"start_index",
"=",
"... | [
201,
0
] | [
223,
22
] | python | en | ['en', 'error', 'th'] | False |
get_safe_text | (text: str) |
This returns text which is rendered by BeautifulSoup and is in the
form that can be split easily and has all IGNORED_PHRASES processed.
|
This returns text which is rendered by BeautifulSoup and is in the
form that can be split easily and has all IGNORED_PHRASES processed.
| def get_safe_text(text: str) -> str:
"""
This returns text which is rendered by BeautifulSoup and is in the
form that can be split easily and has all IGNORED_PHRASES processed.
"""
soup = BeautifulSoup(text, "lxml")
text = " ".join(soup.text.split()) # Remove extra whitespaces.
for phrase_r... | [
"def",
"get_safe_text",
"(",
"text",
":",
"str",
")",
"->",
"str",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"text",
",",
"\"lxml\"",
")",
"text",
"=",
"\" \"",
".",
"join",
"(",
"soup",
".",
"text",
".",
"split",
"(",
")",
")",
"# Remove extra whitespac... | [
226,
0
] | [
236,
15
] | python | en | ['en', 'error', 'th'] | False |
Ticket17477RegressionTests.test_ticket_17477 | (self) | manage.py help test' works after r16352. | manage.py help test' works after r16352. | def test_ticket_17477(self):
"""'manage.py help test' works after r16352."""
args = ['help', 'test']
out, err = self.run_manage(args)
self.assertNoOutput(err) | [
"def",
"test_ticket_17477",
"(",
"self",
")",
":",
"args",
"=",
"[",
"'help'",
",",
"'test'",
"]",
"out",
",",
"err",
"=",
"self",
".",
"run_manage",
"(",
"args",
")",
"self",
".",
"assertNoOutput",
"(",
"err",
")"
] | [
216,
4
] | [
220,
32
] | python | en | ['en', 'en', 'en'] | True |
Sqlite3InMemoryTestDbs.test_transaction_support | (self) | Ticket #16329: sqlite3 in-memory test databases | Ticket #16329: sqlite3 in-memory test databases | def test_transaction_support(self):
"""Ticket #16329: sqlite3 in-memory test databases"""
old_db_connections = db.connections
for option_key, option_value in (
('NAME', ':memory:'), ('TEST', {'NAME': ':memory:'})):
try:
db.connections = db.ConnectionHa... | [
"def",
"test_transaction_support",
"(",
"self",
")",
":",
"old_db_connections",
"=",
"db",
".",
"connections",
"for",
"option_key",
",",
"option_value",
"in",
"(",
"(",
"'NAME'",
",",
"':memory:'",
")",
",",
"(",
"'TEST'",
",",
"{",
"'NAME'",
":",
"':memory:... | [
232,
4
] | [
256,
51
] | python | en | ['en', 'en', 'it'] | True |
DummyBackendTest.test_setup_databases | (self) |
Test that setup_databases() doesn't fail with dummy database backend.
|
Test that setup_databases() doesn't fail with dummy database backend.
| def test_setup_databases(self):
"""
Test that setup_databases() doesn't fail with dummy database backend.
"""
runner_instance = runner.DiscoverRunner(verbosity=0)
old_db_connections = db.connections
try:
db.connections = db.ConnectionHandler({})
ol... | [
"def",
"test_setup_databases",
"(",
"self",
")",
":",
"runner_instance",
"=",
"runner",
".",
"DiscoverRunner",
"(",
"verbosity",
"=",
"0",
")",
"old_db_connections",
"=",
"db",
".",
"connections",
"try",
":",
"db",
".",
"connections",
"=",
"db",
".",
"Connec... | [
260,
4
] | [
274,
47
] | python | en | ['en', 'error', 'th'] | False |
AliasedDefaultTestSetupTest.test_setup_aliased_default_database | (self) |
Test that setup_datebases() doesn't fail when 'default' is aliased
|
Test that setup_datebases() doesn't fail when 'default' is aliased
| def test_setup_aliased_default_database(self):
"""
Test that setup_datebases() doesn't fail when 'default' is aliased
"""
runner_instance = runner.DiscoverRunner(verbosity=0)
old_db_connections = db.connections
try:
db.connections = db.ConnectionHandler({
... | [
"def",
"test_setup_aliased_default_database",
"(",
"self",
")",
":",
"runner_instance",
"=",
"runner",
".",
"DiscoverRunner",
"(",
"verbosity",
"=",
"0",
")",
"old_db_connections",
"=",
"db",
".",
"connections",
"try",
":",
"db",
".",
"connections",
"=",
"db",
... | [
278,
4
] | [
299,
47
] | python | en | ['en', 'error', 'th'] | False |
Command.sync_apps | (self, connection, app_labels) | Runs the old syncdb-style operation on a list of app_labels. | Runs the old syncdb-style operation on a list of app_labels. | def sync_apps(self, connection, app_labels):
"Runs the old syncdb-style operation on a list of app_labels."
cursor = connection.cursor()
try:
# Get a list of already installed *models* so that references work right.
tables = connection.introspection.table_names(cursor)
... | [
"def",
"sync_apps",
"(",
"self",
",",
"connection",
",",
"app_labels",
")",
":",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"try",
":",
"# Get a list of already installed *models* so that references work right.",
"tables",
"=",
"connection",
".",
"introspec... | [
217,
4
] | [
357,
29
] | python | en | ['en', 'en', 'en'] | True |
Command.show_migration_list | (self, connection, app_names=None) |
Shows a list of all migrations on the system, or only those of
some named apps.
|
Shows a list of all migrations on the system, or only those of
some named apps.
| def show_migration_list(self, connection, app_names=None):
"""
Shows a list of all migrations on the system, or only those of
some named apps.
"""
# Load migrations from disk/DB
loader = MigrationLoader(connection)
graph = loader.graph
# If we were passed ... | [
"def",
"show_migration_list",
"(",
"self",
",",
"connection",
",",
"app_names",
"=",
"None",
")",
":",
"# Load migrations from disk/DB",
"loader",
"=",
"MigrationLoader",
"(",
"connection",
")",
"graph",
"=",
"loader",
".",
"graph",
"# If we were passed a list of apps... | [
359,
4
] | [
398,
81
] | python | en | ['en', 'error', 'th'] | False |
dump_file | (filename, head=None) | Dumps a file content into log.info.
If head is not None, will be dumped before the file content.
| Dumps a file content into log.info. | def dump_file(filename, head=None):
"""Dumps a file content into log.info.
If head is not None, will be dumped before the file content.
"""
if head is None:
log.info('%s', filename)
else:
log.info(head)
file = open(filename)
try:
log.info(file.read())
finally:
... | [
"def",
"dump_file",
"(",
"filename",
",",
"head",
"=",
"None",
")",
":",
"if",
"head",
"is",
"None",
":",
"log",
".",
"info",
"(",
"'%s'",
",",
"filename",
")",
"else",
":",
"log",
".",
"info",
"(",
"head",
")",
"file",
"=",
"open",
"(",
"filenam... | [
330,
0
] | [
343,
20
] | python | en | ['en', 'fr', 'en'] | True |
config._check_compiler | (self) | Check that 'self.compiler' really is a CCompiler object;
if not, make it one.
| Check that 'self.compiler' really is a CCompiler object;
if not, make it one.
| def _check_compiler(self):
"""Check that 'self.compiler' really is a CCompiler object;
if not, make it one.
"""
# We do this late, and only on-demand, because this is an expensive
# import.
from distutils.ccompiler import CCompiler, new_compiler
if not isinstance(... | [
"def",
"_check_compiler",
"(",
"self",
")",
":",
"# We do this late, and only on-demand, because this is an expensive",
"# import.",
"from",
"distutils",
".",
"ccompiler",
"import",
"CCompiler",
",",
"new_compiler",
"if",
"not",
"isinstance",
"(",
"self",
".",
"compiler",... | [
88,
4
] | [
104,
65
] | python | en | ['en', 'en', 'en'] | True |
config.try_cpp | (self, body=None, headers=None, include_dirs=None, lang="c") | Construct a source file from 'body' (a string containing lines
of C/C++ code) and 'headers' (a list of header files to include)
and run it through the preprocessor. Return true if the
preprocessor succeeded, false if there were any errors.
('body' probably isn't of much use, but what th... | Construct a source file from 'body' (a string containing lines
of C/C++ code) and 'headers' (a list of header files to include)
and run it through the preprocessor. Return true if the
preprocessor succeeded, false if there were any errors.
('body' probably isn't of much use, but what th... | def try_cpp(self, body=None, headers=None, include_dirs=None, lang="c"):
"""Construct a source file from 'body' (a string containing lines
of C/C++ code) and 'headers' (a list of header files to include)
and run it through the preprocessor. Return true if the
preprocessor succeeded, fal... | [
"def",
"try_cpp",
"(",
"self",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"lang",
"=",
"\"c\"",
")",
":",
"from",
"distutils",
".",
"ccompiler",
"import",
"CompileError",
"self",
".",
"_check_compiler",
... | [
171,
4
] | [
187,
17
] | python | en | ['en', 'en', 'en'] | True |
config.search_cpp | (self, pattern, body=None, headers=None, include_dirs=None,
lang="c") | Construct a source file (just like 'try_cpp()'), run it through
the preprocessor, and return true if any line of the output matches
'pattern'. 'pattern' should either be a compiled regex object or a
string containing a regex. If both 'body' and 'headers' are None,
preprocesses an empty... | Construct a source file (just like 'try_cpp()'), run it through
the preprocessor, and return true if any line of the output matches
'pattern'. 'pattern' should either be a compiled regex object or a
string containing a regex. If both 'body' and 'headers' are None,
preprocesses an empty... | def search_cpp(self, pattern, body=None, headers=None, include_dirs=None,
lang="c"):
"""Construct a source file (just like 'try_cpp()'), run it through
the preprocessor, and return true if any line of the output matches
'pattern'. 'pattern' should either be a compiled regex o... | [
"def",
"search_cpp",
"(",
"self",
",",
"pattern",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"lang",
"=",
"\"c\"",
")",
":",
"self",
".",
"_check_compiler",
"(",
")",
"src",
",",
"out",
"=",
"self",
... | [
189,
4
] | [
215,
20
] | python | en | ['en', 'en', 'en'] | True |
config.try_compile | (self, body, headers=None, include_dirs=None, lang="c") | Try to compile a source file built from 'body' and 'headers'.
Return true on success, false otherwise.
| Try to compile a source file built from 'body' and 'headers'.
Return true on success, false otherwise.
| def try_compile(self, body, headers=None, include_dirs=None, lang="c"):
"""Try to compile a source file built from 'body' and 'headers'.
Return true on success, false otherwise.
"""
from distutils.ccompiler import CompileError
self._check_compiler()
try:
self.... | [
"def",
"try_compile",
"(",
"self",
",",
"body",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"lang",
"=",
"\"c\"",
")",
":",
"from",
"distutils",
".",
"ccompiler",
"import",
"CompileError",
"self",
".",
"_check_compiler",
"(",
")",
... | [
217,
4
] | [
231,
17
] | python | en | ['en', 'en', 'en'] | True |
config.try_link | (self, body, headers=None, include_dirs=None, libraries=None,
library_dirs=None, lang="c") | Try to compile and link a source file, built from 'body' and
'headers', to executable form. Return true on success, false
otherwise.
| Try to compile and link a source file, built from 'body' and
'headers', to executable form. Return true on success, false
otherwise.
| def try_link(self, body, headers=None, include_dirs=None, libraries=None,
library_dirs=None, lang="c"):
"""Try to compile and link a source file, built from 'body' and
'headers', to executable form. Return true on success, false
otherwise.
"""
from distutils.cco... | [
"def",
"try_link",
"(",
"self",
",",
"body",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"lang",
"=",
"\"c\"",
")",
":",
"from",
"distutils",
".",
"ccompiler",
"im... | [
233,
4
] | [
250,
17
] | python | en | ['en', 'en', 'en'] | True |
config.try_run | (self, body, headers=None, include_dirs=None, libraries=None,
library_dirs=None, lang="c") | Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Return true on success, false
otherwise.
| Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Return true on success, false
otherwise.
| def try_run(self, body, headers=None, include_dirs=None, libraries=None,
library_dirs=None, lang="c"):
"""Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Return true on success, false
otherwise.
"""
from distutils.ccompil... | [
"def",
"try_run",
"(",
"self",
",",
"body",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"lang",
"=",
"\"c\"",
")",
":",
"from",
"distutils",
".",
"ccompiler",
"imp... | [
252,
4
] | [
270,
17
] | python | en | ['en', 'en', 'en'] | True |
config.check_func | (self, func, headers=None, include_dirs=None,
libraries=None, library_dirs=None, decl=0, call=0) | Determine if function 'func' is available by constructing a
source file that refers to 'func', and compiles and links it.
If everything succeeds, returns true; otherwise returns false.
The constructed source file starts out by including the header
files listed in 'headers'. If 'decl' i... | Determine if function 'func' is available by constructing a
source file that refers to 'func', and compiles and links it.
If everything succeeds, returns true; otherwise returns false. | def check_func(self, func, headers=None, include_dirs=None,
libraries=None, library_dirs=None, decl=0, call=0):
"""Determine if function 'func' is available by constructing a
source file that refers to 'func', and compiles and links it.
If everything succeeds, returns true; ot... | [
"def",
"check_func",
"(",
"self",
",",
"func",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"decl",
"=",
"0",
",",
"call",
"=",
"0",
")",
":",
"self",
".",
"_ch... | [
277,
4
] | [
305,
53
] | python | en | ['en', 'en', 'en'] | True |
config.check_lib | (self, library, library_dirs=None, headers=None,
include_dirs=None, other_libraries=[]) | Determine if 'library' is available to be linked against,
without actually checking that any particular symbols are provided
by it. 'headers' will be used in constructing the source file to
be compiled, but the only effect of this is to check if all the
header files listed are available... | Determine if 'library' is available to be linked against,
without actually checking that any particular symbols are provided
by it. 'headers' will be used in constructing the source file to
be compiled, but the only effect of this is to check if all the
header files listed are available... | def check_lib(self, library, library_dirs=None, headers=None,
include_dirs=None, other_libraries=[]):
"""Determine if 'library' is available to be linked against,
without actually checking that any particular symbols are provided
by it. 'headers' will be used in constructing t... | [
"def",
"check_lib",
"(",
"self",
",",
"library",
",",
"library_dirs",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"other_libraries",
"=",
"[",
"]",
")",
":",
"self",
".",
"_check_compiler",
"(",
")",
"return",
"self",... | [
307,
4
] | [
319,
71
] | python | en | ['en', 'en', 'en'] | True |
config.check_header | (self, header, include_dirs=None, library_dirs=None,
lang="c") | Determine if the system header file named by 'header_file'
exists and can be found by the preprocessor; return true if so,
false otherwise.
| Determine if the system header file named by 'header_file'
exists and can be found by the preprocessor; return true if so,
false otherwise.
| def check_header(self, header, include_dirs=None, library_dirs=None,
lang="c"):
"""Determine if the system header file named by 'header_file'
exists and can be found by the preprocessor; return true if so,
false otherwise.
"""
return self.try_cpp(body="/* No ... | [
"def",
"check_header",
"(",
"self",
",",
"header",
",",
"include_dirs",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"lang",
"=",
"\"c\"",
")",
":",
"return",
"self",
".",
"try_cpp",
"(",
"body",
"=",
"\"/* No body */\"",
",",
"headers",
"=",
"[",... | [
321,
4
] | [
328,
54
] | python | en | ['en', 'en', 'en'] | True |
Filter.__init__ | (self, source, encoding) | Creates a Filter
:arg source: the source token stream
:arg encoding: the encoding to set
| Creates a Filter | def __init__(self, source, encoding):
"""Creates a Filter
:arg source: the source token stream
:arg encoding: the encoding to set
"""
base.Filter.__init__(self, source)
self.encoding = encoding | [
"def",
"__init__",
"(",
"self",
",",
"source",
",",
"encoding",
")",
":",
"base",
".",
"Filter",
".",
"__init__",
"(",
"self",
",",
"source",
")",
"self",
".",
"encoding",
"=",
"encoding"
] | [
7,
4
] | [
16,
32
] | python | en | ['en', 'gl', 'en'] | True |
visit_snippet_literal | (self, node) |
default literal block handler
|
default literal block handler
| def visit_snippet_literal(self, node):
"""
default literal block handler
"""
self.visit_literal_block(node) | [
"def",
"visit_snippet_literal",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"visit_literal_block",
"(",
"node",
")"
] | [
79,
0
] | [
83,
34
] | python | en | ['en', 'error', 'th'] | False |
depart_snippet_literal | (self, node) |
default literal block handler
|
default literal block handler
| def depart_snippet_literal(self, node):
"""
default literal block handler
"""
self.depart_literal_block(node) | [
"def",
"depart_snippet_literal",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"depart_literal_block",
"(",
"node",
")"
] | [
86,
0
] | [
90,
35
] | python | en | ['en', 'error', 'th'] | False |
visit_snippet | (self, node) |
HTML document generator visit handler
|
HTML document generator visit handler
| def visit_snippet(self, node):
"""
HTML document generator visit handler
"""
lang = self.highlightlang
linenos = node.rawsource.count('\n') >= self.highlightlinenothreshold - 1
fname = node['filename']
highlight_args = node.get('highlight_args', {})
if 'language' in node:
# code-... | [
"def",
"visit_snippet",
"(",
"self",
",",
"node",
")",
":",
"lang",
"=",
"self",
".",
"highlightlang",
"linenos",
"=",
"node",
".",
"rawsource",
".",
"count",
"(",
"'\\n'",
")",
">=",
"self",
".",
"highlightlinenothreshold",
"-",
"1",
"fname",
"=",
"node... | [
93,
0
] | [
121,
24
] | python | en | ['en', 'error', 'th'] | False |
visit_snippet_latex | (self, node) |
Latex document generator visit handler
|
Latex document generator visit handler
| def visit_snippet_latex(self, node):
"""
Latex document generator visit handler
"""
self.verbatim = '' | [
"def",
"visit_snippet_latex",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"verbatim",
"=",
"''"
] | [
124,
0
] | [
128,
22
] | python | en | ['en', 'error', 'th'] | False |
depart_snippet_latex | (self, node) |
Latex document generator depart handler.
|
Latex document generator depart handler.
| def depart_snippet_latex(self, node):
"""
Latex document generator depart handler.
"""
code = self.verbatim.rstrip('\n')
lang = self.hlsettingstack[-1][0]
linenos = code.count('\n') >= self.hlsettingstack[-1][1] - 1
fname = node['filename']
highlight_args = node.get('highlight_args', {})... | [
"def",
"depart_snippet_latex",
"(",
"self",
",",
"node",
")",
":",
"code",
"=",
"self",
".",
"verbatim",
".",
"rstrip",
"(",
"'\\n'",
")",
"lang",
"=",
"self",
".",
"hlsettingstack",
"[",
"-",
"1",
"]",
"[",
"0",
"]",
"linenos",
"=",
"code",
".",
"... | [
131,
0
] | [
168,
24
] | python | en | ['en', 'error', 'th'] | False |
parse_django_adminopt_node | (env, sig, signode) | A copy of sphinx.directives.CmdoptionDesc.parse_signature() | A copy of sphinx.directives.CmdoptionDesc.parse_signature() | def parse_django_adminopt_node(env, sig, signode):
"""A copy of sphinx.directives.CmdoptionDesc.parse_signature()"""
from sphinx.domains.std import option_desc_re
count = 0
firstname = ''
for m in option_desc_re.finditer(sig):
optname, args = m.groups()
if count:
signode ... | [
"def",
"parse_django_adminopt_node",
"(",
"env",
",",
"sig",
",",
"signode",
")",
":",
"from",
"sphinx",
".",
"domains",
".",
"std",
"import",
"option_desc_re",
"count",
"=",
"0",
"firstname",
"=",
"''",
"for",
"m",
"in",
"option_desc_re",
".",
"finditer",
... | [
307,
0
] | [
333,
20
] | python | en | ['en', 'en', 'en'] | True |
GeometryField.to_python | (self, value) |
Transforms the value to a Geometry object.
|
Transforms the value to a Geometry object.
| def to_python(self, value):
"""
Transforms the value to a Geometry object.
"""
if value in self.empty_values:
return None
if not isinstance(value, GEOSGeometry):
try:
value = GEOSGeometry(value)
except (GEOSException, ValueErro... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"self",
".",
"empty_values",
":",
"return",
"None",
"if",
"not",
"isinstance",
"(",
"value",
",",
"GEOSGeometry",
")",
":",
"try",
":",
"value",
"=",
"GEOSGeometry",
"(",
"va... | [
36,
4
] | [
56,
20
] | python | en | ['en', 'error', 'th'] | False |
GeometryField.clean | (self, value) |
Validates that the input value can be converted to a Geometry
object (which is returned). A ValidationError is raised if
the value cannot be instantiated as a Geometry.
|
Validates that the input value can be converted to a Geometry
object (which is returned). A ValidationError is raised if
the value cannot be instantiated as a Geometry.
| def clean(self, value):
"""
Validates that the input value can be converted to a Geometry
object (which is returned). A ValidationError is raised if
the value cannot be instantiated as a Geometry.
"""
geom = super(GeometryField, self).clean(value)
if geom is None... | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"geom",
"=",
"super",
"(",
"GeometryField",
",",
"self",
")",
".",
"clean",
"(",
"value",
")",
"if",
"geom",
"is",
"None",
":",
"return",
"geom",
"# Ensuring that the geometry is of the correct type (indicat... | [
58,
4
] | [
81,
19
] | python | en | ['en', 'error', 'th'] | False |
GeometryField.has_changed | (self, initial, data) | Compare geographic value of data with its initial value. | Compare geographic value of data with its initial value. | def has_changed(self, initial, data):
""" Compare geographic value of data with its initial value. """
try:
data = self.to_python(data)
initial = self.to_python(initial)
except forms.ValidationError:
return True
# Only do a geographic comparison if b... | [
"def",
"has_changed",
"(",
"self",
",",
"initial",
",",
"data",
")",
":",
"try",
":",
"data",
"=",
"self",
".",
"to_python",
"(",
"data",
")",
"initial",
"=",
"self",
".",
"to_python",
"(",
"initial",
")",
"except",
"forms",
".",
"ValidationError",
":"... | [
83,
4
] | [
101,
46
] | python | en | ['en', 'en', 'en'] | True |
get_display_recipient_remote_cache | (
recipient_id: int, recipient_type: int, recipient_type_id: Optional[int]
) |
returns: an appropriate object describing the recipient. For a
stream this will be the stream name as a string. For a huddle or
personal, it will be an array of dicts about each recipient.
|
returns: an appropriate object describing the recipient. For a
stream this will be the stream name as a string. For a huddle or
personal, it will be an array of dicts about each recipient.
| def get_display_recipient_remote_cache(
recipient_id: int, recipient_type: int, recipient_type_id: Optional[int]
) -> DisplayRecipientT:
"""
returns: an appropriate object describing the recipient. For a
stream this will be the stream name as a string. For a huddle or
personal, it will be an array... | [
"def",
"get_display_recipient_remote_cache",
"(",
"recipient_id",
":",
"int",
",",
"recipient_type",
":",
"int",
",",
"recipient_type_id",
":",
"Optional",
"[",
"int",
"]",
")",
"->",
"DisplayRecipientT",
":",
"if",
"recipient_type",
"==",
"Recipient",
".",
"STREA... | [
28,
0
] | [
51,
34
] | python | en | ['en', 'error', 'th'] | False |
bulk_fetch_display_recipients | (
recipient_tuples: Set[Tuple[int, int, int]],
) |
Takes set of tuples of the form (recipient_id, recipient_type, recipient_type_id)
Returns dict mapping recipient_id to corresponding display_recipient
|
Takes set of tuples of the form (recipient_id, recipient_type, recipient_type_id)
Returns dict mapping recipient_id to corresponding display_recipient
| def bulk_fetch_display_recipients(
recipient_tuples: Set[Tuple[int, int, int]],
) -> Dict[int, DisplayRecipientT]:
"""
Takes set of tuples of the form (recipient_id, recipient_type, recipient_type_id)
Returns dict mapping recipient_id to corresponding display_recipient
"""
# Build dict mapping ... | [
"def",
"bulk_fetch_display_recipients",
"(",
"recipient_tuples",
":",
"Set",
"[",
"Tuple",
"[",
"int",
",",
"int",
",",
"int",
"]",
"]",
",",
")",
"->",
"Dict",
"[",
"int",
",",
"DisplayRecipientT",
"]",
":",
"# Build dict mapping recipient id to (type, type_id) o... | [
72,
0
] | [
201,
82
] | python | en | ['en', 'error', 'th'] | False |
_find_vc2017 | () | Returns "15, path" based on the result of invoking vswhere.exe
If no install is found, returns "None, None"
The version is returned to avoid unnecessarily changing the function
result. It may be ignored when the path is not None.
If vswhere.exe is not available, by definition, VS 2017 is not
insta... | Returns "15, path" based on the result of invoking vswhere.exe
If no install is found, returns "None, None" | def _find_vc2017():
"""Returns "15, path" based on the result of invoking vswhere.exe
If no install is found, returns "None, None"
The version is returned to avoid unnecessarily changing the function
result. It may be ignored when the path is not None.
If vswhere.exe is not available, by definitio... | [
"def",
"_find_vc2017",
"(",
")",
":",
"root",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"ProgramFiles(x86)\"",
")",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"\"ProgramFiles\"",
")",
"if",
"not",
"root",
":",
"return",
"None",
",",
"None",
"try"... | [
55,
0
] | [
85,
21
] | python | en | ['en', 'en', 'en'] | True |
_find_exe | (exe, paths=None) | Return path to an MSVC executable program.
Tries to find the program in several places: first, one of the
MSVC program search paths from the registry; next, the directories
in the PATH environment variable. If any of those work, return an
absolute path that is known to exist. If none of them work, ju... | Return path to an MSVC executable program. | def _find_exe(exe, paths=None):
"""Return path to an MSVC executable program.
Tries to find the program in several places: first, one of the
MSVC program search paths from the registry; next, the directories
in the PATH environment variable. If any of those work, return an
absolute path that is kn... | [
"def",
"_find_exe",
"(",
"exe",
",",
"paths",
"=",
"None",
")",
":",
"if",
"not",
"paths",
":",
"paths",
"=",
"os",
".",
"getenv",
"(",
"'path'",
")",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
"for",
"p",
"in",
"paths",
":",
"fn",
"=",
"os"... | [
142,
0
] | [
157,
14
] | python | en | ['en', 'en', 'en'] | True |
Filter.__init__ | (self,
source,
allowed_elements=allowed_elements,
allowed_attributes=allowed_attributes,
allowed_css_properties=allowed_css_properties,
allowed_css_keywords=allowed_css_keywords,
allowed_svg_properties=allowed_svg_prop... | Creates a Filter
:arg allowed_elements: set of elements to allow--everything else will
be escaped
:arg allowed_attributes: set of attributes to allow in
elements--everything else will be stripped
:arg allowed_css_properties: set of CSS properties to allow--everything
... | Creates a Filter | def __init__(self,
source,
allowed_elements=allowed_elements,
allowed_attributes=allowed_attributes,
allowed_css_properties=allowed_css_properties,
allowed_css_keywords=allowed_css_keywords,
allowed_svg_properties=allo... | [
"def",
"__init__",
"(",
"self",
",",
"source",
",",
"allowed_elements",
"=",
"allowed_elements",
",",
"allowed_attributes",
"=",
"allowed_attributes",
",",
"allowed_css_properties",
"=",
"allowed_css_properties",
",",
"allowed_css_keywords",
"=",
"allowed_css_keywords",
"... | [
708,
4
] | [
761,
56
] | python | en | ['en', 'gl', 'en'] | True |
Dib.expose | (self, handle) |
Copy the bitmap contents to a device context.
:param handle: Device context (HDC), cast to a Python integer, or an
HDC or HWND instance. In PythonWin, you can use the
:py:meth:`CDC.GetHandleAttrib` to get a suitable handle.
|
Copy the bitmap contents to a device context. | def expose(self, handle):
"""
Copy the bitmap contents to a device context.
:param handle: Device context (HDC), cast to a Python integer, or an
HDC or HWND instance. In PythonWin, you can use the
:py:meth:`CDC.GetHandleAttrib` to get a suitable ha... | [
"def",
"expose",
"(",
"self",
",",
"handle",
")",
":",
"if",
"isinstance",
"(",
"handle",
",",
"HWND",
")",
":",
"dc",
"=",
"self",
".",
"image",
".",
"getdc",
"(",
"handle",
")",
"try",
":",
"result",
"=",
"self",
".",
"image",
".",
"expose",
"(... | [
85,
4
] | [
101,
21
] | python | en | ['en', 'error', 'th'] | False |
Dib.draw | (self, handle, dst, src=None) |
Same as expose, but allows you to specify where to draw the image, and
what part of it to draw.
The destination and source areas are given as 4-tuple rectangles. If
the source is omitted, the entire image is copied. If the source and
the destination have different sizes, the im... |
Same as expose, but allows you to specify where to draw the image, and
what part of it to draw. | def draw(self, handle, dst, src=None):
"""
Same as expose, but allows you to specify where to draw the image, and
what part of it to draw.
The destination and source areas are given as 4-tuple rectangles. If
the source is omitted, the entire image is copied. If the source and
... | [
"def",
"draw",
"(",
"self",
",",
"handle",
",",
"dst",
",",
"src",
"=",
"None",
")",
":",
"if",
"not",
"src",
":",
"src",
"=",
"(",
"0",
",",
"0",
")",
"+",
"self",
".",
"size",
"if",
"isinstance",
"(",
"handle",
",",
"HWND",
")",
":",
"dc",
... | [
103,
4
] | [
123,
21
] | python | en | ['en', 'error', 'th'] | False |
Dib.query_palette | (self, handle) |
Installs the palette associated with the image in the given device
context.
This method should be called upon **QUERYNEWPALETTE** and
**PALETTECHANGED** events from Windows. If this method returns a
non-zero value, one or more display palette entries were changed, and
t... |
Installs the palette associated with the image in the given device
context. | def query_palette(self, handle):
"""
Installs the palette associated with the image in the given device
context.
This method should be called upon **QUERYNEWPALETTE** and
**PALETTECHANGED** events from Windows. If this method returns a
non-zero value, one or more display... | [
"def",
"query_palette",
"(",
"self",
",",
"handle",
")",
":",
"if",
"isinstance",
"(",
"handle",
",",
"HWND",
")",
":",
"handle",
"=",
"self",
".",
"image",
".",
"getdc",
"(",
"handle",
")",
"try",
":",
"result",
"=",
"self",
".",
"image",
".",
"qu... | [
125,
4
] | [
148,
21
] | python | en | ['en', 'error', 'th'] | False |
Dib.paste | (self, im, box=None) |
Paste a PIL image into the bitmap image.
:param im: A PIL image. The size must match the target region.
If the mode does not match, the image is converted to the
mode of the bitmap image.
:param box: A 4-tuple defining the left, upper, right, and
... |
Paste a PIL image into the bitmap image. | def paste(self, im, box=None):
"""
Paste a PIL image into the bitmap image.
:param im: A PIL image. The size must match the target region.
If the mode does not match, the image is converted to the
mode of the bitmap image.
:param box: A 4-tuple def... | [
"def",
"paste",
"(",
"self",
",",
"im",
",",
"box",
"=",
"None",
")",
":",
"im",
".",
"load",
"(",
")",
"if",
"self",
".",
"mode",
"!=",
"im",
".",
"mode",
":",
"im",
"=",
"im",
".",
"convert",
"(",
"self",
".",
"mode",
")",
"if",
"box",
":... | [
150,
4
] | [
168,
35
] | python | en | ['en', 'error', 'th'] | False |
Dib.frombytes | (self, buffer) |
Load display memory contents from byte data.
:param buffer: A buffer containing display data (usually
data returned from :py:func:`~PIL.ImageWin.Dib.tobytes`)
|
Load display memory contents from byte data. | def frombytes(self, buffer):
"""
Load display memory contents from byte data.
:param buffer: A buffer containing display data (usually
data returned from :py:func:`~PIL.ImageWin.Dib.tobytes`)
"""
return self.image.frombytes(buffer) | [
"def",
"frombytes",
"(",
"self",
",",
"buffer",
")",
":",
"return",
"self",
".",
"image",
".",
"frombytes",
"(",
"buffer",
")"
] | [
170,
4
] | [
177,
43
] | python | en | ['en', 'error', 'th'] | False |
Dib.tobytes | (self) |
Copy display memory contents to bytes object.
:return: A bytes object containing display data.
|
Copy display memory contents to bytes object. | def tobytes(self):
"""
Copy display memory contents to bytes object.
:return: A bytes object containing display data.
"""
return self.image.tobytes() | [
"def",
"tobytes",
"(",
"self",
")",
":",
"return",
"self",
".",
"image",
".",
"tobytes",
"(",
")"
] | [
179,
4
] | [
185,
35
] | python | en | ['en', 'error', 'th'] | False |
PingdomHookTests.test_pingdom_from_up_to_down_http_check_message | (self) |
Tests if pingdom http check from up to down is handled correctly
|
Tests if pingdom http check from up to down is handled correctly
| def test_pingdom_from_up_to_down_http_check_message(self) -> None:
"""
Tests if pingdom http check from up to down is handled correctly
"""
expected_message = "Service someurl.com changed its HTTP status from UP to DOWN:\n\n``` quote\nNon-recoverable failure in name resolution\n```"
... | [
"def",
"test_pingdom_from_up_to_down_http_check_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"Service someurl.com changed its HTTP status from UP to DOWN:\\n\\n``` quote\\nNon-recoverable failure in name resolution\\n```\"",
"self",
".",
"check_webhook",
"(",... | [
8,
4
] | [
13,
85
] | python | en | ['en', 'error', 'th'] | False |
PingdomHookTests.test_pingdom_from_up_to_down_smtp_check_message | (self) |
Tests if pingdom smtp check from up to down is handled correctly
|
Tests if pingdom smtp check from up to down is handled correctly
| def test_pingdom_from_up_to_down_smtp_check_message(self) -> None:
"""
Tests if pingdom smtp check from up to down is handled correctly
"""
expected_message = "Service smtp.someurl.com changed its SMTP status from UP to DOWN:\n\n``` quote\nConnection refused\n```"
self.check_webh... | [
"def",
"test_pingdom_from_up_to_down_smtp_check_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"Service smtp.someurl.com changed its SMTP status from UP to DOWN:\\n\\n``` quote\\nConnection refused\\n```\"",
"self",
".",
"check_webhook",
"(",
"\"smtp_up_to_do... | [
15,
4
] | [
20,
85
] | python | en | ['en', 'error', 'th'] | False |
PingdomHookTests.test_pingdom_from_up_to_down_imap_check_message | (self) |
Tests if pingdom imap check from up to down is handled correctly
|
Tests if pingdom imap check from up to down is handled correctly
| def test_pingdom_from_up_to_down_imap_check_message(self) -> None:
"""
Tests if pingdom imap check from up to down is handled correctly
"""
expected_message = "Service imap.someurl.com changed its IMAP status from UP to DOWN:\n\n``` quote\nInvalid hostname, address or socket\n```"
... | [
"def",
"test_pingdom_from_up_to_down_imap_check_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"Service imap.someurl.com changed its IMAP status from UP to DOWN:\\n\\n``` quote\\nInvalid hostname, address or socket\\n```\"",
"self",
".",
"check_webhook",
"(",
... | [
22,
4
] | [
27,
85
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.