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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ServiceDefinition.findport | (self, port) |
Find and return a port tuple for the specified port.
Created and added when not found.
@param port: A port.
@type port: I{service.Port}
@return: A port tuple.
@rtype: (port, [method])
|
Find and return a port tuple for the specified port.
Created and added when not found.
| def findport(self, port):
"""
Find and return a port tuple for the specified port.
Created and added when not found.
@param port: A port.
@type port: I{service.Port}
@return: A port tuple.
@rtype: (port, [method])
"""
for p in self.ports:
... | [
"def",
"findport",
"(",
"self",
",",
"port",
")",
":",
"for",
"p",
"in",
"self",
".",
"ports",
":",
"if",
"p",
"[",
"0",
"]",
"==",
"p",
":",
"return",
"p",
"p",
"=",
"(",
"port",
",",
"[",
"]",
")",
"self",
".",
"ports",
".",
"append",
"("... | [
90,
4
] | [
103,
16
] | python | en | ['en', 'error', 'th'] | False |
ServiceDefinition.getprefixes | (self) |
Add prefixes foreach namespace referenced by parameter types.
|
Add prefixes foreach namespace referenced by parameter types.
| def getprefixes(self):
"""
Add prefixes foreach namespace referenced by parameter types.
"""
namespaces = []
for l in (self.params, self.types):
for t,r in l:
ns = r.namespace()
if ns[1] is None: continue
if ns[1] in nam... | [
"def",
"getprefixes",
"(",
"self",
")",
":",
"namespaces",
"=",
"[",
"]",
"for",
"l",
"in",
"(",
"self",
".",
"params",
",",
"self",
".",
"types",
")",
":",
"for",
"t",
",",
"r",
"in",
"l",
":",
"ns",
"=",
"r",
".",
"namespace",
"(",
")",
"if... | [
105,
4
] | [
128,
36
] | python | en | ['en', 'error', 'th'] | False |
ServiceDefinition.paramtypes | (self) | get all parameter types | get all parameter types | def paramtypes(self):
""" get all parameter types """
for m in [p[1] for p in self.ports]:
for p in [p[1] for p in m]:
for pd in p:
if pd[1] in self.params: continue
item = (pd[1], pd[1].resolve())
self.params.append... | [
"def",
"paramtypes",
"(",
"self",
")",
":",
"for",
"m",
"in",
"[",
"p",
"[",
"1",
"]",
"for",
"p",
"in",
"self",
".",
"ports",
"]",
":",
"for",
"p",
"in",
"[",
"p",
"[",
"1",
"]",
"for",
"p",
"in",
"m",
"]",
":",
"for",
"pd",
"in",
"p",
... | [
130,
4
] | [
137,
44
] | python | en | ['en', 'lb', 'en'] | True |
ServiceDefinition.publictypes | (self) | get all public types | get all public types | def publictypes(self):
""" get all public types """
for t in self.wsdl.schema.types.values():
if t in self.params: continue
if t in self.types: continue
item = (t, t)
self.types.append(item)
tc = lambda x,y: cmp(x[0].name, y[0].name)
self.t... | [
"def",
"publictypes",
"(",
"self",
")",
":",
"for",
"t",
"in",
"self",
".",
"wsdl",
".",
"schema",
".",
"types",
".",
"values",
"(",
")",
":",
"if",
"t",
"in",
"self",
".",
"params",
":",
"continue",
"if",
"t",
"in",
"self",
".",
"types",
":",
... | [
139,
4
] | [
147,
31
] | python | en | ['en', 'en', 'en'] | True |
ServiceDefinition.nextprefix | (self) |
Get the next available prefix. This means a prefix starting with 'ns' with
a number appended as (ns0, ns1, ..) that is not already defined on the
wsdl document.
|
Get the next available prefix. This means a prefix starting with 'ns' with
a number appended as (ns0, ns1, ..) that is not already defined on the
wsdl document.
| def nextprefix(self):
"""
Get the next available prefix. This means a prefix starting with 'ns' with
a number appended as (ns0, ns1, ..) that is not already defined on the
wsdl document.
"""
used = [ns[0] for ns in self.prefixes]
used += [ns[0] for ns in self.wsd... | [
"def",
"nextprefix",
"(",
"self",
")",
":",
"used",
"=",
"[",
"ns",
"[",
"0",
"]",
"for",
"ns",
"in",
"self",
".",
"prefixes",
"]",
"used",
"+=",
"[",
"ns",
"[",
"0",
"]",
"for",
"ns",
"in",
"self",
".",
"wsdl",
".",
"root",
".",
"nsprefixes",
... | [
149,
4
] | [
161,
45
] | python | en | ['en', 'error', 'th'] | False |
ServiceDefinition.getprefix | (self, u) |
Get the prefix for the specified namespace (uri)
@param u: A namespace uri.
@type u: str
@return: The namspace.
@rtype: (prefix, uri).
|
Get the prefix for the specified namespace (uri)
| def getprefix(self, u):
"""
Get the prefix for the specified namespace (uri)
@param u: A namespace uri.
@type u: str
@return: The namspace.
@rtype: (prefix, uri).
"""
for ns in Namespace.all:
if u == ns[1]: return ns[0]
for ns in self.p... | [
"def",
"getprefix",
"(",
"self",
",",
"u",
")",
":",
"for",
"ns",
"in",
"Namespace",
".",
"all",
":",
"if",
"u",
"==",
"ns",
"[",
"1",
"]",
":",
"return",
"ns",
"[",
"0",
"]",
"for",
"ns",
"in",
"self",
".",
"prefixes",
":",
"if",
"u",
"==",
... | [
163,
4
] | [
175,
50
] | python | en | ['en', 'error', 'th'] | False |
ServiceDefinition.xlate | (self, type) |
Get a (namespace) translated I{qualified} name for specified type.
@param type: A schema type.
@type type: I{suds.xsd.sxbasic.SchemaObject}
@return: A translated I{qualified} name.
@rtype: str
|
Get a (namespace) translated I{qualified} name for specified type.
| def xlate(self, type):
"""
Get a (namespace) translated I{qualified} name for specified type.
@param type: A schema type.
@type type: I{suds.xsd.sxbasic.SchemaObject}
@return: A translated I{qualified} name.
@rtype: str
"""
resolved = type.resolve()
... | [
"def",
"xlate",
"(",
"self",
",",
"type",
")",
":",
"resolved",
"=",
"type",
".",
"resolve",
"(",
")",
"name",
"=",
"resolved",
".",
"name",
"if",
"type",
".",
"unbounded",
"(",
")",
":",
"name",
"+=",
"'[]'",
"ns",
"=",
"resolved",
".",
"namespace... | [
177,
4
] | [
193,
39
] | python | en | ['en', 'error', 'th'] | False |
ServiceDefinition.description | (self) |
Get a textual description of the service for which this object represents.
@return: A textual description.
@rtype: str
|
Get a textual description of the service for which this object represents.
| def description(self):
"""
Get a textual description of the service for which this object represents.
@return: A textual description.
@rtype: str
"""
s = []
indent = (lambda n : '\n%*s'%(n*3,' '))
s.append('Service ( %s ) tns="%s"' % (self.service.name, s... | [
"def",
"description",
"(",
"self",
")",
":",
"s",
"=",
"[",
"]",
"indent",
"=",
"(",
"lambda",
"n",
":",
"'\\n%*s'",
"%",
"(",
"n",
"*",
"3",
",",
"' '",
")",
")",
"s",
".",
"append",
"(",
"'Service ( %s ) tns=\"%s\"'",
"%",
"(",
"self",
".",
"se... | [
195,
4
] | [
237,
25
] | python | en | ['en', 'error', 'th'] | False |
version_lt | (ver1: str, ver2: str) |
Compare two Zulip-style version strings.
Versions are dot-separated sequences of decimal integers,
followed by arbitrary trailing decoration. Comparison is
lexicographic on the integer sequences, and refuses to
guess how any trailing decoration compares to any other,
to further numerals, or t... |
Compare two Zulip-style version strings. | def version_lt(ver1: str, ver2: str) -> Optional[bool]:
"""
Compare two Zulip-style version strings.
Versions are dot-separated sequences of decimal integers,
followed by arbitrary trailing decoration. Comparison is
lexicographic on the integer sequences, and refuses to
guess how any trailing ... | [
"def",
"version_lt",
"(",
"ver1",
":",
"str",
",",
"ver2",
":",
"str",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"num1",
",",
"rest1",
"=",
"pop_numerals",
"(",
"ver1",
")",
"num2",
",",
"rest2",
"=",
"pop_numerals",
"(",
"ver2",
")",
"if",
"no... | [
21,
0
] | [
60,
15
] | python | en | ['en', 'error', 'th'] | False |
SimpleQueueClient.ensure_queue | (self, queue_name: str, callback: Callable[[BlockingChannel], None]) | Ensure that a given queue has been declared, and then call
the callback with no arguments. | Ensure that a given queue has been declared, and then call
the callback with no arguments. | def ensure_queue(self, queue_name: str, callback: Callable[[BlockingChannel], None]) -> None:
"""Ensure that a given queue has been declared, and then call
the callback with no arguments."""
if self.connection is None or not self.connection.is_open:
self._connect()
assert se... | [
"def",
"ensure_queue",
"(",
"self",
",",
"queue_name",
":",
"str",
",",
"callback",
":",
"Callable",
"[",
"[",
"BlockingChannel",
"]",
",",
"None",
"]",
")",
"->",
"None",
":",
"if",
"self",
".",
"connection",
"is",
"None",
"or",
"not",
"self",
".",
... | [
106,
4
] | [
116,
30
] | python | en | ['en', 'en', 'en'] | True |
untokenize | (iterable) | Transform tokens back into Python source code.
It returns a bytes object, encoded using the ENCODING
token, which is the first token sequence output by tokenize.
Each element returned by the iterable must be a token sequence
with at least two elements, a token number and token value. If
only two t... | Transform tokens back into Python source code.
It returns a bytes object, encoded using the ENCODING
token, which is the first token sequence output by tokenize. | def untokenize(iterable):
"""Transform tokens back into Python source code.
It returns a bytes object, encoded using the ENCODING
token, which is the first token sequence output by tokenize.
Each element returned by the iterable must be a token sequence
with at least two elements, a token number an... | [
"def",
"untokenize",
"(",
"iterable",
")",
":",
"ut",
"=",
"Untokenizer",
"(",
")",
"out",
"=",
"ut",
".",
"untokenize",
"(",
"iterable",
")",
"if",
"ut",
".",
"encoding",
"is",
"not",
"None",
":",
"out",
"=",
"out",
".",
"encode",
"(",
"ut",
".",
... | [
316,
0
] | [
340,
14
] | python | en | ['en', 'pt', 'en'] | True |
_get_normal_name | (orig_enc) | Imitates get_normal_name in tokenizer.c. | Imitates get_normal_name in tokenizer.c. | def _get_normal_name(orig_enc):
"""Imitates get_normal_name in tokenizer.c."""
# Only care about the first 12 characters.
enc = orig_enc[:12].lower().replace("_", "-")
if enc == "utf-8" or enc.startswith("utf-8-"):
return "utf-8"
if enc in ("latin-1", "iso-8859-1", "iso-latin-1") or \
... | [
"def",
"_get_normal_name",
"(",
"orig_enc",
")",
":",
"# Only care about the first 12 characters.",
"enc",
"=",
"orig_enc",
"[",
":",
"12",
"]",
".",
"lower",
"(",
")",
".",
"replace",
"(",
"\"_\"",
",",
"\"-\"",
")",
"if",
"enc",
"==",
"\"utf-8\"",
"or",
... | [
343,
0
] | [
352,
19
] | python | it | ['nl', 'jv', 'it'] | False |
detect_encoding | (readline) |
The detect_encoding() function is used to detect the encoding that should
be used to decode a Python source file. It requires one argument, readline,
in the same way as the tokenize() generator.
It will call readline a maximum of twice, and return the encoding used
(as a string) and a list of any... |
The detect_encoding() function is used to detect the encoding that should
be used to decode a Python source file. It requires one argument, readline,
in the same way as the tokenize() generator. | def detect_encoding(readline):
"""
The detect_encoding() function is used to detect the encoding that should
be used to decode a Python source file. It requires one argument, readline,
in the same way as the tokenize() generator.
It will call readline a maximum of twice, and return the encoding us... | [
"def",
"detect_encoding",
"(",
"readline",
")",
":",
"try",
":",
"filename",
"=",
"readline",
".",
"__self__",
".",
"name",
"except",
"AttributeError",
":",
"filename",
"=",
"None",
"bom_found",
"=",
"False",
"encoding",
"=",
"None",
"default",
"=",
"'utf-8'... | [
354,
0
] | [
444,
35
] | python | en | ['en', 'error', 'th'] | False |
open | (filename) | Open a file in read only mode using the encoding detected by
detect_encoding().
| Open a file in read only mode using the encoding detected by
detect_encoding().
| def open(filename):
"""Open a file in read only mode using the encoding detected by
detect_encoding().
"""
buffer = _builtin_open(filename, 'rb')
try:
encoding, lines = detect_encoding(buffer.readline)
buffer.seek(0)
text = TextIOWrapper(buffer, encoding, line_buffering=True)... | [
"def",
"open",
"(",
"filename",
")",
":",
"buffer",
"=",
"_builtin_open",
"(",
"filename",
",",
"'rb'",
")",
"try",
":",
"encoding",
",",
"lines",
"=",
"detect_encoding",
"(",
"buffer",
".",
"readline",
")",
"buffer",
".",
"seek",
"(",
"0",
")",
"text"... | [
447,
0
] | [
460,
13
] | python | en | ['en', 'en', 'en'] | True |
tokenize | (readline) |
The tokenize() generator requires one argument, readline, which
must be a callable object which provides the same interface as the
readline() method of built-in file objects. Each call to the function
should return one line of input as bytes. Alternatively, readline
can be a callable function ter... |
The tokenize() generator requires one argument, readline, which
must be a callable object which provides the same interface as the
readline() method of built-in file objects. Each call to the function
should return one line of input as bytes. Alternatively, readline
can be a callable function ter... | def tokenize(readline):
"""
The tokenize() generator requires one argument, readline, which
must be a callable object which provides the same interface as the
readline() method of built-in file objects. Each call to the function
should return one line of input as bytes. Alternatively, readline
... | [
"def",
"tokenize",
"(",
"readline",
")",
":",
"# This import is here to avoid problems when the itertools module is not",
"# built yet and tokenize is imported.",
"from",
"itertools",
"import",
"chain",
",",
"repeat",
"encoding",
",",
"consumed",
"=",
"detect_encoding",
"(",
... | [
463,
0
] | [
488,
71
] | python | en | ['en', 'error', 'th'] | False |
TestActionDistributions.test_gumbel_trick | (self) |
We use a Gumbel noise which seems to be faster compared to using pytorch multinomial.
Here we test that those are actually equivalent.
|
We use a Gumbel noise which seems to be faster compared to using pytorch multinomial.
Here we test that those are actually equivalent.
| def test_gumbel_trick(self):
"""
We use a Gumbel noise which seems to be faster compared to using pytorch multinomial.
Here we test that those are actually equivalent.
"""
timing = Timing()
torch.backends.cudnn.enabled = True
torch.backends.cudnn.benchmark = Tru... | [
"def",
"test_gumbel_trick",
"(",
"self",
")",
":",
"timing",
"=",
"Timing",
"(",
")",
"torch",
".",
"backends",
".",
"cudnn",
".",
"enabled",
"=",
"True",
"torch",
".",
"backends",
".",
"cudnn",
".",
"benchmark",
"=",
"True",
"with",
"torch",
".",
"no_... | [
30,
4
] | [
81,
27
] | python | en | ['en', 'error', 'th'] | False |
GroupSnapshotsFilterAction.filter | (self, table, vg_snapshots, filter_string) | Naive case-insensitive search. | Naive case-insensitive search. | def filter(self, table, vg_snapshots, filter_string):
"""Naive case-insensitive search."""
query = filter_string.lower()
return [vg_snapshot for vg_snapshot in vg_snapshots
if query in vg_snapshot.name.lower()] | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"vg_snapshots",
",",
"filter_string",
")",
":",
"query",
"=",
"filter_string",
".",
"lower",
"(",
")",
"return",
"[",
"vg_snapshot",
"for",
"vg_snapshot",
"in",
"vg_snapshots",
"if",
"query",
"in",
"vg_snapsho... | [
84,
4
] | [
88,
53
] | python | en | ['en', 'it', 'en'] | True |
create_mocks | (target_methods) | decorator to simplify setting up multiple mocks at once
:param target_methods: a dict to define methods to be patched using mock.
A key of "target_methods" is a target object whose attribute(s) are
patched.
A value of "target_methods" is a list of methods to be patched
using mock. Each element of... | decorator to simplify setting up multiple mocks at once | def create_mocks(target_methods):
"""decorator to simplify setting up multiple mocks at once
:param target_methods: a dict to define methods to be patched using mock.
A key of "target_methods" is a target object whose attribute(s) are
patched.
A value of "target_methods" is a list of methods to b... | [
"def",
"create_mocks",
"(",
"target_methods",
")",
":",
"def",
"wrapper",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"wrapped",
"(",
"inst",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"target",
",",
"method... | [
58,
0
] | [
131,
18
] | python | en | ['en', 'en', 'en'] | True |
_apply_panel_mocks | (patchers=None) | Global mocks on panels that get called on all views. | Global mocks on panels that get called on all views. | def _apply_panel_mocks(patchers=None):
"""Global mocks on panels that get called on all views."""
if patchers is None:
patchers = {}
mocked_methods = settings.TEST_GLOBAL_MOCKS_ON_PANELS
for name, mock_config in mocked_methods.items():
method = mock_config['method']
mock_params =... | [
"def",
"_apply_panel_mocks",
"(",
"patchers",
"=",
"None",
")",
":",
"if",
"patchers",
"is",
"None",
":",
"patchers",
"=",
"{",
"}",
"mocked_methods",
"=",
"settings",
".",
"TEST_GLOBAL_MOCKS_ON_PANELS",
"for",
"name",
",",
"mock_config",
"in",
"mocked_methods",... | [
134,
0
] | [
148,
19
] | python | en | ['en', 'en', 'en'] | True |
mock_factory | (r) | mocks all the attributes as well as the to_dict | mocks all the attributes as well as the to_dict | def mock_factory(r):
"""mocks all the attributes as well as the to_dict """
mocked = mock_obj_to_dict(r)
mocked.configure_mock(**r)
return mocked | [
"def",
"mock_factory",
"(",
"r",
")",
":",
"mocked",
"=",
"mock_obj_to_dict",
"(",
"r",
")",
"mocked",
".",
"configure_mock",
"(",
"*",
"*",
"r",
")",
"return",
"mocked"
] | [
602,
0
] | [
606,
17
] | python | en | ['en', 'en', 'en'] | True |
TestCase.assertRedirectsNoFollow | (self, response, expected_url) | Check for redirect.
Asserts that the given response issued a 302 redirect without
processing the view which is redirected to.
| Check for redirect. | def assertRedirectsNoFollow(self, response, expected_url):
"""Check for redirect.
Asserts that the given response issued a 302 redirect without
processing the view which is redirected to.
"""
loc = six.text_type(response._headers.get('location', None)[1])
loc = http.urlu... | [
"def",
"assertRedirectsNoFollow",
"(",
"self",
",",
"response",
",",
"expected_url",
")",
":",
"loc",
"=",
"six",
".",
"text_type",
"(",
"response",
".",
"_headers",
".",
"get",
"(",
"'location'",
",",
"None",
")",
"[",
"1",
"]",
")",
"loc",
"=",
"http... | [
269,
4
] | [
279,
51
] | python | en | ['en', 'en', 'en'] | True |
TestCase.assertNoFormErrors | (self, response, context_name="form") | Checks for no form errors.
Asserts that the response either does not contain a form in its
context, or that if it does, that form has no errors.
| Checks for no form errors. | def assertNoFormErrors(self, response, context_name="form"):
"""Checks for no form errors.
Asserts that the response either does not contain a form in its
context, or that if it does, that form has no errors.
"""
context = getattr(response, "context", {})
if not context ... | [
"def",
"assertNoFormErrors",
"(",
"self",
",",
"response",
",",
"context_name",
"=",
"\"form\"",
")",
":",
"context",
"=",
"getattr",
"(",
"response",
",",
"\"context\"",
",",
"{",
"}",
")",
"if",
"not",
"context",
"or",
"context_name",
"not",
"in",
"conte... | [
281,
4
] | [
292,
67
] | python | en | ['en', 'pt', 'en'] | True |
TestCase.assertFormErrors | (self, response, count=0, message=None,
context_name="form") | Check for form errors.
Asserts that the response does contain a form in its
context, and that form has errors, if count were given,
it must match the exact numbers of errors
| Check for form errors. | def assertFormErrors(self, response, count=0, message=None,
context_name="form"):
"""Check for form errors.
Asserts that the response does contain a form in its
context, and that form has errors, if count were given,
it must match the exact numbers of errors
... | [
"def",
"assertFormErrors",
"(",
"self",
",",
"response",
",",
"count",
"=",
"0",
",",
"message",
"=",
"None",
",",
"context_name",
"=",
"\"form\"",
")",
":",
"context",
"=",
"getattr",
"(",
"response",
",",
"\"context\"",
",",
"{",
"}",
")",
"assert",
... | [
294,
4
] | [
315,
70
] | python | en | ['da', 'en', 'en'] | True |
TestCase.assertStatusCode | (self, response, expected_code) | Validates an expected status code.
Matches camel case of other assert functions
| Validates an expected status code. | def assertStatusCode(self, response, expected_code):
"""Validates an expected status code.
Matches camel case of other assert functions
"""
if response.status_code == expected_code:
return
self.fail('status code %r != %r: %s' % (response.status_code,
... | [
"def",
"assertStatusCode",
"(",
"self",
",",
"response",
",",
"expected_code",
")",
":",
"if",
"response",
".",
"status_code",
"==",
"expected_code",
":",
"return",
"self",
".",
"fail",
"(",
"'status code %r != %r: %s'",
"%",
"(",
"response",
".",
"status_code",... | [
317,
4
] | [
326,
66
] | python | en | ['en', 'en', 'en'] | True |
TestCase.assertNoWorkflowErrors | (self, response, context_name="workflow") | Checks for no workflow errors.
Asserts that the response either does not contain a workflow in its
context, or that if it does, that workflow has no errors.
| Checks for no workflow errors. | def assertNoWorkflowErrors(self, response, context_name="workflow"):
"""Checks for no workflow errors.
Asserts that the response either does not contain a workflow in its
context, or that if it does, that workflow has no errors.
"""
context = getattr(response, "context", {})
... | [
"def",
"assertNoWorkflowErrors",
"(",
"self",
",",
"response",
",",
"context_name",
"=",
"\"workflow\"",
")",
":",
"context",
"=",
"getattr",
"(",
"response",
",",
"\"context\"",
",",
"{",
"}",
")",
"if",
"not",
"context",
"or",
"context_name",
"not",
"in",
... | [
387,
4
] | [
400,
72
] | python | en | ['en', 'en', 'en'] | True |
TestCase.assertWorkflowErrors | (self, response, count=0, message=None,
context_name="workflow") | Check for workflow errors.
Asserts that the response does contain a workflow in its
context, and that workflow has errors, if count were given,
it must match the exact numbers of errors
| Check for workflow errors. | def assertWorkflowErrors(self, response, count=0, message=None,
context_name="workflow"):
"""Check for workflow errors.
Asserts that the response does contain a workflow in its
context, and that workflow has errors, if count were given,
it must match the exa... | [
"def",
"assertWorkflowErrors",
"(",
"self",
",",
"response",
",",
"count",
"=",
"0",
",",
"message",
"=",
"None",
",",
"context_name",
"=",
"\"workflow\"",
")",
":",
"context",
"=",
"getattr",
"(",
"response",
",",
"\"context\"",
",",
"{",
"}",
")",
"sel... | [
402,
4
] | [
428,
55
] | python | en | ['en', 'en', 'en'] | True |
get_url_for_service | (service, region, endpoint_type) | if we are dealing with the identity service and there is no endpoint
in the current region, it is okay to use the first endpoint for any
identity service endpoints and we can assume that it is global
| if we are dealing with the identity service and there is no endpoint
in the current region, it is okay to use the first endpoint for any
identity service endpoints and we can assume that it is global
| def get_url_for_service(service, region, endpoint_type):
if 'type' not in service:
return None
identity_version = get_version_from_service(service)
service_endpoints = service.get('endpoints', [])
available_endpoints = [endpoint for endpoint in service_endpoints
if re... | [
"def",
"get_url_for_service",
"(",
"service",
",",
"region",
",",
"endpoint_type",
")",
":",
"if",
"'type'",
"not",
"in",
"service",
":",
"return",
"None",
"identity_version",
"=",
"get_version_from_service",
"(",
"service",
")",
"service_endpoints",
"=",
"service... | [
323,
0
] | [
351,
15
] | python | en | ['en', 'en', 'en'] | True |
_get_endpoint_region | (endpoint) | Common function for getting the region from endpoint.
In Keystone V3, region has been deprecated in favor of
region_id.
This method provides a way to get region that works for
both Keystone V2 and V3.
| Common function for getting the region from endpoint. | def _get_endpoint_region(endpoint):
"""Common function for getting the region from endpoint.
In Keystone V3, region has been deprecated in favor of
region_id.
This method provides a way to get region that works for
both Keystone V2 and V3.
"""
return endpoint.get('region_id') or endpoint.g... | [
"def",
"_get_endpoint_region",
"(",
"endpoint",
")",
":",
"return",
"endpoint",
".",
"get",
"(",
"'region_id'",
")",
"or",
"endpoint",
".",
"get",
"(",
"'region'",
")"
] | [
390,
0
] | [
399,
62
] | python | en | ['en', 'en', 'en'] | True |
QuotaSet.__add__ | (self, other) | Merge another QuotaSet into this one.
Existing quotas are not overridden.
| Merge another QuotaSet into this one. | def __add__(self, other):
"""Merge another QuotaSet into this one.
Existing quotas are not overridden.
"""
if not isinstance(other, QuotaSet):
msg = "Can only add QuotaSet to QuotaSet, " \
"but received %s instead" % type(other)
raise ValueError... | [
"def",
"__add__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"QuotaSet",
")",
":",
"msg",
"=",
"\"Can only add QuotaSet to QuotaSet, \"",
"\"but received %s instead\"",
"%",
"type",
"(",
"other",
")",
"raise",
"ValueError"... | [
266,
4
] | [
279,
19
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.__init__ | (self, seconds, nanoseconds=0) | Initialize a Timestamp object.
:param int seconds:
Number of seconds since the UNIX epoch (00:00:00 UTC Jan 1 1970, minus leap seconds).
May be negative.
:param int nanoseconds:
Number of nanoseconds to add to `seconds` to get fractional time.
Maximum is... | Initialize a Timestamp object. | def __init__(self, seconds, nanoseconds=0):
"""Initialize a Timestamp object.
:param int seconds:
Number of seconds since the UNIX epoch (00:00:00 UTC Jan 1 1970, minus leap seconds).
May be negative.
:param int nanoseconds:
Number of nanoseconds to add to `... | [
"def",
"__init__",
"(",
"self",
",",
"seconds",
",",
"nanoseconds",
"=",
"0",
")",
":",
"if",
"not",
"isinstance",
"(",
"seconds",
",",
"int_types",
")",
":",
"raise",
"TypeError",
"(",
"\"seconds must be an interger\"",
")",
"if",
"not",
"isinstance",
"(",
... | [
44,
4
] | [
66,
38
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.__repr__ | (self) | String representation of Timestamp. | String representation of Timestamp. | def __repr__(self):
"""String representation of Timestamp."""
return "Timestamp(seconds={0}, nanoseconds={1})".format(
self.seconds, self.nanoseconds
) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"\"Timestamp(seconds={0}, nanoseconds={1})\"",
".",
"format",
"(",
"self",
".",
"seconds",
",",
"self",
".",
"nanoseconds",
")"
] | [
68,
4
] | [
72,
9
] | python | en | ['en', 'kk', 'en'] | True |
Timestamp.__eq__ | (self, other) | Check for equality with another Timestamp object | Check for equality with another Timestamp object | def __eq__(self, other):
"""Check for equality with another Timestamp object"""
if type(other) is self.__class__:
return (
self.seconds == other.seconds and self.nanoseconds == other.nanoseconds
)
return False | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"type",
"(",
"other",
")",
"is",
"self",
".",
"__class__",
":",
"return",
"(",
"self",
".",
"seconds",
"==",
"other",
".",
"seconds",
"and",
"self",
".",
"nanoseconds",
"==",
"other",
".",
... | [
74,
4
] | [
80,
20
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.__ne__ | (self, other) | not-equals method (see :func:`__eq__()`) | not-equals method (see :func:`__eq__()`) | def __ne__(self, other):
"""not-equals method (see :func:`__eq__()`)"""
return not self.__eq__(other) | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"return",
"not",
"self",
".",
"__eq__",
"(",
"other",
")"
] | [
82,
4
] | [
84,
37
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.from_bytes | (b) | Unpack bytes into a `Timestamp` object.
Used for pure-Python msgpack unpacking.
:param b: Payload from msgpack ext message with code -1
:type b: bytes
:returns: Timestamp object unpacked from msgpack ext payload
:rtype: Timestamp
| Unpack bytes into a `Timestamp` object. | def from_bytes(b):
"""Unpack bytes into a `Timestamp` object.
Used for pure-Python msgpack unpacking.
:param b: Payload from msgpack ext message with code -1
:type b: bytes
:returns: Timestamp object unpacked from msgpack ext payload
:rtype: Timestamp
"""
... | [
"def",
"from_bytes",
"(",
"b",
")",
":",
"if",
"len",
"(",
"b",
")",
"==",
"4",
":",
"seconds",
"=",
"struct",
".",
"unpack",
"(",
"\"!L\"",
",",
"b",
")",
"[",
"0",
"]",
"nanoseconds",
"=",
"0",
"elif",
"len",
"(",
"b",
")",
"==",
"8",
":",
... | [
90,
4
] | [
114,
46
] | python | en | ['pt', 'en', 'en'] | True |
Timestamp.to_bytes | (self) | Pack this Timestamp object into bytes.
Used for pure-Python msgpack packing.
:returns data: Payload for EXT message with code -1 (timestamp type)
:rtype: bytes
| Pack this Timestamp object into bytes. | def to_bytes(self):
"""Pack this Timestamp object into bytes.
Used for pure-Python msgpack packing.
:returns data: Payload for EXT message with code -1 (timestamp type)
:rtype: bytes
"""
if (self.seconds >> 34) == 0: # seconds is non-negative and fits in 34 bits
... | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"seconds",
">>",
"34",
")",
"==",
"0",
":",
"# seconds is non-negative and fits in 34 bits",
"data64",
"=",
"self",
".",
"nanoseconds",
"<<",
"34",
"|",
"self",
".",
"seconds",
"if",
"data64... | [
116,
4
] | [
135,
19
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.from_unix | (unix_sec) | Create a Timestamp from posix timestamp in seconds.
:param unix_float: Posix timestamp in seconds.
:type unix_float: int or float.
| Create a Timestamp from posix timestamp in seconds. | def from_unix(unix_sec):
"""Create a Timestamp from posix timestamp in seconds.
:param unix_float: Posix timestamp in seconds.
:type unix_float: int or float.
"""
seconds = int(unix_sec // 1)
nanoseconds = int((unix_sec % 1) * 10 ** 9)
return Timestamp(seconds, n... | [
"def",
"from_unix",
"(",
"unix_sec",
")",
":",
"seconds",
"=",
"int",
"(",
"unix_sec",
"//",
"1",
")",
"nanoseconds",
"=",
"int",
"(",
"(",
"unix_sec",
"%",
"1",
")",
"*",
"10",
"**",
"9",
")",
"return",
"Timestamp",
"(",
"seconds",
",",
"nanoseconds... | [
138,
4
] | [
146,
46
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.to_unix | (self) | Get the timestamp as a floating-point value.
:returns: posix timestamp
:rtype: float
| Get the timestamp as a floating-point value. | def to_unix(self):
"""Get the timestamp as a floating-point value.
:returns: posix timestamp
:rtype: float
"""
return self.seconds + self.nanoseconds / 1e9 | [
"def",
"to_unix",
"(",
"self",
")",
":",
"return",
"self",
".",
"seconds",
"+",
"self",
".",
"nanoseconds",
"/",
"1e9"
] | [
148,
4
] | [
154,
52
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.from_unix_nano | (unix_ns) | Create a Timestamp from posix timestamp in nanoseconds.
:param int unix_ns: Posix timestamp in nanoseconds.
:rtype: Timestamp
| Create a Timestamp from posix timestamp in nanoseconds. | def from_unix_nano(unix_ns):
"""Create a Timestamp from posix timestamp in nanoseconds.
:param int unix_ns: Posix timestamp in nanoseconds.
:rtype: Timestamp
"""
return Timestamp(*divmod(unix_ns, 10 ** 9)) | [
"def",
"from_unix_nano",
"(",
"unix_ns",
")",
":",
"return",
"Timestamp",
"(",
"*",
"divmod",
"(",
"unix_ns",
",",
"10",
"**",
"9",
")",
")"
] | [
157,
4
] | [
163,
51
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.to_unix_nano | (self) | Get the timestamp as a unixtime in nanoseconds.
:returns: posix timestamp in nanoseconds
:rtype: int
| Get the timestamp as a unixtime in nanoseconds. | def to_unix_nano(self):
"""Get the timestamp as a unixtime in nanoseconds.
:returns: posix timestamp in nanoseconds
:rtype: int
"""
return self.seconds * 10 ** 9 + self.nanoseconds | [
"def",
"to_unix_nano",
"(",
"self",
")",
":",
"return",
"self",
".",
"seconds",
"*",
"10",
"**",
"9",
"+",
"self",
".",
"nanoseconds"
] | [
165,
4
] | [
171,
56
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.to_datetime | (self) | Get the timestamp as a UTC datetime.
Python 2 is not supported.
:rtype: datetime.
| Get the timestamp as a UTC datetime. | def to_datetime(self):
"""Get the timestamp as a UTC datetime.
Python 2 is not supported.
:rtype: datetime.
"""
return datetime.datetime.fromtimestamp(self.to_unix(), _utc) | [
"def",
"to_datetime",
"(",
"self",
")",
":",
"return",
"datetime",
".",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"to_unix",
"(",
")",
",",
"_utc",
")"
] | [
173,
4
] | [
180,
68
] | python | en | ['en', 'en', 'en'] | True |
Timestamp.from_datetime | (dt) | Create a Timestamp from datetime with tzinfo.
Python 2 is not supported.
:rtype: Timestamp
| Create a Timestamp from datetime with tzinfo. | def from_datetime(dt):
"""Create a Timestamp from datetime with tzinfo.
Python 2 is not supported.
:rtype: Timestamp
"""
return Timestamp.from_unix(dt.timestamp()) | [
"def",
"from_datetime",
"(",
"dt",
")",
":",
"return",
"Timestamp",
".",
"from_unix",
"(",
"dt",
".",
"timestamp",
"(",
")",
")"
] | [
183,
4
] | [
190,
50
] | python | en | ['en', 'en', 'en'] | True |
SentryFilter.process | (self, data) | ``self.request`` is not available within this method | ``self.request`` is not available within this method | def process(self, data):
"""``self.request`` is not available within this method"""
return data | [
"def",
"process",
"(",
"self",
",",
"data",
")",
":",
"return",
"data"
] | [
105,
4
] | [
107,
19
] | python | en | ['en', 'en', 'en'] | True |
SelectWidget.build_attrs | (self, extra_attrs=None, **kwargs) | Helper function for building an attribute dictionary. | Helper function for building an attribute dictionary. | def build_attrs(self, extra_attrs=None, **kwargs):
"""Helper function for building an attribute dictionary."""
attrs = dict(self.attrs, **kwargs)
if extra_attrs:
attrs.update(extra_attrs)
return attrs | [
"def",
"build_attrs",
"(",
"self",
",",
"extra_attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"attrs",
"=",
"dict",
"(",
"self",
".",
"attrs",
",",
"*",
"*",
"kwargs",
")",
"if",
"extra_attrs",
":",
"attrs",
".",
"update",
"(",
"extra_attrs"... | [
238,
4
] | [
243,
20
] | python | en | ['en', 'en', 'en'] | True |
ThemableCheckboxSelectMultiple.render | (self, name=None, value=None, attrs=None, renderer=None) | Outputs a <ul> for this set of choice fields.
If an id was given to the field, it is applied to the <ul> (each
item in the list will get an id of `$id_$i`).
| Outputs a <ul> for this set of choice fields. | def render(self, name=None, value=None, attrs=None, renderer=None):
"""Outputs a <ul> for this set of choice fields.
If an id was given to the field, it is applied to the <ul> (each
item in the list will get an id of `$id_$i`).
"""
attrs = {} or attrs
self.attrs = attrs
... | [
"def",
"render",
"(",
"self",
",",
"name",
"=",
"None",
",",
"value",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"renderer",
"=",
"None",
")",
":",
"attrs",
"=",
"{",
"}",
"or",
"attrs",
"self",
".",
"attrs",
"=",
"attrs",
"self",
".",
"name",
... | [
557,
4
] | [
596,
9
] | python | en | ['en', 'en', 'en'] | True |
_add_doc | (func, doc) | Add documentation to a function. | Add documentation to a function. | def _add_doc(func, doc):
"""Add documentation to a function."""
func.__doc__ = doc | [
"def",
"_add_doc",
"(",
"func",
",",
"doc",
")",
":",
"func",
".",
"__doc__",
"=",
"doc"
] | [
74,
0
] | [
76,
22
] | python | en | ['en', 'en', 'en'] | True |
_import_module | (name) | Import module, returning the module after the last dot. | Import module, returning the module after the last dot. | def _import_module(name):
"""Import module, returning the module after the last dot."""
__import__(name)
return sys.modules[name] | [
"def",
"_import_module",
"(",
"name",
")",
":",
"__import__",
"(",
"name",
")",
"return",
"sys",
".",
"modules",
"[",
"name",
"]"
] | [
79,
0
] | [
82,
28
] | python | en | ['en', 'en', 'en'] | True |
add_move | (move) | Add an item to six.moves. | Add an item to six.moves. | def add_move(move):
"""Add an item to six.moves."""
setattr(_MovedItems, move.name, move) | [
"def",
"add_move",
"(",
"move",
")",
":",
"setattr",
"(",
"_MovedItems",
",",
"move",
".",
"name",
",",
"move",
")"
] | [
493,
0
] | [
495,
41
] | python | en | ['en', 'en', 'en'] | True |
remove_move | (name) | Remove item from six.moves. | Remove item from six.moves. | def remove_move(name):
"""Remove item from six.moves."""
try:
delattr(_MovedItems, name)
except AttributeError:
try:
del moves.__dict__[name]
except KeyError:
raise AttributeError("no such move, %r" % (name,)) | [
"def",
"remove_move",
"(",
"name",
")",
":",
"try",
":",
"delattr",
"(",
"_MovedItems",
",",
"name",
")",
"except",
"AttributeError",
":",
"try",
":",
"del",
"moves",
".",
"__dict__",
"[",
"name",
"]",
"except",
"KeyError",
":",
"raise",
"AttributeError",
... | [
498,
0
] | [
506,
62
] | python | en | ['en', 'en', 'en'] | True |
with_metaclass | (meta, *bases) | Create a base class with a metaclass. | Create a base class with a metaclass. | def with_metaclass(meta, *bases):
"""Create a base class with a metaclass."""
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself with
# the actual metaclass.
class metaclass(type):
def __new__(cls, na... | [
"def",
"with_metaclass",
"(",
"meta",
",",
"*",
"bases",
")",
":",
"# This requires a bit of explanation: the basic idea is to make a dummy",
"# metaclass for one level of class instantiation that replaces itself with",
"# the actual metaclass.",
"class",
"metaclass",
"(",
"type",
")... | [
839,
0
] | [
860,
61
] | python | en | ['en', 'en', 'en'] | True |
add_metaclass | (metaclass) | Class decorator for creating a class with a metaclass. | Class decorator for creating a class with a metaclass. | def add_metaclass(metaclass):
"""Class decorator for creating a class with a metaclass."""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
slots = orig_vars.get('__slots__')
if slots is not None:
if isinstance(slots, str):
slots = [slots]
for slo... | [
"def",
"add_metaclass",
"(",
"metaclass",
")",
":",
"def",
"wrapper",
"(",
"cls",
")",
":",
"orig_vars",
"=",
"cls",
".",
"__dict__",
".",
"copy",
"(",
")",
"slots",
"=",
"orig_vars",
".",
"get",
"(",
"'__slots__'",
")",
"if",
"slots",
"is",
"not",
"... | [
863,
0
] | [
878,
18
] | python | en | ['en', 'en', 'en'] | True |
ensure_binary | (s, encoding='utf-8', errors='strict') | Coerce **s** to six.binary_type.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> encoded to `bytes`
- `bytes` -> `bytes`
| Coerce **s** to six.binary_type. | def ensure_binary(s, encoding='utf-8', errors='strict'):
"""Coerce **s** to six.binary_type.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> encoded to `bytes`
- `bytes` -> `bytes`
"""
if isinstance(s, binary_type):
return s
... | [
"def",
"ensure_binary",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"binary_type",
")",
":",
"return",
"s",
"if",
"isinstance",
"(",
"s",
",",
"text_type",
")",
":",
"return",
... | [
881,
0
] | [
896,
56
] | python | en | ['en', 'sn', 'en'] | True |
ensure_str | (s, encoding='utf-8', errors='strict') | Coerce *s* to `str`.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
| Coerce *s* to `str`. | def ensure_str(s, encoding='utf-8', errors='strict'):
"""Coerce *s* to `str`.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
"""
# Optimization: Fast return for the common case.
if type(s) is s... | [
"def",
"ensure_str",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"# Optimization: Fast return for the common case.",
"if",
"type",
"(",
"s",
")",
"is",
"str",
":",
"return",
"s",
"if",
"PY2",
"and",
"isinstance",
"(",... | [
899,
0
] | [
919,
12
] | python | en | ['en', 'sl', 'en'] | True |
ensure_text | (s, encoding='utf-8', errors='strict') | Coerce *s* to six.text_type.
For Python 2:
- `unicode` -> `unicode`
- `str` -> `unicode`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
| Coerce *s* to six.text_type. | def ensure_text(s, encoding='utf-8', errors='strict'):
"""Coerce *s* to six.text_type.
For Python 2:
- `unicode` -> `unicode`
- `str` -> `unicode`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
"""
if isinstance(s, binary_type):
return s.decode(encodin... | [
"def",
"ensure_text",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"binary_type",
")",
":",
"return",
"s",
".",
"decode",
"(",
"encoding",
",",
"errors",
")",
"elif",
"isinstanc... | [
922,
0
] | [
938,
60
] | python | en | ['en', 'sr', 'en'] | True |
python_2_unicode_compatible | (klass) |
A class decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
|
A class decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing. | def python_2_unicode_compatible(klass):
"""
A class decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
"""
if ... | [
"def",
"python_2_unicode_compatible",
"(",
"klass",
")",
":",
"if",
"PY2",
":",
"if",
"'__str__'",
"not",
"in",
"klass",
".",
"__dict__",
":",
"raise",
"ValueError",
"(",
"\"@python_2_unicode_compatible cannot be applied \"",
"\"to %s because it doesn't define __str__().\""... | [
941,
0
] | [
956,
16
] | python | en | ['en', 'error', 'th'] | False |
_SixMetaPathImporter.is_package | (self, fullname) |
Return true, if the named module is a package.
We need this method to get correct spec objects with
Python 3.4 (see PEP451)
|
Return true, if the named module is a package. | def is_package(self, fullname):
"""
Return true, if the named module is a package.
We need this method to get correct spec objects with
Python 3.4 (see PEP451)
"""
return hasattr(self.__get_module(fullname), "__path__") | [
"def",
"is_package",
"(",
"self",
",",
"fullname",
")",
":",
"return",
"hasattr",
"(",
"self",
".",
"__get_module",
"(",
"fullname",
")",
",",
"\"__path__\"",
")"
] | [
208,
4
] | [
215,
63
] | python | en | ['en', 'error', 'th'] | False |
_SixMetaPathImporter.get_code | (self, fullname) | Return None
Required, if is_package is implemented | Return None | def get_code(self, fullname):
"""Return None
Required, if is_package is implemented"""
self.__get_module(fullname) # eventually raises ImportError
return None | [
"def",
"get_code",
"(",
"self",
",",
"fullname",
")",
":",
"self",
".",
"__get_module",
"(",
"fullname",
")",
"# eventually raises ImportError",
"return",
"None"
] | [
217,
4
] | [
222,
19
] | python | en | ['en', 'co', 'en'] | False |
_check_link_requires_python | (
link, # type: Link
version_info, # type: Tuple[int, int, int]
ignore_requires_python=False, # type: bool
) |
Return whether the given Python version is compatible with a link's
"Requires-Python" value.
:param version_info: A 3-tuple of ints representing the Python
major-minor-micro version to check.
:param ignore_requires_python: Whether to ignore the "Requires-Python"
value if the given Pyth... |
Return whether the given Python version is compatible with a link's
"Requires-Python" value. | def _check_link_requires_python(
link, # type: Link
version_info, # type: Tuple[int, int, int]
ignore_requires_python=False, # type: bool
):
# type: (...) -> bool
"""
Return whether the given Python version is compatible with a link's
"Requires-Python" value.
:param version_info: A 3... | [
"def",
"_check_link_requires_python",
"(",
"link",
",",
"# type: Link",
"version_info",
",",
"# type: Tuple[int, int, int]",
"ignore_requires_python",
"=",
"False",
",",
"# type: bool",
")",
":",
"# type: (...) -> bool",
"try",
":",
"is_compatible",
"=",
"check_requires_pyt... | [
60,
0
] | [
100,
15
] | python | en | ['en', 'error', 'th'] | False |
filter_unallowed_hashes | (
candidates, # type: List[InstallationCandidate]
hashes, # type: Hashes
project_name, # type: str
) |
Filter out candidates whose hashes aren't allowed, and return a new
list of candidates.
If at least one candidate has an allowed hash, then all candidates with
either an allowed hash or no hash specified are returned. Otherwise,
the given candidates are returned.
Including the candidates wit... |
Filter out candidates whose hashes aren't allowed, and return a new
list of candidates. | def filter_unallowed_hashes(
candidates, # type: List[InstallationCandidate]
hashes, # type: Hashes
project_name, # type: str
):
# type: (...) -> List[InstallationCandidate]
"""
Filter out candidates whose hashes aren't allowed, and return a new
list of candidates.
If at leas... | [
"def",
"filter_unallowed_hashes",
"(",
"candidates",
",",
"# type: List[InstallationCandidate]",
"hashes",
",",
"# type: Hashes",
"project_name",
",",
"# type: str",
")",
":",
"# type: (...) -> List[InstallationCandidate]",
"if",
"not",
"hashes",
":",
"logger",
".",
"debug"... | [
244,
0
] | [
316,
19
] | python | en | ['en', 'error', 'th'] | False |
_find_name_version_sep | (fragment, canonical_name) | Find the separator's index based on the package's canonical name.
:param fragment: A <package>+<version> filename "fragment" (stem) or
egg fragment.
:param canonical_name: The package's canonical name.
This function is needed since the canonicalized name does not necessarily
have the same leng... | Find the separator's index based on the package's canonical name. | def _find_name_version_sep(fragment, canonical_name):
# type: (str, str) -> int
"""Find the separator's index based on the package's canonical name.
:param fragment: A <package>+<version> filename "fragment" (stem) or
egg fragment.
:param canonical_name: The package's canonical name.
This ... | [
"def",
"_find_name_version_sep",
"(",
"fragment",
",",
"canonical_name",
")",
":",
"# type: (str, str) -> int",
"# Project name and version must be separated by one single dash. Find all",
"# occurrences of dashes; if the string in front of it matches the canonical",
"# name, this is the one s... | [
970,
0
] | [
994,
77
] | python | en | ['en', 'en', 'en'] | True |
_extract_version_from_fragment | (fragment, canonical_name) | Parse the version string from a <package>+<version> filename
"fragment" (stem) or egg fragment.
:param fragment: The string to parse. E.g. foo-2.1
:param canonical_name: The canonicalized name of the package this
belongs to.
| Parse the version string from a <package>+<version> filename
"fragment" (stem) or egg fragment. | def _extract_version_from_fragment(fragment, canonical_name):
# type: (str, str) -> Optional[str]
"""Parse the version string from a <package>+<version> filename
"fragment" (stem) or egg fragment.
:param fragment: The string to parse. E.g. foo-2.1
:param canonical_name: The canonicalized name of th... | [
"def",
"_extract_version_from_fragment",
"(",
"fragment",
",",
"canonical_name",
")",
":",
"# type: (str, str) -> Optional[str]",
"try",
":",
"version_start",
"=",
"_find_name_version_sep",
"(",
"fragment",
",",
"canonical_name",
")",
"+",
"1",
"except",
"ValueError",
"... | [
997,
0
] | [
1013,
18
] | python | en | ['en', 'en', 'en'] | True |
LinkEvaluator.__init__ | (
self,
project_name, # type: str
canonical_name, # type: str
formats, # type: FrozenSet[str]
target_python, # type: TargetPython
allow_yanked, # type: bool
ignore_requires_python=None, # type: Optional[bool]
) |
:param project_name: The user supplied package name.
:param canonical_name: The canonical package name.
:param formats: The formats allowed for this package. Should be a set
with 'binary' or 'source' or both in it.
:param target_python: The target Python interpreter to use w... |
:param project_name: The user supplied package name.
:param canonical_name: The canonical package name.
:param formats: The formats allowed for this package. Should be a set
with 'binary' or 'source' or both in it.
:param target_python: The target Python interpreter to use w... | def __init__(
self,
project_name, # type: str
canonical_name, # type: str
formats, # type: FrozenSet[str]
target_python, # type: TargetPython
allow_yanked, # type: bool
ignore_requires_python=None, # type: Optional[bool]
):
# type: (.... | [
"def",
"__init__",
"(",
"self",
",",
"project_name",
",",
"# type: str",
"canonical_name",
",",
"# type: str",
"formats",
",",
"# type: FrozenSet[str]",
"target_python",
",",
"# type: TargetPython",
"allow_yanked",
",",
"# type: bool",
"ignore_requires_python",
"=",
"None... | [
115,
4
] | [
151,
40
] | python | en | ['en', 'error', 'th'] | False |
LinkEvaluator.evaluate_link | (self, link) |
Determine whether a link is a candidate for installation.
:return: A tuple (is_candidate, result), where `result` is (1) a
version string if `is_candidate` is True, and (2) if
`is_candidate` is False, an optional string to log the reason
the link fails to qualify.
... |
Determine whether a link is a candidate for installation. | def evaluate_link(self, link):
# type: (Link) -> Tuple[bool, Optional[Text]]
"""
Determine whether a link is a candidate for installation.
:return: A tuple (is_candidate, result), where `result` is (1) a
version string if `is_candidate` is True, and (2) if
`is_ca... | [
"def",
"evaluate_link",
"(",
"self",
",",
"link",
")",
":",
"# type: (Link) -> Tuple[bool, Optional[Text]]",
"version",
"=",
"None",
"if",
"link",
".",
"is_yanked",
"and",
"not",
"self",
".",
"_allow_yanked",
":",
"reason",
"=",
"link",
".",
"yanked_reason",
"or... | [
153,
4
] | [
241,
30
] | python | en | ['en', 'error', 'th'] | False |
CandidatePreferences.__init__ | (
self,
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
) |
:param allow_all_prereleases: Whether to allow all pre-releases.
|
:param allow_all_prereleases: Whether to allow all pre-releases.
| def __init__(
self,
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
):
# type: (...) -> None
"""
:param allow_all_prereleases: Whether to allow all pre-releases.
"""
self.allow_all_prereleases = allow_all_prereleases
... | [
"def",
"__init__",
"(",
"self",
",",
"prefer_binary",
"=",
"False",
",",
"# type: bool",
"allow_all_prereleases",
"=",
"False",
",",
"# type: bool",
")",
":",
"# type: (...) -> None",
"self",
".",
"allow_all_prereleases",
"=",
"allow_all_prereleases",
"self",
".",
"... | [
326,
4
] | [
336,
42
] | python | en | ['en', 'error', 'th'] | False |
BestCandidateResult.__init__ | (
self,
candidates, # type: List[InstallationCandidate]
applicable_candidates, # type: List[InstallationCandidate]
best_candidate, # type: Optional[InstallationCandidate]
) |
:param candidates: A sequence of all available candidates found.
:param applicable_candidates: The applicable candidates.
:param best_candidate: The most preferred candidate found, or None
if no applicable candidates were found.
|
:param candidates: A sequence of all available candidates found.
:param applicable_candidates: The applicable candidates.
:param best_candidate: The most preferred candidate found, or None
if no applicable candidates were found.
| def __init__(
self,
candidates, # type: List[InstallationCandidate]
applicable_candidates, # type: List[InstallationCandidate]
best_candidate, # type: Optional[InstallationCandidate]
):
# type: (...) -> None
"""
:param candidates: A sequen... | [
"def",
"__init__",
"(",
"self",
",",
"candidates",
",",
"# type: List[InstallationCandidate]",
"applicable_candidates",
",",
"# type: List[InstallationCandidate]",
"best_candidate",
",",
"# type: Optional[InstallationCandidate]",
")",
":",
"# type: (...) -> None",
"assert",
"set"... | [
346,
4
] | [
369,
44
] | python | en | ['en', 'error', 'th'] | False |
BestCandidateResult.iter_all | (self) | Iterate through all candidates.
| Iterate through all candidates.
| def iter_all(self):
# type: () -> Iterable[InstallationCandidate]
"""Iterate through all candidates.
"""
return iter(self._candidates) | [
"def",
"iter_all",
"(",
"self",
")",
":",
"# type: () -> Iterable[InstallationCandidate]",
"return",
"iter",
"(",
"self",
".",
"_candidates",
")"
] | [
371,
4
] | [
375,
37
] | python | en | ['en', 'en', 'en'] | True |
BestCandidateResult.iter_applicable | (self) | Iterate through the applicable candidates.
| Iterate through the applicable candidates.
| def iter_applicable(self):
# type: () -> Iterable[InstallationCandidate]
"""Iterate through the applicable candidates.
"""
return iter(self._applicable_candidates) | [
"def",
"iter_applicable",
"(",
"self",
")",
":",
"# type: () -> Iterable[InstallationCandidate]",
"return",
"iter",
"(",
"self",
".",
"_applicable_candidates",
")"
] | [
377,
4
] | [
381,
48
] | python | en | ['en', 'en', 'en'] | True |
CandidateEvaluator.create | (
cls,
project_name, # type: str
target_python=None, # type: Optional[TargetPython]
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # typ... | Create a CandidateEvaluator object.
:param target_python: The target Python interpreter to use when
checking compatibility. If None (the default), a TargetPython
object will be constructed from the running Python.
:param specifier: An optional object implementing `filter`
... | Create a CandidateEvaluator object. | def create(
cls,
project_name, # type: str
target_python=None, # type: Optional[TargetPython]
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, ... | [
"def",
"create",
"(",
"cls",
",",
"project_name",
",",
"# type: str",
"target_python",
"=",
"None",
",",
"# type: Optional[TargetPython]",
"prefer_binary",
"=",
"False",
",",
"# type: bool",
"allow_all_prereleases",
"=",
"False",
",",
"# type: bool",
"specifier",
"=",... | [
392,
4
] | [
426,
9
] | python | en | ['pt', 'en', 'en'] | True |
CandidateEvaluator.__init__ | (
self,
project_name, # type: str
supported_tags, # type: List[Tag]
specifier, # type: specifiers.BaseSpecifier
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
hashes=None, # type: Optional[Ha... |
:param supported_tags: The PEP 425 tags supported by the target
Python in order of preference (most preferred first).
|
:param supported_tags: The PEP 425 tags supported by the target
Python in order of preference (most preferred first).
| def __init__(
self,
project_name, # type: str
supported_tags, # type: List[Tag]
specifier, # type: specifiers.BaseSpecifier
prefer_binary=False, # type: bool
allow_all_prereleases=False, # type: bool
hashes=None, # type:... | [
"def",
"__init__",
"(",
"self",
",",
"project_name",
",",
"# type: str",
"supported_tags",
",",
"# type: List[Tag]",
"specifier",
",",
"# type: specifiers.BaseSpecifier",
"prefer_binary",
"=",
"False",
",",
"# type: bool",
"allow_all_prereleases",
"=",
"False",
",",
"# ... | [
428,
4
] | [
447,
45
] | python | en | ['en', 'error', 'th'] | False |
CandidateEvaluator.get_applicable_candidates | (
self,
candidates, # type: List[InstallationCandidate]
) |
Return the applicable candidates from a list of candidates.
|
Return the applicable candidates from a list of candidates.
| def get_applicable_candidates(
self,
candidates, # type: List[InstallationCandidate]
):
# type: (...) -> List[InstallationCandidate]
"""
Return the applicable candidates from a list of candidates.
"""
# Using None infers from the specifier instead.
al... | [
"def",
"get_applicable_candidates",
"(",
"self",
",",
"candidates",
",",
"# type: List[InstallationCandidate]",
")",
":",
"# type: (...) -> List[InstallationCandidate]",
"# Using None infers from the specifier instead.",
"allow_prereleases",
"=",
"self",
".",
"_allow_all_prereleases"... | [
449,
4
] | [
485,
73
] | python | en | ['en', 'error', 'th'] | False |
CandidateEvaluator._sort_key | (self, candidate) |
Function to pass as the `key` argument to a call to sorted() to sort
InstallationCandidates by preference.
Returns a tuple such that tuples sorting as greater using Python's
default comparison operator are more preferred.
The preference is as follows:
First and foremo... |
Function to pass as the `key` argument to a call to sorted() to sort
InstallationCandidates by preference. | def _sort_key(self, candidate):
# type: (InstallationCandidate) -> CandidateSortingKey
"""
Function to pass as the `key` argument to a call to sorted() to sort
InstallationCandidates by preference.
Returns a tuple such that tuples sorting as greater using Python's
defaul... | [
"def",
"_sort_key",
"(",
"self",
",",
"candidate",
")",
":",
"# type: (InstallationCandidate) -> CandidateSortingKey",
"valid_tags",
"=",
"self",
".",
"_supported_tags",
"support_num",
"=",
"len",
"(",
"valid_tags",
")",
"build_tag",
"=",
"(",
")",
"# type: BuildTag",... | [
487,
4
] | [
545,
9
] | python | en | ['en', 'error', 'th'] | False |
CandidateEvaluator.sort_best_candidate | (
self,
candidates, # type: List[InstallationCandidate]
) |
Return the best candidate per the instance's sort order, or None if
no candidate is acceptable.
|
Return the best candidate per the instance's sort order, or None if
no candidate is acceptable.
| def sort_best_candidate(
self,
candidates, # type: List[InstallationCandidate]
):
# type: (...) -> Optional[InstallationCandidate]
"""
Return the best candidate per the instance's sort order, or None if
no candidate is acceptable.
"""
if not candida... | [
"def",
"sort_best_candidate",
"(",
"self",
",",
"candidates",
",",
"# type: List[InstallationCandidate]",
")",
":",
"# type: (...) -> Optional[InstallationCandidate]",
"if",
"not",
"candidates",
":",
"return",
"None",
"best_candidate",
"=",
"max",
"(",
"candidates",
",",
... | [
547,
4
] | [
559,
29
] | python | en | ['en', 'error', 'th'] | False |
CandidateEvaluator.compute_best_candidate | (
self,
candidates, # type: List[InstallationCandidate]
) |
Compute and return a `BestCandidateResult` instance.
|
Compute and return a `BestCandidateResult` instance.
| def compute_best_candidate(
self,
candidates, # type: List[InstallationCandidate]
):
# type: (...) -> BestCandidateResult
"""
Compute and return a `BestCandidateResult` instance.
"""
applicable_candidates = self.get_applicable_candidates(candidates)
... | [
"def",
"compute_best_candidate",
"(",
"self",
",",
"candidates",
",",
"# type: List[InstallationCandidate]",
")",
":",
"# type: (...) -> BestCandidateResult",
"applicable_candidates",
"=",
"self",
".",
"get_applicable_candidates",
"(",
"candidates",
")",
"best_candidate",
"="... | [
561,
4
] | [
577,
9
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.__init__ | (
self,
link_collector, # type: LinkCollector
target_python, # type: TargetPython
allow_yanked, # type: bool
format_control=None, # type: Optional[FormatControl]
candidate_prefs=None, # type: CandidatePreferences
ignore_requires_pytho... |
This constructor is primarily meant to be used by the create() class
method and from tests.
:param format_control: A FormatControl object, used to control
the selection of source packages / binary packages when consulting
the index and links.
:param candidate_pr... |
This constructor is primarily meant to be used by the create() class
method and from tests. | def __init__(
self,
link_collector, # type: LinkCollector
target_python, # type: TargetPython
allow_yanked, # type: bool
format_control=None, # type: Optional[FormatControl]
candidate_prefs=None, # type: CandidatePreferences
ignore_re... | [
"def",
"__init__",
"(",
"self",
",",
"link_collector",
",",
"# type: LinkCollector",
"target_python",
",",
"# type: TargetPython",
"allow_yanked",
",",
"# type: bool",
"format_control",
"=",
"None",
",",
"# type: Optional[FormatControl]",
"candidate_prefs",
"=",
"None",
"... | [
587,
4
] | [
621,
34
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.create | (
cls,
link_collector, # type: LinkCollector
selection_prefs, # type: SelectionPreferences
target_python=None, # type: Optional[TargetPython]
) | Create a PackageFinder.
:param selection_prefs: The candidate selection preferences, as a
SelectionPreferences object.
:param target_python: The target Python interpreter to use when
checking compatibility. If None (the default), a TargetPython
object will be constru... | Create a PackageFinder. | def create(
cls,
link_collector, # type: LinkCollector
selection_prefs, # type: SelectionPreferences
target_python=None, # type: Optional[TargetPython]
):
# type: (...) -> PackageFinder
"""Create a PackageFinder.
:param selection_prefs: The candidat... | [
"def",
"create",
"(",
"cls",
",",
"link_collector",
",",
"# type: LinkCollector",
"selection_prefs",
",",
"# type: SelectionPreferences",
"target_python",
"=",
"None",
",",
"# type: Optional[TargetPython]",
")",
":",
"# type: (...) -> PackageFinder",
"if",
"target_python",
... | [
628,
4
] | [
658,
9
] | python | en | ['en', 'af', 'en'] | True |
PackageFinder._sort_links | (self, links) |
Returns elements of links in order, non-egg links first, egg links
second, while eliminating duplicates
|
Returns elements of links in order, non-egg links first, egg links
second, while eliminating duplicates
| def _sort_links(self, links):
# type: (Iterable[Link]) -> List[Link]
"""
Returns elements of links in order, non-egg links first, egg links
second, while eliminating duplicates
"""
eggs, no_eggs = [], []
seen = set() # type: Set[Link]
for link in links:
... | [
"def",
"_sort_links",
"(",
"self",
",",
"links",
")",
":",
"# type: (Iterable[Link]) -> List[Link]",
"eggs",
",",
"no_eggs",
"=",
"[",
"]",
",",
"[",
"]",
"seen",
"=",
"set",
"(",
")",
"# type: Set[Link]",
"for",
"link",
"in",
"links",
":",
"if",
"link",
... | [
723,
4
] | [
738,
29
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.get_install_candidate | (self, link_evaluator, link) |
If the link is a candidate for install, convert it to an
InstallationCandidate and return it. Otherwise, return None.
|
If the link is a candidate for install, convert it to an
InstallationCandidate and return it. Otherwise, return None.
| def get_install_candidate(self, link_evaluator, link):
# type: (LinkEvaluator, Link) -> Optional[InstallationCandidate]
"""
If the link is a candidate for install, convert it to an
InstallationCandidate and return it. Otherwise, return None.
"""
is_candidate, result = lin... | [
"def",
"get_install_candidate",
"(",
"self",
",",
"link_evaluator",
",",
"link",
")",
":",
"# type: (LinkEvaluator, Link) -> Optional[InstallationCandidate]",
"is_candidate",
",",
"result",
"=",
"link_evaluator",
".",
"evaluate_link",
"(",
"link",
")",
"if",
"not",
"is_... | [
751,
4
] | [
769,
9
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.evaluate_links | (self, link_evaluator, links) |
Convert links that are candidates to InstallationCandidate objects.
|
Convert links that are candidates to InstallationCandidate objects.
| def evaluate_links(self, link_evaluator, links):
# type: (LinkEvaluator, Iterable[Link]) -> List[InstallationCandidate]
"""
Convert links that are candidates to InstallationCandidate objects.
"""
candidates = []
for link in self._sort_links(links):
candidate =... | [
"def",
"evaluate_links",
"(",
"self",
",",
"link_evaluator",
",",
"links",
")",
":",
"# type: (LinkEvaluator, Iterable[Link]) -> List[InstallationCandidate]",
"candidates",
"=",
"[",
"]",
"for",
"link",
"in",
"self",
".",
"_sort_links",
"(",
"links",
")",
":",
"cand... | [
771,
4
] | [
782,
25
] | python | en | ['en', 'error', 'th'] | False |
PackageFinder.find_all_candidates | (self, project_name) | Find all available InstallationCandidate for project_name
This checks index_urls and find_links.
All versions found are returned as an InstallationCandidate list.
See LinkEvaluator.evaluate_link() for details on which files
are accepted.
| Find all available InstallationCandidate for project_name | def find_all_candidates(self, project_name):
# type: (str) -> List[InstallationCandidate]
"""Find all available InstallationCandidate for project_name
This checks index_urls and find_links.
All versions found are returned as an InstallationCandidate list.
See LinkEvaluator.eval... | [
"def",
"find_all_candidates",
"(",
"self",
",",
"project_name",
")",
":",
"# type: (str) -> List[InstallationCandidate]",
"collected_links",
"=",
"self",
".",
"_link_collector",
".",
"collect_links",
"(",
"project_name",
")",
"link_evaluator",
"=",
"self",
".",
"make_li... | [
803,
4
] | [
844,
66
] | python | en | ['en', 'en', 'en'] | True |
PackageFinder.make_candidate_evaluator | (
self,
project_name, # type: str
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # type: Optional[Hashes]
) | Create a CandidateEvaluator object to use.
| Create a CandidateEvaluator object to use.
| def make_candidate_evaluator(
self,
project_name, # type: str
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # type: Optional[Hashes]
):
# type: (...) -> CandidateEvaluator
"""Create a CandidateEvaluator object to use.
"""
... | [
"def",
"make_candidate_evaluator",
"(",
"self",
",",
"project_name",
",",
"# type: str",
"specifier",
"=",
"None",
",",
"# type: Optional[specifiers.BaseSpecifier]",
"hashes",
"=",
"None",
",",
"# type: Optional[Hashes]",
")",
":",
"# type: (...) -> CandidateEvaluator",
"ca... | [
846,
4
] | [
863,
9
] | python | en | ['en', 'en', 'en'] | True |
PackageFinder.find_best_candidate | (
self,
project_name, # type: str
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # type: Optional[Hashes]
) | Find matches for the given project and specifier.
:param specifier: An optional object implementing `filter`
(e.g. `packaging.specifiers.SpecifierSet`) to filter applicable
versions.
:return: A `BestCandidateResult` instance.
| Find matches for the given project and specifier. | def find_best_candidate(
self,
project_name, # type: str
specifier=None, # type: Optional[specifiers.BaseSpecifier]
hashes=None, # type: Optional[Hashes]
):
# type: (...) -> BestCandidateResult
"""Find matches for the given project and specifier.
... | [
"def",
"find_best_candidate",
"(",
"self",
",",
"project_name",
",",
"# type: str",
"specifier",
"=",
"None",
",",
"# type: Optional[specifiers.BaseSpecifier]",
"hashes",
"=",
"None",
",",
"# type: Optional[Hashes]",
")",
":",
"# type: (...) -> BestCandidateResult",
"candid... | [
865,
4
] | [
886,
69
] | python | en | ['en', 'en', 'en'] | True |
PackageFinder.find_requirement | (self, req, upgrade) | Try to find a Link matching req
Expects req, an InstallRequirement and upgrade, a boolean
Returns a InstallationCandidate if found,
Raises DistributionNotFound or BestVersionAlreadyInstalled otherwise
| Try to find a Link matching req | def find_requirement(self, req, upgrade):
# type: (InstallRequirement, bool) -> Optional[InstallationCandidate]
"""Try to find a Link matching req
Expects req, an InstallRequirement and upgrade, a boolean
Returns a InstallationCandidate if found,
Raises DistributionNotFound or B... | [
"def",
"find_requirement",
"(",
"self",
",",
"req",
",",
"upgrade",
")",
":",
"# type: (InstallRequirement, bool) -> Optional[InstallationCandidate]",
"hashes",
"=",
"req",
".",
"hashes",
"(",
"trust_internet",
"=",
"False",
")",
"best_candidate_result",
"=",
"self",
... | [
888,
4
] | [
967,
29
] | python | en | ['en', 'en', 'en'] | True |
getrawcode | (obj, trycall=True) | return code object for given function. | return code object for given function. | def getrawcode(obj, trycall=True):
""" return code object for given function. """
try:
return obj.__code__
except AttributeError:
obj = getattr(obj, 'im_func', obj)
obj = getattr(obj, 'func_code', obj)
obj = getattr(obj, 'f_code', obj)
obj = getattr(obj, '__code__', o... | [
"def",
"getrawcode",
"(",
"obj",
",",
"trycall",
"=",
"True",
")",
":",
"try",
":",
"return",
"obj",
".",
"__code__",
"except",
"AttributeError",
":",
"obj",
"=",
"getattr",
"(",
"obj",
",",
"'im_func'",
",",
"obj",
")",
"obj",
"=",
"getattr",
"(",
"... | [
880,
0
] | [
894,
18
] | python | en | ['en', 'en', 'en'] | True |
Code.path | (self) | return a path object pointing to source code (note that it
might not point to an actually existing file). | return a path object pointing to source code (note that it
might not point to an actually existing file). | def path(self):
""" return a path object pointing to source code (note that it
might not point to an actually existing file). """
try:
p = py.path.local(self.raw.co_filename)
# maybe don't try this checking
if not p.check():
raise OSError("py.p... | [
"def",
"path",
"(",
"self",
")",
":",
"try",
":",
"p",
"=",
"py",
".",
"path",
".",
"local",
"(",
"self",
".",
"raw",
".",
"co_filename",
")",
"# maybe don't try this checking",
"if",
"not",
"p",
".",
"check",
"(",
")",
":",
"raise",
"OSError",
"(",
... | [
41,
4
] | [
54,
16
] | python | en | ['en', 'en', 'en'] | True |
Code.fullsource | (self) | return a _pytest._code.Source object for the full source file of the code
| return a _pytest._code.Source object for the full source file of the code
| def fullsource(self):
""" return a _pytest._code.Source object for the full source file of the code
"""
from _pytest._code import source
full, _ = source.findsource(self.raw)
return full | [
"def",
"fullsource",
"(",
"self",
")",
":",
"from",
"_pytest",
".",
"_code",
"import",
"source",
"full",
",",
"_",
"=",
"source",
".",
"findsource",
"(",
"self",
".",
"raw",
")",
"return",
"full"
] | [
57,
4
] | [
62,
19
] | python | en | ['en', 'en', 'en'] | True |
Code.source | (self) | return a _pytest._code.Source object for the code object's source only
| return a _pytest._code.Source object for the code object's source only
| def source(self):
""" return a _pytest._code.Source object for the code object's source only
"""
# return source only for that part of code
import _pytest._code
return _pytest._code.Source(self.raw) | [
"def",
"source",
"(",
"self",
")",
":",
"# return source only for that part of code",
"import",
"_pytest",
".",
"_code",
"return",
"_pytest",
".",
"_code",
".",
"Source",
"(",
"self",
".",
"raw",
")"
] | [
64,
4
] | [
69,
45
] | python | en | ['en', 'en', 'en'] | True |
Code.getargs | (self, var=False) | return a tuple with the argument names for the code object
if 'var' is set True also return the names of the variable and
keyword arguments when present
| return a tuple with the argument names for the code object | def getargs(self, var=False):
""" return a tuple with the argument names for the code object
if 'var' is set True also return the names of the variable and
keyword arguments when present
"""
# handfull shortcut for getting args
raw = self.raw
argcount = r... | [
"def",
"getargs",
"(",
"self",
",",
"var",
"=",
"False",
")",
":",
"# handfull shortcut for getting args",
"raw",
"=",
"self",
".",
"raw",
"argcount",
"=",
"raw",
".",
"co_argcount",
"if",
"var",
":",
"argcount",
"+=",
"raw",
".",
"co_flags",
"&",
"CO_VARA... | [
71,
4
] | [
83,
41
] | python | en | ['en', 'en', 'en'] | True |
Frame.statement | (self) | statement this frame is at | statement this frame is at | def statement(self):
""" statement this frame is at """
import _pytest._code
if self.code.fullsource is None:
return _pytest._code.Source("")
return self.code.fullsource.getstatement(self.lineno) | [
"def",
"statement",
"(",
"self",
")",
":",
"import",
"_pytest",
".",
"_code",
"if",
"self",
".",
"code",
".",
"fullsource",
"is",
"None",
":",
"return",
"_pytest",
".",
"_code",
".",
"Source",
"(",
"\"\"",
")",
"return",
"self",
".",
"code",
".",
"fu... | [
98,
4
] | [
103,
61
] | python | en | ['en', 'en', 'en'] | True |
Frame.eval | (self, code, **vars) | evaluate 'code' in the frame
'vars' are optional additional local variables
returns the result of the evaluation
| evaluate 'code' in the frame | def eval(self, code, **vars):
""" evaluate 'code' in the frame
'vars' are optional additional local variables
returns the result of the evaluation
"""
f_locals = self.f_locals.copy()
f_locals.update(vars)
return eval(code, self.f_globals, f_locals) | [
"def",
"eval",
"(",
"self",
",",
"code",
",",
"*",
"*",
"vars",
")",
":",
"f_locals",
"=",
"self",
".",
"f_locals",
".",
"copy",
"(",
")",
"f_locals",
".",
"update",
"(",
"vars",
")",
"return",
"eval",
"(",
"code",
",",
"self",
".",
"f_globals",
... | [
105,
4
] | [
114,
51
] | python | en | ['en', 'en', 'en'] | True |
Frame.exec_ | (self, code, **vars) | exec 'code' in the frame
'vars' are optiona; additional local variables
| exec 'code' in the frame | def exec_(self, code, **vars):
""" exec 'code' in the frame
'vars' are optiona; additional local variables
"""
f_locals = self.f_locals.copy()
f_locals.update(vars)
py.builtin.exec_(code, self.f_globals, f_locals) | [
"def",
"exec_",
"(",
"self",
",",
"code",
",",
"*",
"*",
"vars",
")",
":",
"f_locals",
"=",
"self",
".",
"f_locals",
".",
"copy",
"(",
")",
"f_locals",
".",
"update",
"(",
"vars",
")",
"py",
".",
"builtin",
".",
"exec_",
"(",
"code",
",",
"self",... | [
116,
4
] | [
123,
56
] | python | en | ['en', 'en', 'en'] | True |
Frame.repr | (self, object) | return a 'safe' (non-recursive, one-line) string repr for 'object'
| return a 'safe' (non-recursive, one-line) string repr for 'object'
| def repr(self, object):
""" return a 'safe' (non-recursive, one-line) string repr for 'object'
"""
return py.io.saferepr(object) | [
"def",
"repr",
"(",
"self",
",",
"object",
")",
":",
"return",
"py",
".",
"io",
".",
"saferepr",
"(",
"object",
")"
] | [
125,
4
] | [
128,
37
] | python | en | ['en', 'en', 'en'] | True |
Frame.getargs | (self, var=False) | return a list of tuples (name, value) for all arguments
if 'var' is set True also include the variable and keyword
arguments when present
| return a list of tuples (name, value) for all arguments | def getargs(self, var=False):
""" return a list of tuples (name, value) for all arguments
if 'var' is set True also include the variable and keyword
arguments when present
"""
retval = []
for arg in self.code.getargs(var):
try:
retval.... | [
"def",
"getargs",
"(",
"self",
",",
"var",
"=",
"False",
")",
":",
"retval",
"=",
"[",
"]",
"for",
"arg",
"in",
"self",
".",
"code",
".",
"getargs",
"(",
"var",
")",
":",
"try",
":",
"retval",
".",
"append",
"(",
"(",
"arg",
",",
"self",
".",
... | [
133,
4
] | [
145,
21
] | python | en | ['en', 'en', 'en'] | True |
TracebackEntry.statement | (self) | _pytest._code.Source object for the current statement | _pytest._code.Source object for the current statement | def statement(self):
""" _pytest._code.Source object for the current statement """
source = self.frame.code.fullsource
return source.getstatement(self.lineno) | [
"def",
"statement",
"(",
"self",
")",
":",
"source",
"=",
"self",
".",
"frame",
".",
"code",
".",
"fullsource",
"return",
"source",
".",
"getstatement",
"(",
"self",
".",
"lineno",
")"
] | [
176,
4
] | [
179,
47
] | python | en | ['en', 'en', 'en'] | True |
TracebackEntry.path | (self) | path to the source code | path to the source code | def path(self):
""" path to the source code """
return self.frame.code.path | [
"def",
"path",
"(",
"self",
")",
":",
"return",
"self",
".",
"frame",
".",
"code",
".",
"path"
] | [
182,
4
] | [
184,
35
] | python | en | ['en', 'en', 'en'] | True |
TracebackEntry.getsource | (self, astcache=None) | return failing source code. | return failing source code. | def getsource(self, astcache=None):
""" return failing source code. """
# we use the passed in astcache to not reparse asttrees
# within exception info printing
from _pytest._code.source import getstatementrange_ast
source = self.frame.code.fullsource
if source is None:
... | [
"def",
"getsource",
"(",
"self",
",",
"astcache",
"=",
"None",
")",
":",
"# we use the passed in astcache to not reparse asttrees",
"# within exception info printing",
"from",
"_pytest",
".",
"_code",
".",
"source",
"import",
"getstatementrange_ast",
"source",
"=",
"self"... | [
194,
4
] | [
216,
32
] | python | bg | ['fr', 'bg', 'en'] | False |
TracebackEntry.ishidden | (self) | return True if the current frame has a var __tracebackhide__
resolving to True
If __tracebackhide__ is a callable, it gets called with the
ExceptionInfo instance and can decide whether to hide the traceback.
mostly for internal use
| return True if the current frame has a var __tracebackhide__
resolving to True | def ishidden(self):
""" return True if the current frame has a var __tracebackhide__
resolving to True
If __tracebackhide__ is a callable, it gets called with the
ExceptionInfo instance and can decide whether to hide the traceback.
mostly for internal use
... | [
"def",
"ishidden",
"(",
"self",
")",
":",
"try",
":",
"tbh",
"=",
"self",
".",
"frame",
".",
"f_locals",
"[",
"'__tracebackhide__'",
"]",
"except",
"KeyError",
":",
"try",
":",
"tbh",
"=",
"self",
".",
"frame",
".",
"f_globals",
"[",
"'__tracebackhide__'... | [
220,
4
] | [
240,
22
] | python | en | ['en', 'da', 'en'] | True |
Traceback.__init__ | (self, tb, excinfo=None) | initialize from given python traceback object and ExceptionInfo | initialize from given python traceback object and ExceptionInfo | def __init__(self, tb, excinfo=None):
""" initialize from given python traceback object and ExceptionInfo """
self._excinfo = excinfo
if hasattr(tb, 'tb_next'):
def f(cur):
while cur is not None:
yield self.Entry(cur, excinfo=excinfo)
... | [
"def",
"__init__",
"(",
"self",
",",
"tb",
",",
"excinfo",
"=",
"None",
")",
":",
"self",
".",
"_excinfo",
"=",
"excinfo",
"if",
"hasattr",
"(",
"tb",
",",
"'tb_next'",
")",
":",
"def",
"f",
"(",
"cur",
")",
":",
"while",
"cur",
"is",
"not",
"Non... | [
267,
4
] | [
277,
35
] | python | en | ['en', 'en', 'en'] | True |
Traceback.cut | (self, path=None, lineno=None, firstlineno=None, excludepath=None) | return a Traceback instance wrapping part of this Traceback
by provding any combination of path, lineno and firstlineno, the
first frame to start the to-be-returned traceback is determined
this allows cutting the first part of a Traceback instance e.g.
for formatting r... | return a Traceback instance wrapping part of this Traceback | def cut(self, path=None, lineno=None, firstlineno=None, excludepath=None):
""" return a Traceback instance wrapping part of this Traceback
by provding any combination of path, lineno and firstlineno, the
first frame to start the to-be-returned traceback is determined
this a... | [
"def",
"cut",
"(",
"self",
",",
"path",
"=",
"None",
",",
"lineno",
"=",
"None",
",",
"firstlineno",
"=",
"None",
",",
"excludepath",
"=",
"None",
")",
":",
"for",
"x",
"in",
"self",
":",
"code",
"=",
"x",
".",
"frame",
".",
"code",
"codepath",
"... | [
279,
4
] | [
298,
19
] | python | en | ['en', 'en', 'en'] | True |
Traceback.filter | (self, fn=lambda x: not x.ishidden()) | return a Traceback instance with certain items removed
fn is a function that gets a single argument, a TracebackEntry
instance, and should return True when the item should be added
to the Traceback, False when not
by default this removes all the TracebackEntries which ... | return a Traceback instance with certain items removed | def filter(self, fn=lambda x: not x.ishidden()):
""" return a Traceback instance with certain items removed
fn is a function that gets a single argument, a TracebackEntry
instance, and should return True when the item should be added
to the Traceback, False when not
... | [
"def",
"filter",
"(",
"self",
",",
"fn",
"=",
"lambda",
"x",
":",
"not",
"x",
".",
"ishidden",
"(",
")",
")",
":",
"return",
"Traceback",
"(",
"filter",
"(",
"fn",
",",
"self",
")",
",",
"self",
".",
"_excinfo",
")"
] | [
306,
4
] | [
316,
57
] | python | en | ['en', 'en', 'en'] | True |
Traceback.getcrashentry | (self) | return last non-hidden traceback entry that lead
to the exception of a traceback.
| return last non-hidden traceback entry that lead
to the exception of a traceback.
| def getcrashentry(self):
""" return last non-hidden traceback entry that lead
to the exception of a traceback.
"""
for i in range(-1, -len(self) - 1, -1):
entry = self[i]
if not entry.ishidden():
return entry
return self[-1] | [
"def",
"getcrashentry",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"-",
"1",
",",
"-",
"len",
"(",
"self",
")",
"-",
"1",
",",
"-",
"1",
")",
":",
"entry",
"=",
"self",
"[",
"i",
"]",
"if",
"not",
"entry",
".",
"ishidden",
"(",
... | [
318,
4
] | [
326,
23
] | python | en | ['en', 'en', 'en'] | True |
Traceback.recursionindex | (self) | return the index of the frame/TracebackEntry where recursion
originates if appropriate, None if no recursion occurred
| return the index of the frame/TracebackEntry where recursion
originates if appropriate, None if no recursion occurred
| def recursionindex(self):
""" return the index of the frame/TracebackEntry where recursion
originates if appropriate, None if no recursion occurred
"""
cache = {}
for i, entry in enumerate(self):
# id for the code.raw is needed to work around
# the str... | [
"def",
"recursionindex",
"(",
"self",
")",
":",
"cache",
"=",
"{",
"}",
"for",
"i",
",",
"entry",
"in",
"enumerate",
"(",
"self",
")",
":",
"# id for the code.raw is needed to work around",
"# the strange metaprogramming in the decorator lib from pypi",
"# which generates... | [
328,
4
] | [
350,
19
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.