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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
_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 |
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 |
ExtraRegressTests.test_regression_7314_7372 | (self) |
Regression tests for #7314 and #7372
|
Regression tests for #7314 and #7372
| def test_regression_7314_7372(self):
"""
Regression tests for #7314 and #7372
"""
rm = RevisionableModel.objects.create(
title='First Revision',
when=datetime.datetime(2008, 9, 28, 10, 30, 0)
)
self.assertEqual(rm.pk, rm.base.pk)
rm2 = rm.... | [
"def",
"test_regression_7314_7372",
"(",
"self",
")",
":",
"rm",
"=",
"RevisionableModel",
".",
"objects",
".",
"create",
"(",
"title",
"=",
"'First Revision'",
",",
"when",
"=",
"datetime",
".",
"datetime",
"(",
"2008",
",",
"9",
",",
"28",
",",
"10",
"... | [
20,
4
] | [
69,
9
] | python | en | ['en', 'error', 'th'] | False |
ExtraRegressTests.test_regression_7957 | (self) |
Regression test for #7957: Combining extra() calls should leave the
corresponding parameters associated with the right extra() bit. I.e.
internal dictionary must remain sorted.
|
Regression test for #7957: Combining extra() calls should leave the
corresponding parameters associated with the right extra() bit. I.e.
internal dictionary must remain sorted.
| def test_regression_7957(self):
"""
Regression test for #7957: Combining extra() calls should leave the
corresponding parameters associated with the right extra() bit. I.e.
internal dictionary must remain sorted.
"""
self.assertEqual(
(User.objects
... | [
"def",
"test_regression_7957",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"(",
"User",
".",
"objects",
".",
"extra",
"(",
"select",
"=",
"{",
"\"alpha\"",
":",
"\"%s\"",
"}",
",",
"select_params",
"=",
"(",
"1",
",",
")",
")",
".",
"extr... | [
86,
4
] | [
104,
9
] | python | en | ['en', 'error', 'th'] | False |
ExtraRegressTests.test_regression_7961 | (self) |
Regression test for #7961: When not using a portion of an
extra(...) in a query, remove any corresponding parameters from the
query as well.
|
Regression test for #7961: When not using a portion of an
extra(...) in a query, remove any corresponding parameters from the
query as well.
| def test_regression_7961(self):
"""
Regression test for #7961: When not using a portion of an
extra(...) in a query, remove any corresponding parameters from the
query as well.
"""
self.assertEqual(
list(User.objects
.extra(select={"alpha": "%s... | [
"def",
"test_regression_7961",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"list",
"(",
"User",
".",
"objects",
".",
"extra",
"(",
"select",
"=",
"{",
"\"alpha\"",
":",
"\"%s\"",
"}",
",",
"select_params",
"=",
"(",
"-",
"6",
",",
")",
")... | [
106,
4
] | [
118,
9
] | python | en | ['en', 'error', 'th'] | False |
ExtraRegressTests.test_regression_8063 | (self) |
Regression test for #8063: limiting a query shouldn't discard any
extra() bits.
|
Regression test for #8063: limiting a query shouldn't discard any
extra() bits.
| def test_regression_8063(self):
"""
Regression test for #8063: limiting a query shouldn't discard any
extra() bits.
"""
qs = User.objects.all().extra(where=['id=%s'], params=[self.u.id])
self.assertQuerysetEqual(qs, ['<User: fred>'])
self.assertQuerysetEqual(qs[:1... | [
"def",
"test_regression_8063",
"(",
"self",
")",
":",
"qs",
"=",
"User",
".",
"objects",
".",
"all",
"(",
")",
".",
"extra",
"(",
"where",
"=",
"[",
"'id=%s'",
"]",
",",
"params",
"=",
"[",
"self",
".",
"u",
".",
"id",
"]",
")",
"self",
".",
"a... | [
120,
4
] | [
127,
58
] | python | en | ['en', 'error', 'th'] | False |
ExtraRegressTests.test_regression_8039 | (self) |
Regression test for #8039: Ordering sometimes removed relevant tables
from extra(). This test is the critical case: ordering uses a table,
but then removes the reference because of an optimization. The table
should still be present because of the extra() call.
|
Regression test for #8039: Ordering sometimes removed relevant tables
from extra(). This test is the critical case: ordering uses a table,
but then removes the reference because of an optimization. The table
should still be present because of the extra() call.
| def test_regression_8039(self):
"""
Regression test for #8039: Ordering sometimes removed relevant tables
from extra(). This test is the critical case: ordering uses a table,
but then removes the reference because of an optimization. The table
should still be present because of t... | [
"def",
"test_regression_8039",
"(",
"self",
")",
":",
"self",
".",
"assertQuerysetEqual",
"(",
"(",
"Order",
".",
"objects",
".",
"extra",
"(",
"where",
"=",
"[",
"\"username=%s\"",
"]",
",",
"params",
"=",
"[",
"\"fred\"",
"]",
",",
"tables",
"=",
"[",
... | [
129,
4
] | [
141,
9
] | python | en | ['en', 'error', 'th'] | False |
ExtraRegressTests.test_regression_8819 | (self) |
Regression test for #8819: Fields in the extra(select=...) list
should be available to extra(order_by=...).
|
Regression test for #8819: Fields in the extra(select=...) list
should be available to extra(order_by=...).
| def test_regression_8819(self):
"""
Regression test for #8819: Fields in the extra(select=...) list
should be available to extra(order_by=...).
"""
self.assertQuerysetEqual(
User.objects.filter(pk=self.u.id).extra(select={'extra_field': 1}).distinct(),
['<... | [
"def",
"test_regression_8819",
"(",
"self",
")",
":",
"self",
".",
"assertQuerysetEqual",
"(",
"User",
".",
"objects",
".",
"filter",
"(",
"pk",
"=",
"self",
".",
"u",
".",
"id",
")",
".",
"extra",
"(",
"select",
"=",
"{",
"'extra_field'",
":",
"1",
... | [
143,
4
] | [
159,
9
] | python | en | ['en', 'error', 'th'] | False |
ExtraRegressTests.test_dates_query | (self) |
When calling the dates() method on a queryset with extra selection
columns, we can (and should) ignore those columns. They don't change
the result and cause incorrect SQL to be produced otherwise.
|
When calling the dates() method on a queryset with extra selection
columns, we can (and should) ignore those columns. They don't change
the result and cause incorrect SQL to be produced otherwise.
| def test_dates_query(self):
"""
When calling the dates() method on a queryset with extra selection
columns, we can (and should) ignore those columns. They don't change
the result and cause incorrect SQL to be produced otherwise.
"""
RevisionableModel.objects.create(
... | [
"def",
"test_dates_query",
"(",
"self",
")",
":",
"RevisionableModel",
".",
"objects",
".",
"create",
"(",
"title",
"=",
"'First Revision'",
",",
"when",
"=",
"datetime",
".",
"datetime",
"(",
"2008",
",",
"9",
",",
"28",
",",
"10",
",",
"30",
",",
"0"... | [
161,
4
] | [
176,
9
] | python | en | ['en', 'error', 'th'] | False |
ExtraRegressTests.test_values_with_extra | (self) |
Regression test for #10256... If there is a values() clause, Extra
columns are only returned if they are explicitly mentioned.
|
Regression test for #10256... If there is a values() clause, Extra
columns are only returned if they are explicitly mentioned.
| def test_values_with_extra(self):
"""
Regression test for #10256... If there is a values() clause, Extra
columns are only returned if they are explicitly mentioned.
"""
obj = TestObject(first='first', second='second', third='third')
obj.save()
self.assertEqual(
... | [
"def",
"test_values_with_extra",
"(",
"self",
")",
":",
"obj",
"=",
"TestObject",
"(",
"first",
"=",
"'first'",
",",
"second",
"=",
"'second'",
",",
"third",
"=",
"'third'",
")",
"obj",
".",
"save",
"(",
")",
"self",
".",
"assertEqual",
"(",
"list",
"(... | [
178,
4
] | [
282,
9
] | python | en | ['en', 'error', 'th'] | False |
ExtraRegressTests.test_regression_10847 | (self) |
Regression for #10847: the list of extra columns can always be
accurately evaluated. Using an inner query ensures that as_sql() is
producing correct output without requiring full evaluation and
execution of the inner query.
|
Regression for #10847: the list of extra columns can always be
accurately evaluated. Using an inner query ensures that as_sql() is
producing correct output without requiring full evaluation and
execution of the inner query.
| def test_regression_10847(self):
"""
Regression for #10847: the list of extra columns can always be
accurately evaluated. Using an inner query ensures that as_sql() is
producing correct output without requiring full evaluation and
execution of the inner query.
"""
... | [
"def",
"test_regression_10847",
"(",
"self",
")",
":",
"obj",
"=",
"TestObject",
"(",
"first",
"=",
"'first'",
",",
"second",
"=",
"'second'",
",",
"third",
"=",
"'third'",
")",
"obj",
".",
"save",
"(",
")",
"self",
".",
"assertEqual",
"(",
"list",
"("... | [
284,
4
] | [
321,
9
] | python | en | ['en', 'error', 'th'] | False |
ExtraRegressTests.test_regression_17877 | (self) |
Ensure that extra WHERE clauses get correctly ANDed, even when they
contain OR operations.
|
Ensure that extra WHERE clauses get correctly ANDed, even when they
contain OR operations.
| def test_regression_17877(self):
"""
Ensure that extra WHERE clauses get correctly ANDed, even when they
contain OR operations.
"""
# Test Case 1: should appear in queryset.
t = TestObject(first='a', second='a', third='a')
t.save()
# Test Case 2: should ap... | [
"def",
"test_regression_17877",
"(",
"self",
")",
":",
"# Test Case 1: should appear in queryset.",
"t",
"=",
"TestObject",
"(",
"first",
"=",
"'a'",
",",
"second",
"=",
"'a'",
",",
"third",
"=",
"'a'",
")",
"t",
".",
"save",
"(",
")",
"# Test Case 2: should a... | [
323,
4
] | [
353,
9
] | python | en | ['en', 'error', 'th'] | False |
default_key_func | (key, key_prefix, version) |
Default function to generate keys.
Construct the key used by all other methods. By default, prepend
the `key_prefix'. KEY_FUNCTION can be used to specify an alternate
function with custom key making behavior.
|
Default function to generate keys. | def default_key_func(key, key_prefix, version):
"""
Default function to generate keys.
Construct the key used by all other methods. By default, prepend
the `key_prefix'. KEY_FUNCTION can be used to specify an alternate
function with custom key making behavior.
"""
return '%s:%s:%s' % (key_p... | [
"def",
"default_key_func",
"(",
"key",
",",
"key_prefix",
",",
"version",
")",
":",
"return",
"'%s:%s:%s'",
"%",
"(",
"key_prefix",
",",
"version",
",",
"key",
")"
] | [
28,
0
] | [
36,
50
] | python | en | ['en', 'error', 'th'] | False |
get_key_func | (key_func) |
Function to decide which key function to use.
Default to ``default_key_func``.
|
Function to decide which key function to use. | def get_key_func(key_func):
"""
Function to decide which key function to use.
Default to ``default_key_func``.
"""
if key_func is not None:
if callable(key_func):
return key_func
else:
return import_string(key_func)
return default_key_func | [
"def",
"get_key_func",
"(",
"key_func",
")",
":",
"if",
"key_func",
"is",
"not",
"None",
":",
"if",
"callable",
"(",
"key_func",
")",
":",
"return",
"key_func",
"else",
":",
"return",
"import_string",
"(",
"key_func",
")",
"return",
"default_key_func"
] | [
39,
0
] | [
50,
27
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.get_backend_timeout | (self, timeout=DEFAULT_TIMEOUT) |
Return the timeout value usable by this backend based upon the provided
timeout.
|
Return the timeout value usable by this backend based upon the provided
timeout.
| def get_backend_timeout(self, timeout=DEFAULT_TIMEOUT):
"""
Return the timeout value usable by this backend based upon the provided
timeout.
"""
if timeout == DEFAULT_TIMEOUT:
timeout = self.default_timeout
elif timeout == 0:
# ticket 21147 - avoid... | [
"def",
"get_backend_timeout",
"(",
"self",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
":",
"if",
"timeout",
"==",
"DEFAULT_TIMEOUT",
":",
"timeout",
"=",
"self",
".",
"default_timeout",
"elif",
"timeout",
"==",
"0",
":",
"# ticket 21147 - avoid time.time() related... | [
80,
4
] | [
90,
65
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.make_key | (self, key, version=None) |
Construct the key used by all other methods. By default, use the
key_func to generate a key (which, by default, prepends the
`key_prefix' and 'version'). A different key function can be provided
at the time of cache construction; alternatively, you can subclass the
cache backend... |
Construct the key used by all other methods. By default, use the
key_func to generate a key (which, by default, prepends the
`key_prefix' and 'version'). A different key function can be provided
at the time of cache construction; alternatively, you can subclass the
cache backend... | def make_key(self, key, version=None):
"""
Construct the key used by all other methods. By default, use the
key_func to generate a key (which, by default, prepends the
`key_prefix' and 'version'). A different key function can be provided
at the time of cache construction; alterna... | [
"def",
"make_key",
"(",
"self",
",",
"key",
",",
"version",
"=",
"None",
")",
":",
"if",
"version",
"is",
"None",
":",
"version",
"=",
"self",
".",
"version",
"return",
"self",
".",
"key_func",
"(",
"key",
",",
"self",
".",
"key_prefix",
",",
"versio... | [
92,
4
] | [
103,
59
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.add | (self, key, value, timeout=DEFAULT_TIMEOUT, version=None) |
Set a value in the cache if the key does not already exist. If
timeout is given, use that timeout for the key; otherwise use the
default cache timeout.
Return True if the value was stored, False otherwise.
|
Set a value in the cache if the key does not already exist. If
timeout is given, use that timeout for the key; otherwise use the
default cache timeout. | def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
"""
Set a value in the cache if the key does not already exist. If
timeout is given, use that timeout for the key; otherwise use the
default cache timeout.
Return True if the value was stored, False otherwise.
... | [
"def",
"add",
"(",
"self",
",",
"key",
",",
"value",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide an add() method'",
")"
] | [
105,
4
] | [
113,
89
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.get | (self, key, default=None, version=None) |
Fetch a given key from the cache. If the key does not exist, return
default, which itself defaults to None.
|
Fetch a given key from the cache. If the key does not exist, return
default, which itself defaults to None.
| def get(self, key, default=None, version=None):
"""
Fetch a given key from the cache. If the key does not exist, return
default, which itself defaults to None.
"""
raise NotImplementedError('subclasses of BaseCache must provide a get() method') | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a get() method'",
")"
] | [
115,
4
] | [
120,
88
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.set | (self, key, value, timeout=DEFAULT_TIMEOUT, version=None) |
Set a value in the cache. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout.
|
Set a value in the cache. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout.
| def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
"""
Set a value in the cache. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout.
"""
raise NotImplementedError('subclasses of BaseCache must provide a set() method') | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a set() method'",
")"
] | [
122,
4
] | [
127,
88
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.touch | (self, key, timeout=DEFAULT_TIMEOUT, version=None) |
Update the key's expiry time using timeout. Return True if successful
or False if the key does not exist.
|
Update the key's expiry time using timeout. Return True if successful
or False if the key does not exist.
| def touch(self, key, timeout=DEFAULT_TIMEOUT, version=None):
"""
Update the key's expiry time using timeout. Return True if successful
or False if the key does not exist.
"""
raise NotImplementedError('subclasses of BaseCache must provide a touch() method') | [
"def",
"touch",
"(",
"self",
",",
"key",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a touch() method'",
")"
] | [
129,
4
] | [
134,
90
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.delete | (self, key, version=None) |
Delete a key from the cache, failing silently.
|
Delete a key from the cache, failing silently.
| def delete(self, key, version=None):
"""
Delete a key from the cache, failing silently.
"""
raise NotImplementedError('subclasses of BaseCache must provide a delete() method') | [
"def",
"delete",
"(",
"self",
",",
"key",
",",
"version",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a delete() method'",
")"
] | [
136,
4
] | [
140,
91
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.get_many | (self, keys, version=None) |
Fetch a bunch of keys from the cache. For certain backends (memcached,
pgsql) this can be *much* faster when fetching multiple values.
Return a dict mapping each key in keys to its value. If the given
key is missing, it will be missing from the response dict.
|
Fetch a bunch of keys from the cache. For certain backends (memcached,
pgsql) this can be *much* faster when fetching multiple values. | def get_many(self, keys, version=None):
"""
Fetch a bunch of keys from the cache. For certain backends (memcached,
pgsql) this can be *much* faster when fetching multiple values.
Return a dict mapping each key in keys to its value. If the given
key is missing, it will be missing... | [
"def",
"get_many",
"(",
"self",
",",
"keys",
",",
"version",
"=",
"None",
")",
":",
"d",
"=",
"{",
"}",
"for",
"k",
"in",
"keys",
":",
"val",
"=",
"self",
".",
"get",
"(",
"k",
",",
"version",
"=",
"version",
")",
"if",
"val",
"is",
"not",
"N... | [
142,
4
] | [
155,
16
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.get_or_set | (self, key, default, timeout=DEFAULT_TIMEOUT, version=None) |
Fetch a given key from the cache. If the key does not exist,
add the key and set it to the default value. The default value can
also be any callable. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout.
Return the value of the key stored o... |
Fetch a given key from the cache. If the key does not exist,
add the key and set it to the default value. The default value can
also be any callable. If timeout is given, use that timeout for the
key; otherwise use the default cache timeout. | def get_or_set(self, key, default, timeout=DEFAULT_TIMEOUT, version=None):
"""
Fetch a given key from the cache. If the key does not exist,
add the key and set it to the default value. The default value can
also be any callable. If timeout is given, use that timeout for the
key; ... | [
"def",
"get_or_set",
"(",
"self",
",",
"key",
",",
"default",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"val",
"=",
"self",
".",
"get",
"(",
"key",
",",
"version",
"=",
"version",
")",
"if",
"val",
"is",
"None",
... | [
157,
4
] | [
176,
18
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.has_key | (self, key, version=None) |
Return True if the key is in the cache and has not expired.
|
Return True if the key is in the cache and has not expired.
| def has_key(self, key, version=None):
"""
Return True if the key is in the cache and has not expired.
"""
return self.get(key, version=version) is not None | [
"def",
"has_key",
"(",
"self",
",",
"key",
",",
"version",
"=",
"None",
")",
":",
"return",
"self",
".",
"get",
"(",
"key",
",",
"version",
"=",
"version",
")",
"is",
"not",
"None"
] | [
178,
4
] | [
182,
57
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.incr | (self, key, delta=1, version=None) |
Add delta to value in the cache. If the key does not exist, raise a
ValueError exception.
|
Add delta to value in the cache. If the key does not exist, raise a
ValueError exception.
| def incr(self, key, delta=1, version=None):
"""
Add delta to value in the cache. If the key does not exist, raise a
ValueError exception.
"""
value = self.get(key, version=version)
if value is None:
raise ValueError("Key '%s' not found" % key)
new_valu... | [
"def",
"incr",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
",",
"version",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"get",
"(",
"key",
",",
"version",
"=",
"version",
")",
"if",
"value",
"is",
"None",
":",
"raise",
"ValueError",
"("... | [
184,
4
] | [
194,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.decr | (self, key, delta=1, version=None) |
Subtract delta from value in the cache. If the key does not exist, raise
a ValueError exception.
|
Subtract delta from value in the cache. If the key does not exist, raise
a ValueError exception.
| def decr(self, key, delta=1, version=None):
"""
Subtract delta from value in the cache. If the key does not exist, raise
a ValueError exception.
"""
return self.incr(key, -delta, version=version) | [
"def",
"decr",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
",",
"version",
"=",
"None",
")",
":",
"return",
"self",
".",
"incr",
"(",
"key",
",",
"-",
"delta",
",",
"version",
"=",
"version",
")"
] | [
196,
4
] | [
201,
54
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.__contains__ | (self, key) |
Return True if the key is in the cache and has not expired.
|
Return True if the key is in the cache and has not expired.
| def __contains__(self, key):
"""
Return True if the key is in the cache and has not expired.
"""
# This is a separate method, rather than just a copy of has_key(),
# so that it always has the same functionality as has_key(), even
# if a subclass overrides it.
retu... | [
"def",
"__contains__",
"(",
"self",
",",
"key",
")",
":",
"# This is a separate method, rather than just a copy of has_key(),",
"# so that it always has the same functionality as has_key(), even",
"# if a subclass overrides it.",
"return",
"self",
".",
"has_key",
"(",
"key",
")"
] | [
203,
4
] | [
210,
32
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.set_many | (self, data, timeout=DEFAULT_TIMEOUT, version=None) |
Set a bunch of values in the cache at once from a dict of key/value
pairs. For certain backends (memcached), this is much more efficient
than calling set() multiple times.
If timeout is given, use that timeout for the key; otherwise use the
default cache timeout.
On b... |
Set a bunch of values in the cache at once from a dict of key/value
pairs. For certain backends (memcached), this is much more efficient
than calling set() multiple times. | def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None):
"""
Set a bunch of values in the cache at once from a dict of key/value
pairs. For certain backends (memcached), this is much more efficient
than calling set() multiple times.
If timeout is given, use that timeout... | [
"def",
"set_many",
"(",
"self",
",",
"data",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
",",
"version",
"=",
"None",
")",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"self",
".",
"set",
"(",
"key",
",",
"value",
",",
... | [
212,
4
] | [
226,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.delete_many | (self, keys, version=None) |
Delete a bunch of values in the cache at once. For certain backends
(memcached), this is much more efficient than calling delete() multiple
times.
|
Delete a bunch of values in the cache at once. For certain backends
(memcached), this is much more efficient than calling delete() multiple
times.
| def delete_many(self, keys, version=None):
"""
Delete a bunch of values in the cache at once. For certain backends
(memcached), this is much more efficient than calling delete() multiple
times.
"""
for key in keys:
self.delete(key, version=version) | [
"def",
"delete_many",
"(",
"self",
",",
"keys",
",",
"version",
"=",
"None",
")",
":",
"for",
"key",
"in",
"keys",
":",
"self",
".",
"delete",
"(",
"key",
",",
"version",
"=",
"version",
")"
] | [
228,
4
] | [
235,
45
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.clear | (self) | Remove *all* values from the cache at once. | Remove *all* values from the cache at once. | def clear(self):
"""Remove *all* values from the cache at once."""
raise NotImplementedError('subclasses of BaseCache must provide a clear() method') | [
"def",
"clear",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseCache must provide a clear() method'",
")"
] | [
237,
4
] | [
239,
90
] | python | en | ['en', 'en', 'en'] | True |
BaseCache.validate_key | (self, key) |
Warn about keys that would not be portable to the memcached
backend. This encourages (but does not force) writing backend-portable
cache code.
|
Warn about keys that would not be portable to the memcached
backend. This encourages (but does not force) writing backend-portable
cache code.
| def validate_key(self, key):
"""
Warn about keys that would not be portable to the memcached
backend. This encourages (but does not force) writing backend-portable
cache code.
"""
for warning in memcache_key_warnings(key):
warnings.warn(warning, CacheKeyWarnin... | [
"def",
"validate_key",
"(",
"self",
",",
"key",
")",
":",
"for",
"warning",
"in",
"memcache_key_warnings",
"(",
"key",
")",
":",
"warnings",
".",
"warn",
"(",
"warning",
",",
"CacheKeyWarning",
")"
] | [
241,
4
] | [
248,
51
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.incr_version | (self, key, delta=1, version=None) |
Add delta to the cache version for the supplied key. Return the new
version.
|
Add delta to the cache version for the supplied key. Return the new
version.
| def incr_version(self, key, delta=1, version=None):
"""
Add delta to the cache version for the supplied key. Return the new
version.
"""
if version is None:
version = self.version
value = self.get(key, version=version)
if value is None:
ra... | [
"def",
"incr_version",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
",",
"version",
"=",
"None",
")",
":",
"if",
"version",
"is",
"None",
":",
"version",
"=",
"self",
".",
"version",
"value",
"=",
"self",
".",
"get",
"(",
"key",
",",
"version",... | [
250,
4
] | [
264,
30
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.decr_version | (self, key, delta=1, version=None) |
Subtract delta from the cache version for the supplied key. Return the
new version.
|
Subtract delta from the cache version for the supplied key. Return the
new version.
| def decr_version(self, key, delta=1, version=None):
"""
Subtract delta from the cache version for the supplied key. Return the
new version.
"""
return self.incr_version(key, -delta, version) | [
"def",
"decr_version",
"(",
"self",
",",
"key",
",",
"delta",
"=",
"1",
",",
"version",
"=",
"None",
")",
":",
"return",
"self",
".",
"incr_version",
"(",
"key",
",",
"-",
"delta",
",",
"version",
")"
] | [
266,
4
] | [
271,
54
] | python | en | ['en', 'error', 'th'] | False |
BaseCache.close | (self, **kwargs) | Close the cache connection | Close the cache connection | def close(self, **kwargs):
"""Close the cache connection"""
pass | [
"def",
"close",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
273,
4
] | [
275,
12
] | python | en | ['en', 'en', 'en'] | True |
is_appengine_sandbox | () | Reports if the app is running in the first generation sandbox.
The second generation runtimes are technically still in a sandbox, but it
is much less restrictive, so generally you shouldn't need to check for it.
see https://cloud.google.com/appengine/docs/standard/runtimes
| Reports if the app is running in the first generation sandbox. | def is_appengine_sandbox():
"""Reports if the app is running in the first generation sandbox.
The second generation runtimes are technically still in a sandbox, but it
is much less restrictive, so generally you shouldn't need to check for it.
see https://cloud.google.com/appengine/docs/standard/runtime... | [
"def",
"is_appengine_sandbox",
"(",
")",
":",
"return",
"is_appengine",
"(",
")",
"and",
"os",
".",
"environ",
"[",
"\"APPENGINE_RUNTIME\"",
"]",
"==",
"\"python27\""
] | [
11,
0
] | [
18,
75
] | python | en | ['en', 'en', 'en'] | True |
is_prod_appengine_mvms | () | Deprecated. | Deprecated. | def is_prod_appengine_mvms():
"""Deprecated."""
return False | [
"def",
"is_prod_appengine_mvms",
"(",
")",
":",
"return",
"False"
] | [
33,
0
] | [
35,
16
] | python | en | ['en', 'la', 'it'] | False |
SimpleTemplateResponseTest.test_post_callbacks | (self) | Rendering a template response triggers the post-render callbacks | Rendering a template response triggers the post-render callbacks | def test_post_callbacks(self):
"Rendering a template response triggers the post-render callbacks"
post = []
def post1(obj):
post.append('post1')
def post2(obj):
post.append('post2')
response = SimpleTemplateResponse('first/test.html', {})
respon... | [
"def",
"test_post_callbacks",
"(",
"self",
")",
":",
"post",
"=",
"[",
"]",
"def",
"post1",
"(",
"obj",
")",
":",
"post",
".",
"append",
"(",
"'post1'",
")",
"def",
"post2",
"(",
"obj",
")",
":",
"post",
".",
"append",
"(",
"'post2'",
")",
"respons... | [
131,
4
] | [
148,
50
] | python | en | ['en', 'en', 'en'] | True |
configure_reproducible_wheels | () | Modifies the environment to make wheel building reproducible.
Wheels created from sdists are not reproducible by default. We can however workaround this by
patching in some configuration with environment variables.
| Modifies the environment to make wheel building reproducible. | def configure_reproducible_wheels() -> None:
"""Modifies the environment to make wheel building reproducible.
Wheels created from sdists are not reproducible by default. We can however workaround this by
patching in some configuration with environment variables.
"""
# wheel, by default, enables de... | [
"def",
"configure_reproducible_wheels",
"(",
")",
"->",
"None",
":",
"# wheel, by default, enables debug symbols in GCC. This incidentally captures the build path in the .so file",
"# We can override this behavior by disabling debug symbols entirely.",
"# https://github.com/pypa/pip/issues/6505",
... | [
17,
0
] | [
40,
42
] | python | en | ['en', 'gl', 'en'] | True |
main | () | Main program.
Exits zero on successful program termination, non-zero otherwise.
| Main program. | def main() -> None:
"""Main program.
Exits zero on successful program termination, non-zero otherwise.
"""
configure_reproducible_wheels()
parser = argparse.ArgumentParser(
description="Resolve and fetch artifacts transitively from PyPI"
)
parser.add_argument(
"--requireme... | [
"def",
"main",
"(",
")",
"->",
"None",
":",
"configure_reproducible_wheels",
"(",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Resolve and fetch artifacts transitively from PyPI\"",
")",
"parser",
".",
"add_argument",
"(",
"\"--re... | [
43,
0
] | [
109,
9
] | python | en | ['en', 'hi-Latn', 'en'] | False |
get_python_version | () | Return a string containing the major and minor Python version,
leaving off the patchlevel. Sample return values could be '1.5'
or '2.2'.
| Return a string containing the major and minor Python version,
leaving off the patchlevel. Sample return values could be '1.5'
or '2.2'.
| def get_python_version():
"""Return a string containing the major and minor Python version,
leaving off the patchlevel. Sample return values could be '1.5'
or '2.2'.
"""
return '%d.%d' % sys.version_info[:2] | [
"def",
"get_python_version",
"(",
")",
":",
"return",
"'%d.%d'",
"%",
"sys",
".",
"version_info",
"[",
":",
"2",
"]"
] | [
80,
0
] | [
85,
41
] | python | en | ['en', 'en', 'en'] | True |
get_python_inc | (plat_specific=0, prefix=None) | Return the directory containing installed Python header files.
If 'plat_specific' is false (the default), this is the path to the
non-platform-specific header files, i.e. Python.h and so on;
otherwise, this is the path to platform-specific header files
(namely pyconfig.h).
If 'prefix' is supplied,... | Return the directory containing installed Python header files. | def get_python_inc(plat_specific=0, prefix=None):
"""Return the directory containing installed Python header files.
If 'plat_specific' is false (the default), this is the path to the
non-platform-specific header files, i.e. Python.h and so on;
otherwise, this is the path to platform-specific header fil... | [
"def",
"get_python_inc",
"(",
"plat_specific",
"=",
"0",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"prefix",
"is",
"None",
":",
"prefix",
"=",
"plat_specific",
"and",
"BASE_EXEC_PREFIX",
"or",
"BASE_PREFIX",
"if",
"IS_PYPY",
":",
"return",
"os",
".",
"pa... | [
88,
0
] | [
127,
41
] | python | en | ['en', 'en', 'en'] | True |
get_python_lib | (plat_specific=0, standard_lib=0, prefix=None) | Return the directory containing the Python library (standard or
site additions).
If 'plat_specific' is true, return the directory containing
platform-specific modules, i.e. any module from a non-pure-Python
module distribution; otherwise, return the platform-shared library
directory. If 'standard_... | Return the directory containing the Python library (standard or
site additions). | def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
"""Return the directory containing the Python library (standard or
site additions).
If 'plat_specific' is true, return the directory containing
platform-specific modules, i.e. any module from a non-pure-Python
module distribution; ot... | [
"def",
"get_python_lib",
"(",
"plat_specific",
"=",
"0",
",",
"standard_lib",
"=",
"0",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"IS_PYPY",
":",
"# PyPy-specific schema",
"if",
"prefix",
"is",
"None",
":",
"prefix",
"=",
"PREFIX",
"if",
"standard_lib",
... | [
130,
0
] | [
180,
41
] | python | en | ['en', 'en', 'en'] | True |
customize_compiler | (compiler) | Do any platform-specific customization of a CCompiler instance.
Mainly needed on Unix, so we can plug in the information that
varies across Unices and is stored in Python's Makefile.
| Do any platform-specific customization of a CCompiler instance. | def customize_compiler(compiler):
"""Do any platform-specific customization of a CCompiler instance.
Mainly needed on Unix, so we can plug in the information that
varies across Unices and is stored in Python's Makefile.
"""
if compiler.compiler_type == "unix":
if sys.platform == "darwin":
... | [
"def",
"customize_compiler",
"(",
"compiler",
")",
":",
"if",
"compiler",
".",
"compiler_type",
"==",
"\"unix\"",
":",
"if",
"sys",
".",
"platform",
"==",
"\"darwin\"",
":",
"# Perform first-time customization of compiler-related",
"# config vars on OS X now that we know we... | [
184,
0
] | [
254,
52
] | python | en | ['en', 'en', 'en'] | True |
get_config_h_filename | () | Return full pathname of installed pyconfig.h file. | Return full pathname of installed pyconfig.h file. | def get_config_h_filename():
"""Return full pathname of installed pyconfig.h file."""
if python_build:
if os.name == "nt":
inc_dir = os.path.join(_sys_home or project_base, "PC")
else:
inc_dir = _sys_home or project_base
else:
inc_dir = get_python_inc(plat_spe... | [
"def",
"get_config_h_filename",
"(",
")",
":",
"if",
"python_build",
":",
"if",
"os",
".",
"name",
"==",
"\"nt\"",
":",
"inc_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_sys_home",
"or",
"project_base",
",",
"\"PC\"",
")",
"else",
":",
"inc_dir",
... | [
257,
0
] | [
267,
46
] | python | en | ['en', 'en', 'en'] | True |
get_makefile_filename | () | Return full pathname of installed Makefile from the Python build. | Return full pathname of installed Makefile from the Python build. | def get_makefile_filename():
"""Return full pathname of installed Makefile from the Python build."""
if python_build:
return os.path.join(_sys_home or project_base, "Makefile")
lib_dir = get_python_lib(plat_specific=0, standard_lib=1)
config_file = 'config-{}{}'.format(get_python_version(), buil... | [
"def",
"get_makefile_filename",
"(",
")",
":",
"if",
"python_build",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"_sys_home",
"or",
"project_base",
",",
"\"Makefile\"",
")",
"lib_dir",
"=",
"get_python_lib",
"(",
"plat_specific",
"=",
"0",
",",
"stan... | [
270,
0
] | [
278,
57
] | python | en | ['en', 'en', 'en'] | True |
parse_config_h | (fp, g=None) | Parse a config.h-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
| Parse a config.h-style file. | def parse_config_h(fp, g=None):
"""Parse a config.h-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
"""
if g is None:
g = {}
define_rx = re.compile("#define ([A-... | [
"def",
"parse_config_h",
"(",
"fp",
",",
"g",
"=",
"None",
")",
":",
"if",
"g",
"is",
"None",
":",
"g",
"=",
"{",
"}",
"define_rx",
"=",
"re",
".",
"compile",
"(",
"\"#define ([A-Z][A-Za-z0-9_]+) (.*)\\n\"",
")",
"undef_rx",
"=",
"re",
".",
"compile",
... | [
281,
0
] | [
307,
12
] | python | en | ['es', 'en', 'en'] | True |
parse_makefile | (fn, g=None) | Parse a Makefile-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
| Parse a Makefile-style file. | def parse_makefile(fn, g=None):
"""Parse a Makefile-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
"""
from distutils.text_file import TextFile
fp = TextFile(fn, strip_... | [
"def",
"parse_makefile",
"(",
"fn",
",",
"g",
"=",
"None",
")",
":",
"from",
"distutils",
".",
"text_file",
"import",
"TextFile",
"fp",
"=",
"TextFile",
"(",
"fn",
",",
"strip_comments",
"=",
"1",
",",
"skip_blanks",
"=",
"1",
",",
"join_lines",
"=",
"... | [
316,
0
] | [
419,
12
] | python | en | ['en', 'en', 'en'] | True |
expand_makefile_vars | (s, vars) | Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
'string' according to 'vars' (a dictionary mapping variable names to
values). Variables not present in 'vars' are silently expanded to the
empty string. The variable values in 'vars' should not contain further
variable expansions; if 'vars'... | Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
'string' according to 'vars' (a dictionary mapping variable names to
values). Variables not present in 'vars' are silently expanded to the
empty string. The variable values in 'vars' should not contain further
variable expansions; if 'vars'... | def expand_makefile_vars(s, vars):
"""Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
'string' according to 'vars' (a dictionary mapping variable names to
values). Variables not present in 'vars' are silently expanded to the
empty string. The variable values in 'vars' should not contain ... | [
"def",
"expand_makefile_vars",
"(",
"s",
",",
"vars",
")",
":",
"# This algorithm does multiple expansion, so if vars['foo'] contains",
"# \"${bar}\", it will expand ${foo} to ${bar}, and then expand",
"# ${bar}... and so forth. This is fine as long as 'vars' comes from",
"# 'parse_makefile()... | [
422,
0
] | [
444,
12
] | python | en | ['en', 'en', 'en'] | True |
_init_posix | () | Initialize the module as appropriate for POSIX systems. | Initialize the module as appropriate for POSIX systems. | def _init_posix():
"""Initialize the module as appropriate for POSIX systems."""
# _sysconfigdata is generated at build time, see the sysconfig module
name = os.environ.get('_PYTHON_SYSCONFIGDATA_NAME',
'_sysconfigdata_{abi}_{platform}_{multiarch}'.format(
abi=sys.abiflags,
platform=... | [
"def",
"_init_posix",
"(",
")",
":",
"# _sysconfigdata is generated at build time, see the sysconfig module",
"name",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'_PYTHON_SYSCONFIGDATA_NAME'",
",",
"'_sysconfigdata_{abi}_{platform}_{multiarch}'",
".",
"format",
"(",
"abi",
... | [
449,
0
] | [
467,
40
] | python | en | ['en', 'en', 'en'] | True |
_init_nt | () | Initialize the module as appropriate for NT | Initialize the module as appropriate for NT | def _init_nt():
"""Initialize the module as appropriate for NT"""
g = {}
# set basic install directories
g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
# XXX hmmm.. a normal install puts include files here
g['... | [
"def",
"_init_nt",
"(",
")",
":",
"g",
"=",
"{",
"}",
"# set basic install directories",
"g",
"[",
"'LIBDEST'",
"]",
"=",
"get_python_lib",
"(",
"plat_specific",
"=",
"0",
",",
"standard_lib",
"=",
"1",
")",
"g",
"[",
"'BINLIBDEST'",
"]",
"=",
"get_python_... | [
470,
0
] | [
486,
20
] | python | en | ['en', 'en', 'en'] | True |
get_config_vars | (*args) | With no arguments, return a dictionary of all configuration
variables relevant for the current platform. Generally this includes
everything needed to build extensions and install both pure modules and
extensions. On Unix, this means every variable defined in Python's
installed Makefile; on Windows it'... | With no arguments, return a dictionary of all configuration
variables relevant for the current platform. Generally this includes
everything needed to build extensions and install both pure modules and
extensions. On Unix, this means every variable defined in Python's
installed Makefile; on Windows it'... | def get_config_vars(*args):
"""With no arguments, return a dictionary of all configuration
variables relevant for the current platform. Generally this includes
everything needed to build extensions and install both pure modules and
extensions. On Unix, this means every variable defined in Python's
... | [
"def",
"get_config_vars",
"(",
"*",
"args",
")",
":",
"global",
"_config_vars",
"if",
"_config_vars",
"is",
"None",
":",
"func",
"=",
"globals",
"(",
")",
".",
"get",
"(",
"\"_init_\"",
"+",
"os",
".",
"name",
")",
"if",
"func",
":",
"func",
"(",
")"... | [
489,
0
] | [
562,
27
] | python | en | ['en', 'en', 'en'] | True |
get_config_var | (name) | Return the value of a single variable using the dictionary
returned by 'get_config_vars()'. Equivalent to
get_config_vars().get(name)
| Return the value of a single variable using the dictionary
returned by 'get_config_vars()'. Equivalent to
get_config_vars().get(name)
| def get_config_var(name):
"""Return the value of a single variable using the dictionary
returned by 'get_config_vars()'. Equivalent to
get_config_vars().get(name)
"""
if name == 'SO':
import warnings
warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning, 2)
return... | [
"def",
"get_config_var",
"(",
"name",
")",
":",
"if",
"name",
"==",
"'SO'",
":",
"import",
"warnings",
"warnings",
".",
"warn",
"(",
"'SO is deprecated, use EXT_SUFFIX'",
",",
"DeprecationWarning",
",",
"2",
")",
"return",
"get_config_vars",
"(",
")",
".",
"ge... | [
564,
0
] | [
572,
38
] | python | en | ['en', 'en', 'en'] | True |
Config.__init__ | (self) | config object constructor
Returns:
void
| config object constructor | def __init__(self):
"""config object constructor
Returns:
void
"""
self.css = []
self.views = []
self.js = []
self.ignore = []
self.class_selectors = ["getElementsByClassName", "hasClass", "addClass", "removeClass"]
self.id_selectors = ["... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"css",
"=",
"[",
"]",
"self",
".",
"views",
"=",
"[",
"]",
"self",
".",
"js",
"=",
"[",
"]",
"self",
".",
"ignore",
"=",
"[",
"]",
"self",
".",
"class_selectors",
"=",
"[",
"\"getElementsByCl... | [
20,
4
] | [
40,
28
] | python | en | ['de', 'en', 'en'] | True |
Config.getArgCount | (self) | gets the count of how many arguments are present
Returns:
int
| gets the count of how many arguments are present | def getArgCount(self):
"""gets the count of how many arguments are present
Returns:
int
"""
return len(sys.argv) | [
"def",
"getArgCount",
"(",
"self",
")",
":",
"return",
"len",
"(",
"sys",
".",
"argv",
")"
] | [
42,
4
] | [
49,
28
] | python | en | ['en', 'en', 'en'] | True |
Config.setIgnore | (self, value) | sets what classes and ids we should ignore and not shorten
Arguments:
value -- comma separated list of classes or ids
Returns:
void
| sets what classes and ids we should ignore and not shorten | def setIgnore(self, value):
"""sets what classes and ids we should ignore and not shorten
Arguments:
value -- comma separated list of classes or ids
Returns:
void
"""
for name in value.split(","):
self.ignore.append(name) | [
"def",
"setIgnore",
"(",
"self",
",",
"value",
")",
":",
"for",
"name",
"in",
"value",
".",
"split",
"(",
"\",\"",
")",
":",
"self",
".",
"ignore",
".",
"append",
"(",
"name",
")"
] | [
51,
4
] | [
62,
36
] | python | en | ['en', 'en', 'en'] | True |
Config.processArgs | (self) | processes arguments passed in via command line and sets config settings accordingly
Returns:
void
| processes arguments passed in via command line and sets config settings accordingly | def processArgs(self):
"""processes arguments passed in via command line and sets config settings accordingly
Returns:
void
"""
try:
opts, args = getopt.getopt(sys.argv[1:], "", ["css=", "views=", "html=", "js=", "help", "view-ext=", "ignore=", "framework=", "select... | [
"def",
"processArgs",
"(",
"self",
")",
":",
"try",
":",
"opts",
",",
"args",
"=",
"getopt",
".",
"getopt",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
",",
"\"\"",
",",
"[",
"\"css=\"",
",",
"\"views=\"",
",",
"\"html=\"",
",",
"\"js=\"",
",",
... | [
97,
4
] | [
146,
31
] | python | en | ['en', 'en', 'en'] | True |
DatabaseWrapper.check_constraints | (self, table_names=None) |
Check constraints by setting them to immediate. Return them to deferred
afterward.
|
Check constraints by setting them to immediate. Return them to deferred
afterward.
| def check_constraints(self, table_names=None):
"""
Check constraints by setting them to immediate. Return them to deferred
afterward.
"""
self.cursor().execute('SET CONSTRAINTS ALL IMMEDIATE')
self.cursor().execute('SET CONSTRAINTS ALL DEFERRED') | [
"def",
"check_constraints",
"(",
"self",
",",
"table_names",
"=",
"None",
")",
":",
"self",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"'SET CONSTRAINTS ALL IMMEDIATE'",
")",
"self",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"'SET CONSTRAINTS ALL DEFERR... | [
270,
4
] | [
276,
61
] | python | en | ['en', 'error', 'th'] | False |
_get | (d, expected_type, key, default=None) | Get value from dictionary and verify expected type. | Get value from dictionary and verify expected type. | def _get(d, expected_type, key, default=None):
# type: (Dict[str, Any], Type[T], str, Optional[T]) -> Optional[T]
"""Get value from dictionary and verify expected type."""
if key not in d:
return default
value = d[key]
if six.PY2 and expected_type is str:
expected_type = six.string_t... | [
"def",
"_get",
"(",
"d",
",",
"expected_type",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"# type: (Dict[str, Any], Type[T], str, Optional[T]) -> Optional[T]",
"if",
"key",
"not",
"in",
"d",
":",
"return",
"default",
"value",
"=",
"d",
"[",
"key",
"]",... | [
33,
0
] | [
47,
16
] | python | en | ['en', 'en', 'en'] | True |
_filter_none | (**kwargs) | Make dict excluding None values. | Make dict excluding None values. | def _filter_none(**kwargs):
# type: (Any) -> Dict[str, Any]
"""Make dict excluding None values."""
return {k: v for k, v in kwargs.items() if v is not None} | [
"def",
"_filter_none",
"(",
"*",
"*",
"kwargs",
")",
":",
"# type: (Any) -> Dict[str, Any]",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
"if",
"v",
"is",
"not",
"None",
"}"
] | [
73,
0
] | [
76,
61
] | python | en | ['en', 'en', 'en'] | True |
DirectUrl.redacted_url | (self) | url with user:password part removed unless it is formed with
environment variables as specified in PEP 610, or it is ``git``
in the case of a git URL.
| url with user:password part removed unless it is formed with
environment variables as specified in PEP 610, or it is ``git``
in the case of a git URL.
| def redacted_url(self):
# type: () -> str
"""url with user:password part removed unless it is formed with
environment variables as specified in PEP 610, or it is ``git``
in the case of a git URL.
"""
purl = urllib_parse.urlsplit(self.url)
netloc = self._remove_aut... | [
"def",
"redacted_url",
"(",
"self",
")",
":",
"# type: () -> str",
"purl",
"=",
"urllib_parse",
".",
"urlsplit",
"(",
"self",
".",
"url",
")",
"netloc",
"=",
"self",
".",
"_remove_auth_from_netloc",
"(",
"purl",
".",
"netloc",
")",
"surl",
"=",
"urllib_parse... | [
196,
4
] | [
207,
19
] | python | en | ['en', 'en', 'en'] | True |
inject_into_urllib3 | () |
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
|
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
| def inject_into_urllib3():
"""
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
"""
util.SSLContext = SecureTransportContext
util.ssl_.SSLContext = SecureTransportContext
util.HAS_SNI = HAS_SNI
util.ssl_.HAS_SNI = HAS_SNI
util.IS_SECURETRANSPORT = True
util.ssl_.IS_SECUR... | [
"def",
"inject_into_urllib3",
"(",
")",
":",
"util",
".",
"SSLContext",
"=",
"SecureTransportContext",
"util",
".",
"ssl_",
".",
"SSLContext",
"=",
"SecureTransportContext",
"util",
".",
"HAS_SNI",
"=",
"HAS_SNI",
"util",
".",
"ssl_",
".",
"HAS_SNI",
"=",
"HAS... | [
179,
0
] | [
188,
39
] | python | en | ['en', 'error', 'th'] | False |
extract_from_urllib3 | () |
Undo monkey-patching by :func:`inject_into_urllib3`.
|
Undo monkey-patching by :func:`inject_into_urllib3`.
| def extract_from_urllib3():
"""
Undo monkey-patching by :func:`inject_into_urllib3`.
"""
util.SSLContext = orig_util_SSLContext
util.ssl_.SSLContext = orig_util_SSLContext
util.HAS_SNI = orig_util_HAS_SNI
util.ssl_.HAS_SNI = orig_util_HAS_SNI
util.IS_SECURETRANSPORT = False
util.ssl_... | [
"def",
"extract_from_urllib3",
"(",
")",
":",
"util",
".",
"SSLContext",
"=",
"orig_util_SSLContext",
"util",
".",
"ssl_",
".",
"SSLContext",
"=",
"orig_util_SSLContext",
"util",
".",
"HAS_SNI",
"=",
"orig_util_HAS_SNI",
"util",
".",
"ssl_",
".",
"HAS_SNI",
"=",... | [
191,
0
] | [
200,
40
] | python | en | ['en', 'error', 'th'] | False |
_read_callback | (connection_id, data_buffer, data_length_pointer) |
SecureTransport read callback. This is called by ST to request that data
be returned from the socket.
|
SecureTransport read callback. This is called by ST to request that data
be returned from the socket.
| def _read_callback(connection_id, data_buffer, data_length_pointer):
"""
SecureTransport read callback. This is called by ST to request that data
be returned from the socket.
"""
wrapped_socket = None
try:
wrapped_socket = _connection_refs.get(connection_id)
if wrapped_socket is ... | [
"def",
"_read_callback",
"(",
"connection_id",
",",
"data_buffer",
",",
"data_length_pointer",
")",
":",
"wrapped_socket",
"=",
"None",
"try",
":",
"wrapped_socket",
"=",
"_connection_refs",
".",
"get",
"(",
"connection_id",
")",
"if",
"wrapped_socket",
"is",
"Non... | [
203,
0
] | [
255,
43
] | python | en | ['en', 'error', 'th'] | False |
_write_callback | (connection_id, data_buffer, data_length_pointer) |
SecureTransport write callback. This is called by ST to request that data
actually be sent on the network.
|
SecureTransport write callback. This is called by ST to request that data
actually be sent on the network.
| def _write_callback(connection_id, data_buffer, data_length_pointer):
"""
SecureTransport write callback. This is called by ST to request that data
actually be sent on the network.
"""
wrapped_socket = None
try:
wrapped_socket = _connection_refs.get(connection_id)
if wrapped_sock... | [
"def",
"_write_callback",
"(",
"connection_id",
",",
"data_buffer",
",",
"data_length_pointer",
")",
":",
"wrapped_socket",
"=",
"None",
"try",
":",
"wrapped_socket",
"=",
"_connection_refs",
".",
"get",
"(",
"connection_id",
")",
"if",
"wrapped_socket",
"is",
"No... | [
258,
0
] | [
306,
43
] | python | en | ['en', 'error', 'th'] | False |
WrappedSocket._raise_on_error | (self) |
A context manager that can be used to wrap calls that do I/O from
SecureTransport. If any of the I/O callbacks hit an exception, this
context manager will correctly propagate the exception after the fact.
This avoids silently swallowing those exceptions.
It also correctly force... |
A context manager that can be used to wrap calls that do I/O from
SecureTransport. If any of the I/O callbacks hit an exception, this
context manager will correctly propagate the exception after the fact.
This avoids silently swallowing those exceptions. | def _raise_on_error(self):
"""
A context manager that can be used to wrap calls that do I/O from
SecureTransport. If any of the I/O callbacks hit an exception, this
context manager will correctly propagate the exception after the fact.
This avoids silently swallowing those except... | [
"def",
"_raise_on_error",
"(",
"self",
")",
":",
"self",
".",
"_exception",
"=",
"None",
"# We explicitly don't catch around this yield because in the unlikely",
"# event that an exception was hit in the block we don't want to swallow",
"# it.",
"yield",
"if",
"self",
".",
"_exce... | [
343,
4
] | [
361,
27
] | python | en | ['en', 'error', 'th'] | False |
WrappedSocket._set_ciphers | (self) |
Sets up the allowed ciphers. By default this matches the set in
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
custom and doesn't allow changing at this time, mostly because parsing
OpenSSL cipher strings is going to be a freaking nightmare.
|
Sets up the allowed ciphers. By default this matches the set in
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
custom and doesn't allow changing at this time, mostly because parsing
OpenSSL cipher strings is going to be a freaking nightmare.
| def _set_ciphers(self):
"""
Sets up the allowed ciphers. By default this matches the set in
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
custom and doesn't allow changing at this time, mostly because parsing
OpenSSL cipher strings is going to be a freak... | [
"def",
"_set_ciphers",
"(",
"self",
")",
":",
"ciphers",
"=",
"(",
"Security",
".",
"SSLCipherSuite",
"*",
"len",
"(",
"CIPHER_SUITES",
")",
")",
"(",
"*",
"CIPHER_SUITES",
")",
"result",
"=",
"Security",
".",
"SSLSetEnabledCiphers",
"(",
"self",
".",
"con... | [
363,
4
] | [
374,
32
] | python | en | ['en', 'error', 'th'] | False |
WrappedSocket._custom_validate | (self, verify, trust_bundle) |
Called when we have set custom validation. We do this in two cases:
first, when cert validation is entirely disabled; and second, when
using a custom trust DB.
|
Called when we have set custom validation. We do this in two cases:
first, when cert validation is entirely disabled; and second, when
using a custom trust DB.
| def _custom_validate(self, verify, trust_bundle):
"""
Called when we have set custom validation. We do this in two cases:
first, when cert validation is entirely disabled; and second, when
using a custom trust DB.
"""
# If we disabled cert validation, just say: cool.
... | [
"def",
"_custom_validate",
"(",
"self",
",",
"verify",
",",
"trust_bundle",
")",
":",
"# If we disabled cert validation, just say: cool.",
"if",
"not",
"verify",
":",
"return",
"# We want data in memory, so load it up.",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"t... | [
376,
4
] | [
431,
13
] | python | en | ['en', 'error', 'th'] | False |
WrappedSocket.handshake | (
self,
server_hostname,
verify,
trust_bundle,
min_version,
max_version,
client_cert,
client_key,
client_key_passphrase,
) |
Actually performs the TLS handshake. This is run automatically by
wrapped socket, and shouldn't be needed in user code.
|
Actually performs the TLS handshake. This is run automatically by
wrapped socket, and shouldn't be needed in user code.
| def handshake(
self,
server_hostname,
verify,
trust_bundle,
min_version,
max_version,
client_cert,
client_key,
client_key_passphrase,
):
"""
Actually performs the TLS handshake. This is run automatically by
wrapped socke... | [
"def",
"handshake",
"(",
"self",
",",
"server_hostname",
",",
"verify",
",",
"trust_bundle",
",",
"min_version",
",",
"max_version",
",",
"client_cert",
",",
"client_key",
",",
"client_key_passphrase",
",",
")",
":",
"# First, we do the initial bits of connection setup.... | [
433,
4
] | [
520,
25
] | python | en | ['en', 'error', 'th'] | False |
SecureTransportContext.check_hostname | (self) |
SecureTransport cannot have its hostname checking disabled. For more,
see the comment on getpeercert() in this file.
|
SecureTransport cannot have its hostname checking disabled. For more,
see the comment on getpeercert() in this file.
| def check_hostname(self):
"""
SecureTransport cannot have its hostname checking disabled. For more,
see the comment on getpeercert() in this file.
"""
return True | [
"def",
"check_hostname",
"(",
"self",
")",
":",
"return",
"True"
] | [
758,
4
] | [
763,
19
] | python | en | ['en', 'error', 'th'] | False |
SecureTransportContext.check_hostname | (self, value) |
SecureTransport cannot have its hostname checking disabled. For more,
see the comment on getpeercert() in this file.
|
SecureTransport cannot have its hostname checking disabled. For more,
see the comment on getpeercert() in this file.
| def check_hostname(self, value):
"""
SecureTransport cannot have its hostname checking disabled. For more,
see the comment on getpeercert() in this file.
"""
pass | [
"def",
"check_hostname",
"(",
"self",
",",
"value",
")",
":",
"pass"
] | [
766,
4
] | [
771,
12
] | python | en | ['en', 'error', 'th'] | False |
fromfile | (file_h) |
Given a string file name, returns a GEOSGeometry. The file may contain WKB,
WKT, or HEX.
|
Given a string file name, returns a GEOSGeometry. The file may contain WKB,
WKT, or HEX.
| def fromfile(file_h):
"""
Given a string file name, returns a GEOSGeometry. The file may contain WKB,
WKT, or HEX.
"""
# If given a file name, get a real handle.
if isinstance(file_h, six.string_types):
with open(file_h, 'rb') as file_h:
buf = file_h.read()
else:
... | [
"def",
"fromfile",
"(",
"file_h",
")",
":",
"# If given a file name, get a real handle.",
"if",
"isinstance",
"(",
"file_h",
",",
"six",
".",
"string_types",
")",
":",
"with",
"open",
"(",
"file_h",
",",
"'rb'",
")",
"as",
"file_h",
":",
"buf",
"=",
"file_h"... | [
5,
0
] | [
28,
44
] | python | en | ['en', 'error', 'th'] | False |
fromstr | (string, **kwargs) | Given a string value, returns a GEOSGeometry object. | Given a string value, returns a GEOSGeometry object. | def fromstr(string, **kwargs):
"Given a string value, returns a GEOSGeometry object."
return GEOSGeometry(string, **kwargs) | [
"def",
"fromstr",
"(",
"string",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GEOSGeometry",
"(",
"string",
",",
"*",
"*",
"kwargs",
")"
] | [
31,
0
] | [
33,
41
] | python | en | ['en', 'en', 'en'] | True |
colorize | (text='', opts=(), **kwargs) |
Return your text, enclosed in ANSI graphics codes.
Depends on the keyword arguments 'fg' and 'bg', and the contents of
the opts tuple/list.
Return the RESET code if no parameters are given.
Valid colors:
'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
Valid opt... |
Return your text, enclosed in ANSI graphics codes. | def colorize(text='', opts=(), **kwargs):
"""
Return your text, enclosed in ANSI graphics codes.
Depends on the keyword arguments 'fg' and 'bg', and the contents of
the opts tuple/list.
Return the RESET code if no parameters are given.
Valid colors:
'black', 'red', 'green', 'yellow', ... | [
"def",
"colorize",
"(",
"text",
"=",
"''",
",",
"opts",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"code_list",
"=",
"[",
"]",
"if",
"text",
"==",
"''",
"and",
"len",
"(",
"opts",
")",
"==",
"1",
"and",
"opts",
"[",
"0",
"]",
"==",
"... | [
12,
0
] | [
54,
68
] | python | en | ['en', 'error', 'th'] | False |
make_style | (opts=(), **kwargs) |
Return a function with default parameters for colorize()
Example:
bold_red = make_style(opts=('bold',), fg='red')
print(bold_red('hello'))
KEYWORD = make_style(fg='yellow')
COMMENT = make_style(fg='blue', opts=('bold',))
|
Return a function with default parameters for colorize() | def make_style(opts=(), **kwargs):
"""
Return a function with default parameters for colorize()
Example:
bold_red = make_style(opts=('bold',), fg='red')
print(bold_red('hello'))
KEYWORD = make_style(fg='yellow')
COMMENT = make_style(fg='blue', opts=('bold',))
"""
ret... | [
"def",
"make_style",
"(",
"opts",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"lambda",
"text",
":",
"colorize",
"(",
"text",
",",
"opts",
",",
"*",
"*",
"kwargs",
")"
] | [
57,
0
] | [
67,
54
] | python | en | ['en', 'error', 'th'] | False |
parse_color_setting | (config_string) | Parse a DJANGO_COLORS environment variable to produce the system palette
The general form of a palette definition is:
"palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option"
where:
palette is a named palette; one of 'light', 'dark', or 'nocolor'.
role is a named st... | Parse a DJANGO_COLORS environment variable to produce the system palette | def parse_color_setting(config_string):
"""Parse a DJANGO_COLORS environment variable to produce the system palette
The general form of a palette definition is:
"palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option"
where:
palette is a named palette; one of 'light', '... | [
"def",
"parse_color_setting",
"(",
"config_string",
")",
":",
"if",
"not",
"config_string",
":",
"return",
"PALETTES",
"[",
"DEFAULT_PALETTE",
"]",
"# Split the color configuration into parts",
"parts",
"=",
"config_string",
".",
"lower",
"(",
")",
".",
"split",
"("... | [
136,
0
] | [
214,
18
] | python | en | ['en', 'en', 'en'] | True |
canonicalize_version | (version) |
This is very similar to Version.__str__, but has one subtle differences
with the way it handles the release segment.
|
This is very similar to Version.__str__, but has one subtle differences
with the way it handles the release segment.
| def canonicalize_version(version):
"""
This is very similar to Version.__str__, but has one subtle differences
with the way it handles the release segment.
"""
try:
version = Version(version)
except InvalidVersion:
# Legacy versions cannot be normalized
return version
... | [
"def",
"canonicalize_version",
"(",
"version",
")",
":",
"try",
":",
"version",
"=",
"Version",
"(",
"version",
")",
"except",
"InvalidVersion",
":",
"# Legacy versions cannot be normalized",
"return",
"version",
"parts",
"=",
"[",
"]",
"# Epoch",
"if",
"version",... | [
18,
0
] | [
56,
25
] | python | en | ['en', 'error', 'th'] | False |
ProjectModule.parent | (self) | Component Parent. | Component Parent. | def parent(self):
"""Component Parent."""
return self._parent | [
"def",
"parent",
"(",
"self",
")",
":",
"return",
"self",
".",
"_parent"
] | [
29,
4
] | [
31,
27
] | python | de | ['de', 'fr', 'en'] | False |
ProjectModule.parent | (self, parent: Type["ProjectModule"]) | Sets component parent.
Args:
parent (Any): Parent to set
| Sets component parent. | def parent(self, parent: Type["ProjectModule"]) -> Type["ProjectModule"]:
"""Sets component parent.
Args:
parent (Any): Parent to set
"""
self._parent = parent
return self.parent | [
"def",
"parent",
"(",
"self",
",",
"parent",
":",
"Type",
"[",
"\"ProjectModule\"",
"]",
")",
"->",
"Type",
"[",
"\"ProjectModule\"",
"]",
":",
"self",
".",
"_parent",
"=",
"parent",
"return",
"self",
".",
"parent"
] | [
34,
4
] | [
42,
26
] | python | en | ['en', 'fr', 'en'] | True |
ProjectModule.config | (self) | Config values specific to component. | Config values specific to component. | def config(self) -> Union[dict, Config]:
"""Config values specific to component.""" | [
"def",
"config",
"(",
"self",
")",
"->",
"Union",
"[",
"dict",
",",
"Config",
"]",
":"
] | [
45,
4
] | [
46,
50
] | python | en | ['en', 'en', 'en'] | True |
ProjectModule.load | (self) | Method to load component. | Method to load component. | def load(self):
"""Method to load component.""" | [
"def",
"load",
"(",
"self",
")",
":"
] | [
49,
4
] | [
50,
39
] | python | en | ['en', 'en', 'en'] | True |
ProjectModule.create | (self, *args: Any, **kwargs: Any) | Method to create component. | Method to create component. | def create(self, *args: Any, **kwargs: Any) -> Any:
"""Method to create component.""" | [
"def",
"create",
"(",
"self",
",",
"*",
"args",
":",
"Any",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Any",
":"
] | [
53,
4
] | [
54,
41
] | python | en | ['en', 'en', 'en'] | True |
ProjectModule.update | (self) | Method to update component. | Method to update component. | def update(self):
"""Method to update component.""" | [
"def",
"update",
"(",
"self",
")",
":"
] | [
57,
4
] | [
58,
41
] | python | en | ['en', 'en', 'en'] | True |
ProjectModule.add | (self, component: Type["ProjectModule"], *args: Any, **kwargs: Any) | Adds component.
Args:
component (Any): Component to add.
| Adds component. | def add(self, component: Type["ProjectModule"], *args: Any, **kwargs: Any) -> Any:
"""Adds component.
Args:
component (Any): Component to add.
""" | [
"def",
"add",
"(",
"self",
",",
"component",
":",
"Type",
"[",
"\"ProjectModule\"",
"]",
",",
"*",
"args",
":",
"Any",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Any",
":"
] | [
60,
4
] | [
66,
11
] | python | en | ['de', 'en', 'en'] | False |
ProjectModule.remove | (self, component: Type["ProjectModule"]) | Removes component.
Args:
component (Any): Component to remove.
| Removes component. | def remove(self, component: Type["ProjectModule"]) -> Any:
"""Removes component.
Args:
component (Any): Component to remove.
""" | [
"def",
"remove",
"(",
"self",
",",
"component",
":",
"Type",
"[",
"\"ProjectModule\"",
"]",
")",
"->",
"Any",
":"
] | [
68,
4
] | [
74,
11
] | python | en | ['de', 'en', 'en'] | False |
ProjectModule.hook | (cls, *args: Any, **kwargs: Any) | Decorator for creating a Project Hook.
Allows decorated method to be called from parent
container.
Returns:
Callable: Decorated function.
| Decorator for creating a Project Hook. | def hook(cls, *args: Any, **kwargs: Any) -> Callable[..., Any]:
"""Decorator for creating a Project Hook.
Allows decorated method to be called from parent
container.
Returns:
Callable: Decorated function.
"""
def _hook(func: T) -> Callable[..., Any]:
... | [
"def",
"hook",
"(",
"cls",
",",
"*",
"args",
":",
"Any",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Callable",
"[",
"...",
",",
"Any",
"]",
":",
"def",
"_hook",
"(",
"func",
":",
"T",
")",
"->",
"Callable",
"[",
"...",
",",
"Any",
"]",
... | [
77,
4
] | [
102,
20
] | python | en | ['en', 'en', 'en'] | True |
ProjectModule.resolve_hook | (self, name: str) | Resolves appropriate hook for attribute name.
Args:
name (str): Attribute name to resolve hook for.
Returns:
Optional[HookProxy]: Callable Proxy for ProjectHook.
NoneType: Name could not be resolved.
| Resolves appropriate hook for attribute name. | def resolve_hook(self, name: str) -> Union[Optional["HookProxy"], T]:
"""Resolves appropriate hook for attribute name.
Args:
name (str): Attribute name to resolve hook for.
Returns:
Optional[HookProxy]: Callable Proxy for ProjectHook.
NoneType: Name could no... | [
"def",
"resolve_hook",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"Union",
"[",
"Optional",
"[",
"\"HookProxy\"",
"]",
",",
"T",
"]",
":",
"_hook",
"=",
"None",
"for",
"hook",
"in",
"self",
".",
"_hooks",
":",
"if",
"hook",
".",
"_name",
"=="... | [
104,
4
] | [
122,
20
] | python | en | ['en', 'en', 'en'] | True |
HookProxy.resolve_proxy | (self, **kwargs: Any) | Resolves appropriate instance and method to proxy to.
If additional kwargs are provided and a proxy is not found,
the function will continue to remove one kwarg and
recurse into itself until either a match is found or it runs
out of kwargs.
Returns:
Instance and met... | Resolves appropriate instance and method to proxy to. | def resolve_proxy(self, **kwargs: Any) -> (Type[ProjectModule], str):
"""Resolves appropriate instance and method to proxy to.
If additional kwargs are provided and a proxy is not found,
the function will continue to remove one kwarg and
recurse into itself until either a match is found... | [
"def",
"resolve_proxy",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"(",
"Type",
"[",
"ProjectModule",
"]",
",",
"str",
")",
":",
"proxy_kwargs",
"=",
"deepcopy",
"(",
"kwargs",
")",
"for",
"method",
",",
"name",
"in",
"self",
".",
... | [
161,
4
] | [
186,
19
] | python | en | ['en', 'en', 'en'] | True |
HookProxy._get_instance | (self, attr: Callable[..., Any]) | Retrieves instance from attribute.
Args:
attr (Callable): Attribute to use.
Returns:
Instance the attribute belongs to.
| Retrieves instance from attribute. | def _get_instance(self, attr: Callable[..., Any]) -> Optional[Type[ProjectModule]]:
"""Retrieves instance from attribute.
Args:
attr (Callable): Attribute to use.
Returns:
Instance the attribute belongs to.
"""
_class = utils.get_class_that_defined_meth... | [
"def",
"_get_instance",
"(",
"self",
",",
"attr",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
")",
"->",
"Optional",
"[",
"Type",
"[",
"ProjectModule",
"]",
"]",
":",
"_class",
"=",
"utils",
".",
"get_class_that_defined_method",
"(",
"attr",
")",
"if",... | [
188,
4
] | [
201,
27
] | python | en | ['en', 'en', 'en'] | True |
HookProxy.is_descriptor | (self) | Determine if initial method provided is a descriptor. | Determine if initial method provided is a descriptor. | def is_descriptor(self) -> bool:
"""Determine if initial method provided is a descriptor."""
method = self.methods[0][0]
instance = self._get_instance(method)
if instance:
attr = inspect.getattr_static(instance, self._name)
return inspect.isdatadescriptor(attr)
... | [
"def",
"is_descriptor",
"(",
"self",
")",
"->",
"bool",
":",
"method",
"=",
"self",
".",
"methods",
"[",
"0",
"]",
"[",
"0",
"]",
"instance",
"=",
"self",
".",
"_get_instance",
"(",
"method",
")",
"if",
"instance",
":",
"attr",
"=",
"inspect",
".",
... | [
203,
4
] | [
210,
20
] | python | en | ['en', 'en', 'en'] | True |
HookProxy.get | (self) | Get initial method descriptor value. | Get initial method descriptor value. | def get(self) -> T:
"""Get initial method descriptor value."""
instance = self._get_instance(self.methods[0][0])
self.log.debug(f"{self._name} proxied to [property@{instance}]")
return getattr(instance, self._name) | [
"def",
"get",
"(",
"self",
")",
"->",
"T",
":",
"instance",
"=",
"self",
".",
"_get_instance",
"(",
"self",
".",
"methods",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"self",
".",
"log",
".",
"debug",
"(",
"f\"{self._name} proxied to [property@{instance}]\"",
")... | [
212,
4
] | [
216,
44
] | python | en | ['fr', 'la', 'en'] | False |
HookProxy.add_method | (self, func: Callable[..., Any], **kwargs: Any) | Adds method to Proxy.
Any kwargs provided will be used to generate the unique
hook name.
Args:
func (Callable): Method to add
Example:
>>> def test_func(arg1, kwarg1=False):
pass
>>> self.add_method(test_func, {'kwarg1': False})... | Adds method to Proxy. | def add_method(self, func: Callable[..., Any], **kwargs: Any) -> ProxyItem[Callable[..., Any]]:
"""Adds method to Proxy.
Any kwargs provided will be used to generate the unique
hook name.
Args:
func (Callable): Method to add
Example:
>>> def test_func(a... | [
"def",
"add_method",
"(",
"self",
",",
"func",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"ProxyItem",
"[",
"Callable",
"[",
"...",
",",
"Any",
"]",
"]",
":",
"name",
"=",
"self",
".",
"get_name"... | [
218,
4
] | [
242,
19
] | python | en | ['en', 'xh', 'en'] | True |
HookProxy.add_instance | (self, inst: Any) | Add instance to Proxy.
Args:
inst (Any): Instance to add.
| Add instance to Proxy. | def add_instance(self, inst: Any) -> Any:
"""Add instance to Proxy.
Args:
inst (Any): Instance to add.
"""
return self.instances.append(inst) | [
"def",
"add_instance",
"(",
"self",
",",
"inst",
":",
"Any",
")",
"->",
"Any",
":",
"return",
"self",
".",
"instances",
".",
"append",
"(",
"inst",
")"
] | [
244,
4
] | [
251,
42
] | python | en | ['en', 'pl', 'en'] | True |
HookProxy.get_name | (self, func: Callable[..., Any], params: Optional[dict] = None) | Generates name from method and provided kwargs.
Args:
func (Callable): Method to generate name for.
params (Dict[Any, Any], optional): Any kwargs to update the defaults with.
Defaults to None. If none, uses default kwargs.
Returns:
str: Generated nam... | Generates name from method and provided kwargs. | def get_name(self, func: Callable[..., Any], params: Optional[dict] = None) -> str:
"""Generates name from method and provided kwargs.
Args:
func (Callable): Method to generate name for.
params (Dict[Any, Any], optional): Any kwargs to update the defaults with.
D... | [
"def",
"get_name",
"(",
"self",
",",
"func",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
",",
"params",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
")",
"->",
"str",
":",
"params",
"=",
"params",
"or",
"{",
"}",
"sig",
"=",
"inspect",
".",
... | [
253,
4
] | [
274,
19
] | python | en | ['en', 'en', 'sw'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.