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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ExceptionInfo.exconly | (self, tryshort=False) | return the exception as a string
when 'tryshort' resolves to True, and the exception is a
_pytest._code._AssertionError, only the actual exception part of
the exception representation is returned (so 'AssertionError: ' is
removed from the beginning)
| return the exception as a string | def exconly(self, tryshort=False):
""" return the exception as a string
when 'tryshort' resolves to True, and the exception is a
_pytest._code._AssertionError, only the actual exception part of
the exception representation is returned (so 'AssertionError: ' is
re... | [
"def",
"exconly",
"(",
"self",
",",
"tryshort",
"=",
"False",
")",
":",
"lines",
"=",
"format_exception_only",
"(",
"self",
".",
"type",
",",
"self",
".",
"value",
")",
"text",
"=",
"''",
".",
"join",
"(",
"lines",
")",
"text",
"=",
"text",
".",
"r... | [
389,
4
] | [
403,
19
] | python | en | ['en', 'en', 'en'] | True |
ExceptionInfo.errisinstance | (self, exc) | return True if the exception is an instance of exc | return True if the exception is an instance of exc | def errisinstance(self, exc):
""" return True if the exception is an instance of exc """
return isinstance(self.value, exc) | [
"def",
"errisinstance",
"(",
"self",
",",
"exc",
")",
":",
"return",
"isinstance",
"(",
"self",
".",
"value",
",",
"exc",
")"
] | [
405,
4
] | [
407,
42
] | python | en | ['en', 'en', 'en'] | True |
ExceptionInfo.getrepr | (self, showlocals=False, style="long",
abspath=False, tbfilter=True, funcargs=False) | return str()able representation of this exception info.
showlocals: show locals per traceback entry
style: long|short|no|native traceback style
tbfilter: hide entries (where __tracebackhide__ is true)
in case of style==native, tbfilter and showlocals is ignored.
... | return str()able representation of this exception info.
showlocals: show locals per traceback entry
style: long|short|no|native traceback style
tbfilter: hide entries (where __tracebackhide__ is true) | def getrepr(self, showlocals=False, style="long",
abspath=False, tbfilter=True, funcargs=False):
""" return str()able representation of this exception info.
showlocals: show locals per traceback entry
style: long|short|no|native traceback style
tbfilter: hide ... | [
"def",
"getrepr",
"(",
"self",
",",
"showlocals",
"=",
"False",
",",
"style",
"=",
"\"long\"",
",",
"abspath",
"=",
"False",
",",
"tbfilter",
"=",
"True",
",",
"funcargs",
"=",
"False",
")",
":",
"if",
"style",
"==",
"'native'",
":",
"return",
"ReprExc... | [
415,
4
] | [
434,
37
] | python | en | ['en', 'en', 'en'] | True |
ExceptionInfo.match | (self, regexp) |
Match the regular expression 'regexp' on the string representation of
the exception. If it matches then True is returned (so that it is
possible to write 'assert excinfo.match()'). If it doesn't match an
AssertionError is raised.
|
Match the regular expression 'regexp' on the string representation of
the exception. If it matches then True is returned (so that it is
possible to write 'assert excinfo.match()'). If it doesn't match an
AssertionError is raised.
| def match(self, regexp):
"""
Match the regular expression 'regexp' on the string representation of
the exception. If it matches then True is returned (so that it is
possible to write 'assert excinfo.match()'). If it doesn't match an
AssertionError is raised.
"""
_... | [
"def",
"match",
"(",
"self",
",",
"regexp",
")",
":",
"__tracebackhide__",
"=",
"True",
"if",
"not",
"re",
".",
"search",
"(",
"regexp",
",",
"str",
"(",
"self",
".",
"value",
")",
")",
":",
"assert",
"0",
",",
"\"Pattern '{0!s}' not found in '{1!s}'\"",
... | [
446,
4
] | [
457,
19
] | python | en | ['en', 'error', 'th'] | False |
FormattedExcinfo.get_source | (self, source, line_index=-1, excinfo=None, short=False) | return formatted and marked up source lines. | return formatted and marked up source lines. | def get_source(self, source, line_index=-1, excinfo=None, short=False):
""" return formatted and marked up source lines. """
import _pytest._code
lines = []
if source is None or line_index >= len(source.lines):
source = _pytest._code.Source("???")
line_index = 0
... | [
"def",
"get_source",
"(",
"self",
",",
"source",
",",
"line_index",
"=",
"-",
"1",
",",
"excinfo",
"=",
"None",
",",
"short",
"=",
"False",
")",
":",
"import",
"_pytest",
".",
"_code",
"lines",
"=",
"[",
"]",
"if",
"source",
"is",
"None",
"or",
"li... | [
505,
4
] | [
526,
20
] | python | en | ['en', 'en', 'en'] | True |
FormattedExcinfo._truncate_recursive_traceback | (self, traceback) |
Truncate the given recursive traceback trying to find the starting point
of the recursion.
The detection is done by going through each traceback entry and finding the
point in which the locals of the frame are equal to the locals of a previous frame (see ``recursionindex()``.
... |
Truncate the given recursive traceback trying to find the starting point
of the recursion. | def _truncate_recursive_traceback(self, traceback):
"""
Truncate the given recursive traceback trying to find the starting point
of the recursion.
The detection is done by going through each traceback entry and finding the
point in which the locals of the frame are equal to the ... | [
"def",
"_truncate_recursive_traceback",
"(",
"self",
",",
"traceback",
")",
":",
"try",
":",
"recursionindex",
"=",
"traceback",
".",
"recursionindex",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"max_frames",
"=",
"10",
"extraline",
"=",
"(",
"'!!! Recur... | [
624,
4
] | [
654,
35
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_content_types | (self) |
Test old `/json/messages` returns reactions.
|
Test old `/json/messages` returns reactions.
| def test_content_types(self) -> None:
"""
Test old `/json/messages` returns reactions.
"""
self.login("hamlet")
def get_content_type(apply_markdown: bool) -> str:
req: Dict[str, Any] = dict(
apply_markdown=orjson.dumps(apply_markdown).decode(),
... | [
"def",
"test_content_types",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"def",
"get_content_type",
"(",
"apply_markdown",
":",
"bool",
")",
"->",
"str",
":",
"req",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
... | [
1380,
4
] | [
1402,
9
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_successful_get_messages_reaction | (self) |
Test old `/json/messages` returns reactions.
|
Test old `/json/messages` returns reactions.
| def test_successful_get_messages_reaction(self) -> None:
"""
Test old `/json/messages` returns reactions.
"""
self.login("hamlet")
messages = self.get_and_check_messages({})
message_id = messages["messages"][0]["id"]
self.login("othello")
reaction_name = ... | [
"def",
"test_successful_get_messages_reaction",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"messages",
"=",
"self",
".",
"get_and_check_messages",
"(",
"{",
"}",
")",
"message_id",
"=",
"messages",
"[",
"\"messages\"",
"... | [
1404,
4
] | [
1431,
88
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_successful_get_messages | (self) |
A call to GET /json/messages with valid parameters returns a list of
messages.
|
A call to GET /json/messages with valid parameters returns a list of
messages.
| def test_successful_get_messages(self) -> None:
"""
A call to GET /json/messages with valid parameters returns a list of
messages.
"""
self.login("hamlet")
self.get_and_check_messages({})
othello_email = self.example_user("othello").email
# We have to su... | [
"def",
"test_successful_get_messages",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"self",
".",
"get_and_check_messages",
"(",
"{",
"}",
")",
"othello_email",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"... | [
1433,
4
] | [
1459,
9
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_unauthenticated_get_messages_without_web_public | (self) |
An unauthenticated call to GET /json/messages with valid parameters
returns a 401.
|
An unauthenticated call to GET /json/messages with valid parameters
returns a 401.
| def test_unauthenticated_get_messages_without_web_public(self) -> None:
"""
An unauthenticated call to GET /json/messages with valid parameters
returns a 401.
"""
post_params = {
"anchor": 1,
"num_before": 1,
"num_after": 1,
"narrow... | [
"def",
"test_unauthenticated_get_messages_without_web_public",
"(",
"self",
")",
"->",
"None",
":",
"post_params",
"=",
"{",
"\"anchor\"",
":",
"1",
",",
"\"num_before\"",
":",
"1",
",",
"\"num_after\"",
":",
"1",
",",
"\"narrow\"",
":",
"orjson",
".",
"dumps",
... | [
1473,
4
] | [
1497,
9
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_unauthenticated_get_messages_with_web_public | (self) |
An unauthenticated call to GET /json/messages without valid
parameters in the `streams:web-public` narrow returns a 401.
|
An unauthenticated call to GET /json/messages without valid
parameters in the `streams:web-public` narrow returns a 401.
| def test_unauthenticated_get_messages_with_web_public(self) -> None:
"""
An unauthenticated call to GET /json/messages without valid
parameters in the `streams:web-public` narrow returns a 401.
"""
post_params: Dict[str, Union[int, str, bool]] = {
"anchor": 1,
... | [
"def",
"test_unauthenticated_get_messages_with_web_public",
"(",
"self",
")",
"->",
"None",
":",
"post_params",
":",
"Dict",
"[",
"str",
",",
"Union",
"[",
"int",
",",
"str",
",",
"bool",
"]",
"]",
"=",
"{",
"\"anchor\"",
":",
"1",
",",
"\"num_before\"",
"... | [
1499,
4
] | [
1519,
9
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_unauthenticated_narrow_to_non_web_public_streams_without_web_public | (self) |
An unauthenticated call to GET /json/messages without `streams:web-public` narrow returns a 401.
|
An unauthenticated call to GET /json/messages without `streams:web-public` narrow returns a 401.
| def test_unauthenticated_narrow_to_non_web_public_streams_without_web_public(self) -> None:
"""
An unauthenticated call to GET /json/messages without `streams:web-public` narrow returns a 401.
"""
post_params: Dict[str, Union[int, str, bool]] = {
"anchor": 1,
"num... | [
"def",
"test_unauthenticated_narrow_to_non_web_public_streams_without_web_public",
"(",
"self",
")",
"->",
"None",
":",
"post_params",
":",
"Dict",
"[",
"str",
",",
"Union",
"[",
"int",
",",
"str",
",",
"bool",
"]",
"]",
"=",
"{",
"\"anchor\"",
":",
"1",
",",
... | [
1521,
4
] | [
1534,
9
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_unauthenticated_narrow_to_non_web_public_streams_with_web_public | (self) |
An unauthenticated call to GET /json/messages with valid
parameters in the `streams:web-public` narrow + narrow to stream returns
a 400 if the target stream is not web-public.
|
An unauthenticated call to GET /json/messages with valid
parameters in the `streams:web-public` narrow + narrow to stream returns
a 400 if the target stream is not web-public.
| def test_unauthenticated_narrow_to_non_web_public_streams_with_web_public(self) -> None:
"""
An unauthenticated call to GET /json/messages with valid
parameters in the `streams:web-public` narrow + narrow to stream returns
a 400 if the target stream is not web-public.
"""
... | [
"def",
"test_unauthenticated_narrow_to_non_web_public_streams_with_web_public",
"(",
"self",
")",
"->",
"None",
":",
"post_params",
":",
"Dict",
"[",
"str",
",",
"Union",
"[",
"int",
",",
"str",
",",
"bool",
"]",
"]",
"=",
"{",
"\"anchor\"",
":",
"1",
",",
"... | [
1536,
4
] | [
1556,
9
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.setup_web_public_test | (self, num_web_public_message: int = 1) |
Send N+2 messages, N in a web-public stream, then one in a non web-public stream
and then a private message.
|
Send N+2 messages, N in a web-public stream, then one in a non web-public stream
and then a private message.
| def setup_web_public_test(self, num_web_public_message: int = 1) -> None:
"""
Send N+2 messages, N in a web-public stream, then one in a non web-public stream
and then a private message.
"""
user_profile = self.example_user("iago")
self.login("iago")
web_public_st... | [
"def",
"setup_web_public_test",
"(",
"self",
",",
"num_web_public_message",
":",
"int",
"=",
"1",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
"self",
".",
"login",
"(",
"\"iago\"",
")",
"web_public_stream",
... | [
1558,
4
] | [
1580,
21
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_get_messages_with_web_public | (self) |
An unauthenticated call to GET /json/messages with valid parameters
including `streams:web-public` narrow returns list of messages in the
`web-public` streams.
|
An unauthenticated call to GET /json/messages with valid parameters
including `streams:web-public` narrow returns list of messages in the
`web-public` streams.
| def test_get_messages_with_web_public(self) -> None:
"""
An unauthenticated call to GET /json/messages with valid parameters
including `streams:web-public` narrow returns list of messages in the
`web-public` streams.
"""
self.setup_web_public_test(num_web_public_message=8... | [
"def",
"test_get_messages_with_web_public",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"setup_web_public_test",
"(",
"num_web_public_message",
"=",
"8",
")",
"post_params",
"=",
"{",
"\"anchor\"",
":",
"\"first_unread\"",
",",
"\"num_before\"",
":",
"5",
",... | [
1612,
4
] | [
1631,
62
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_client_avatar | (self) |
The client_gravatar flag determines whether we send avatar_url.
|
The client_gravatar flag determines whether we send avatar_url.
| def test_client_avatar(self) -> None:
"""
The client_gravatar flag determines whether we send avatar_url.
"""
hamlet = self.example_user("hamlet")
self.login_user(hamlet)
do_set_realm_property(
hamlet.realm,
"email_address_visibility",
... | [
"def",
"test_client_avatar",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"hamlet",
")",
"do_set_realm_property",
"(",
"hamlet",
".",
"realm",
",",
"\"email_address_vis... | [
1633,
4
] | [
1666,
60
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_get_messages_with_narrow_pm_with | (self) |
A request for old messages with a narrow by pm-with only returns
conversations with that user.
|
A request for old messages with a narrow by pm-with only returns
conversations with that user.
| def test_get_messages_with_narrow_pm_with(self) -> None:
"""
A request for old messages with a narrow by pm-with only returns
conversations with that user.
"""
me = self.example_user("hamlet")
def dr_emails(dr: DisplayRecipientT) -> str:
assert isinstance(dr,... | [
"def",
"test_get_messages_with_narrow_pm_with",
"(",
"self",
")",
"->",
"None",
":",
"me",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"def",
"dr_emails",
"(",
"dr",
":",
"DisplayRecipientT",
")",
"->",
"str",
":",
"assert",
"isinstance",
"(",
... | [
1668,
4
] | [
1720,
81
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_get_messages_with_narrow_group_pm_with | (self) |
A request for old messages with a narrow by group-pm-with only returns
group-private conversations with that user.
|
A request for old messages with a narrow by group-pm-with only returns
group-private conversations with that user.
| def test_get_messages_with_narrow_group_pm_with(self) -> None:
"""
A request for old messages with a narrow by group-pm-with only returns
group-private conversations with that user.
"""
me = self.example_user("hamlet")
iago = self.example_user("iago")
cordelia = ... | [
"def",
"test_get_messages_with_narrow_group_pm_with",
"(",
"self",
")",
"->",
"None",
":",
"me",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"iago",
"=",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
"cordelia",
"=",
"self",
".",
"example_us... | [
1734,
4
] | [
1788,
73
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_get_messages_with_narrow_stream | (self) |
A request for old messages with a narrow by stream only returns
messages for that stream.
|
A request for old messages with a narrow by stream only returns
messages for that stream.
| def test_get_messages_with_narrow_stream(self) -> None:
"""
A request for old messages with a narrow by stream only returns
messages for that stream.
"""
self.login("hamlet")
# We need to subscribe to a stream and then send a message to
# it to ensure that we actu... | [
"def",
"test_get_messages_with_narrow_stream",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"# We need to subscribe to a stream and then send a message to",
"# it to ensure that we actually have a stream message in this",
"# narrow view.",
"sel... | [
1862,
4
] | [
1886,
78
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_get_messages_with_narrow_stream_mit_unicode_regex | (self) |
A request for old messages for a user in the mit.edu relam with Unicode
stream name should be correctly escaped in the database query.
|
A request for old messages for a user in the mit.edu relam with Unicode
stream name should be correctly escaped in the database query.
| def test_get_messages_with_narrow_stream_mit_unicode_regex(self) -> None:
"""
A request for old messages for a user in the mit.edu relam with Unicode
stream name should be correctly escaped in the database query.
"""
user = self.mit_user("starnine")
self.login_user(user)
... | [
"def",
"test_get_messages_with_narrow_stream_mit_unicode_regex",
"(",
"self",
")",
"->",
"None",
":",
"user",
"=",
"self",
".",
"mit_user",
"(",
"\"starnine\"",
")",
"self",
".",
"login_user",
"(",
"user",
")",
"# We need to susbcribe to a stream and then send a message t... | [
1899,
4
] | [
1931,
64
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_get_messages_with_narrow_topic_mit_unicode_regex | (self) |
A request for old messages for a user in the mit.edu realm with Unicode
topic name should be correctly escaped in the database query.
|
A request for old messages for a user in the mit.edu realm with Unicode
topic name should be correctly escaped in the database query.
| def test_get_messages_with_narrow_topic_mit_unicode_regex(self) -> None:
"""
A request for old messages for a user in the mit.edu realm with Unicode
topic name should be correctly escaped in the database query.
"""
mit_user_profile = self.mit_user("starnine")
self.login_u... | [
"def",
"test_get_messages_with_narrow_topic_mit_unicode_regex",
"(",
"self",
")",
"->",
"None",
":",
"mit_user_profile",
"=",
"self",
".",
"mit_user",
"(",
"\"starnine\"",
")",
"self",
".",
"login_user",
"(",
"mit_user_profile",
")",
"# We need to susbcribe to a stream an... | [
1933,
4
] | [
1961,
64
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_get_messages_with_narrow_topic_mit_personal | (self) |
We handle .d grouping for MIT realm personal messages correctly.
|
We handle .d grouping for MIT realm personal messages correctly.
| def test_get_messages_with_narrow_topic_mit_personal(self) -> None:
"""
We handle .d grouping for MIT realm personal messages correctly.
"""
mit_user_profile = self.mit_user("starnine")
# We need to susbcribe to a stream and then send a message to
# it to ensure that we ... | [
"def",
"test_get_messages_with_narrow_topic_mit_personal",
"(",
"self",
")",
"->",
"None",
":",
"mit_user_profile",
"=",
"self",
".",
"mit_user",
"(",
"\"starnine\"",
")",
"# We need to susbcribe to a stream and then send a message to",
"# it to ensure that we actually have a strea... | [
1963,
4
] | [
1995,
64
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_get_messages_with_narrow_sender | (self) |
A request for old messages with a narrow by sender only returns
messages sent by that person.
|
A request for old messages with a narrow by sender only returns
messages sent by that person.
| def test_get_messages_with_narrow_sender(self) -> None:
"""
A request for old messages with a narrow by sender only returns
messages sent by that person.
"""
self.login("hamlet")
hamlet = self.example_user("hamlet")
othello = self.example_user("othello")
... | [
"def",
"test_get_messages_with_narrow_sender",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"othello",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"... | [
1997,
4
] | [
2021,
66
] | python | en | ['en', 'error', 'th'] | False |
GetOldMessagesTest.test_get_messages_with_search_not_subscribed | (self) | Verify support for searching a stream you're not subscribed to | Verify support for searching a stream you're not subscribed to | def test_get_messages_with_search_not_subscribed(self) -> None:
"""Verify support for searching a stream you're not subscribed to"""
self.subscribe(self.example_user("hamlet"), "newstream")
self.send_stream_message(
sender=self.example_user("hamlet"),
stream_name="newstre... | [
"def",
"test_get_messages_with_search_not_subscribed",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"subscribe",
"(",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
",",
"\"newstream\"",
")",
"self",
".",
"send_stream_message",
"(",
"sender",
"=",
"se... | [
2246,
4
] | [
2275,
9
] | python | en | ['en', 'en', 'en'] | True |
GetOldMessagesTest.test_get_messages_with_only_searching_anchor | (self) |
Test that specifying an anchor but 0 for num_before and num_after
returns at most 1 message.
|
Test that specifying an anchor but 0 for num_before and num_after
returns at most 1 message.
| def test_get_messages_with_only_searching_anchor(self) -> None:
"""
Test that specifying an anchor but 0 for num_before and num_after
returns at most 1 message.
"""
self.login("cordelia")
cordelia = self.example_user("cordelia")
anchor = self.send_stream_message... | [
"def",
"test_get_messages_with_only_searching_anchor",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"cordelia\"",
")",
"cordelia",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"anchor",
"=",
"self",
".",
"send_stream_message",
... | [
2467,
4
] | [
2493,
52
] | python | en | ['en', 'error', 'th'] | False |
_getattr | (obj, name, default) | Like getattr but return `default` if None or False.
By default, getattr(obj, name, default) returns default only if
attr does not exist, here, we return `default` even if attr evaluates to
None or False.
| Like getattr but return `default` if None or False. | def _getattr(obj, name, default):
"""Like getattr but return `default` if None or False.
By default, getattr(obj, name, default) returns default only if
attr does not exist, here, we return `default` even if attr evaluates to
None or False.
"""
value = getattr(obj, name, default)
if value:
... | [
"def",
"_getattr",
"(",
"obj",
",",
"name",
",",
"default",
")",
":",
"value",
"=",
"getattr",
"(",
"obj",
",",
"name",
",",
"default",
")",
"if",
"value",
":",
"return",
"value",
"else",
":",
"return",
"default"
] | [
55,
0
] | [
66,
22
] | python | en | ['en', 'da', 'en'] | True |
logout_with_message | (request, msg, redirect=True, status='success') | Send HttpResponseRedirect to LOGOUT_URL.
`msg` is a message displayed on the login page after the logout, to explain
the logout reason.
| Send HttpResponseRedirect to LOGOUT_URL. | def logout_with_message(request, msg, redirect=True, status='success'):
"""Send HttpResponseRedirect to LOGOUT_URL.
`msg` is a message displayed on the login page after the logout, to explain
the logout reason.
"""
logout(request)
if redirect:
response = http.HttpResponseRedirect(
... | [
"def",
"logout_with_message",
"(",
"request",
",",
"msg",
",",
"redirect",
"=",
"True",
",",
"status",
"=",
"'success'",
")",
":",
"logout",
"(",
"request",
")",
"if",
"redirect",
":",
"response",
"=",
"http",
".",
"HttpResponseRedirect",
"(",
"'%s?next=%s'"... | [
54,
0
] | [
67,
19
] | python | en | ['en', 'de', 'en'] | True |
get_config_value | (request, key, default, search_in_settings=True) | Retrieves the value of `key` from configuration in the following order:
- from the session; if not found there then
- from cookies; if not found there then
- from the settings file if `search_in_settings` is True,
otherwise this step is skipped; if not found there
- `default` is returned
| Retrieves the value of `key` from configuration in the following order: | def get_config_value(request, key, default, search_in_settings=True):
"""Retrieves the value of `key` from configuration in the following order:
- from the session; if not found there then
- from cookies; if not found there then
- from the settings file if `search_in_settings` is True,
otherwise ... | [
"def",
"get_config_value",
"(",
"request",
",",
"key",
",",
"default",
",",
"search_in_settings",
"=",
"True",
")",
":",
"value",
"=",
"request",
".",
"session",
".",
"get",
"(",
"key",
",",
"request",
".",
"COOKIES",
".",
"get",
"(",
"key",
")",
")",
... | [
70,
0
] | [
93,
16
] | python | en | ['en', 'en', 'en'] | True |
save_config_value | (request, response, key, value) | Sets value of key `key` to `value` in both session and cookies. | Sets value of key `key` to `value` in both session and cookies. | def save_config_value(request, response, key, value):
"""Sets value of key `key` to `value` in both session and cookies."""
request.session[key] = value
response.set_cookie(key, value, expires=one_year_from_now())
return response | [
"def",
"save_config_value",
"(",
"request",
",",
"response",
",",
"key",
",",
"value",
")",
":",
"request",
".",
"session",
"[",
"key",
"]",
"=",
"value",
"response",
".",
"set_cookie",
"(",
"key",
",",
"value",
",",
"expires",
"=",
"one_year_from_now",
... | [
96,
0
] | [
100,
19
] | python | en | ['en', 'en', 'en'] | True |
get_keys | (tuple_of_tuples) | Returns a tuple containing first component of each tuple.
It processes a tuple of 2-element tuples and returns a tuple containing
first component of each tuple.
| Returns a tuple containing first component of each tuple. | def get_keys(tuple_of_tuples):
"""Returns a tuple containing first component of each tuple.
It processes a tuple of 2-element tuples and returns a tuple containing
first component of each tuple.
"""
return tuple([t[0] for t in tuple_of_tuples]) | [
"def",
"get_keys",
"(",
"tuple_of_tuples",
")",
":",
"return",
"tuple",
"(",
"[",
"t",
"[",
"0",
"]",
"for",
"t",
"in",
"tuple_of_tuples",
"]",
")"
] | [
129,
0
] | [
135,
49
] | python | en | ['en', 'en', 'en'] | True |
value_for_key | (tuple_of_tuples, key) | Returns a value containing to the given key.
It processes a tuple of 2-element tuples and returns the value
corresponding to the given key. If no value is found, the key is returned.
| Returns a value containing to the given key. | def value_for_key(tuple_of_tuples, key):
"""Returns a value containing to the given key.
It processes a tuple of 2-element tuples and returns the value
corresponding to the given key. If no value is found, the key is returned.
"""
for t in tuple_of_tuples:
if t[0] == key:
return... | [
"def",
"value_for_key",
"(",
"tuple_of_tuples",
",",
"key",
")",
":",
"for",
"t",
"in",
"tuple_of_tuples",
":",
"if",
"t",
"[",
"0",
"]",
"==",
"key",
":",
"return",
"t",
"[",
"1",
"]",
"else",
":",
"return",
"key"
] | [
138,
0
] | [
148,
18
] | python | en | ['en', 'en', 'en'] | True |
next_key | (tuple_of_tuples, key) | Returns the key which comes after the given key.
It processes a tuple of 2-element tuples and returns the key which comes
after the given key.
| Returns the key which comes after the given key. | def next_key(tuple_of_tuples, key):
"""Returns the key which comes after the given key.
It processes a tuple of 2-element tuples and returns the key which comes
after the given key.
"""
for i, t in enumerate(tuple_of_tuples):
if t[0] == key:
try:
return tuple_of_... | [
"def",
"next_key",
"(",
"tuple_of_tuples",
",",
"key",
")",
":",
"for",
"i",
",",
"t",
"in",
"enumerate",
"(",
"tuple_of_tuples",
")",
":",
"if",
"t",
"[",
"0",
"]",
"==",
"key",
":",
"try",
":",
"return",
"tuple_of_tuples",
"[",
"i",
"+",
"1",
"]"... | [
151,
0
] | [
162,
27
] | python | en | ['en', 'en', 'en'] | True |
previous_key | (tuple_of_tuples, key) | Returns the key which comes before the give key.
It Processes a tuple of 2-element tuples and returns the key which comes
before the given key.
| Returns the key which comes before the give key. | def previous_key(tuple_of_tuples, key):
"""Returns the key which comes before the give key.
It Processes a tuple of 2-element tuples and returns the key which comes
before the given key.
"""
for i, t in enumerate(tuple_of_tuples):
if t[0] == key:
try:
return tupl... | [
"def",
"previous_key",
"(",
"tuple_of_tuples",
",",
"key",
")",
":",
"for",
"i",
",",
"t",
"in",
"enumerate",
"(",
"tuple_of_tuples",
")",
":",
"if",
"t",
"[",
"0",
"]",
"==",
"key",
":",
"try",
":",
"return",
"tuple_of_tuples",
"[",
"i",
"-",
"1",
... | [
165,
0
] | [
176,
27
] | python | en | ['en', 'en', 'en'] | True |
format_value | (value) | Returns the given value rounded to one decimal place if deciaml.
Returns the integer if an integer is given.
| Returns the given value rounded to one decimal place if deciaml. | def format_value(value):
"""Returns the given value rounded to one decimal place if deciaml.
Returns the integer if an integer is given.
"""
value = decimal.Decimal(str(value))
if int(value) == value:
return int(value)
# On Python 3, an explicit cast to float is required
return flo... | [
"def",
"format_value",
"(",
"value",
")",
":",
"value",
"=",
"decimal",
".",
"Decimal",
"(",
"str",
"(",
"value",
")",
")",
"if",
"int",
"(",
"value",
")",
"==",
"value",
":",
"return",
"int",
"(",
"value",
")",
"# On Python 3, an explicit cast to float is... | [
179,
0
] | [
189,
33
] | python | en | ['en', 'en', 'en'] | True |
hexlify | (text) | Hexlify raw text, return hexlified text. | Hexlify raw text, return hexlified text. | def hexlify(text):
"""Hexlify raw text, return hexlified text."""
hexlified = binascii.hexlify(text.encode('utf-8'))
return hexlified.decode('utf-8') | [
"def",
"hexlify",
"(",
"text",
")",
":",
"hexlified",
"=",
"binascii",
".",
"hexlify",
"(",
"text",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"return",
"hexlified",
".",
"decode",
"(",
"'utf-8'",
")"
] | [
197,
0
] | [
200,
36
] | python | en | ['en', 'pl', 'en'] | True |
install_given_reqs | (
requirements, # type: List[InstallRequirement]
install_options, # type: List[str]
global_options, # type: Sequence[str]
root, # type: Optional[str]
home, # type: Optional[str]
prefix, # type: Optional[str]
warn_script_location, # type: bool
use_user_site, # type: bool
pycom... |
Install everything in the given list.
(to be called after having downloaded and unpacked the packages)
|
Install everything in the given list. | def install_given_reqs(
requirements, # type: List[InstallRequirement]
install_options, # type: List[str]
global_options, # type: Sequence[str]
root, # type: Optional[str]
home, # type: Optional[str]
prefix, # type: Optional[str]
warn_script_location, # type: bool
use_user_site, ... | [
"def",
"install_given_reqs",
"(",
"requirements",
",",
"# type: List[InstallRequirement]",
"install_options",
",",
"# type: List[str]",
"global_options",
",",
"# type: Sequence[str]",
"root",
",",
"# type: Optional[str]",
"home",
",",
"# type: Optional[str]",
"prefix",
",",
"... | [
42,
0
] | [
102,
20
] | python | en | ['en', 'error', 'th'] | False |
DocumentStore.open | (self, url) |
Open a document at the specified url.
@param url: A document URL.
@type url: str
@return: A file pointer to the document.
@rtype: StringIO
|
Open a document at the specified url.
| def open(self, url):
"""
Open a document at the specified url.
@param url: A document URL.
@type url: str
@return: A file pointer to the document.
@rtype: StringIO
"""
protocol, location = self.split(url)
if protocol == self.protocol:
r... | [
"def",
"open",
"(",
"self",
",",
"url",
")",
":",
"protocol",
",",
"location",
"=",
"self",
".",
"split",
"(",
"url",
")",
"if",
"protocol",
"==",
"self",
".",
"protocol",
":",
"return",
"self",
".",
"find",
"(",
"location",
")",
"else",
":",
"retu... | [
552,
4
] | [
564,
23
] | python | en | ['en', 'error', 'th'] | False |
DocumentStore.find | (self, location) |
Find the specified location in the store.
@param location: The I{location} part of a URL.
@type location: str
@return: An input stream to the document.
@rtype: StringIO
|
Find the specified location in the store.
| def find(self, location):
"""
Find the specified location in the store.
@param location: The I{location} part of a URL.
@type location: str
@return: An input stream to the document.
@rtype: StringIO
"""
try:
content = self.store[location]
... | [
"def",
"find",
"(",
"self",
",",
"location",
")",
":",
"try",
":",
"content",
"=",
"self",
".",
"store",
"[",
"location",
"]",
"return",
"StringIO",
"(",
"content",
")",
"except",
":",
"reason",
"=",
"'location \"%s\" not in document store'",
"%",
"location"... | [
566,
4
] | [
579,
35
] | python | en | ['en', 'error', 'th'] | False |
DocumentStore.split | (self, url) |
Split the url into I{protocol} and I{location}
@param url: A URL.
@param url: str
@return: (I{url}, I{location})
@rtype: tuple
|
Split the url into I{protocol} and I{location}
| def split(self, url):
"""
Split the url into I{protocol} and I{location}
@param url: A URL.
@param url: str
@return: (I{url}, I{location})
@rtype: tuple
"""
parts = url.split('://', 1)
if len(parts) == 2:
return parts
else:
... | [
"def",
"split",
"(",
"self",
",",
"url",
")",
":",
"parts",
"=",
"url",
".",
"split",
"(",
"'://'",
",",
"1",
")",
"if",
"len",
"(",
"parts",
")",
"==",
"2",
":",
"return",
"parts",
"else",
":",
"return",
"(",
"None",
",",
"url",
")"
] | [
581,
4
] | [
593,
30
] | python | en | ['en', 'error', 'th'] | False |
TestFillFixtures.test_override_parametrized_fixture_conftest_module | (self, testdir) | Test override of the parametrized fixture with non-parametrized one on the test module level. | Test override of the parametrized fixture with non-parametrized one on the test module level. | def test_override_parametrized_fixture_conftest_module(self, testdir):
"""Test override of the parametrized fixture with non-parametrized one on the test module level."""
testdir.makeconftest("""
import pytest
@pytest.fixture(params=[1, 2, 3])
def spam(request):
... | [
"def",
"test_override_parametrized_fixture_conftest_module",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"\"\"\"\n import pytest\n\n @pytest.fixture(params=[1, 2, 3])\n def spam(request):\n return request.param\n... | [
258,
4
] | [
280,
51
] | python | en | ['en', 'en', 'en'] | True |
TestFillFixtures.test_override_parametrized_fixture_conftest_conftest | (self, testdir) | Test override of the parametrized fixture with non-parametrized one on the conftest level. | Test override of the parametrized fixture with non-parametrized one on the conftest level. | def test_override_parametrized_fixture_conftest_conftest(self, testdir):
"""Test override of the parametrized fixture with non-parametrized one on the conftest level."""
testdir.makeconftest("""
import pytest
@pytest.fixture(params=[1, 2, 3])
def spam(request):
... | [
"def",
"test_override_parametrized_fixture_conftest_conftest",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"\"\"\"\n import pytest\n\n @pytest.fixture(params=[1, 2, 3])\n def spam(request):\n return request.param... | [
282,
4
] | [
307,
51
] | python | en | ['en', 'en', 'en'] | True |
TestFillFixtures.test_override_non_parametrized_fixture_conftest_module | (self, testdir) | Test override of the non-parametrized fixture with parametrized one on the test module level. | Test override of the non-parametrized fixture with parametrized one on the test module level. | def test_override_non_parametrized_fixture_conftest_module(self, testdir):
"""Test override of the non-parametrized fixture with parametrized one on the test module level."""
testdir.makeconftest("""
import pytest
@pytest.fixture
def spam():
return 's... | [
"def",
"test_override_non_parametrized_fixture_conftest_module",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"\"\"\"\n import pytest\n\n @pytest.fixture\n def spam():\n return 'spam'\n \"\"\"",
")",
"t... | [
309,
4
] | [
334,
51
] | python | en | ['en', 'en', 'en'] | True |
TestFillFixtures.test_override_non_parametrized_fixture_conftest_conftest | (self, testdir) | Test override of the non-parametrized fixture with parametrized one on the conftest level. | Test override of the non-parametrized fixture with parametrized one on the conftest level. | def test_override_non_parametrized_fixture_conftest_conftest(self, testdir):
"""Test override of the non-parametrized fixture with parametrized one on the conftest level."""
testdir.makeconftest("""
import pytest
@pytest.fixture
def spam():
return 'sp... | [
"def",
"test_override_non_parametrized_fixture_conftest_conftest",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"\"\"\"\n import pytest\n\n @pytest.fixture\n def spam():\n return 'spam'\n \"\"\"",
")",
... | [
336,
4
] | [
364,
51
] | python | en | ['en', 'en', 'en'] | True |
TestFillFixtures.test_override_autouse_fixture_with_parametrized_fixture_conftest_conftest | (self, testdir) | Test override of the autouse fixture with parametrized one on the conftest level.
This test covers the issue explained in issue 1601
| Test override of the autouse fixture with parametrized one on the conftest level.
This test covers the issue explained in issue 1601
| def test_override_autouse_fixture_with_parametrized_fixture_conftest_conftest(self, testdir):
"""Test override of the autouse fixture with parametrized one on the conftest level.
This test covers the issue explained in issue 1601
"""
testdir.makeconftest("""
import pytest
... | [
"def",
"test_override_autouse_fixture_with_parametrized_fixture_conftest_conftest",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makeconftest",
"(",
"\"\"\"\n import pytest\n\n @pytest.fixture(autouse=True)\n def spam():\n return 'sp... | [
366,
4
] | [
396,
51
] | python | en | ['en', 'en', 'en'] | True |
TestRequestBasic.test_request_subrequest_addfinalizer_exceptions | (self, testdir) |
Ensure exceptions raised during teardown by a finalizer are suppressed
until all finalizers are called, re-raising the first exception (#2440)
|
Ensure exceptions raised during teardown by a finalizer are suppressed
until all finalizers are called, re-raising the first exception (#2440)
| def test_request_subrequest_addfinalizer_exceptions(self, testdir):
"""
Ensure exceptions raised during teardown by a finalizer are suppressed
until all finalizers are called, re-raising the first exception (#2440)
"""
testdir.makepyfile("""
import pytest
... | [
"def",
"test_request_subrequest_addfinalizer_exceptions",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n import pytest\n values = []\n def _excepts(where):\n raise Exception('Error in %s fixture' % where)\n ... | [
701,
4
] | [
732,
10
] | python | en | ['en', 'error', 'th'] | False |
TestAutouseDiscovery.test_callables_nocode | (self, testdir) |
a imported mock.call would break setup/factory discovery
due to it being callable and __code__ not being a code object
|
a imported mock.call would break setup/factory discovery
due to it being callable and __code__ not being a code object
| def test_callables_nocode(self, testdir):
"""
a imported mock.call would break setup/factory discovery
due to it being callable and __code__ not being a code object
"""
testdir.makepyfile("""
class _call(tuple):
def __call__(self, *k, **kw):
... | [
"def",
"test_callables_nocode",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n class _call(tuple):\n def __call__(self, *k, **kw):\n pass\n def __getattr__(self, k):\n return self\n... | [
1552,
4
] | [
1567,
48
] | python | en | ['en', 'error', 'th'] | False |
TestFixtureMarker.test_override_parametrized_fixture_issue_979 | (self, testdir, param_args) | Make sure a parametrized argument can override a parametrized fixture.
This was a regression introduced in the fix for #736.
| Make sure a parametrized argument can override a parametrized fixture. | def test_override_parametrized_fixture_issue_979(self, testdir, param_args):
"""Make sure a parametrized argument can override a parametrized fixture.
This was a regression introduced in the fix for #736.
"""
testdir.makepyfile("""
import pytest
@pytest.fixture(... | [
"def",
"test_override_parametrized_fixture_issue_979",
"(",
"self",
",",
"testdir",
",",
"param_args",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n import pytest\n\n @pytest.fixture(params=[1, 2])\n def fixt(request):\n return req... | [
1878,
4
] | [
1895,
38
] | python | en | ['en', 'fr', 'en'] | True |
TestShowFixtures.test_show_fixtures_different_files | (self, testdir) |
#833: --fixtures only shows fixtures from first file
|
#833: --fixtures only shows fixtures from first file
| def test_show_fixtures_different_files(self, testdir):
"""
#833: --fixtures only shows fixtures from first file
"""
testdir.makepyfile(test_a='''
import pytest
@pytest.fixture
def fix_a():
"""Fixture A"""
pass
... | [
"def",
"test_show_fixtures_different_files",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"test_a",
"=",
"'''\n import pytest\n\n @pytest.fixture\n def fix_a():\n \"\"\"Fixture A\"\"\"\n pass\n\n ... | [
2923,
4
] | [
2958,
12
] | python | en | ['en', 'error', 'th'] | False |
FinderTests.test_find_all | (self) | Find all files | Find all files | def test_find_all(self):
"""Find all files"""
files = fd.discover_files(base_path)
self.assertEqual(len(files), 18) | [
"def",
"test_find_all",
"(",
"self",
")",
":",
"files",
"=",
"fd",
".",
"discover_files",
"(",
"base_path",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"files",
")",
",",
"18",
")"
] | [
74,
4
] | [
77,
40
] | python | en | ['en', 'en', 'en'] | True |
FinderTests.test_find_a | (self) | Find all files in folder `a` | Find all files in folder `a` | def test_find_a(self):
"""Find all files in folder `a`"""
files = fd.discover_files(base_path, sub_path='a')
self.assertEqual(len(files), 8) | [
"def",
"test_find_a",
"(",
"self",
")",
":",
"files",
"=",
"fd",
".",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"'a'",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"files",
")",
",",
"8",
")"
] | [
79,
4
] | [
82,
39
] | python | en | ['en', 'co', 'en'] | True |
FinderTests.test_find_b | (self) | Find all files in folder `b` | Find all files in folder `b` | def test_find_b(self):
"""Find all files in folder `b`"""
files = fd.discover_files(base_path, sub_path='b')
self.assertEqual(len(files), 10) | [
"def",
"test_find_b",
"(",
"self",
")",
":",
"files",
"=",
"fd",
".",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"'b'",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"files",
")",
",",
"10",
")"
] | [
84,
4
] | [
87,
40
] | python | en | ['en', 'co', 'en'] | True |
FinderTests.test_find_all_js | (self) | Find all files with extension of `.js` | Find all files with extension of `.js` | def test_find_all_js(self):
"""Find all files with extension of `.js`"""
files = fd.discover_files(base_path, ext='.js')
self.assertEqual(len(files), 14) | [
"def",
"test_find_all_js",
"(",
"self",
")",
":",
"files",
"=",
"fd",
".",
"discover_files",
"(",
"base_path",
",",
"ext",
"=",
"'.js'",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"files",
")",
",",
"14",
")"
] | [
89,
4
] | [
92,
40
] | python | en | ['en', 'en', 'en'] | True |
FinderTests.test_find_all_html | (self) | Find all files with extension of `.html` | Find all files with extension of `.html` | def test_find_all_html(self):
"""Find all files with extension of `.html`"""
files = fd.discover_files(base_path, ext='.html')
self.assertEqual(len(files), 2) | [
"def",
"test_find_all_html",
"(",
"self",
")",
":",
"files",
"=",
"fd",
".",
"discover_files",
"(",
"base_path",
",",
"ext",
"=",
"'.html'",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"files",
")",
",",
"2",
")"
] | [
94,
4
] | [
97,
39
] | python | en | ['en', 'en', 'en'] | True |
FinderTests.test_find_all_js_in_a | (self) | Find all files with extension of `.js` in folder a | Find all files with extension of `.js` in folder a | def test_find_all_js_in_a(self):
"""Find all files with extension of `.js` in folder a"""
files = fd.discover_files(base_path, sub_path='b', ext='.js')
self.assertEqual(len(files), 7) | [
"def",
"test_find_all_js_in_a",
"(",
"self",
")",
":",
"files",
"=",
"fd",
".",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"'b'",
",",
"ext",
"=",
"'.js'",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"files",
")",
",",
"7",
")"
] | [
99,
4
] | [
102,
39
] | python | en | ['en', 'en', 'en'] | True |
FinderTests.test_find_all_html_in_a | (self) | Find all files with extension of `.html` in folder a | Find all files with extension of `.html` in folder a | def test_find_all_html_in_a(self):
"""Find all files with extension of `.html` in folder a"""
files = fd.discover_files(base_path, sub_path='b', ext='.html')
self.assertEqual(len(files), 1) | [
"def",
"test_find_all_html_in_a",
"(",
"self",
")",
":",
"files",
"=",
"fd",
".",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"'b'",
",",
"ext",
"=",
"'.html'",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"files",
")",
",",
"1",
")"... | [
104,
4
] | [
107,
39
] | python | en | ['en', 'en', 'en'] | True |
FinderTests.test_find_all_file_trim_base_path | (self) | Find all files in folder, trim base path | Find all files in folder, trim base path | def test_find_all_file_trim_base_path(self):
"""Find all files in folder, trim base path"""
files = fd.discover_files(base_path, sub_path='a', trim_base_path=True)
self.assertTrue(files[0].startswith('a/'))
files = fd.discover_files(base_path, sub_path='b', trim_base_path=True)
... | [
"def",
"test_find_all_file_trim_base_path",
"(",
"self",
")",
":",
"files",
"=",
"fd",
".",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"'a'",
",",
"trim_base_path",
"=",
"True",
")",
"self",
".",
"assertTrue",
"(",
"files",
"[",
"0",
"]",
".... | [
109,
4
] | [
115,
50
] | python | en | ['en', 'co', 'en'] | True |
FinderTests.test_sort_js_files | (self) | Sort all JavaScript files | Sort all JavaScript files | def test_sort_js_files(self):
"""Sort all JavaScript files"""
files = fd.discover_files(base_path, ext='.js')
sources, mocks, specs = fd.sort_js_files(files)
self.assertEqual(len(sources), 6)
self.assertEqual(len(mocks), 2)
self.assertEqual(len(specs), 6)
self.a... | [
"def",
"test_sort_js_files",
"(",
"self",
")",
":",
"files",
"=",
"fd",
".",
"discover_files",
"(",
"base_path",
",",
"ext",
"=",
"'.js'",
")",
"sources",
",",
"mocks",
",",
"specs",
"=",
"fd",
".",
"sort_js_files",
"(",
"files",
")",
"self",
".",
"ass... | [
120,
4
] | [
145,
54
] | python | en | ['en', 'et', 'en'] | True |
FinderTests.test_discover_all_static_files | (self) | Find all static files | Find all static files | def test_discover_all_static_files(self):
"""Find all static files"""
sources, mocks, specs, templates = fd.discover_static_files(base_path)
self.assertEqual(len(sources), 6)
self.assertEqual(len(mocks), 2)
self.assertEqual(len(specs), 6)
self.assertEqual(len(templates), ... | [
"def",
"test_discover_all_static_files",
"(",
"self",
")",
":",
"sources",
",",
"mocks",
",",
"specs",
",",
"templates",
"=",
"fd",
".",
"discover_static_files",
"(",
"base_path",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"sources",
")",
",",
"6",
... | [
150,
4
] | [
177,
55
] | python | en | ['en', 'en', 'en'] | True |
FinderTests.test_populate_horizon_config | (self) | Populate horizon config | Populate horizon config | def test_populate_horizon_config(self):
"""Populate horizon config"""
horizon_config = {}
fd.populate_horizon_config(horizon_config, base_path)
sources = horizon_config['js_files']
test_files = horizon_config['js_spec_files']
templates = horizon_config['external_template... | [
"def",
"test_populate_horizon_config",
"(",
"self",
")",
":",
"horizon_config",
"=",
"{",
"}",
"fd",
".",
"populate_horizon_config",
"(",
"horizon_config",
",",
"base_path",
")",
"sources",
"=",
"horizon_config",
"[",
"'js_files'",
"]",
"test_files",
"=",
"horizon... | [
182,
4
] | [
214,
55
] | python | es | ['es', 'sr', 'it'] | False |
new_module | (name) | **DEPRECATED**
Create a new module.
The module is not entered into sys.modules.
| **DEPRECATED** | def new_module(name):
"""**DEPRECATED**
Create a new module.
The module is not entered into sys.modules.
"""
return types.ModuleType(name) | [
"def",
"new_module",
"(",
"name",
")",
":",
"return",
"types",
".",
"ModuleType",
"(",
"name",
")"
] | [
47,
0
] | [
55,
33
] | python | en | ['en', 'la', 'hi'] | False |
get_magic | () | **DEPRECATED**
Return the magic number for .pyc files.
| **DEPRECATED** | def get_magic():
"""**DEPRECATED**
Return the magic number for .pyc files.
"""
return util.MAGIC_NUMBER | [
"def",
"get_magic",
"(",
")",
":",
"return",
"util",
".",
"MAGIC_NUMBER"
] | [
58,
0
] | [
63,
28
] | python | en | ['en', 'la', 'hi'] | False |
get_tag | () | Return the magic tag for .pyc files. | Return the magic tag for .pyc files. | def get_tag():
"""Return the magic tag for .pyc files."""
return sys.implementation.cache_tag | [
"def",
"get_tag",
"(",
")",
":",
"return",
"sys",
".",
"implementation",
".",
"cache_tag"
] | [
66,
0
] | [
68,
39
] | python | en | ['en', 'en', 'en'] | True |
cache_from_source | (path, debug_override=None) | **DEPRECATED**
Given the path to a .py file, return the path to its .pyc file.
The .py file does not need to exist; this simply returns the path to the
.pyc file calculated as if the .py file were imported.
If debug_override is not None, then it must be a boolean and is used in
place of sys.flags... | **DEPRECATED** | def cache_from_source(path, debug_override=None):
"""**DEPRECATED**
Given the path to a .py file, return the path to its .pyc file.
The .py file does not need to exist; this simply returns the path to the
.pyc file calculated as if the .py file were imported.
If debug_override is not None, then i... | [
"def",
"cache_from_source",
"(",
"path",
",",
"debug_override",
"=",
"None",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"'ignore'",
")",
"return",
"util",
".",
"cache_from_source",
"(",
"path",
"... | [
71,
0
] | [
87,
59
] | python | en | ['en', 'la', 'hi'] | False |
source_from_cache | (path) | **DEPRECATED**
Given the path to a .pyc. file, return the path to its .py file.
The .pyc file does not need to exist; this simply returns the path to
the .py file calculated to correspond to the .pyc file. If path does
not conform to PEP 3147 format, ValueError will be raised. If
sys.implementati... | **DEPRECATED** | def source_from_cache(path):
"""**DEPRECATED**
Given the path to a .pyc. file, return the path to its .py file.
The .pyc file does not need to exist; this simply returns the path to
the .py file calculated to correspond to the .pyc file. If path does
not conform to PEP 3147 format, ValueError wil... | [
"def",
"source_from_cache",
"(",
"path",
")",
":",
"return",
"util",
".",
"source_from_cache",
"(",
"path",
")"
] | [
90,
0
] | [
101,
39
] | python | en | ['en', 'la', 'hi'] | False |
get_suffixes | () | **DEPRECATED** | **DEPRECATED** | def get_suffixes():
"""**DEPRECATED**"""
extensions = [(s, 'rb', C_EXTENSION) for s in machinery.EXTENSION_SUFFIXES]
source = [(s, 'r', PY_SOURCE) for s in machinery.SOURCE_SUFFIXES]
bytecode = [(s, 'rb', PY_COMPILED) for s in machinery.BYTECODE_SUFFIXES]
return extensions + source + bytecode | [
"def",
"get_suffixes",
"(",
")",
":",
"extensions",
"=",
"[",
"(",
"s",
",",
"'rb'",
",",
"C_EXTENSION",
")",
"for",
"s",
"in",
"machinery",
".",
"EXTENSION_SUFFIXES",
"]",
"source",
"=",
"[",
"(",
"s",
",",
"'r'",
",",
"PY_SOURCE",
")",
"for",
"s",
... | [
104,
0
] | [
110,
41
] | python | en | ['en', 'la', 'hi'] | False |
load_compiled | (name, pathname, file=None) | **DEPRECATED** | **DEPRECATED** | def load_compiled(name, pathname, file=None):
"""**DEPRECATED**"""
loader = _LoadCompiledCompatibility(name, pathname, file)
spec = util.spec_from_file_location(name, pathname, loader=loader)
if name in sys.modules:
module = _exec(spec, sys.modules[name])
else:
module = _load(spec)
... | [
"def",
"load_compiled",
"(",
"name",
",",
"pathname",
",",
"file",
"=",
"None",
")",
":",
"loader",
"=",
"_LoadCompiledCompatibility",
"(",
"name",
",",
"pathname",
",",
"file",
")",
"spec",
"=",
"util",
".",
"spec_from_file_location",
"(",
"name",
",",
"p... | [
184,
0
] | [
196,
17
] | python | en | ['en', 'la', 'hi'] | False |
load_package | (name, path) | **DEPRECATED** | **DEPRECATED** | def load_package(name, path):
"""**DEPRECATED**"""
if os.path.isdir(path):
extensions = (machinery.SOURCE_SUFFIXES[:] +
machinery.BYTECODE_SUFFIXES[:])
for extension in extensions:
init_path = os.path.join(path, '__init__' + extension)
if os.path.exi... | [
"def",
"load_package",
"(",
"name",
",",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"extensions",
"=",
"(",
"machinery",
".",
"SOURCE_SUFFIXES",
"[",
":",
"]",
"+",
"machinery",
".",
"BYTECODE_SUFFIXES",
"[",
":",
... | [
199,
0
] | [
216,
26
] | python | en | ['en', 'la', 'hi'] | False |
load_module | (name, file, filename, details) | **DEPRECATED**
Load a module, given information returned by find_module().
The module name must include the full package name, if any.
| **DEPRECATED** | def load_module(name, file, filename, details):
"""**DEPRECATED**
Load a module, given information returned by find_module().
The module name must include the full package name, if any.
"""
suffix, mode, type_ = details
if mode and (not mode.startswith(('r', 'U')) or '+' in mode):
rai... | [
"def",
"load_module",
"(",
"name",
",",
"file",
",",
"filename",
",",
"details",
")",
":",
"suffix",
",",
"mode",
",",
"type_",
"=",
"details",
"if",
"mode",
"and",
"(",
"not",
"mode",
".",
"startswith",
"(",
"(",
"'r'",
",",
"'U'",
")",
")",
"or",... | [
219,
0
] | [
251,
41
] | python | en | ['en', 'la', 'hi'] | False |
find_module | (name, path=None) | **DEPRECATED**
Search for a module.
If path is omitted or None, search for a built-in, frozen or special
module and continue search in sys.path. The module name cannot
contain '.'; to search for a submodule of a package, pass the
submodule name and the package's __path__.
| **DEPRECATED** | def find_module(name, path=None):
"""**DEPRECATED**
Search for a module.
If path is omitted or None, search for a built-in, frozen or special
module and continue search in sys.path. The module name cannot
contain '.'; to search for a submodule of a package, pass the
submodule name and the pack... | [
"def",
"find_module",
"(",
"name",
",",
"path",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"'name' must be a str, not {}\"",
".",
"format",
"(",
"type",
"(",
"name",
")",
")",
")",
... | [
254,
0
] | [
303,
49
] | python | en | ['en', 'la', 'hi'] | False |
reload | (module) | **DEPRECATED**
Reload the module and return it.
The module must have been successfully imported before.
| **DEPRECATED** | def reload(module):
"""**DEPRECATED**
Reload the module and return it.
The module must have been successfully imported before.
"""
return importlib.reload(module) | [
"def",
"reload",
"(",
"module",
")",
":",
"return",
"importlib",
".",
"reload",
"(",
"module",
")"
] | [
306,
0
] | [
314,
35
] | python | en | ['en', 'la', 'hi'] | False |
init_builtin | (name) | **DEPRECATED**
Load and return a built-in module by name, or None is such module doesn't
exist
| **DEPRECATED** | def init_builtin(name):
"""**DEPRECATED**
Load and return a built-in module by name, or None is such module doesn't
exist
"""
try:
return _builtin_from_name(name)
except ImportError:
return None | [
"def",
"init_builtin",
"(",
"name",
")",
":",
"try",
":",
"return",
"_builtin_from_name",
"(",
"name",
")",
"except",
"ImportError",
":",
"return",
"None"
] | [
317,
0
] | [
326,
19
] | python | en | ['en', 'la', 'hi'] | False |
NullImporter.find_module | (self, fullname) | Always returns None. | Always returns None. | def find_module(self, fullname):
"""Always returns None."""
return None | [
"def",
"find_module",
"(",
"self",
",",
"fullname",
")",
":",
"return",
"None"
] | [
127,
4
] | [
129,
19
] | python | en | ['en', 'de', 'en'] | True |
_HackedGetData.get_data | (self, path) | Gross hack to contort loader to deal w/ load_*()'s bad API. | Gross hack to contort loader to deal w/ load_*()'s bad API. | def get_data(self, path):
"""Gross hack to contort loader to deal w/ load_*()'s bad API."""
if self.file and path == self.path:
if not self.file.closed:
file = self.file
else:
self.file = file = open(self.path, 'r')
with file:
... | [
"def",
"get_data",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"file",
"and",
"path",
"==",
"self",
".",
"path",
":",
"if",
"not",
"self",
".",
"file",
".",
"closed",
":",
"file",
"=",
"self",
".",
"file",
"else",
":",
"self",
".",
"... | [
141,
4
] | [
157,
41
] | python | en | ['en', 'en', 'en'] | True |
GroupTypesFilterAction.filter | (self, table, group_types, filter_string) | Naive case-insensitive search. | Naive case-insensitive search. | def filter(self, table, group_types, filter_string):
"""Naive case-insensitive search."""
query = filter_string.lower()
return [group_type for group_type in group_types
if query in group_type.name.lower()] | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"group_types",
",",
"filter_string",
")",
":",
"query",
"=",
"filter_string",
".",
"lower",
"(",
")",
"return",
"[",
"group_type",
"for",
"group_type",
"in",
"group_types",
"if",
"query",
"in",
"group_type",
... | [
54,
4
] | [
58,
52
] | python | en | ['en', 'it', 'en'] | True |
Attribute.__init__ | (self, name, value=None) |
@param name: The attribute's name with I{optional} namespace prefix.
@type name: basestring
@param value: The attribute's value
@type value: basestring
| def __init__(self, name, value=None):
"""
@param name: The attribute's name with I{optional} namespace prefix.
@type name: basestring
@param value: The attribute's value
@type value: basestring
"""
self.parent = None
self.prefix, self.name = splitPrefix(n... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"self",
".",
"parent",
"=",
"None",
"self",
".",
"prefix",
",",
"self",
".",
"name",
"=",
"splitPrefix",
"(",
"name",
")",
"self",
".",
"setValue",
"(",
"value",
")"
... | [
40,
4
] | [
49,
28
] | python | en | ['en', 'error', 'th'] | False | |
Attribute.clone | (self, parent=None) |
Clone this object.
@param parent: The parent for the clone.
@type parent: L{element.Element}
@return: A copy of this object assigned to the new parent.
@rtype: L{Attribute}
|
Clone this object.
| def clone(self, parent=None):
"""
Clone this object.
@param parent: The parent for the clone.
@type parent: L{element.Element}
@return: A copy of this object assigned to the new parent.
@rtype: L{Attribute}
"""
a = Attribute(self.qname(), self.value)
... | [
"def",
"clone",
"(",
"self",
",",
"parent",
"=",
"None",
")",
":",
"a",
"=",
"Attribute",
"(",
"self",
".",
"qname",
"(",
")",
",",
"self",
".",
"value",
")",
"a",
".",
"parent",
"=",
"parent",
"return",
"a"
] | [
51,
4
] | [
61,
16
] | python | en | ['en', 'error', 'th'] | False |
Attribute.qname | (self) |
Get the B{fully} qualified name of this attribute
@return: The fully qualified name.
@rtype: basestring
|
Get the B{fully} qualified name of this attribute
| def qname(self):
"""
Get the B{fully} qualified name of this attribute
@return: The fully qualified name.
@rtype: basestring
"""
if self.prefix is None:
return self.name
else:
return ':'.join((self.prefix, self.name)) | [
"def",
"qname",
"(",
"self",
")",
":",
"if",
"self",
".",
"prefix",
"is",
"None",
":",
"return",
"self",
".",
"name",
"else",
":",
"return",
"':'",
".",
"join",
"(",
"(",
"self",
".",
"prefix",
",",
"self",
".",
"name",
")",
")"
] | [
63,
4
] | [
72,
53
] | python | en | ['en', 'error', 'th'] | False |
Attribute.setValue | (self, value) |
Set the attributes value
@param value: The new value (may be None)
@type value: basestring
@return: self
@rtype: L{Attribute}
|
Set the attributes value
| def setValue(self, value):
"""
Set the attributes value
@param value: The new value (may be None)
@type value: basestring
@return: self
@rtype: L{Attribute}
"""
if isinstance(value, Text):
self.value = value
else:
self.value... | [
"def",
"setValue",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Text",
")",
":",
"self",
".",
"value",
"=",
"value",
"else",
":",
"self",
".",
"value",
"=",
"Text",
"(",
"value",
")",
"return",
"self"
] | [
74,
4
] | [
86,
19
] | python | en | ['en', 'error', 'th'] | False |
Attribute.getValue | (self, default=Text('')) |
Get the attributes value with optional default.
@param default: An optional value to be return when the
attribute's has not been set.
@type default: basestring
@return: The attribute's value, or I{default}
@rtype: L{Text}
|
Get the attributes value with optional default.
| def getValue(self, default=Text('')):
"""
Get the attributes value with optional default.
@param default: An optional value to be return when the
attribute's has not been set.
@type default: basestring
@return: The attribute's value, or I{default}
@rtype: L{Te... | [
"def",
"getValue",
"(",
"self",
",",
"default",
"=",
"Text",
"(",
"''",
")",
")",
":",
"if",
"self",
".",
"hasText",
"(",
")",
":",
"return",
"self",
".",
"value",
"else",
":",
"return",
"default"
] | [
88,
4
] | [
100,
26
] | python | en | ['en', 'error', 'th'] | False |
Attribute.hasText | (self) |
Get whether the attribute has I{text} and that it is not an empty
(zero length) string.
@return: True when has I{text}.
@rtype: boolean
|
Get whether the attribute has I{text} and that it is not an empty
(zero length) string.
| def hasText(self):
"""
Get whether the attribute has I{text} and that it is not an empty
(zero length) string.
@return: True when has I{text}.
@rtype: boolean
"""
return ( self.value is not None and len(self.value) ) | [
"def",
"hasText",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"value",
"is",
"not",
"None",
"and",
"len",
"(",
"self",
".",
"value",
")",
")"
] | [
102,
4
] | [
109,
61
] | python | en | ['en', 'error', 'th'] | False |
Attribute.namespace | (self) |
Get the attributes namespace. This may either be the namespace
defined by an optional prefix, or its parent's namespace.
@return: The attribute's namespace
@rtype: (I{prefix}, I{name})
|
Get the attributes namespace. This may either be the namespace
defined by an optional prefix, or its parent's namespace.
| def namespace(self):
"""
Get the attributes namespace. This may either be the namespace
defined by an optional prefix, or its parent's namespace.
@return: The attribute's namespace
@rtype: (I{prefix}, I{name})
"""
if self.prefix is None:
return Namesp... | [
"def",
"namespace",
"(",
"self",
")",
":",
"if",
"self",
".",
"prefix",
"is",
"None",
":",
"return",
"Namespace",
".",
"default",
"else",
":",
"return",
"self",
".",
"resolvePrefix",
"(",
"self",
".",
"prefix",
")"
] | [
111,
4
] | [
121,
50
] | python | en | ['en', 'error', 'th'] | False |
Attribute.resolvePrefix | (self, prefix) |
Resolve the specified prefix to a known namespace.
@param prefix: A declared prefix
@type prefix: basestring
@return: The namespace that has been mapped to I{prefix}
@rtype: (I{prefix}, I{name})
|
Resolve the specified prefix to a known namespace.
| def resolvePrefix(self, prefix):
"""
Resolve the specified prefix to a known namespace.
@param prefix: A declared prefix
@type prefix: basestring
@return: The namespace that has been mapped to I{prefix}
@rtype: (I{prefix}, I{name})
"""
ns = Namespace.defau... | [
"def",
"resolvePrefix",
"(",
"self",
",",
"prefix",
")",
":",
"ns",
"=",
"Namespace",
".",
"default",
"if",
"self",
".",
"parent",
"is",
"not",
"None",
":",
"ns",
"=",
"self",
".",
"parent",
".",
"resolvePrefix",
"(",
"prefix",
")",
"return",
"ns"
] | [
123,
4
] | [
134,
17
] | python | en | ['en', 'error', 'th'] | False |
Attribute.match | (self, name=None, ns=None) |
Match by (optional) name and/or (optional) namespace.
@param name: The optional attribute tag name.
@type name: str
@param ns: An optional namespace.
@type ns: (I{prefix}, I{name})
@return: True if matched.
@rtype: boolean
|
Match by (optional) name and/or (optional) namespace.
| def match(self, name=None, ns=None):
"""
Match by (optional) name and/or (optional) namespace.
@param name: The optional attribute tag name.
@type name: str
@param ns: An optional namespace.
@type ns: (I{prefix}, I{name})
@return: True if matched.
@rtype: ... | [
"def",
"match",
"(",
"self",
",",
"name",
"=",
"None",
",",
"ns",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"byname",
"=",
"True",
"else",
":",
"byname",
"=",
"(",
"self",
".",
"name",
"==",
"name",
")",
"if",
"ns",
"is",
"None",
... | [
136,
4
] | [
154,
34
] | python | en | ['en', 'error', 'th'] | False |
Attribute.__eq__ | (self, rhs) | equals operator | equals operator | def __eq__(self, rhs):
""" equals operator """
return rhs is not None and \
isinstance(rhs, Attribute) and \
self.prefix == rhs.name and \
self.name == rhs.name | [
"def",
"__eq__",
"(",
"self",
",",
"rhs",
")",
":",
"return",
"rhs",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"rhs",
",",
"Attribute",
")",
"and",
"self",
".",
"prefix",
"==",
"rhs",
".",
"name",
"and",
"self",
".",
"name",
"==",
"rhs",
".",
... | [
156,
4
] | [
161,
33
] | python | en | ['en', 'la', 'en'] | False |
Attribute.__repr__ | (self) | get a string representation | get a string representation | def __repr__(self):
""" get a string representation """
return \
'attr (prefix=%s, name=%s, value=(%s))' %\
(self.prefix, self.name, self.value) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"'attr (prefix=%s, name=%s, value=(%s))'",
"%",
"(",
"self",
".",
"prefix",
",",
"self",
".",
"name",
",",
"self",
".",
"value",
")"
] | [
163,
4
] | [
167,
52
] | python | en | ['en', 'pt', 'en'] | True |
Attribute.__str__ | (self) | get an xml string representation | get an xml string representation | def __str__(self):
""" get an xml string representation """
return unicode(self).encode('utf-8') | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"unicode",
"(",
"self",
")",
".",
"encode",
"(",
"'utf-8'",
")"
] | [
169,
4
] | [
171,
44
] | python | en | ['en', 'kk', 'en'] | True |
Attribute.__unicode__ | (self) | get an xml string representation | get an xml string representation | def __unicode__(self):
""" get an xml string representation """
n = self.qname()
if self.hasText():
v = self.value.escape()
else:
v = self.value
return u'%s="%s"' % (n, v) | [
"def",
"__unicode__",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"qname",
"(",
")",
"if",
"self",
".",
"hasText",
"(",
")",
":",
"v",
"=",
"self",
".",
"value",
".",
"escape",
"(",
")",
"else",
":",
"v",
"=",
"self",
".",
"value",
"return",
... | [
173,
4
] | [
180,
34
] | python | en | ['en', 'kk', 'en'] | True |
is_connection_dropped | (conn) |
Returns True if the connection is dropped and should be closed.
:param conn:
:class:`httplib.HTTPConnection` object.
Note: For platforms like AppEngine, this will always return ``False`` to
let the platform handle connection recycling transparently for us.
|
Returns True if the connection is dropped and should be closed. | def is_connection_dropped(conn): # Platform-specific
"""
Returns True if the connection is dropped and should be closed.
:param conn:
:class:`httplib.HTTPConnection` object.
Note: For platforms like AppEngine, this will always return ``False`` to
let the platform handle connection recycli... | [
"def",
"is_connection_dropped",
"(",
"conn",
")",
":",
"# Platform-specific",
"sock",
"=",
"getattr",
"(",
"conn",
",",
"\"sock\"",
",",
"False",
")",
"if",
"sock",
"is",
"False",
":",
"# Platform-specific: AppEngine",
"return",
"False",
"if",
"sock",
"is",
"N... | [
6,
0
] | [
25,
20
] | python | en | ['en', 'error', 'th'] | False |
create_connection | (
address,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None,
socket_options=None,
) | Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the... | Connect to *address* and return the socket object. | def create_connection(
address,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None,
socket_options=None,
):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the opti... | [
"def",
"create_connection",
"(",
"address",
",",
"timeout",
"=",
"socket",
".",
"_GLOBAL_DEFAULT_TIMEOUT",
",",
"source_address",
"=",
"None",
",",
"socket_options",
"=",
"None",
",",
")",
":",
"host",
",",
"port",
"=",
"address",
"if",
"host",
".",
"startsw... | [
32,
0
] | [
85,
59
] | python | en | ['en', 'en', 'en'] | True |
allowed_gai_family | () | This function is designed to work in the context of
getaddrinfo, where family=socket.AF_UNSPEC is the default and
will perform a DNS search for both IPv6 and IPv4 records. | This function is designed to work in the context of
getaddrinfo, where family=socket.AF_UNSPEC is the default and
will perform a DNS search for both IPv6 and IPv4 records. | def allowed_gai_family():
"""This function is designed to work in the context of
getaddrinfo, where family=socket.AF_UNSPEC is the default and
will perform a DNS search for both IPv6 and IPv4 records."""
family = socket.AF_INET
if HAS_IPV6:
family = socket.AF_UNSPEC
return family | [
"def",
"allowed_gai_family",
"(",
")",
":",
"family",
"=",
"socket",
".",
"AF_INET",
"if",
"HAS_IPV6",
":",
"family",
"=",
"socket",
".",
"AF_UNSPEC",
"return",
"family"
] | [
96,
0
] | [
104,
17
] | python | en | ['en', 'en', 'en'] | True |
_has_ipv6 | (host) | Returns True if the system can bind an IPv6 address. | Returns True if the system can bind an IPv6 address. | def _has_ipv6(host):
""" Returns True if the system can bind an IPv6 address. """
sock = None
has_ipv6 = False
# App Engine doesn't support IPV6 sockets and actually has a quota on the
# number of sockets that can be used, so just early out here instead of
# creating a socket needlessly.
# ... | [
"def",
"_has_ipv6",
"(",
"host",
")",
":",
"sock",
"=",
"None",
"has_ipv6",
"=",
"False",
"# App Engine doesn't support IPV6 sockets and actually has a quota on the",
"# number of sockets that can be used, so just early out here instead of",
"# creating a socket needlessly.",
"# See ht... | [
107,
0
] | [
134,
19
] | python | en | ['en', 'lb', 'en'] | True |
test_makepyfile_utf8 | (testdir) | Ensure makepyfile accepts utf-8 bytes as input (#2738) | Ensure makepyfile accepts utf-8 bytes as input (#2738) | def test_makepyfile_utf8(testdir):
"""Ensure makepyfile accepts utf-8 bytes as input (#2738)"""
utf8_contents = u"""
def setup_function(function):
mixed_encoding = u'São Paulo'
""".encode('utf-8')
p = testdir.makepyfile(utf8_contents)
assert u"mixed_encoding = u'São Paulo'".encod... | [
"def",
"test_makepyfile_utf8",
"(",
"testdir",
")",
":",
"utf8_contents",
"=",
"u\"\"\"\n def setup_function(function):\n mixed_encoding = u'São Paulo'\n \"\"\"",
".",
"encode",
"(",
"'utf-8'",
")",
"p",
"=",
"testdir",
".",
"makepyfile",
"(",
"utf8_conte... | [
127,
0
] | [
134,
76
] | python | en | ['en', 'jv', 'en'] | True |
guess_content_type | (filename, default="application/octet-stream") |
Guess the "Content-Type" of a file.
:param filename:
The filename to guess the "Content-Type" of using :mod:`mimetypes`.
:param default:
If no "Content-Type" can be guessed, default to `default`.
|
Guess the "Content-Type" of a file. | def guess_content_type(filename, default="application/octet-stream"):
"""
Guess the "Content-Type" of a file.
:param filename:
The filename to guess the "Content-Type" of using :mod:`mimetypes`.
:param default:
If no "Content-Type" can be guessed, default to `default`.
"""
if fi... | [
"def",
"guess_content_type",
"(",
"filename",
",",
"default",
"=",
"\"application/octet-stream\"",
")",
":",
"if",
"filename",
":",
"return",
"mimetypes",
".",
"guess_type",
"(",
"filename",
")",
"[",
"0",
"]",
"or",
"default",
"return",
"default"
] | [
8,
0
] | [
19,
18
] | python | en | ['en', 'error', 'th'] | False |
format_header_param_rfc2231 | (name, value) |
Helper function to format and quote a single header parameter using the
strategy defined in RFC 2231.
Particularly useful for header parameters which might contain
non-ASCII values, like file names. This follows RFC 2388 Section 4.4.
:param name:
The name of the parameter, a string expect... |
Helper function to format and quote a single header parameter using the
strategy defined in RFC 2231. | def format_header_param_rfc2231(name, value):
"""
Helper function to format and quote a single header parameter using the
strategy defined in RFC 2231.
Particularly useful for header parameters which might contain
non-ASCII values, like file names. This follows RFC 2388 Section 4.4.
:param nam... | [
"def",
"format_header_param_rfc2231",
"(",
"name",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"binary_type",
")",
":",
"value",
"=",
"value",
".",
"decode",
"(",
"\"utf-8\"",
")",
"if",
"not",
"any",
"(",
"ch",
"in",
"va... | [
22,
0
] | [
60,
16
] | python | en | ['en', 'error', 'th'] | False |
format_header_param_html5 | (name, value) |
Helper function to format and quote a single header parameter using the
HTML5 strategy.
Particularly useful for header parameters which might contain
non-ASCII values, like file names. This follows the `HTML5 Working Draft
Section 4.10.22.7`_ and matches the behavior of curl and modern browsers.
... |
Helper function to format and quote a single header parameter using the
HTML5 strategy. | def format_header_param_html5(name, value):
"""
Helper function to format and quote a single header parameter using the
HTML5 strategy.
Particularly useful for header parameters which might contain
non-ASCII values, like file names. This follows the `HTML5 Working Draft
Section 4.10.22.7`_ and ... | [
"def",
"format_header_param_html5",
"(",
"name",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"binary_type",
")",
":",
"value",
"=",
"value",
".",
"decode",
"(",
"\"utf-8\"",
")",
"value",
"=",
"_replace_multiple",
"(",
"value... | [
93,
0
] | [
117,
37
] | python | en | ['en', 'error', 'th'] | False |
RequestField.from_tuples | (cls, fieldname, value, header_formatter=format_header_param_html5) |
A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.
Supports constructing :class:`~urllib3.fields.RequestField` from
parameter of key/value strings AND key/filetuple. A filetuple is a
(filename, data, MIME type) tuple where the MIME type is optional.
... |
A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters. | def from_tuples(cls, fieldname, value, header_formatter=format_header_param_html5):
"""
A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.
Supports constructing :class:`~urllib3.fields.RequestField` from
parameter of key/value strings AND key/filetuple. A f... | [
"def",
"from_tuples",
"(",
"cls",
",",
"fieldname",
",",
"value",
",",
"header_formatter",
"=",
"format_header_param_html5",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"tuple",
")",
":",
"if",
"len",
"(",
"value",
")",
"==",
"3",
":",
"filename",
"... | [
158,
4
] | [
191,
28
] | python | en | ['en', 'error', 'th'] | False |
RequestField._render_part | (self, name, value) |
Overridable helper function to format a single header parameter. By
default, this calls ``self.header_formatter``.
:param name:
The name of the parameter, a string expected to be ASCII only.
:param value:
The value of the parameter, provided as a unicode string.... |
Overridable helper function to format a single header parameter. By
default, this calls ``self.header_formatter``. | def _render_part(self, name, value):
"""
Overridable helper function to format a single header parameter. By
default, this calls ``self.header_formatter``.
:param name:
The name of the parameter, a string expected to be ASCII only.
:param value:
The value... | [
"def",
"_render_part",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"return",
"self",
".",
"header_formatter",
"(",
"name",
",",
"value",
")"
] | [
193,
4
] | [
204,
49
] | python | en | ['en', 'error', 'th'] | False |
RequestField._render_parts | (self, header_parts) |
Helper function to format and quote a single header.
Useful for single headers that are composed of multiple items. E.g.,
'Content-Disposition' fields.
:param header_parts:
A sequence of (k, v) tuples or a :class:`dict` of (k, v) to format
as `k1="v1"; k2="v2";... |
Helper function to format and quote a single header. | def _render_parts(self, header_parts):
"""
Helper function to format and quote a single header.
Useful for single headers that are composed of multiple items. E.g.,
'Content-Disposition' fields.
:param header_parts:
A sequence of (k, v) tuples or a :class:`dict` of ... | [
"def",
"_render_parts",
"(",
"self",
",",
"header_parts",
")",
":",
"parts",
"=",
"[",
"]",
"iterable",
"=",
"header_parts",
"if",
"isinstance",
"(",
"header_parts",
",",
"dict",
")",
":",
"iterable",
"=",
"header_parts",
".",
"items",
"(",
")",
"for",
"... | [
206,
4
] | [
226,
32
] | python | en | ['en', 'error', 'th'] | False |
RequestField.render_headers | (self) |
Renders the headers for this request field.
|
Renders the headers for this request field.
| def render_headers(self):
"""
Renders the headers for this request field.
"""
lines = []
sort_keys = ["Content-Disposition", "Content-Type", "Content-Location"]
for sort_key in sort_keys:
if self.headers.get(sort_key, False):
lines.append(u"%s... | [
"def",
"render_headers",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"sort_keys",
"=",
"[",
"\"Content-Disposition\"",
",",
"\"Content-Type\"",
",",
"\"Content-Location\"",
"]",
"for",
"sort_key",
"in",
"sort_keys",
":",
"if",
"self",
".",
"headers",
".",
... | [
228,
4
] | [
245,
34
] | python | en | ['en', 'error', 'th'] | False |
RequestField.make_multipart | (
self, content_disposition=None, content_type=None, content_location=None
) |
Makes this request field into a multipart request field.
This method overrides "Content-Disposition", "Content-Type" and
"Content-Location" headers to the request parameter.
:param content_type:
The 'Content-Type' of the request body.
:param content_location:
... |
Makes this request field into a multipart request field. | def make_multipart(
self, content_disposition=None, content_type=None, content_location=None
):
"""
Makes this request field into a multipart request field.
This method overrides "Content-Disposition", "Content-Type" and
"Content-Location" headers to the request parameter.
... | [
"def",
"make_multipart",
"(",
"self",
",",
"content_disposition",
"=",
"None",
",",
"content_type",
"=",
"None",
",",
"content_location",
"=",
"None",
")",
":",
"self",
".",
"headers",
"[",
"\"Content-Disposition\"",
"]",
"=",
"content_disposition",
"or",
"u\"fo... | [
247,
4
] | [
272,
59
] | 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.