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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
PyDecoder.cleanup | (self) |
Override to perform decoder specific cleanup
:returns: None
|
Override to perform decoder specific cleanup | def cleanup(self):
"""
Override to perform decoder specific cleanup
:returns: None
"""
pass | [
"def",
"cleanup",
"(",
"self",
")",
":",
"pass"
] | [
621,
4
] | [
627,
12
] | python | en | ['en', 'error', 'th'] | False |
PyDecoder.setfd | (self, fd) |
Called from ImageFile to set the python file-like object
:param fd: A python file-like object
:returns: None
|
Called from ImageFile to set the python file-like object | def setfd(self, fd):
"""
Called from ImageFile to set the python file-like object
:param fd: A python file-like object
:returns: None
"""
self.fd = fd | [
"def",
"setfd",
"(",
"self",
",",
"fd",
")",
":",
"self",
".",
"fd",
"=",
"fd"
] | [
629,
4
] | [
636,
20
] | python | en | ['en', 'error', 'th'] | False |
PyDecoder.setimage | (self, im, extents=None) |
Called from ImageFile to set the core output image for the decoder
:param im: A core image object
:param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle
for this tile
:returns: None
|
Called from ImageFile to set the core output image for the decoder | def setimage(self, im, extents=None):
"""
Called from ImageFile to set the core output image for the decoder
:param im: A core image object
:param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle
for this tile
:returns: None
"""
# follow... | [
"def",
"setimage",
"(",
"self",
",",
"im",
",",
"extents",
"=",
"None",
")",
":",
"# following c code",
"self",
".",
"im",
"=",
"im",
"if",
"extents",
":",
"(",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
")",
"=",
"extents",
"else",
":",
"(",
"x0",
... | [
638,
4
] | [
671,
64
] | python | en | ['en', 'error', 'th'] | False |
PyDecoder.set_as_raw | (self, data, rawmode=None) |
Convenience method to set the internal image from a stream of raw data
:param data: Bytes to be set
:param rawmode: The rawmode to be used for the decoder.
If not specified, it will default to the mode of the image
:returns: None
|
Convenience method to set the internal image from a stream of raw data | def set_as_raw(self, data, rawmode=None):
"""
Convenience method to set the internal image from a stream of raw data
:param data: Bytes to be set
:param rawmode: The rawmode to be used for the decoder.
If not specified, it will default to the mode of the image
:retur... | [
"def",
"set_as_raw",
"(",
"self",
",",
"data",
",",
"rawmode",
"=",
"None",
")",
":",
"if",
"not",
"rawmode",
":",
"rawmode",
"=",
"self",
".",
"mode",
"d",
"=",
"Image",
".",
"_getdecoder",
"(",
"self",
".",
"mode",
",",
"\"raw\"",
",",
"(",
"rawm... | [
673,
4
] | [
692,
56
] | python | en | ['en', 'error', 'th'] | False |
Command.get_handler | (self, *args, **options) |
Returns the static files serving handler wrapping the default handler,
if static files should be served. Otherwise just returns the default
handler.
|
Returns the static files serving handler wrapping the default handler,
if static files should be served. Otherwise just returns the default
handler. | def get_handler(self, *args, **options):
"""
Returns the static files serving handler wrapping the default handler,
if static files should be served. Otherwise just returns the default
handler.
"""
handler = super(Command, self).get_handler(*args, **options)
use_... | [
"def",
"get_handler",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"handler",
"=",
"super",
"(",
"Command",
",",
"self",
")",
".",
"get_handler",
"(",
"*",
"args",
",",
"*",
"*",
"options",
")",
"use_static_handler",
"=",
"optio... | [
16,
4
] | [
28,
22
] | python | en | ['en', 'error', 'th'] | False |
DatabaseCreation.sql_for_inline_foreign_key_references | (self, model, field, known_models, style) | All inline references are pending under MySQL | All inline references are pending under MySQL | def sql_for_inline_foreign_key_references(self, model, field, known_models, style):
"All inline references are pending under MySQL"
return [], True | [
"def",
"sql_for_inline_foreign_key_references",
"(",
"self",
",",
"model",
",",
"field",
",",
"known_models",
",",
"style",
")",
":",
"return",
"[",
"]",
",",
"True"
] | [
44,
4
] | [
46,
23
] | python | en | ['en', 'en', 'en'] | True |
Message._prepare | (self) |
Prepare the message for serialization by forcing the ``message``
and ``extra_tags`` to str in case they are lazy translations.
|
Prepare the message for serialization by forcing the ``message``
and ``extra_tags`` to str in case they are lazy translations.
| def _prepare(self):
"""
Prepare the message for serialization by forcing the ``message``
and ``extra_tags`` to str in case they are lazy translations.
"""
self.message = str(self.message)
self.extra_tags = str(self.extra_tags) if self.extra_tags is not None else None | [
"def",
"_prepare",
"(",
"self",
")",
":",
"self",
".",
"message",
"=",
"str",
"(",
"self",
".",
"message",
")",
"self",
".",
"extra_tags",
"=",
"str",
"(",
"self",
".",
"extra_tags",
")",
"if",
"self",
".",
"extra_tags",
"is",
"not",
"None",
"else",
... | [
18,
4
] | [
24,
87
] | python | en | ['en', 'error', 'th'] | False |
BaseStorage._loaded_messages | (self) |
Return a list of loaded messages, retrieving them first if they have
not been loaded yet.
|
Return a list of loaded messages, retrieving them first if they have
not been loaded yet.
| def _loaded_messages(self):
"""
Return a list of loaded messages, retrieving them first if they have
not been loaded yet.
"""
if not hasattr(self, '_loaded_data'):
messages, all_retrieved = self._get()
self._loaded_data = messages or []
return self... | [
"def",
"_loaded_messages",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_loaded_data'",
")",
":",
"messages",
",",
"all_retrieved",
"=",
"self",
".",
"_get",
"(",
")",
"self",
".",
"_loaded_data",
"=",
"messages",
"or",
"[",
"]",
... | [
71,
4
] | [
79,
32
] | python | en | ['en', 'error', 'th'] | False |
BaseStorage._get | (self, *args, **kwargs) |
Retrieve a list of stored messages. Return a tuple of the messages
and a flag indicating whether or not all the messages originally
intended to be stored in this storage were, in fact, stored and
retrieved; e.g., ``(messages, all_retrieved)``.
**This method must be implemented ... |
Retrieve a list of stored messages. Return a tuple of the messages
and a flag indicating whether or not all the messages originally
intended to be stored in this storage were, in fact, stored and
retrieved; e.g., ``(messages, all_retrieved)``. | def _get(self, *args, **kwargs):
"""
Retrieve a list of stored messages. Return a tuple of the messages
and a flag indicating whether or not all the messages originally
intended to be stored in this storage were, in fact, stored and
retrieved; e.g., ``(messages, all_retrieved)``.... | [
"def",
"_get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseStorage must provide a _get() method'",
")"
] | [
81,
4
] | [
94,
91
] | python | en | ['en', 'error', 'th'] | False |
BaseStorage._store | (self, messages, response, *args, **kwargs) |
Store a list of messages and return a list of any messages which could
not be stored.
One type of object must be able to be stored, ``Message``.
**This method must be implemented by a subclass.**
|
Store a list of messages and return a list of any messages which could
not be stored. | def _store(self, messages, response, *args, **kwargs):
"""
Store a list of messages and return a list of any messages which could
not be stored.
One type of object must be able to be stored, ``Message``.
**This method must be implemented by a subclass.**
"""
rai... | [
"def",
"_store",
"(",
"self",
",",
"messages",
",",
"response",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseStorage must provide a _store() method'",
")"
] | [
96,
4
] | [
105,
93
] | python | en | ['en', 'error', 'th'] | False |
BaseStorage._prepare_messages | (self, messages) |
Prepare a list of messages for storage.
|
Prepare a list of messages for storage.
| def _prepare_messages(self, messages):
"""
Prepare a list of messages for storage.
"""
for message in messages:
message._prepare() | [
"def",
"_prepare_messages",
"(",
"self",
",",
"messages",
")",
":",
"for",
"message",
"in",
"messages",
":",
"message",
".",
"_prepare",
"(",
")"
] | [
107,
4
] | [
112,
30
] | python | en | ['en', 'error', 'th'] | False |
BaseStorage.update | (self, response) |
Store all unread messages.
If the backend has yet to be iterated, store previously stored messages
again. Otherwise, only store messages added after the last iteration.
|
Store all unread messages. | def update(self, response):
"""
Store all unread messages.
If the backend has yet to be iterated, store previously stored messages
again. Otherwise, only store messages added after the last iteration.
"""
self._prepare_messages(self._queued_messages)
if self.used... | [
"def",
"update",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"_prepare_messages",
"(",
"self",
".",
"_queued_messages",
")",
"if",
"self",
".",
"used",
":",
"return",
"self",
".",
"_store",
"(",
"self",
".",
"_queued_messages",
",",
"response",
... | [
114,
4
] | [
126,
50
] | python | en | ['en', 'error', 'th'] | False |
BaseStorage.add | (self, level, message, extra_tags='') |
Queue a message to be stored.
The message is only queued if it contained something and its level is
not less than the recording level (``self.level``).
|
Queue a message to be stored. | def add(self, level, message, extra_tags=''):
"""
Queue a message to be stored.
The message is only queued if it contained something and its level is
not less than the recording level (``self.level``).
"""
if not message:
return
# Check that the messa... | [
"def",
"add",
"(",
"self",
",",
"level",
",",
"message",
",",
"extra_tags",
"=",
"''",
")",
":",
"if",
"not",
"message",
":",
"return",
"# Check that the message level is not less than the recording level.",
"level",
"=",
"int",
"(",
"level",
")",
"if",
"level",... | [
128,
4
] | [
144,
45
] | python | en | ['en', 'error', 'th'] | False |
BaseStorage._get_level | (self) |
Return the minimum recorded level.
The default level is the ``MESSAGE_LEVEL`` setting. If this is
not found, the ``INFO`` level is used.
|
Return the minimum recorded level. | def _get_level(self):
"""
Return the minimum recorded level.
The default level is the ``MESSAGE_LEVEL`` setting. If this is
not found, the ``INFO`` level is used.
"""
if not hasattr(self, '_level'):
self._level = getattr(settings, 'MESSAGE_LEVEL', constants.I... | [
"def",
"_get_level",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_level'",
")",
":",
"self",
".",
"_level",
"=",
"getattr",
"(",
"settings",
",",
"'MESSAGE_LEVEL'",
",",
"constants",
".",
"INFO",
")",
"return",
"self",
".",
"_lev... | [
146,
4
] | [
155,
26
] | python | en | ['en', 'error', 'th'] | False |
BaseStorage._set_level | (self, value=None) |
Set a custom minimum recorded level.
If set to ``None``, the default level will be used (see the
``_get_level`` method).
|
Set a custom minimum recorded level. | def _set_level(self, value=None):
"""
Set a custom minimum recorded level.
If set to ``None``, the default level will be used (see the
``_get_level`` method).
"""
if value is None and hasattr(self, '_level'):
del self._level
else:
self._le... | [
"def",
"_set_level",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
"and",
"hasattr",
"(",
"self",
",",
"'_level'",
")",
":",
"del",
"self",
".",
"_level",
"else",
":",
"self",
".",
"_level",
"=",
"int",
"(",
"value"... | [
157,
4
] | [
167,
36
] | python | en | ['en', 'error', 'th'] | False |
exhaust | (stream_or_iterable) | Exhaust an iterator or stream. | Exhaust an iterator or stream. | def exhaust(stream_or_iterable):
"""Exhaust an iterator or stream."""
try:
iterator = iter(stream_or_iterable)
except TypeError:
iterator = ChunkIter(stream_or_iterable, 16384)
collections.deque(iterator, maxlen=0) | [
"def",
"exhaust",
"(",
"stream_or_iterable",
")",
":",
"try",
":",
"iterator",
"=",
"iter",
"(",
"stream_or_iterable",
")",
"except",
"TypeError",
":",
"iterator",
"=",
"ChunkIter",
"(",
"stream_or_iterable",
",",
"16384",
")",
"collections",
".",
"deque",
"("... | [
564,
0
] | [
570,
41
] | python | en | ['en', 'en', 'nl'] | True |
parse_boundary_stream | (stream, max_header_size) |
Parse one and exactly one stream that encapsulates a boundary.
|
Parse one and exactly one stream that encapsulates a boundary.
| def parse_boundary_stream(stream, max_header_size):
"""
Parse one and exactly one stream that encapsulates a boundary.
"""
# Stream at beginning of header, look for end of header
# and parse it if found. The header must fit within one
# chunk.
chunk = stream.read(max_header_size)
# 'fin... | [
"def",
"parse_boundary_stream",
"(",
"stream",
",",
"max_header_size",
")",
":",
"# Stream at beginning of header, look for end of header",
"# and parse it if found. The header must fit within one",
"# chunk.",
"chunk",
"=",
"stream",
".",
"read",
"(",
"max_header_size",
")",
"... | [
573,
0
] | [
629,
34
] | python | en | ['en', 'error', 'th'] | False |
parse_header | (line) |
Parse the header into a key-value.
Input (line): bytes, output: str for key/name, bytes for values which
will be decoded later.
|
Parse the header into a key-value. | def parse_header(line):
"""
Parse the header into a key-value.
Input (line): bytes, output: str for key/name, bytes for values which
will be decoded later.
"""
plist = _parse_header_params(b';' + line)
key = plist.pop(0).lower().decode('ascii')
pdict = {}
for p in plist:
i =... | [
"def",
"parse_header",
"(",
"line",
")",
":",
"plist",
"=",
"_parse_header_params",
"(",
"b';'",
"+",
"line",
")",
"key",
"=",
"plist",
".",
"pop",
"(",
"0",
")",
".",
"lower",
"(",
")",
".",
"decode",
"(",
"'ascii'",
")",
"pdict",
"=",
"{",
"}",
... | [
644,
0
] | [
673,
21
] | python | en | ['en', 'error', 'th'] | False |
MultiPartParser.__init__ | (self, META, input_data, upload_handlers, encoding=None) |
Initialize the MultiPartParser object.
:META:
The standard ``META`` dictionary in Django request objects.
:input_data:
The raw post data, as a file-like object.
:upload_handlers:
A list of UploadHandler instances that perform operations on the
... |
Initialize the MultiPartParser object. | def __init__(self, META, input_data, upload_handlers, encoding=None):
"""
Initialize the MultiPartParser object.
:META:
The standard ``META`` dictionary in Django request objects.
:input_data:
The raw post data, as a file-like object.
:upload_handlers:
... | [
"def",
"__init__",
"(",
"self",
",",
"META",
",",
"input_data",
",",
"upload_handlers",
",",
"encoding",
"=",
"None",
")",
":",
"# Content-Type should contain multipart and the boundary information.",
"content_type",
"=",
"META",
".",
"get",
"(",
"'CONTENT_TYPE'",
","... | [
49,
4
] | [
101,
47
] | python | en | ['en', 'error', 'th'] | False |
MultiPartParser.parse | (self) |
Parse the POST data and break it into a FILES MultiValueDict and a POST
MultiValueDict.
Return a tuple containing the POST and FILES dictionary, respectively.
|
Parse the POST data and break it into a FILES MultiValueDict and a POST
MultiValueDict. | def parse(self):
"""
Parse the POST data and break it into a FILES MultiValueDict and a POST
MultiValueDict.
Return a tuple containing the POST and FILES dictionary, respectively.
"""
from django.http import QueryDict
encoding = self._encoding
handlers =... | [
"def",
"parse",
"(",
"self",
")",
":",
"from",
"django",
".",
"http",
"import",
"QueryDict",
"encoding",
"=",
"self",
".",
"_encoding",
"handlers",
"=",
"self",
".",
"_upload_handlers",
"# HTTP spec says that Content-Length >= 0 is valid",
"# handling content-length == ... | [
103,
4
] | [
286,
38
] | python | en | ['en', 'error', 'th'] | False |
MultiPartParser.handle_file_complete | (self, old_field_name, counters) |
Handle all the signaling that takes place when a file is complete.
|
Handle all the signaling that takes place when a file is complete.
| def handle_file_complete(self, old_field_name, counters):
"""
Handle all the signaling that takes place when a file is complete.
"""
for i, handler in enumerate(self._upload_handlers):
file_obj = handler.file_complete(counters[i])
if file_obj:
# If... | [
"def",
"handle_file_complete",
"(",
"self",
",",
"old_field_name",
",",
"counters",
")",
":",
"for",
"i",
",",
"handler",
"in",
"enumerate",
"(",
"self",
".",
"_upload_handlers",
")",
":",
"file_obj",
"=",
"handler",
".",
"file_complete",
"(",
"counters",
"[... | [
288,
4
] | [
297,
21
] | python | en | ['en', 'error', 'th'] | False |
MultiPartParser.IE_sanitize | (self, filename) | Cleanup filename from Internet Explorer full paths. | Cleanup filename from Internet Explorer full paths. | def IE_sanitize(self, filename):
"""Cleanup filename from Internet Explorer full paths."""
return filename and filename[filename.rfind("\\") + 1:].strip() | [
"def",
"IE_sanitize",
"(",
"self",
",",
"filename",
")",
":",
"return",
"filename",
"and",
"filename",
"[",
"filename",
".",
"rfind",
"(",
"\"\\\\\"",
")",
"+",
"1",
":",
"]",
".",
"strip",
"(",
")"
] | [
299,
4
] | [
301,
71
] | python | en | ['en', 'en', 'en'] | True |
LazyStream.__init__ | (self, producer, length=None) |
Every LazyStream must have a producer when instantiated.
A producer is an iterable that returns a string each time it
is called.
|
Every LazyStream must have a producer when instantiated. | def __init__(self, producer, length=None):
"""
Every LazyStream must have a producer when instantiated.
A producer is an iterable that returns a string each time it
is called.
"""
self._producer = producer
self._empty = False
self._leftover = b''
... | [
"def",
"__init__",
"(",
"self",
",",
"producer",
",",
"length",
"=",
"None",
")",
":",
"self",
".",
"_producer",
"=",
"producer",
"self",
".",
"_empty",
"=",
"False",
"self",
".",
"_leftover",
"=",
"b''",
"self",
".",
"length",
"=",
"length",
"self",
... | [
320,
4
] | [
333,
32
] | python | en | ['en', 'error', 'th'] | False |
LazyStream.__next__ | (self) |
Used when the exact number of bytes to read is unimportant.
Return whatever chunk is conveniently returned from the iterator.
Useful to avoid unnecessary bookkeeping if performance is an issue.
|
Used when the exact number of bytes to read is unimportant. | def __next__(self):
"""
Used when the exact number of bytes to read is unimportant.
Return whatever chunk is conveniently returned from the iterator.
Useful to avoid unnecessary bookkeeping if performance is an issue.
"""
if self._leftover:
output = self._lef... | [
"def",
"__next__",
"(",
"self",
")",
":",
"if",
"self",
".",
"_leftover",
":",
"output",
"=",
"self",
".",
"_leftover",
"self",
".",
"_leftover",
"=",
"b''",
"else",
":",
"output",
"=",
"next",
"(",
"self",
".",
"_producer",
")",
"self",
".",
"_unget... | [
364,
4
] | [
378,
21
] | python | en | ['en', 'error', 'th'] | False |
LazyStream.close | (self) |
Used to invalidate/disable this lazy stream.
Replace the producer with an empty list. Any leftover bytes that have
already been read will still be reported upon read() and/or next().
|
Used to invalidate/disable this lazy stream. | def close(self):
"""
Used to invalidate/disable this lazy stream.
Replace the producer with an empty list. Any leftover bytes that have
already been read will still be reported upon read() and/or next().
"""
self._producer = [] | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_producer",
"=",
"[",
"]"
] | [
380,
4
] | [
387,
27
] | python | en | ['en', 'error', 'th'] | False |
LazyStream.unget | (self, bytes) |
Place bytes back onto the front of the lazy stream.
Future calls to read() will return those bytes first. The
stream position and thus tell() will be rewound.
|
Place bytes back onto the front of the lazy stream. | def unget(self, bytes):
"""
Place bytes back onto the front of the lazy stream.
Future calls to read() will return those bytes first. The
stream position and thus tell() will be rewound.
"""
if not bytes:
return
self._update_unget_history(len(bytes))
... | [
"def",
"unget",
"(",
"self",
",",
"bytes",
")",
":",
"if",
"not",
"bytes",
":",
"return",
"self",
".",
"_update_unget_history",
"(",
"len",
"(",
"bytes",
")",
")",
"self",
".",
"position",
"-=",
"len",
"(",
"bytes",
")",
"self",
".",
"_leftover",
"="... | [
392,
4
] | [
403,
47
] | python | en | ['en', 'error', 'th'] | False |
LazyStream._update_unget_history | (self, num_bytes) |
Update the unget history as a sanity check to see if we've pushed
back the same number of bytes in one chunk. If we keep ungetting the
same number of bytes many times (here, 50), we're mostly likely in an
infinite loop of some sort. This is usually caused by a
maliciously-malfor... |
Update the unget history as a sanity check to see if we've pushed
back the same number of bytes in one chunk. If we keep ungetting the
same number of bytes many times (here, 50), we're mostly likely in an
infinite loop of some sort. This is usually caused by a
maliciously-malfor... | def _update_unget_history(self, num_bytes):
"""
Update the unget history as a sanity check to see if we've pushed
back the same number of bytes in one chunk. If we keep ungetting the
same number of bytes many times (here, 50), we're mostly likely in an
infinite loop of some sort.... | [
"def",
"_update_unget_history",
"(",
"self",
",",
"num_bytes",
")",
":",
"self",
".",
"_unget_history",
"=",
"[",
"num_bytes",
"]",
"+",
"self",
".",
"_unget_history",
"[",
":",
"49",
"]",
"number_equal",
"=",
"len",
"(",
"[",
"current_number",
"for",
"cur... | [
405,
4
] | [
424,
13
] | python | en | ['en', 'error', 'th'] | False |
BoundaryIter._find_boundary | (self, data) |
Find a multipart boundary in data.
Should no boundary exist in the data, return None. Otherwise, return
a tuple containing the indices of the following:
* the end of current encapsulation
* the start of the next encapsulation
|
Find a multipart boundary in data. | def _find_boundary(self, data):
"""
Find a multipart boundary in data.
Should no boundary exist in the data, return None. Otherwise, return
a tuple containing the indices of the following:
* the end of current encapsulation
* the start of the next encapsulation
... | [
"def",
"_find_boundary",
"(",
"self",
",",
"data",
")",
":",
"index",
"=",
"data",
".",
"find",
"(",
"self",
".",
"_boundary",
")",
"if",
"index",
"<",
"0",
":",
"return",
"None",
"else",
":",
"end",
"=",
"index",
"next",
"=",
"index",
"+",
"len",
... | [
539,
4
] | [
561,
28
] | python | en | ['en', 'error', 'th'] | False |
print_in_box | (text) |
Prints `text` surrounded by a box made of *s
|
Prints `text` surrounded by a box made of *s
| def print_in_box(text):
"""
Prints `text` surrounded by a box made of *s
"""
print("")
print("*" * (len(text) + 6))
print("** " + text + " **")
print("*" * (len(text) + 6))
print("") | [
"def",
"print_in_box",
"(",
"text",
")",
":",
"print",
"(",
"\"\"",
")",
"print",
"(",
"\"*\"",
"*",
"(",
"len",
"(",
"text",
")",
"+",
"6",
")",
")",
"print",
"(",
"\"** \"",
"+",
"text",
"+",
"\" **\"",
")",
"print",
"(",
"\"*\"",
"*",
"(",
"... | [
29,
0
] | [
37,
13
] | python | en | ['en', 'error', 'th'] | False |
main | (args) |
Validates the submission.
|
Validates the submission.
| def main(args):
"""
Validates the submission.
"""
print_in_box("Validating submission " + args.submission_filename)
random.seed()
temp_dir = args.temp_dir
delete_temp_dir = False
if not temp_dir:
temp_dir = tempfile.mkdtemp()
logging.info("Created temporary directory: %s"... | [
"def",
"main",
"(",
"args",
")",
":",
"print_in_box",
"(",
"\"Validating submission \"",
"+",
"args",
".",
"submission_filename",
")",
"random",
".",
"seed",
"(",
")",
"temp_dir",
"=",
"args",
".",
"temp_dir",
"delete_temp_dir",
"=",
"False",
"if",
"not",
"t... | [
40,
0
] | [
59,
48
] | python | en | ['en', 'error', 'th'] | False |
AdminFormfieldForDBFieldTests.assertFormfield | (self, model, fieldname, widgetclass, **admin_overrides) |
Helper to call formfield_for_dbfield for a given model and field name
and verify that the returned formfield is appropriate.
|
Helper to call formfield_for_dbfield for a given model and field name
and verify that the returned formfield is appropriate.
| def assertFormfield(self, model, fieldname, widgetclass, **admin_overrides):
"""
Helper to call formfield_for_dbfield for a given model and field name
and verify that the returned formfield is appropriate.
"""
# Override any settings on the model admin
class MyModelAdmin(... | [
"def",
"assertFormfield",
"(",
"self",
",",
"model",
",",
"fieldname",
",",
"widgetclass",
",",
"*",
"*",
"admin_overrides",
")",
":",
"# Override any settings on the model admin",
"class",
"MyModelAdmin",
"(",
"admin",
".",
"ModelAdmin",
")",
":",
"pass",
"for",
... | [
41,
4
] | [
74,
17
] | python | en | ['en', 'error', 'th'] | False |
AdminFormfieldForDBFieldTests.test_formfield_overrides_widget_instances | (self) |
Test that widget instances in formfield_overrides are not shared between
different fields. (#19423)
|
Test that widget instances in formfield_overrides are not shared between
different fields. (#19423)
| def test_formfield_overrides_widget_instances(self):
"""
Test that widget instances in formfield_overrides are not shared between
different fields. (#19423)
"""
class BandAdmin(admin.ModelAdmin):
formfield_overrides = {
CharField: {'widget': forms.Text... | [
"def",
"test_formfield_overrides_widget_instances",
"(",
"self",
")",
":",
"class",
"BandAdmin",
"(",
"admin",
".",
"ModelAdmin",
")",
":",
"formfield_overrides",
"=",
"{",
"CharField",
":",
"{",
"'widget'",
":",
"forms",
".",
"TextInput",
"(",
"attrs",
"=",
"... | [
130,
4
] | [
145,
55
] | python | en | ['en', 'error', 'th'] | False |
AdminFormfieldForDBFieldTests.test_m2m_widgets | (self) | m2m fields help text as it applies to admin app (#9321). | m2m fields help text as it applies to admin app (#9321). | def test_m2m_widgets(self):
"""m2m fields help text as it applies to admin app (#9321)."""
class AdvisorAdmin(admin.ModelAdmin):
filter_vertical = ['companies']
self.assertFormfield(models.Advisor, 'companies', widgets.FilteredSelectMultiple,
filter_vert... | [
"def",
"test_m2m_widgets",
"(",
"self",
")",
":",
"class",
"AdvisorAdmin",
"(",
"admin",
".",
"ModelAdmin",
")",
":",
"filter_vertical",
"=",
"[",
"'companies'",
"]",
"self",
".",
"assertFormfield",
"(",
"models",
".",
"Advisor",
",",
"'companies'",
",",
"wi... | [
157,
4
] | [
166,
124
] | python | en | ['en', 'lb', 'en'] | True |
AdminDateWidgetTest.test_attrs | (self) |
Ensure that user-supplied attrs are used.
Refs #12073.
|
Ensure that user-supplied attrs are used.
Refs #12073.
| def test_attrs(self):
"""
Ensure that user-supplied attrs are used.
Refs #12073.
"""
w = widgets.AdminDateWidget()
self.assertHTMLEqual(
w.render('test', datetime(2007, 12, 1, 9, 30)),
'<input value="2007-12-01" type="text" class="vDateField" name=... | [
"def",
"test_attrs",
"(",
"self",
")",
":",
"w",
"=",
"widgets",
".",
"AdminDateWidget",
"(",
")",
"self",
".",
"assertHTMLEqual",
"(",
"w",
".",
"render",
"(",
"'test'",
",",
"datetime",
"(",
"2007",
",",
"12",
",",
"1",
",",
"9",
",",
"30",
")",
... | [
265,
4
] | [
280,
9
] | python | en | ['en', 'error', 'th'] | False |
AdminTimeWidgetTest.test_attrs | (self) |
Ensure that user-supplied attrs are used.
Refs #12073.
|
Ensure that user-supplied attrs are used.
Refs #12073.
| def test_attrs(self):
"""
Ensure that user-supplied attrs are used.
Refs #12073.
"""
w = widgets.AdminTimeWidget()
self.assertHTMLEqual(
w.render('test', datetime(2007, 12, 1, 9, 30)),
'<input value="09:30:00" type="text" class="vTimeField" name="t... | [
"def",
"test_attrs",
"(",
"self",
")",
":",
"w",
"=",
"widgets",
".",
"AdminTimeWidget",
"(",
")",
"self",
".",
"assertHTMLEqual",
"(",
"w",
".",
"render",
"(",
"'test'",
",",
"datetime",
"(",
"2007",
",",
"12",
",",
"1",
",",
"9",
",",
"30",
")",
... | [
284,
4
] | [
299,
9
] | python | en | ['en', 'error', 'th'] | False |
Command.get_handler | (self, *args, **options) |
Return the static files serving handler wrapping the default handler,
if static files should be served. Otherwise return the default handler.
|
Return the static files serving handler wrapping the default handler,
if static files should be served. Otherwise return the default handler.
| def get_handler(self, *args, **options):
"""
Return the static files serving handler wrapping the default handler,
if static files should be served. Otherwise return the default handler.
"""
handler = super().get_handler(*args, **options)
use_static_handler = options['use... | [
"def",
"get_handler",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"handler",
"=",
"super",
"(",
")",
".",
"get_handler",
"(",
"*",
"args",
",",
"*",
"*",
"options",
")",
"use_static_handler",
"=",
"options",
"[",
"'use_static_han... | [
21,
4
] | [
31,
22
] | python | en | ['en', 'error', 'th'] | False |
get_version | (package) |
Return package version as listed in `__version__` in `respa/init.py`.
|
Return package version as listed in `__version__` in `respa/init.py`.
| def get_version(package):
'''
Return package version as listed in `__version__` in `respa/init.py`.
'''
init_py = open(os.path.join(package, '__init__.py')).read()
return re.match("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1) | [
"def",
"get_version",
"(",
"package",
")",
":",
"init_py",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"package",
",",
"'__init__.py'",
")",
")",
".",
"read",
"(",
")",
"return",
"re",
".",
"match",
"(",
"\"__version__ = ['\\\"]([^'\\\"]+)['\\\"... | [
6,
0
] | [
11,
74
] | python | en | ['en', 'error', 'th'] | False |
generate_time_series_data | (
days: int = 100,
business_hours_base: float = 10,
non_business_hours_base: float = 10,
growth: float = 1,
autocorrelation: float = 0,
spikiness: float = 1,
holiday_rate: float = 0,
frequency: str = CountStat.DAY,
partial_sum: bool = False,
random_seed: int = 26,
) |
Generate semi-realistic looking time series data for testing analytics graphs.
days -- Number of days of data. Is the number of data points generated if
frequency is CountStat.DAY.
business_hours_base -- Average value during a business hour (or day) at beginning of
time series, if frequenc... |
Generate semi-realistic looking time series data for testing analytics graphs. | def generate_time_series_data(
days: int = 100,
business_hours_base: float = 10,
non_business_hours_base: float = 10,
growth: float = 1,
autocorrelation: float = 0,
spikiness: float = 1,
holiday_rate: float = 0,
frequency: str = CountStat.DAY,
partial_sum: bool = False,
random_se... | [
"def",
"generate_time_series_data",
"(",
"days",
":",
"int",
"=",
"100",
",",
"business_hours_base",
":",
"float",
"=",
"10",
",",
"non_business_hours_base",
":",
"float",
"=",
"10",
",",
"growth",
":",
"float",
"=",
"1",
",",
"autocorrelation",
":",
"float"... | [
7,
0
] | [
78,
38
] | python | en | ['en', 'error', 'th'] | False |
swappable_dependency | (value) | Turn a setting value into a dependency. | Turn a setting value into a dependency. | def swappable_dependency(value):
"""Turn a setting value into a dependency."""
return SwappableTuple((value.split(".", 1)[0], "__first__"), value) | [
"def",
"swappable_dependency",
"(",
"value",
")",
":",
"return",
"SwappableTuple",
"(",
"(",
"value",
".",
"split",
"(",
"\".\"",
",",
"1",
")",
"[",
"0",
"]",
",",
"\"__first__\"",
")",
",",
"value",
")"
] | [
190,
0
] | [
192,
71
] | python | en | ['it', 'en', 'en'] | True |
Migration.mutate_state | (self, project_state, preserve=True) |
Take a ProjectState and return a new one with the migration's
operations applied to it. Preserve the original object state by
default and return a mutated state from a copy.
|
Take a ProjectState and return a new one with the migration's
operations applied to it. Preserve the original object state by
default and return a mutated state from a copy.
| def mutate_state(self, project_state, preserve=True):
"""
Take a ProjectState and return a new one with the migration's
operations applied to it. Preserve the original object state by
default and return a mutated state from a copy.
"""
new_state = project_state
if... | [
"def",
"mutate_state",
"(",
"self",
",",
"project_state",
",",
"preserve",
"=",
"True",
")",
":",
"new_state",
"=",
"project_state",
"if",
"preserve",
":",
"new_state",
"=",
"project_state",
".",
"clone",
"(",
")",
"for",
"operation",
"in",
"self",
".",
"o... | [
75,
4
] | [
87,
24
] | python | en | ['en', 'error', 'th'] | False |
Migration.apply | (self, project_state, schema_editor, collect_sql=False) |
Take a project_state representing all migrations prior to this one
and a schema_editor for a live database and apply the migration
in a forwards order.
Return the resulting project state for efficient reuse by following
Migrations.
|
Take a project_state representing all migrations prior to this one
and a schema_editor for a live database and apply the migration
in a forwards order. | def apply(self, project_state, schema_editor, collect_sql=False):
"""
Take a project_state representing all migrations prior to this one
and a schema_editor for a live database and apply the migration
in a forwards order.
Return the resulting project state for efficient reuse by... | [
"def",
"apply",
"(",
"self",
",",
"project_state",
",",
"schema_editor",
",",
"collect_sql",
"=",
"False",
")",
":",
"for",
"operation",
"in",
"self",
".",
"operations",
":",
"# If this operation cannot be represented as SQL, place a comment",
"# there instead",
"if",
... | [
89,
4
] | [
124,
28
] | python | en | ['en', 'error', 'th'] | False |
Migration.unapply | (self, project_state, schema_editor, collect_sql=False) |
Take a project_state representing all migrations prior to this one
and a schema_editor for a live database and apply the migration
in a reverse order.
The backwards migration process consists of two phases:
1. The intermediate states from right before the first until right
... |
Take a project_state representing all migrations prior to this one
and a schema_editor for a live database and apply the migration
in a reverse order. | def unapply(self, project_state, schema_editor, collect_sql=False):
"""
Take a project_state representing all migrations prior to this one
and a schema_editor for a live database and apply the migration
in a reverse order.
The backwards migration process consists of two phases:
... | [
"def",
"unapply",
"(",
"self",
",",
"project_state",
",",
"schema_editor",
",",
"collect_sql",
"=",
"False",
")",
":",
"# Construct all the intermediate states we need for a reverse migration",
"to_run",
"=",
"[",
"]",
"new_state",
"=",
"project_state",
"# Phase 1",
"fo... | [
126,
4
] | [
175,
28
] | python | en | ['en', 'error', 'th'] | False |
mnist_tutorial_jsma | (
train_start=0,
train_end=60000,
test_start=0,
test_end=10000,
viz_enabled=VIZ_ENABLED,
nb_epochs=NB_EPOCHS,
batch_size=BATCH_SIZE,
source_samples=SOURCE_SAMPLES,
learning_rate=LEARNING_RATE,
) |
MNIST tutorial for the Jacobian-based saliency map approach (JSMA)
:param train_start: index of first training set example
:param train_end: index of last training set example
:param test_start: index of first test set example
:param test_end: index of last test set example
:param viz_enabled: ... |
MNIST tutorial for the Jacobian-based saliency map approach (JSMA)
:param train_start: index of first training set example
:param train_end: index of last training set example
:param test_start: index of first test set example
:param test_end: index of last test set example
:param viz_enabled: ... | def mnist_tutorial_jsma(
train_start=0,
train_end=60000,
test_start=0,
test_end=10000,
viz_enabled=VIZ_ENABLED,
nb_epochs=NB_EPOCHS,
batch_size=BATCH_SIZE,
source_samples=SOURCE_SAMPLES,
learning_rate=LEARNING_RATE,
):
"""
MNIST tutorial for the Jacobian-based saliency map ap... | [
"def",
"mnist_tutorial_jsma",
"(",
"train_start",
"=",
"0",
",",
"train_end",
"=",
"60000",
",",
"test_start",
"=",
"0",
",",
"test_end",
"=",
"10000",
",",
"viz_enabled",
"=",
"VIZ_ENABLED",
",",
"nb_epochs",
"=",
"NB_EPOCHS",
",",
"batch_size",
"=",
"BATCH... | [
36,
0
] | [
235,
17
] | python | en | ['en', 'error', 'th'] | False |
LocalDependencySource.__enter__ | (self) | Determines appropriate path.
Returns:
Path to package root or list of files.
| Determines appropriate path. | def __enter__(self) -> Union[Path, List[Tuple[Path, Optional[Path]]]]:
"""Determines appropriate path.
Returns:
Path to package root or list of files.
"""
return self.path | [
"def",
"__enter__",
"(",
"self",
")",
"->",
"Union",
"[",
"Path",
",",
"List",
"[",
"Tuple",
"[",
"Path",
",",
"Optional",
"[",
"Path",
"]",
"]",
"]",
"]",
":",
"return",
"self",
".",
"path"
] | [
28,
4
] | [
35,
24
] | python | en | ['en', 'en', 'en'] | True |
flatten_dict | (d, tld="") | Flatten the given dict recursively while prepending the upper level key to all the lower level keys separated by a dot (.) | Flatten the given dict recursively while prepending the upper level key to all the lower level keys separated by a dot (.) | def flatten_dict(d, tld="") -> dict:
"""Flatten the given dict recursively while prepending the upper level key to all the lower level keys separated by a dot (.)"""
new_dict = {}
for k, v in d.items():
if isinstance(v, dict):
lower = flatten_dict(v, tld=f"{tld}{k}.")
new_dic... | [
"def",
"flatten_dict",
"(",
"d",
",",
"tld",
"=",
"\"\"",
")",
"->",
"dict",
":",
"new_dict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
"lower",
"=",
"fla... | [
69,
0
] | [
80,
19
] | python | en | ['en', 'en', 'en'] | True |
urlquote | (url, safe='/') |
A legacy compatibility wrapper to Python's urllib.parse.quote() function.
(was used for unicode handling on Python 2)
|
A legacy compatibility wrapper to Python's urllib.parse.quote() function.
(was used for unicode handling on Python 2)
| def urlquote(url, safe='/'):
"""
A legacy compatibility wrapper to Python's urllib.parse.quote() function.
(was used for unicode handling on Python 2)
"""
warnings.warn(
'django.utils.http.urlquote() is deprecated in favor of '
'urllib.parse.quote().',
RemovedInDjango40Warnin... | [
"def",
"urlquote",
"(",
"url",
",",
"safe",
"=",
"'/'",
")",
":",
"warnings",
".",
"warn",
"(",
"'django.utils.http.urlquote() is deprecated in favor of '",
"'urllib.parse.quote().'",
",",
"RemovedInDjango40Warning",
",",
"stacklevel",
"=",
"2",
",",
")",
"return",
... | [
47,
0
] | [
57,
27
] | python | en | ['en', 'error', 'th'] | False |
urlquote_plus | (url, safe='') |
A legacy compatibility wrapper to Python's urllib.parse.quote_plus()
function. (was used for unicode handling on Python 2)
|
A legacy compatibility wrapper to Python's urllib.parse.quote_plus()
function. (was used for unicode handling on Python 2)
| def urlquote_plus(url, safe=''):
"""
A legacy compatibility wrapper to Python's urllib.parse.quote_plus()
function. (was used for unicode handling on Python 2)
"""
warnings.warn(
'django.utils.http.urlquote_plus() is deprecated in favor of '
'urllib.parse.quote_plus(),',
Remo... | [
"def",
"urlquote_plus",
"(",
"url",
",",
"safe",
"=",
"''",
")",
":",
"warnings",
".",
"warn",
"(",
"'django.utils.http.urlquote_plus() is deprecated in favor of '",
"'urllib.parse.quote_plus(),'",
",",
"RemovedInDjango40Warning",
",",
"stacklevel",
"=",
"2",
",",
")",
... | [
61,
0
] | [
71,
32
] | python | en | ['en', 'error', 'th'] | False |
urlunquote | (quoted_url) |
A legacy compatibility wrapper to Python's urllib.parse.unquote() function.
(was used for unicode handling on Python 2)
|
A legacy compatibility wrapper to Python's urllib.parse.unquote() function.
(was used for unicode handling on Python 2)
| def urlunquote(quoted_url):
"""
A legacy compatibility wrapper to Python's urllib.parse.unquote() function.
(was used for unicode handling on Python 2)
"""
warnings.warn(
'django.utils.http.urlunquote() is deprecated in favor of '
'urllib.parse.unquote().',
RemovedInDjango40W... | [
"def",
"urlunquote",
"(",
"quoted_url",
")",
":",
"warnings",
".",
"warn",
"(",
"'django.utils.http.urlunquote() is deprecated in favor of '",
"'urllib.parse.unquote().'",
",",
"RemovedInDjango40Warning",
",",
"stacklevel",
"=",
"2",
",",
")",
"return",
"unquote",
"(",
... | [
75,
0
] | [
85,
30
] | python | en | ['en', 'error', 'th'] | False |
urlunquote_plus | (quoted_url) |
A legacy compatibility wrapper to Python's urllib.parse.unquote_plus()
function. (was used for unicode handling on Python 2)
|
A legacy compatibility wrapper to Python's urllib.parse.unquote_plus()
function. (was used for unicode handling on Python 2)
| def urlunquote_plus(quoted_url):
"""
A legacy compatibility wrapper to Python's urllib.parse.unquote_plus()
function. (was used for unicode handling on Python 2)
"""
warnings.warn(
'django.utils.http.urlunquote_plus() is deprecated in favor of '
'urllib.parse.unquote_plus().',
... | [
"def",
"urlunquote_plus",
"(",
"quoted_url",
")",
":",
"warnings",
".",
"warn",
"(",
"'django.utils.http.urlunquote_plus() is deprecated in favor of '",
"'urllib.parse.unquote_plus().'",
",",
"RemovedInDjango40Warning",
",",
"stacklevel",
"=",
"2",
",",
")",
"return",
"unqu... | [
89,
0
] | [
99,
35
] | python | en | ['en', 'error', 'th'] | False |
urlencode | (query, doseq=False) |
A version of Python's urllib.parse.urlencode() function that can operate on
MultiValueDict and non-string values.
|
A version of Python's urllib.parse.urlencode() function that can operate on
MultiValueDict and non-string values.
| def urlencode(query, doseq=False):
"""
A version of Python's urllib.parse.urlencode() function that can operate on
MultiValueDict and non-string values.
"""
if isinstance(query, MultiValueDict):
query = query.lists()
elif hasattr(query, 'items'):
query = query.items()
query_p... | [
"def",
"urlencode",
"(",
"query",
",",
"doseq",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"query",
",",
"MultiValueDict",
")",
":",
"query",
"=",
"query",
".",
"lists",
"(",
")",
"elif",
"hasattr",
"(",
"query",
",",
"'items'",
")",
":",
"quer... | [
102,
0
] | [
140,
50
] | python | en | ['en', 'error', 'th'] | False |
http_date | (epoch_seconds=None) |
Format the time to match the RFC1123 date format as specified by HTTP
RFC7231 section 7.1.1.1.
`epoch_seconds` is a floating point number expressed in seconds since the
epoch, in UTC - such as that outputted by time.time(). If set to None, it
defaults to the current time.
Output a string in t... |
Format the time to match the RFC1123 date format as specified by HTTP
RFC7231 section 7.1.1.1. | def http_date(epoch_seconds=None):
"""
Format the time to match the RFC1123 date format as specified by HTTP
RFC7231 section 7.1.1.1.
`epoch_seconds` is a floating point number expressed in seconds since the
epoch, in UTC - such as that outputted by time.time(). If set to None, it
defaults to t... | [
"def",
"http_date",
"(",
"epoch_seconds",
"=",
"None",
")",
":",
"return",
"formatdate",
"(",
"epoch_seconds",
",",
"usegmt",
"=",
"True",
")"
] | [
143,
0
] | [
154,
49
] | python | en | ['en', 'error', 'th'] | False |
parse_http_date | (date) |
Parse a date format as specified by HTTP RFC7231 section 7.1.1.1.
The three formats allowed by the RFC are accepted, even if only the first
one is still in widespread use.
Return an integer expressed in seconds since the epoch, in UTC.
|
Parse a date format as specified by HTTP RFC7231 section 7.1.1.1. | def parse_http_date(date):
"""
Parse a date format as specified by HTTP RFC7231 section 7.1.1.1.
The three formats allowed by the RFC are accepted, even if only the first
one is still in widespread use.
Return an integer expressed in seconds since the epoch, in UTC.
"""
# email.utils.parse... | [
"def",
"parse_http_date",
"(",
"date",
")",
":",
"# email.utils.parsedate() does the job for RFC1123 dates; unfortunately",
"# RFC7231 makes it mandatory to support RFC850 dates too. So we roll",
"# our own RFC-compliant parsing.",
"for",
"regex",
"in",
"RFC1123_DATE",
",",
"RFC850_DATE"... | [
157,
0
] | [
194,
66
] | python | en | ['en', 'error', 'th'] | False |
parse_http_date_safe | (date) |
Same as parse_http_date, but return None if the input is invalid.
|
Same as parse_http_date, but return None if the input is invalid.
| def parse_http_date_safe(date):
"""
Same as parse_http_date, but return None if the input is invalid.
"""
try:
return parse_http_date(date)
except Exception:
pass | [
"def",
"parse_http_date_safe",
"(",
"date",
")",
":",
"try",
":",
"return",
"parse_http_date",
"(",
"date",
")",
"except",
"Exception",
":",
"pass"
] | [
197,
0
] | [
204,
12
] | python | en | ['en', 'error', 'th'] | False |
base36_to_int | (s) |
Convert a base 36 string to an int. Raise ValueError if the input won't fit
into an int.
|
Convert a base 36 string to an int. Raise ValueError if the input won't fit
into an int.
| def base36_to_int(s):
"""
Convert a base 36 string to an int. Raise ValueError if the input won't fit
into an int.
"""
# To prevent overconsumption of server resources, reject any
# base36 string that is longer than 13 base36 digits (13 digits
# is sufficient to base36-encode any 64-bit inte... | [
"def",
"base36_to_int",
"(",
"s",
")",
":",
"# To prevent overconsumption of server resources, reject any",
"# base36 string that is longer than 13 base36 digits (13 digits",
"# is sufficient to base36-encode any 64-bit integer)",
"if",
"len",
"(",
"s",
")",
">",
"13",
":",
"raise"... | [
209,
0
] | [
219,
21
] | python | en | ['en', 'error', 'th'] | False |
int_to_base36 | (i) | Convert an integer to a base36 string. | Convert an integer to a base36 string. | def int_to_base36(i):
"""Convert an integer to a base36 string."""
char_set = '0123456789abcdefghijklmnopqrstuvwxyz'
if i < 0:
raise ValueError("Negative base36 conversion input.")
if i < 36:
return char_set[i]
b36 = ''
while i != 0:
i, n = divmod(i, 36)
b36 = cha... | [
"def",
"int_to_base36",
"(",
"i",
")",
":",
"char_set",
"=",
"'0123456789abcdefghijklmnopqrstuvwxyz'",
"if",
"i",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"Negative base36 conversion input.\"",
")",
"if",
"i",
"<",
"36",
":",
"return",
"char_set",
"[",
"i",
... | [
222,
0
] | [
233,
14
] | python | en | ['en', 'lb', 'en'] | True |
urlsafe_base64_encode | (s) |
Encode a bytestring to a base64 string for use in URLs. Strip any trailing
equal signs.
|
Encode a bytestring to a base64 string for use in URLs. Strip any trailing
equal signs.
| def urlsafe_base64_encode(s):
"""
Encode a bytestring to a base64 string for use in URLs. Strip any trailing
equal signs.
"""
return base64.urlsafe_b64encode(s).rstrip(b'\n=').decode('ascii') | [
"def",
"urlsafe_base64_encode",
"(",
"s",
")",
":",
"return",
"base64",
".",
"urlsafe_b64encode",
"(",
"s",
")",
".",
"rstrip",
"(",
"b'\\n='",
")",
".",
"decode",
"(",
"'ascii'",
")"
] | [
236,
0
] | [
241,
69
] | python | en | ['en', 'error', 'th'] | False |
urlsafe_base64_decode | (s) |
Decode a base64 encoded string. Add back any trailing equal signs that
might have been stripped.
|
Decode a base64 encoded string. Add back any trailing equal signs that
might have been stripped.
| def urlsafe_base64_decode(s):
"""
Decode a base64 encoded string. Add back any trailing equal signs that
might have been stripped.
"""
s = s.encode()
try:
return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'='))
except (LookupError, BinasciiError) as e:
raise Value... | [
"def",
"urlsafe_base64_decode",
"(",
"s",
")",
":",
"s",
"=",
"s",
".",
"encode",
"(",
")",
"try",
":",
"return",
"base64",
".",
"urlsafe_b64decode",
"(",
"s",
".",
"ljust",
"(",
"len",
"(",
"s",
")",
"+",
"len",
"(",
"s",
")",
"%",
"4",
",",
"... | [
244,
0
] | [
253,
27
] | python | en | ['en', 'error', 'th'] | False |
parse_etags | (etag_str) |
Parse a string of ETags given in an If-None-Match or If-Match header as
defined by RFC 7232. Return a list of quoted ETags, or ['*'] if all ETags
should be matched.
|
Parse a string of ETags given in an If-None-Match or If-Match header as
defined by RFC 7232. Return a list of quoted ETags, or ['*'] if all ETags
should be matched.
| def parse_etags(etag_str):
"""
Parse a string of ETags given in an If-None-Match or If-Match header as
defined by RFC 7232. Return a list of quoted ETags, or ['*'] if all ETags
should be matched.
"""
if etag_str.strip() == '*':
return ['*']
else:
# Parse each ETag individuall... | [
"def",
"parse_etags",
"(",
"etag_str",
")",
":",
"if",
"etag_str",
".",
"strip",
"(",
")",
"==",
"'*'",
":",
"return",
"[",
"'*'",
"]",
"else",
":",
"# Parse each ETag individually, and return any that are valid.",
"etag_matches",
"=",
"(",
"ETAG_MATCH",
".",
"m... | [
256,
0
] | [
267,
66
] | python | en | ['en', 'error', 'th'] | False |
quote_etag | (etag_str) |
If the provided string is already a quoted ETag, return it. Otherwise, wrap
the string in quotes, making it a strong ETag.
|
If the provided string is already a quoted ETag, return it. Otherwise, wrap
the string in quotes, making it a strong ETag.
| def quote_etag(etag_str):
"""
If the provided string is already a quoted ETag, return it. Otherwise, wrap
the string in quotes, making it a strong ETag.
"""
if ETAG_MATCH.match(etag_str):
return etag_str
else:
return '"%s"' % etag_str | [
"def",
"quote_etag",
"(",
"etag_str",
")",
":",
"if",
"ETAG_MATCH",
".",
"match",
"(",
"etag_str",
")",
":",
"return",
"etag_str",
"else",
":",
"return",
"'\"%s\"'",
"%",
"etag_str"
] | [
270,
0
] | [
278,
32
] | python | en | ['en', 'error', 'th'] | False |
is_same_domain | (host, pattern) |
Return ``True`` if the host is either an exact match or a match
to the wildcard pattern.
Any pattern beginning with a period matches a domain and all of its
subdomains. (e.g. ``.example.com`` matches ``example.com`` and
``foo.example.com``). Anything else is an exact string match.
|
Return ``True`` if the host is either an exact match or a match
to the wildcard pattern. | def is_same_domain(host, pattern):
"""
Return ``True`` if the host is either an exact match or a match
to the wildcard pattern.
Any pattern beginning with a period matches a domain and all of its
subdomains. (e.g. ``.example.com`` matches ``example.com`` and
``foo.example.com``). Anything else ... | [
"def",
"is_same_domain",
"(",
"host",
",",
"pattern",
")",
":",
"if",
"not",
"pattern",
":",
"return",
"False",
"pattern",
"=",
"pattern",
".",
"lower",
"(",
")",
"return",
"(",
"pattern",
"[",
"0",
"]",
"==",
"'.'",
"and",
"(",
"host",
".",
"endswit... | [
281,
0
] | [
297,
5
] | python | en | ['en', 'error', 'th'] | False |
url_has_allowed_host_and_scheme | (url, allowed_hosts, require_https=False) |
Return ``True`` if the url uses an allowed host and a safe scheme.
Always return ``False`` on an empty url.
If ``require_https`` is ``True``, only 'https' will be considered a valid
scheme, as opposed to 'http' and 'https' with the default, ``False``.
Note: "True" doesn't entail that a URL is "s... |
Return ``True`` if the url uses an allowed host and a safe scheme. | def url_has_allowed_host_and_scheme(url, allowed_hosts, require_https=False):
"""
Return ``True`` if the url uses an allowed host and a safe scheme.
Always return ``False`` on an empty url.
If ``require_https`` is ``True``, only 'https' will be considered a valid
scheme, as opposed to 'http' and '... | [
"def",
"url_has_allowed_host_and_scheme",
"(",
"url",
",",
"allowed_hosts",
",",
"require_https",
"=",
"False",
")",
":",
"if",
"url",
"is",
"not",
"None",
":",
"url",
"=",
"url",
".",
"strip",
"(",
")",
"if",
"not",
"url",
":",
"return",
"False",
"if",
... | [
300,
0
] | [
326,
5
] | python | en | ['en', 'error', 'th'] | False |
_urlparse | (url, scheme='', allow_fragments=True) | Parse a URL into 6 components:
<scheme>://<netloc>/<path>;<params>?<query>#<fragment>
Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't expand % escapes. | Parse a URL into 6 components:
<scheme>://<netloc>/<path>;<params>?<query>#<fragment>
Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't expand % escapes. | def _urlparse(url, scheme='', allow_fragments=True):
"""Parse a URL into 6 components:
<scheme>://<netloc>/<path>;<params>?<query>#<fragment>
Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string)... | [
"def",
"_urlparse",
"(",
"url",
",",
"scheme",
"=",
"''",
",",
"allow_fragments",
"=",
"True",
")",
":",
"url",
",",
"scheme",
",",
"_coerce_result",
"=",
"_coerce_args",
"(",
"url",
",",
"scheme",
")",
"splitresult",
"=",
"_urlsplit",
"(",
"url",
",",
... | [
339,
0
] | [
353,
33
] | python | en | ['en', 'en', 'en'] | True |
_urlsplit | (url, scheme='', allow_fragments=True) | Parse a URL into 5 components:
<scheme>://<netloc>/<path>?<query>#<fragment>
Return a 5-tuple: (scheme, netloc, path, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't expand % escapes. | Parse a URL into 5 components:
<scheme>://<netloc>/<path>?<query>#<fragment>
Return a 5-tuple: (scheme, netloc, path, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't expand % escapes. | def _urlsplit(url, scheme='', allow_fragments=True):
"""Parse a URL into 5 components:
<scheme>://<netloc>/<path>?<query>#<fragment>
Return a 5-tuple: (scheme, netloc, path, query, fragment).
Note that we don't break the components up in smaller bits
(e.g. netloc is a single string) and we don't exp... | [
"def",
"_urlsplit",
"(",
"url",
",",
"scheme",
"=",
"''",
",",
"allow_fragments",
"=",
"True",
")",
":",
"url",
",",
"scheme",
",",
"_coerce_result",
"=",
"_coerce_args",
"(",
"url",
",",
"scheme",
")",
"netloc",
"=",
"query",
"=",
"fragment",
"=",
"''... | [
358,
0
] | [
384,
28
] | python | en | ['en', 'en', 'en'] | True |
limited_parse_qsl | (qs, keep_blank_values=False, encoding='utf-8',
errors='replace', fields_limit=None) |
Return a list of key/value tuples parsed from query string.
Copied from urlparse with an additional "fields_limit" argument.
Copyright (C) 2013 Python Software Foundation (see LICENSE.python).
Arguments:
qs: percent-encoded query string to be parsed
keep_blank_values: flag indicating whethe... |
Return a list of key/value tuples parsed from query string. | def limited_parse_qsl(qs, keep_blank_values=False, encoding='utf-8',
errors='replace', fields_limit=None):
"""
Return a list of key/value tuples parsed from query string.
Copied from urlparse with an additional "fields_limit" argument.
Copyright (C) 2013 Python Software Foundation... | [
"def",
"limited_parse_qsl",
"(",
"qs",
",",
"keep_blank_values",
"=",
"False",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'replace'",
",",
"fields_limit",
"=",
"None",
")",
":",
"if",
"fields_limit",
":",
"pairs",
"=",
"FIELDS_MATCH",
".",
"split"... | [
416,
0
] | [
466,
12
] | python | en | ['en', 'error', 'th'] | False |
escape_leading_slashes | (url) |
If redirecting to an absolute path (two leading slashes), a slash must be
escaped to prevent browsers from handling the path as schemaless and
redirecting to another host.
|
If redirecting to an absolute path (two leading slashes), a slash must be
escaped to prevent browsers from handling the path as schemaless and
redirecting to another host.
| def escape_leading_slashes(url):
"""
If redirecting to an absolute path (two leading slashes), a slash must be
escaped to prevent browsers from handling the path as schemaless and
redirecting to another host.
"""
if url.startswith('//'):
url = '/%2F{}'.format(url[2:])
return url | [
"def",
"escape_leading_slashes",
"(",
"url",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"'//'",
")",
":",
"url",
"=",
"'/%2F{}'",
".",
"format",
"(",
"url",
"[",
"2",
":",
"]",
")",
"return",
"url"
] | [
469,
0
] | [
477,
14
] | python | en | ['en', 'error', 'th'] | False |
_download | (url, filename) | Download a url to a file in the JAX data temp directory. | Download a url to a file in the JAX data temp directory. | def _download(url, filename):
"""Download a url to a file in the JAX data temp directory."""
if not path.exists(_DATA):
os.makedirs(_DATA)
out_file = path.join(_DATA, filename)
if not path.isfile(out_file):
urlretrieve(url, out_file)
print("downloaded {} to {}".format(url, _DATA)... | [
"def",
"_download",
"(",
"url",
",",
"filename",
")",
":",
"if",
"not",
"path",
".",
"exists",
"(",
"_DATA",
")",
":",
"os",
".",
"makedirs",
"(",
"_DATA",
")",
"out_file",
"=",
"path",
".",
"join",
"(",
"_DATA",
",",
"filename",
")",
"if",
"not",
... | [
35,
0
] | [
42,
55
] | python | en | ['en', 'en', 'en'] | True |
mnist_raw | () | Download and parse the raw MNIST dataset. | Download and parse the raw MNIST dataset. | def mnist_raw():
"""Download and parse the raw MNIST dataset."""
# CVDF mirror of http://yann.lecun.com/exdb/mnist/
base_url = "https://storage.googleapis.com/cvdf-datasets/mnist/"
def parse_labels(filename):
with gzip.open(filename, "rb") as fh:
_ = struct.unpack(">II", fh.read(8))... | [
"def",
"mnist_raw",
"(",
")",
":",
"# CVDF mirror of http://yann.lecun.com/exdb/mnist/",
"base_url",
"=",
"\"https://storage.googleapis.com/cvdf-datasets/mnist/\"",
"def",
"parse_labels",
"(",
"filename",
")",
":",
"with",
"gzip",
".",
"open",
"(",
"filename",
",",
"\"rb\... | [
45,
0
] | [
75,
63
] | python | en | ['en', 'en', 'en'] | True |
mnist | (permute_train=False) | Download, parse and process MNIST data to unit scale and one-hot labels. | Download, parse and process MNIST data to unit scale and one-hot labels. | def mnist(permute_train=False):
"""Download, parse and process MNIST data to unit scale and one-hot labels."""
train_images, train_labels, test_images, test_labels = mnist_raw()
train_images = partial_flatten(train_images) / np.float32(255.0)
test_images = partial_flatten(test_images) / np.float32(255.... | [
"def",
"mnist",
"(",
"permute_train",
"=",
"False",
")",
":",
"train_images",
",",
"train_labels",
",",
"test_images",
",",
"test_labels",
"=",
"mnist_raw",
"(",
")",
"train_images",
"=",
"partial_flatten",
"(",
"train_images",
")",
"/",
"np",
".",
"float32",
... | [
78,
0
] | [
92,
63
] | python | en | ['en', 'en', 'en'] | True |
bdist_wininst.reinitialize_command | (self, command, reinit_subcommands=0) |
Supplement reinitialize_command to work around
http://bugs.python.org/issue20819
|
Supplement reinitialize_command to work around
http://bugs.python.org/issue20819
| def reinitialize_command(self, command, reinit_subcommands=0):
"""
Supplement reinitialize_command to work around
http://bugs.python.org/issue20819
"""
cmd = self.distribution.reinitialize_command(
command, reinit_subcommands)
if command in ('install', 'instal... | [
"def",
"reinitialize_command",
"(",
"self",
",",
"command",
",",
"reinit_subcommands",
"=",
"0",
")",
":",
"cmd",
"=",
"self",
".",
"distribution",
".",
"reinitialize_command",
"(",
"command",
",",
"reinit_subcommands",
")",
"if",
"command",
"in",
"(",
"'insta... | [
7,
4
] | [
16,
18
] | python | en | ['en', 'error', 'th'] | False |
Engine.get_default | () |
Return the first DjangoTemplates backend that's configured, or raise
ImproperlyConfigured if none are configured.
This is required for preserving historical APIs that rely on a
globally available, implicitly configured engine such as:
>>> from django.template import Context, T... |
Return the first DjangoTemplates backend that's configured, or raise
ImproperlyConfigured if none are configured. | def get_default():
"""
Return the first DjangoTemplates backend that's configured, or raise
ImproperlyConfigured if none are configured.
This is required for preserving historical APIs that rely on a
globally available, implicitly configured engine such as:
>>> from dja... | [
"def",
"get_default",
"(",
")",
":",
"# Since Engine is imported in django.template and since",
"# DjangoTemplates is a wrapper around this Engine class,",
"# local imports are required to avoid import loops.",
"from",
"django",
".",
"template",
"import",
"engines",
"from",
"django",
... | [
56,
4
] | [
78,
79
] | python | en | ['en', 'error', 'th'] | False |
Engine.from_string | (self, template_code) |
Return a compiled Template object for the given template code,
handling template inheritance recursively.
|
Return a compiled Template object for the given template code,
handling template inheritance recursively.
| def from_string(self, template_code):
"""
Return a compiled Template object for the given template code,
handling template inheritance recursively.
"""
return Template(template_code, engine=self) | [
"def",
"from_string",
"(",
"self",
",",
"template_code",
")",
":",
"return",
"Template",
"(",
"template_code",
",",
"engine",
"=",
"self",
")"
] | [
130,
4
] | [
135,
51
] | python | en | ['en', 'error', 'th'] | False |
Engine.get_template | (self, template_name) |
Return a compiled Template object for the given template name,
handling template inheritance recursively.
|
Return a compiled Template object for the given template name,
handling template inheritance recursively.
| def get_template(self, template_name):
"""
Return a compiled Template object for the given template name,
handling template inheritance recursively.
"""
template, origin = self.find_template(template_name)
if not hasattr(template, 'render'):
# template needs t... | [
"def",
"get_template",
"(",
"self",
",",
"template_name",
")",
":",
"template",
",",
"origin",
"=",
"self",
".",
"find_template",
"(",
"template_name",
")",
"if",
"not",
"hasattr",
"(",
"template",
",",
"'render'",
")",
":",
"# template needs to be compiled",
... | [
137,
4
] | [
146,
23
] | python | en | ['en', 'error', 'th'] | False |
Engine.render_to_string | (self, template_name, context=None) |
Render the template specified by template_name with the given context.
For use in Django's test suite.
|
Render the template specified by template_name with the given context.
For use in Django's test suite.
| def render_to_string(self, template_name, context=None):
"""
Render the template specified by template_name with the given context.
For use in Django's test suite.
"""
if isinstance(template_name, (list, tuple)):
t = self.select_template(template_name)
else:
... | [
"def",
"render_to_string",
"(",
"self",
",",
"template_name",
",",
"context",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"template_name",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"t",
"=",
"self",
".",
"select_template",
"(",
"template_name",
... | [
148,
4
] | [
162,
73
] | python | en | ['en', 'error', 'th'] | False |
Engine.select_template | (self, template_name_list) |
Given a list of template names, return the first that can be loaded.
|
Given a list of template names, return the first that can be loaded.
| def select_template(self, template_name_list):
"""
Given a list of template names, return the first that can be loaded.
"""
if not template_name_list:
raise TemplateDoesNotExist("No template names provided")
not_found = []
for template_name in template_name_li... | [
"def",
"select_template",
"(",
"self",
",",
"template_name_list",
")",
":",
"if",
"not",
"template_name_list",
":",
"raise",
"TemplateDoesNotExist",
"(",
"\"No template names provided\"",
")",
"not_found",
"=",
"[",
"]",
"for",
"template_name",
"in",
"template_name_li... | [
164,
4
] | [
179,
56
] | python | en | ['en', 'error', 'th'] | False |
TestUtilsHtml.check_output | (self, function, value, output=None) |
Check that function(value) equals output. If output is None,
check that function(value) equals value.
|
Check that function(value) equals output. If output is None,
check that function(value) equals value.
| def check_output(self, function, value, output=None):
"""
Check that function(value) equals output. If output is None,
check that function(value) equals value.
"""
if output is None:
output = value
self.assertEqual(function(value), output) | [
"def",
"check_output",
"(",
"self",
",",
"function",
",",
"value",
",",
"output",
"=",
"None",
")",
":",
"if",
"output",
"is",
"None",
":",
"output",
"=",
"value",
"self",
".",
"assertEqual",
"(",
"function",
"(",
"value",
")",
",",
"output",
")"
] | [
15,
4
] | [
22,
49
] | python | en | ['en', 'error', 'th'] | False |
ExceptionReporterTests.test_request_and_exception | (self) | A simple exception report can be generated | A simple exception report can be generated | def test_request_and_exception(self):
"A simple exception report can be generated"
try:
request = self.rf.get('/test_view/')
raise ValueError("Can't find my keys")
except ValueError:
exc_type, exc_value, tb = sys.exc_info()
reporter = ExceptionReporter... | [
"def",
"test_request_and_exception",
"(",
"self",
")",
":",
"try",
":",
"request",
"=",
"self",
".",
"rf",
".",
"get",
"(",
"'/test_view/'",
")",
"raise",
"ValueError",
"(",
"\"Can't find my keys\"",
")",
"except",
"ValueError",
":",
"exc_type",
",",
"exc_valu... | [
206,
4
] | [
223,
66
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReporterTests.test_no_request | (self) | An exception report can be generated without request | An exception report can be generated without request | def test_no_request(self):
"An exception report can be generated without request"
try:
raise ValueError("Can't find my keys")
except ValueError:
exc_type, exc_value, tb = sys.exc_info()
reporter = ExceptionReporter(None, exc_type, exc_value, tb)
html = rep... | [
"def",
"test_no_request",
"(",
"self",
")",
":",
"try",
":",
"raise",
"ValueError",
"(",
"\"Can't find my keys\"",
")",
"except",
"ValueError",
":",
"exc_type",
",",
"exc_value",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"reporter",
"=",
"ExceptionRe... | [
225,
4
] | [
241,
63
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReporterTests.test_eol_support | (self) | Test that the ExceptionReporter supports Unix, Windows and Macintosh EOL markers | Test that the ExceptionReporter supports Unix, Windows and Macintosh EOL markers | def test_eol_support(self):
"""Test that the ExceptionReporter supports Unix, Windows and Macintosh EOL markers"""
LINES = list('print %d' % i for i in range(1, 6))
reporter = ExceptionReporter(None, None, None, None)
for newline in ['\n', '\r\n', '\r']:
fd, filename = mkste... | [
"def",
"test_eol_support",
"(",
"self",
")",
":",
"LINES",
"=",
"list",
"(",
"'print %d'",
"%",
"i",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"6",
")",
")",
"reporter",
"=",
"ExceptionReporter",
"(",
"None",
",",
"None",
",",
"None",
",",
"None",
... | [
243,
4
] | [
259,
35
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReporterTests.test_no_exception | (self) | An exception report can be generated for just a request | An exception report can be generated for just a request | def test_no_exception(self):
"An exception report can be generated for just a request"
request = self.rf.get('/test_view/')
reporter = ExceptionReporter(request, None, None, None)
html = reporter.get_traceback_html()
self.assertIn('<h1>Report at /test_view/</h1>', html)
s... | [
"def",
"test_no_exception",
"(",
"self",
")",
":",
"request",
"=",
"self",
".",
"rf",
".",
"get",
"(",
"'/test_view/'",
")",
"reporter",
"=",
"ExceptionReporter",
"(",
"request",
",",
"None",
",",
"None",
",",
"None",
")",
"html",
"=",
"reporter",
".",
... | [
261,
4
] | [
274,
66
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReporterTests.test_request_and_message | (self) | A message can be provided in addition to a request | A message can be provided in addition to a request | def test_request_and_message(self):
"A message can be provided in addition to a request"
request = self.rf.get('/test_view/')
reporter = ExceptionReporter(request, None, "I'm a little teapot", None)
html = reporter.get_traceback_html()
self.assertIn('<h1>Report at /test_view/</h1... | [
"def",
"test_request_and_message",
"(",
"self",
")",
":",
"request",
"=",
"self",
".",
"rf",
".",
"get",
"(",
"'/test_view/'",
")",
"reporter",
"=",
"ExceptionReporter",
"(",
"request",
",",
"None",
",",
"\"I'm a little teapot\"",
",",
"None",
")",
"html",
"... | [
276,
4
] | [
289,
66
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReporterTests.test_non_utf8_values_handling | (self) | Non-UTF-8 exceptions/values should not make the output generation choke. | Non-UTF-8 exceptions/values should not make the output generation choke. | def test_non_utf8_values_handling(self):
"Non-UTF-8 exceptions/values should not make the output generation choke."
try:
class NonUtf8Output(Exception):
def __repr__(self):
return b'EXC\xe9EXC'
somevar = b'VAL\xe9VAL' # NOQA
raise ... | [
"def",
"test_non_utf8_values_handling",
"(",
"self",
")",
":",
"try",
":",
"class",
"NonUtf8Output",
"(",
"Exception",
")",
":",
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"b'EXC\\xe9EXC'",
"somevar",
"=",
"b'VAL\\xe9VAL'",
"# NOQA",
"raise",
"NonUtf8Ou... | [
304,
4
] | [
317,
42
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReporterTests.test_unprintable_values_handling | (self) | Unprintable values should not make the output generation choke. | Unprintable values should not make the output generation choke. | def test_unprintable_values_handling(self):
"Unprintable values should not make the output generation choke."
try:
class OomOutput(object):
def __repr__(self):
raise MemoryError('OOM')
oomvalue = OomOutput() # NOQA
raise ValueError... | [
"def",
"test_unprintable_values_handling",
"(",
"self",
")",
":",
"try",
":",
"class",
"OomOutput",
"(",
"object",
")",
":",
"def",
"__repr__",
"(",
"self",
")",
":",
"raise",
"MemoryError",
"(",
"'OOM'",
")",
"oomvalue",
"=",
"OomOutput",
"(",
")",
"# NOQ... | [
319,
4
] | [
331,
72
] | python | en | ['en', 'st', 'en'] | True |
ExceptionReporterTests.test_too_large_values_handling | (self) | Large values should not create a large HTML. | Large values should not create a large HTML. | def test_too_large_values_handling(self):
"Large values should not create a large HTML."
large = 256 * 1024
repr_of_str_adds = len(repr(''))
try:
class LargeOutput(object):
def __repr__(self):
return repr('A' * large)
largevalue... | [
"def",
"test_too_large_values_handling",
"(",
"self",
")",
":",
"large",
"=",
"256",
"*",
"1024",
"repr_of_str_adds",
"=",
"len",
"(",
"repr",
"(",
"''",
")",
")",
"try",
":",
"class",
"LargeOutput",
"(",
"object",
")",
":",
"def",
"__repr__",
"(",
"self... | [
333,
4
] | [
348,
92
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReporterTests.test_unfrozen_importlib | (self) |
importlib is not a frozen app, but its loader thinks it's frozen which
results in an ImportError on Python 3. Refs #21443.
|
importlib is not a frozen app, but its loader thinks it's frozen which
results in an ImportError on Python 3. Refs #21443.
| def test_unfrozen_importlib(self):
"""
importlib is not a frozen app, but its loader thinks it's frozen which
results in an ImportError on Python 3. Refs #21443.
"""
try:
request = self.rf.get('/test_view/')
importlib.import_module('abc.def.invalid.name')
... | [
"def",
"test_unfrozen_importlib",
"(",
"self",
")",
":",
"try",
":",
"request",
"=",
"self",
".",
"rf",
".",
"get",
"(",
"'/test_view/'",
")",
"importlib",
".",
"import_module",
"(",
"'abc.def.invalid.name'",
")",
"except",
"Exception",
":",
"exc_type",
",",
... | [
351,
4
] | [
363,
66
] | python | en | ['en', 'error', 'th'] | False |
PlainTextReportTests.test_request_and_exception | (self) | A simple exception report can be generated | A simple exception report can be generated | def test_request_and_exception(self):
"A simple exception report can be generated"
try:
request = self.rf.get('/test_view/')
raise ValueError("Can't find my keys")
except ValueError:
exc_type, exc_value, tb = sys.exc_info()
reporter = ExceptionReporter... | [
"def",
"test_request_and_exception",
"(",
"self",
")",
":",
"try",
":",
"request",
"=",
"self",
".",
"rf",
".",
"get",
"(",
"'/test_view/'",
")",
"raise",
"ValueError",
"(",
"\"Can't find my keys\"",
")",
"except",
"ValueError",
":",
"exc_type",
",",
"exc_valu... | [
369,
4
] | [
386,
59
] | python | en | ['en', 'en', 'en'] | True |
PlainTextReportTests.test_no_request | (self) | An exception report can be generated without request | An exception report can be generated without request | def test_no_request(self):
"An exception report can be generated without request"
try:
raise ValueError("Can't find my keys")
except ValueError:
exc_type, exc_value, tb = sys.exc_info()
reporter = ExceptionReporter(None, exc_type, exc_value, tb)
text = rep... | [
"def",
"test_no_request",
"(",
"self",
")",
":",
"try",
":",
"raise",
"ValueError",
"(",
"\"Can't find my keys\"",
")",
"except",
"ValueError",
":",
"exc_type",
",",
"exc_value",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"reporter",
"=",
"ExceptionRe... | [
388,
4
] | [
403,
56
] | python | en | ['en', 'en', 'en'] | True |
PlainTextReportTests.test_no_exception | (self) | An exception report can be generated for just a request | An exception report can be generated for just a request | def test_no_exception(self):
"An exception report can be generated for just a request"
request = self.rf.get('/test_view/')
reporter = ExceptionReporter(request, None, None, None)
reporter.get_traceback_text() | [
"def",
"test_no_exception",
"(",
"self",
")",
":",
"request",
"=",
"self",
".",
"rf",
".",
"get",
"(",
"'/test_view/'",
")",
"reporter",
"=",
"ExceptionReporter",
"(",
"request",
",",
"None",
",",
"None",
",",
"None",
")",
"reporter",
".",
"get_traceback_t... | [
405,
4
] | [
409,
37
] | python | en | ['en', 'en', 'en'] | True |
PlainTextReportTests.test_request_and_message | (self) | A message can be provided in addition to a request | A message can be provided in addition to a request | def test_request_and_message(self):
"A message can be provided in addition to a request"
request = self.rf.get('/test_view/')
reporter = ExceptionReporter(request, None, "I'm a little teapot", None)
reporter.get_traceback_text() | [
"def",
"test_request_and_message",
"(",
"self",
")",
":",
"request",
"=",
"self",
".",
"rf",
".",
"get",
"(",
"'/test_view/'",
")",
"reporter",
"=",
"ExceptionReporter",
"(",
"request",
",",
"None",
",",
"\"I'm a little teapot\"",
",",
"None",
")",
"reporter",... | [
411,
4
] | [
415,
37
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReportTestMixin.verify_unsafe_response | (self, view, check_for_vars=True,
check_for_POST_params=True) |
Asserts that potentially sensitive info are displayed in the response.
|
Asserts that potentially sensitive info are displayed in the response.
| def verify_unsafe_response(self, view, check_for_vars=True,
check_for_POST_params=True):
"""
Asserts that potentially sensitive info are displayed in the response.
"""
request = self.rf.post('/some_url/', self.breakfast_data)
response = view(request... | [
"def",
"verify_unsafe_response",
"(",
"self",
",",
"view",
",",
"check_for_vars",
"=",
"True",
",",
"check_for_POST_params",
"=",
"True",
")",
":",
"request",
"=",
"self",
".",
"rf",
".",
"post",
"(",
"'/some_url/'",
",",
"self",
".",
"breakfast_data",
")",
... | [
432,
4
] | [
449,
65
] | python | en | ['en', 'error', 'th'] | False |
ExceptionReportTestMixin.verify_safe_response | (self, view, check_for_vars=True,
check_for_POST_params=True) |
Asserts that certain sensitive info are not displayed in the response.
|
Asserts that certain sensitive info are not displayed in the response.
| def verify_safe_response(self, view, check_for_vars=True,
check_for_POST_params=True):
"""
Asserts that certain sensitive info are not displayed in the response.
"""
request = self.rf.post('/some_url/', self.breakfast_data)
response = view(request)
... | [
"def",
"verify_safe_response",
"(",
"self",
",",
"view",
",",
"check_for_vars",
"=",
"True",
",",
"check_for_POST_params",
"=",
"True",
")",
":",
"request",
"=",
"self",
".",
"rf",
".",
"post",
"(",
"'/some_url/'",
",",
"self",
".",
"breakfast_data",
")",
... | [
451,
4
] | [
474,
76
] | python | en | ['en', 'error', 'th'] | False |
ExceptionReportTestMixin.verify_paranoid_response | (self, view, check_for_vars=True,
check_for_POST_params=True) |
Asserts that no variables or POST parameters are displayed in the response.
|
Asserts that no variables or POST parameters are displayed in the response.
| def verify_paranoid_response(self, view, check_for_vars=True,
check_for_POST_params=True):
"""
Asserts that no variables or POST parameters are displayed in the response.
"""
request = self.rf.post('/some_url/', self.breakfast_data)
response = vie... | [
"def",
"verify_paranoid_response",
"(",
"self",
",",
"view",
",",
"check_for_vars",
"=",
"True",
",",
"check_for_POST_params",
"=",
"True",
")",
":",
"request",
"=",
"self",
".",
"rf",
".",
"post",
"(",
"'/some_url/'",
",",
"self",
".",
"breakfast_data",
")"... | [
476,
4
] | [
494,
68
] | python | en | ['en', 'error', 'th'] | False |
ExceptionReportTestMixin.verify_unsafe_email | (self, view, check_for_POST_params=True) |
Asserts that potentially sensitive info are displayed in the email report.
|
Asserts that potentially sensitive info are displayed in the email report.
| def verify_unsafe_email(self, view, check_for_POST_params=True):
"""
Asserts that potentially sensitive info are displayed in the email report.
"""
with self.settings(ADMINS=(('Admin', 'admin@fattie-breakie.com'),)):
mail.outbox = [] # Empty outbox
request = self... | [
"def",
"verify_unsafe_email",
"(",
"self",
",",
"view",
",",
"check_for_POST_params",
"=",
"True",
")",
":",
"with",
"self",
".",
"settings",
"(",
"ADMINS",
"=",
"(",
"(",
"'Admin'",
",",
"'admin@fattie-breakie.com'",
")",
",",
")",
")",
":",
"mail",
".",
... | [
496,
4
] | [
527,
47
] | python | en | ['en', 'error', 'th'] | False |
ExceptionReportTestMixin.verify_safe_email | (self, view, check_for_POST_params=True) |
Asserts that certain sensitive info are not displayed in the email report.
|
Asserts that certain sensitive info are not displayed in the email report.
| def verify_safe_email(self, view, check_for_POST_params=True):
"""
Asserts that certain sensitive info are not displayed in the email report.
"""
with self.settings(ADMINS=(('Admin', 'admin@fattie-breakie.com'),)):
mail.outbox = [] # Empty outbox
request = self.r... | [
"def",
"verify_safe_email",
"(",
"self",
",",
"view",
",",
"check_for_POST_params",
"=",
"True",
")",
":",
"with",
"self",
".",
"settings",
"(",
"ADMINS",
"=",
"(",
"(",
"'Admin'",
",",
"'admin@fattie-breakie.com'",
")",
",",
")",
")",
":",
"mail",
".",
... | [
529,
4
] | [
567,
58
] | python | en | ['en', 'error', 'th'] | False |
ExceptionReportTestMixin.verify_paranoid_email | (self, view) |
Asserts that no variables or POST parameters are displayed in the email report.
|
Asserts that no variables or POST parameters are displayed in the email report.
| def verify_paranoid_email(self, view):
"""
Asserts that no variables or POST parameters are displayed in the email report.
"""
with self.settings(ADMINS=(('Admin', 'admin@fattie-breakie.com'),)):
mail.outbox = [] # Empty outbox
request = self.rf.post('/some_url/'... | [
"def",
"verify_paranoid_email",
"(",
"self",
",",
"view",
")",
":",
"with",
"self",
".",
"settings",
"(",
"ADMINS",
"=",
"(",
"(",
"'Admin'",
",",
"'admin@fattie-breakie.com'",
")",
",",
")",
")",
":",
"mail",
".",
"outbox",
"=",
"[",
"]",
"# Empty outbo... | [
569,
4
] | [
589,
41
] | python | en | ['en', 'error', 'th'] | False |
AjaxResponseExceptionReporterFilter.test_non_sensitive_request | (self) |
Ensure that request info can bee seen in the default error reports for
non-sensitive requests.
|
Ensure that request info can bee seen in the default error reports for
non-sensitive requests.
| def test_non_sensitive_request(self):
"""
Ensure that request info can bee seen in the default error reports for
non-sensitive requests.
"""
with self.settings(DEBUG=True):
self.verify_unsafe_response(non_sensitive_view, check_for_vars=False)
with self.settin... | [
"def",
"test_non_sensitive_request",
"(",
"self",
")",
":",
"with",
"self",
".",
"settings",
"(",
"DEBUG",
"=",
"True",
")",
":",
"self",
".",
"verify_unsafe_response",
"(",
"non_sensitive_view",
",",
"check_for_vars",
"=",
"False",
")",
"with",
"self",
".",
... | [
796,
4
] | [
805,
81
] | python | en | ['en', 'error', 'th'] | False |
AjaxResponseExceptionReporterFilter.test_sensitive_request | (self) |
Ensure that sensitive POST parameters cannot be seen in the default
error reports for sensitive requests.
|
Ensure that sensitive POST parameters cannot be seen in the default
error reports for sensitive requests.
| def test_sensitive_request(self):
"""
Ensure that sensitive POST parameters cannot be seen in the default
error reports for sensitive requests.
"""
with self.settings(DEBUG=True):
self.verify_unsafe_response(sensitive_view, check_for_vars=False)
with self.set... | [
"def",
"test_sensitive_request",
"(",
"self",
")",
":",
"with",
"self",
".",
"settings",
"(",
"DEBUG",
"=",
"True",
")",
":",
"self",
".",
"verify_unsafe_response",
"(",
"sensitive_view",
",",
"check_for_vars",
"=",
"False",
")",
"with",
"self",
".",
"settin... | [
807,
4
] | [
816,
75
] | python | en | ['en', 'error', 'th'] | False |
AjaxResponseExceptionReporterFilter.test_paranoid_request | (self) |
Ensure that no POST parameters can be seen in the default error reports
for "paranoid" requests.
|
Ensure that no POST parameters can be seen in the default error reports
for "paranoid" requests.
| def test_paranoid_request(self):
"""
Ensure that no POST parameters can be seen in the default error reports
for "paranoid" requests.
"""
with self.settings(DEBUG=True):
self.verify_unsafe_response(paranoid_view, check_for_vars=False)
with self.settings(DEBUG... | [
"def",
"test_paranoid_request",
"(",
"self",
")",
":",
"with",
"self",
".",
"settings",
"(",
"DEBUG",
"=",
"True",
")",
":",
"self",
".",
"verify_unsafe_response",
"(",
"paranoid_view",
",",
"check_for_vars",
"=",
"False",
")",
"with",
"self",
".",
"settings... | [
818,
4
] | [
827,
78
] | python | en | ['en', 'error', 'th'] | False |
AjaxResponseExceptionReporterFilter.test_custom_exception_reporter_filter | (self) |
Ensure that it's possible to assign an exception reporter filter to
the request to bypass the one set in DEFAULT_EXCEPTION_REPORTER_FILTER.
|
Ensure that it's possible to assign an exception reporter filter to
the request to bypass the one set in DEFAULT_EXCEPTION_REPORTER_FILTER.
| def test_custom_exception_reporter_filter(self):
"""
Ensure that it's possible to assign an exception reporter filter to
the request to bypass the one set in DEFAULT_EXCEPTION_REPORTER_FILTER.
"""
with self.settings(DEBUG=True):
self.verify_unsafe_response(custom_exce... | [
"def",
"test_custom_exception_reporter_filter",
"(",
"self",
")",
":",
"with",
"self",
".",
"settings",
"(",
"DEBUG",
"=",
"True",
")",
":",
"self",
".",
"verify_unsafe_response",
"(",
"custom_exception_reporter_filter_view",
",",
"check_for_vars",
"=",
"False",
")"... | [
829,
4
] | [
840,
37
] | python | en | ['en', 'error', 'th'] | False |
Textfont.color | (self) |
Sets the text font color of selected points.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,1... |
Sets the text font color of selected points.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,1... | def color(self):
"""
Sets the text font color of selected points.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hs... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
65,
28
] | python | en | ['en', 'error', 'th'] | False |
Textfont.__init__ | (self, arg=None, color=None, **kwargs) |
Construct a new Textfont object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatter.selected.Textfont`
color
Sets the text font color of selecte... |
Construct a new Textfont object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatter.selected.Textfont`
color
Sets the text font color of selecte... | def __init__(self, arg=None, color=None, **kwargs):
"""
Construct a new Textfont object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatter.selected.Textfont... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Textfont",
",",
"self",
")",
".",
"__init__",
"(",
"\"textfont\"",
")",
"if",
"\"_parent\"",
"in",
"kwargs",
":",
... | [
80,
4
] | [
137,
34
] | 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.