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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
CaseInsensitiveUniqueTogetherValidator.process_field_name | (self, field_name) |
Right now, we presume that certain names are string-y, and can be
case-insensitive compared.
|
Right now, we presume that certain names are string-y, and can be
case-insensitive compared.
| def process_field_name(self, field_name):
"""
Right now, we presume that certain names are string-y, and can be
case-insensitive compared.
"""
if field_name == "name":
return "name__iexact"
return field_name | [
"def",
"process_field_name",
"(",
"self",
",",
"field_name",
")",
":",
"if",
"field_name",
"==",
"\"name\"",
":",
"return",
"\"name__iexact\"",
"return",
"field_name"
] | [
7,
4
] | [
14,
25
] | python | en | ['en', 'error', 'th'] | False |
CaseInsensitiveUniqueTogetherValidator.filter_queryset | (self, attrs, queryset, serializer) |
Filter the queryset to all instances matching the given attributes.
|
Filter the queryset to all instances matching the given attributes.
| def filter_queryset(self, attrs, queryset, serializer):
"""
Filter the queryset to all instances matching the given attributes.
"""
# This is a modified version of `UniqueTogetherValidator.filter_queryset`,
# modifed to preprocess field names for case-insensitive matching.
... | [
"def",
"filter_queryset",
"(",
"self",
",",
"attrs",
",",
"queryset",
",",
"serializer",
")",
":",
"# This is a modified version of `UniqueTogetherValidator.filter_queryset`,",
"# modifed to preprocess field names for case-insensitive matching.",
"# It also handles filtering on soft-dele... | [
16,
4
] | [
40,
51
] | python | en | ['en', 'error', 'th'] | False |
BaseValidator.validate | (self, runnable) |
Точка входа работы валидатора.
Результат валидации должен быть записан в runnable.result
|
Точка входа работы валидатора. | def validate(self, runnable):
"""
Точка входа работы валидатора.
Результат валидации должен быть записан в runnable.result
""" | [
"def",
"validate",
"(",
"self",
",",
"runnable",
")",
":"
] | [
8,
4
] | [
13,
11
] | python | en | ['en', 'error', 'th'] | False |
voxel_env_override_defaults | (env, parser) | RL params specific to VoxelEnv envs. | RL params specific to VoxelEnv envs. | def voxel_env_override_defaults(env, parser):
"""RL params specific to VoxelEnv envs."""
parser.set_defaults(
encoder_type='conv',
encoder_subtype='convnet_simple',
hidden_size=512,
obs_subtract_mean=0.0,
obs_scale=255.0,
actor_worker_gpus=[0],
exploration... | [
"def",
"voxel_env_override_defaults",
"(",
"env",
",",
"parser",
")",
":",
"parser",
".",
"set_defaults",
"(",
"encoder_type",
"=",
"'conv'",
",",
"encoder_subtype",
"=",
"'convnet_simple'",
",",
"hidden_size",
"=",
"512",
",",
"obs_subtract_mean",
"=",
"0.0",
"... | [
96,
0
] | [
107,
5
] | python | en | ['en', 'en', 'pt'] | True |
_splitnode | (nodeid) | Split a nodeid into constituent 'parts'.
Node IDs are strings, and can be things like:
''
'testing/code'
'testing/code/test_excinfo.py'
'testing/code/test_excinfo.py::TestFormattedExcinfo::()'
Return values are lists e.g.
[]
['testing', 'code']
['testing... | Split a nodeid into constituent 'parts'. | def _splitnode(nodeid):
"""Split a nodeid into constituent 'parts'.
Node IDs are strings, and can be things like:
''
'testing/code'
'testing/code/test_excinfo.py'
'testing/code/test_excinfo.py::TestFormattedExcinfo::()'
Return values are lists e.g.
[]
['test... | [
"def",
"_splitnode",
"(",
"nodeid",
")",
":",
"if",
"nodeid",
"==",
"''",
":",
"# If there is no root node at all, return an empty list so the caller's logic can remain sane",
"return",
"[",
"]",
"parts",
"=",
"nodeid",
".",
"split",
"(",
"SEP",
")",
"# Replace single l... | [
16,
0
] | [
37,
16
] | python | en | ['it', 'fr', 'en'] | False |
ischildnode | (baseid, nodeid) | Return True if the nodeid is a child node of the baseid.
E.g. 'foo/bar::Baz::()' is a child of 'foo', 'foo/bar' and 'foo/bar::Baz', but not of 'foo/blorp'
| Return True if the nodeid is a child node of the baseid. | def ischildnode(baseid, nodeid):
"""Return True if the nodeid is a child node of the baseid.
E.g. 'foo/bar::Baz::()' is a child of 'foo', 'foo/bar' and 'foo/bar::Baz', but not of 'foo/blorp'
"""
base_parts = _splitnode(baseid)
node_parts = _splitnode(nodeid)
if len(node_parts) < len(base_parts)... | [
"def",
"ischildnode",
"(",
"baseid",
",",
"nodeid",
")",
":",
"base_parts",
"=",
"_splitnode",
"(",
"baseid",
")",
"node_parts",
"=",
"_splitnode",
"(",
"nodeid",
")",
"if",
"len",
"(",
"node_parts",
")",
"<",
"len",
"(",
"base_parts",
")",
":",
"return"... | [
40,
0
] | [
49,
53
] | python | en | ['en', 'en', 'en'] | True |
Node.ihook | (self) | fspath sensitive hook proxy used to call pytest hooks | fspath sensitive hook proxy used to call pytest hooks | def ihook(self):
""" fspath sensitive hook proxy used to call pytest hooks"""
return self.session.gethookproxy(self.fspath) | [
"def",
"ihook",
"(",
"self",
")",
":",
"return",
"self",
".",
"session",
".",
"gethookproxy",
"(",
"self",
".",
"fspath",
")"
] | [
134,
4
] | [
136,
53
] | python | en | ['en', 'haw', 'en'] | True |
Node.warn | (self, code, message) | generate a warning with the given code and message for this
item. | generate a warning with the given code and message for this
item. | def warn(self, code, message):
""" generate a warning with the given code and message for this
item. """
assert isinstance(code, str)
fslocation = getattr(self, "location", None)
if fslocation is None:
fslocation = getattr(self, "fspath", None)
self.ihook.pyte... | [
"def",
"warn",
"(",
"self",
",",
"code",
",",
"message",
")",
":",
"assert",
"isinstance",
"(",
"code",
",",
"str",
")",
"fslocation",
"=",
"getattr",
"(",
"self",
",",
"\"location\"",
",",
"None",
")",
"if",
"fslocation",
"is",
"None",
":",
"fslocatio... | [
161,
4
] | [
170,
55
] | python | en | ['en', 'en', 'en'] | True |
Node.nodeid | (self) | a ::-separated string denoting its collection tree address. | a ::-separated string denoting its collection tree address. | def nodeid(self):
""" a ::-separated string denoting its collection tree address. """
try:
return self._nodeid
except AttributeError:
self._nodeid = x = self._makeid()
return x | [
"def",
"nodeid",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_nodeid",
"except",
"AttributeError",
":",
"self",
".",
"_nodeid",
"=",
"x",
"=",
"self",
".",
"_makeid",
"(",
")",
"return",
"x"
] | [
174,
4
] | [
180,
20
] | python | en | ['en', 'en', 'en'] | True |
Node.listchain | (self) | return list of all parent collectors up to self,
starting from root of collection tree. | return list of all parent collectors up to self,
starting from root of collection tree. | def listchain(self):
""" return list of all parent collectors up to self,
starting from root of collection tree. """
chain = []
item = self
while item is not None:
chain.append(item)
item = item.parent
chain.reverse()
return chain | [
"def",
"listchain",
"(",
"self",
")",
":",
"chain",
"=",
"[",
"]",
"item",
"=",
"self",
"while",
"item",
"is",
"not",
"None",
":",
"chain",
".",
"append",
"(",
"item",
")",
"item",
"=",
"item",
".",
"parent",
"chain",
".",
"reverse",
"(",
")",
"r... | [
194,
4
] | [
203,
20
] | python | en | ['en', 'en', 'en'] | True |
Node.add_marker | (self, marker) | dynamically add a marker object to the node.
``marker`` can be a string or pytest.mark.* instance.
| dynamically add a marker object to the node. | def add_marker(self, marker):
""" dynamically add a marker object to the node.
``marker`` can be a string or pytest.mark.* instance.
"""
from _pytest.mark import MarkDecorator, MARK_GEN
if isinstance(marker, six.string_types):
marker = getattr(MARK_GEN, marker)
... | [
"def",
"add_marker",
"(",
"self",
",",
"marker",
")",
":",
"from",
"_pytest",
".",
"mark",
"import",
"MarkDecorator",
",",
"MARK_GEN",
"if",
"isinstance",
"(",
"marker",
",",
"six",
".",
"string_types",
")",
":",
"marker",
"=",
"getattr",
"(",
"MARK_GEN",
... | [
205,
4
] | [
215,
43
] | python | en | ['en', 'en', 'en'] | True |
Node.get_marker | (self, name) | get a marker object from this node or None if
the node doesn't have a marker with that name. | get a marker object from this node or None if
the node doesn't have a marker with that name. | def get_marker(self, name):
""" get a marker object from this node or None if
the node doesn't have a marker with that name. """
val = self.keywords.get(name, None)
if val is not None:
from _pytest.mark import MarkInfo, MarkDecorator
if isinstance(val, (MarkDecora... | [
"def",
"get_marker",
"(",
"self",
",",
"name",
")",
":",
"val",
"=",
"self",
".",
"keywords",
".",
"get",
"(",
"name",
",",
"None",
")",
"if",
"val",
"is",
"not",
"None",
":",
"from",
"_pytest",
".",
"mark",
"import",
"MarkInfo",
",",
"MarkDecorator"... | [
217,
4
] | [
224,
26
] | python | en | ['en', 'en', 'en'] | True |
Node.listextrakeywords | (self) | Return a set of all extra keywords in self and any parents. | Return a set of all extra keywords in self and any parents. | def listextrakeywords(self):
""" Return a set of all extra keywords in self and any parents."""
extra_keywords = set()
item = self
for item in self.listchain():
extra_keywords.update(item.extra_keyword_matches)
return extra_keywords | [
"def",
"listextrakeywords",
"(",
"self",
")",
":",
"extra_keywords",
"=",
"set",
"(",
")",
"item",
"=",
"self",
"for",
"item",
"in",
"self",
".",
"listchain",
"(",
")",
":",
"extra_keywords",
".",
"update",
"(",
"item",
".",
"extra_keyword_matches",
")",
... | [
226,
4
] | [
232,
29
] | python | en | ['en', 'en', 'en'] | True |
Node.addfinalizer | (self, fin) | register a function to be called when this node is finalized.
This method can only be called when this node is active
in a setup chain, for example during self.setup().
| register a function to be called when this node is finalized. | def addfinalizer(self, fin):
""" register a function to be called when this node is finalized.
This method can only be called when this node is active
in a setup chain, for example during self.setup().
"""
self.session._setupstate.addfinalizer(fin, self) | [
"def",
"addfinalizer",
"(",
"self",
",",
"fin",
")",
":",
"self",
".",
"session",
".",
"_setupstate",
".",
"addfinalizer",
"(",
"fin",
",",
"self",
")"
] | [
237,
4
] | [
243,
56
] | python | en | ['en', 'en', 'en'] | True |
Node.getparent | (self, cls) | get the next parent node (including ourself)
which is an instance of the given class | get the next parent node (including ourself)
which is an instance of the given class | def getparent(self, cls):
""" get the next parent node (including ourself)
which is an instance of the given class"""
current = self
while current and not isinstance(current, cls):
current = current.parent
return current | [
"def",
"getparent",
"(",
"self",
",",
"cls",
")",
":",
"current",
"=",
"self",
"while",
"current",
"and",
"not",
"isinstance",
"(",
"current",
",",
"cls",
")",
":",
"current",
"=",
"current",
".",
"parent",
"return",
"current"
] | [
245,
4
] | [
251,
22
] | python | en | ['en', 'pt', 'en'] | True |
Collector.collect | (self) | returns a list of children (items and collectors)
for this collection node.
| returns a list of children (items and collectors)
for this collection node.
| def collect(self):
""" returns a list of children (items and collectors)
for this collection node.
"""
raise NotImplementedError("abstract") | [
"def",
"collect",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"abstract\"",
")"
] | [
299,
4
] | [
303,
45
] | python | en | ['en', 'en', 'en'] | True |
Collector.repr_failure | (self, excinfo) | represent a collection failure. | represent a collection failure. | def repr_failure(self, excinfo):
""" represent a collection failure. """
if excinfo.errisinstance(self.CollectError):
exc = excinfo.value
return str(exc.args[0])
return self._repr_failure_py(excinfo, style="short") | [
"def",
"repr_failure",
"(",
"self",
",",
"excinfo",
")",
":",
"if",
"excinfo",
".",
"errisinstance",
"(",
"self",
".",
"CollectError",
")",
":",
"exc",
"=",
"excinfo",
".",
"value",
"return",
"str",
"(",
"exc",
".",
"args",
"[",
"0",
"]",
")",
"retur... | [
305,
4
] | [
310,
60
] | python | en | ['fr', 'gl', 'en'] | False |
Item.add_report_section | (self, when, key, content) |
Adds a new report section, similar to what's done internally to add stdout and
stderr captured output::
item.add_report_section("call", "stdout", "report section contents")
:param str when:
One of the possible capture states, ``"setup"``, ``"call"``, ``"teardown"``.
... |
Adds a new report section, similar to what's done internally to add stdout and
stderr captured output:: | def add_report_section(self, when, key, content):
"""
Adds a new report section, similar to what's done internally to add stdout and
stderr captured output::
item.add_report_section("call", "stdout", "report section contents")
:param str when:
One of the possibl... | [
"def",
"add_report_section",
"(",
"self",
",",
"when",
",",
"key",
",",
"content",
")",
":",
"if",
"content",
":",
"self",
".",
"_report_sections",
".",
"append",
"(",
"(",
"when",
",",
"key",
",",
"content",
")",
")"
] | [
362,
4
] | [
379,
62
] | python | en | ['en', 'error', 'th'] | False |
filesys_decode | (path) |
Ensure that the given path is decoded,
NONE when no expected encoding works
|
Ensure that the given path is decoded,
NONE when no expected encoding works
| def filesys_decode(path):
"""
Ensure that the given path is decoded,
NONE when no expected encoding works
"""
if isinstance(path, str):
return path
fs_enc = sys.getfilesystemencoding() or 'utf-8'
candidates = fs_enc, 'utf-8'
for enc in candidates:
try:
retu... | [
"def",
"filesys_decode",
"(",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"return",
"path",
"fs_enc",
"=",
"sys",
".",
"getfilesystemencoding",
"(",
")",
"or",
"'utf-8'",
"candidates",
"=",
"fs_enc",
",",
"'utf-8'",
"for",
"e... | [
17,
0
] | [
33,
20
] | python | en | ['en', 'error', 'th'] | False |
try_encode | (string, enc) | turn unicode encoding into a functional routine | turn unicode encoding into a functional routine | def try_encode(string, enc):
"turn unicode encoding into a functional routine"
try:
return string.encode(enc)
except UnicodeEncodeError:
return None | [
"def",
"try_encode",
"(",
"string",
",",
"enc",
")",
":",
"try",
":",
"return",
"string",
".",
"encode",
"(",
"enc",
")",
"except",
"UnicodeEncodeError",
":",
"return",
"None"
] | [
36,
0
] | [
41,
19
] | python | en | ['en', 'en', 'en'] | True |
_strcoll | (a,b) | strcoll(string,string) -> int.
Compares two strings according to the locale.
| strcoll(string,string) -> int.
Compares two strings according to the locale.
| def _strcoll(a,b):
""" strcoll(string,string) -> int.
Compares two strings according to the locale.
"""
return (a > b) - (a < b) | [
"def",
"_strcoll",
"(",
"a",
",",
"b",
")",
":",
"return",
"(",
"a",
">",
"b",
")",
"-",
"(",
"a",
"<",
"b",
")"
] | [
32,
0
] | [
36,
28
] | python | en | ['en', 'kk', 'it'] | False |
_strxfrm | (s) | strxfrm(string) -> string.
Returns a string that behaves for cmp locale-aware.
| strxfrm(string) -> string.
Returns a string that behaves for cmp locale-aware.
| def _strxfrm(s):
""" strxfrm(string) -> string.
Returns a string that behaves for cmp locale-aware.
"""
return s | [
"def",
"_strxfrm",
"(",
"s",
")",
":",
"return",
"s"
] | [
38,
0
] | [
42,
12
] | python | en | ['en', 'kk', 'it'] | False |
format | (percent, value, grouping=False, monetary=False, *additional) | Returns the locale-aware substitution of a %? specifier
(percent).
additional is for format strings which contain one or more
'*' modifiers. | Returns the locale-aware substitution of a %? specifier
(percent). | def format(percent, value, grouping=False, monetary=False, *additional):
"""Returns the locale-aware substitution of a %? specifier
(percent).
additional is for format strings which contain one or more
'*' modifiers."""
# this is only for one-percent-specifier strings and this should be checked
... | [
"def",
"format",
"(",
"percent",
",",
"value",
",",
"grouping",
"=",
"False",
",",
"monetary",
"=",
"False",
",",
"*",
"additional",
")",
":",
"# this is only for one-percent-specifier strings and this should be checked",
"match",
"=",
"_percent_re",
".",
"match",
"... | [
182,
0
] | [
193,
67
] | python | en | ['en', 'en', 'en'] | True |
format_string | (f, val, grouping=False) | Formats a string in the same way that the % formatting would use,
but takes the current locale into account.
Grouping is applied if the third parameter is true. | Formats a string in the same way that the % formatting would use,
but takes the current locale into account.
Grouping is applied if the third parameter is true. | def format_string(f, val, grouping=False):
"""Formats a string in the same way that the % formatting would use,
but takes the current locale into account.
Grouping is applied if the third parameter is true."""
percents = list(_percent_re.finditer(f))
new_f = _percent_re.sub('%s', f)
if isinstan... | [
"def",
"format_string",
"(",
"f",
",",
"val",
",",
"grouping",
"=",
"False",
")",
":",
"percents",
"=",
"list",
"(",
"_percent_re",
".",
"finditer",
"(",
"f",
")",
")",
"new_f",
"=",
"_percent_re",
".",
"sub",
"(",
"'%s'",
",",
"f",
")",
"if",
"isi... | [
219,
0
] | [
251,
22
] | python | en | ['en', 'en', 'en'] | True |
currency | (val, symbol=True, grouping=False, international=False) | Formats val according to the currency settings
in the current locale. | Formats val according to the currency settings
in the current locale. | def currency(val, symbol=True, grouping=False, international=False):
"""Formats val according to the currency settings
in the current locale."""
conv = localeconv()
# check for illegal values
digits = conv[international and 'int_frac_digits' or 'frac_digits']
if digits == 127:
raise Val... | [
"def",
"currency",
"(",
"val",
",",
"symbol",
"=",
"True",
",",
"grouping",
"=",
"False",
",",
"international",
"=",
"False",
")",
":",
"conv",
"=",
"localeconv",
"(",
")",
"# check for illegal values",
"digits",
"=",
"conv",
"[",
"international",
"and",
"... | [
253,
0
] | [
296,
46
] | python | en | ['en', 'en', 'en'] | True |
str | (val) | Convert float to string, taking the locale into account. | Convert float to string, taking the locale into account. | def str(val):
"""Convert float to string, taking the locale into account."""
return format("%.12g", val) | [
"def",
"str",
"(",
"val",
")",
":",
"return",
"format",
"(",
"\"%.12g\"",
",",
"val",
")"
] | [
298,
0
] | [
300,
31
] | python | en | ['en', 'en', 'en'] | True |
delocalize | (string) | Parses a string as a normalized number according to the locale settings. | Parses a string as a normalized number according to the locale settings. | def delocalize(string):
"Parses a string as a normalized number according to the locale settings."
conv = localeconv()
#First, get rid of the grouping
ts = conv['thousands_sep']
if ts:
string = string.replace(ts, '')
#next, replace the decimal point with a dot
dd = conv['decimal_p... | [
"def",
"delocalize",
"(",
"string",
")",
":",
"conv",
"=",
"localeconv",
"(",
")",
"#First, get rid of the grouping",
"ts",
"=",
"conv",
"[",
"'thousands_sep'",
"]",
"if",
"ts",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"ts",
",",
"''",
")",
"#n... | [
302,
0
] | [
316,
17
] | python | en | ['en', 'en', 'en'] | True |
atof | (string, func=float) | Parses a string as a float according to the locale settings. | Parses a string as a float according to the locale settings. | def atof(string, func=float):
"Parses a string as a float according to the locale settings."
return func(delocalize(string)) | [
"def",
"atof",
"(",
"string",
",",
"func",
"=",
"float",
")",
":",
"return",
"func",
"(",
"delocalize",
"(",
"string",
")",
")"
] | [
318,
0
] | [
320,
35
] | python | en | ['en', 'en', 'en'] | True |
atoi | (string) | Converts a string to an integer according to the locale settings. | Converts a string to an integer according to the locale settings. | def atoi(string):
"Converts a string to an integer according to the locale settings."
return int(delocalize(string)) | [
"def",
"atoi",
"(",
"string",
")",
":",
"return",
"int",
"(",
"delocalize",
"(",
"string",
")",
")"
] | [
322,
0
] | [
324,
34
] | python | en | ['en', 'en', 'en'] | True |
normalize | (localename) | Returns a normalized locale code for the given locale
name.
The returned locale code is formatted for use with
setlocale().
If normalization fails, the original name is returned
unchanged.
If the given encoding is not known, the function defaults to
the defaul... | Returns a normalized locale code for the given locale
name. | def normalize(localename):
""" Returns a normalized locale code for the given locale
name.
The returned locale code is formatted for use with
setlocale().
If normalization fails, the original name is returned
unchanged.
If the given encoding is not known, the func... | [
"def",
"normalize",
"(",
"localename",
")",
":",
"# Normalize the locale name and extract the encoding and modifier",
"code",
"=",
"localename",
".",
"lower",
"(",
")",
"if",
"':'",
"in",
"code",
":",
"# ':' is sometimes used as encoding delimiter.",
"code",
"=",
"code",
... | [
378,
0
] | [
459,
21
] | python | en | ['en', 'en', 'en'] | True |
_parse_localename | (localename) | Parses the locale code for localename and returns the
result as tuple (language code, encoding).
The localename is normalized and passed through the locale
alias engine. A ValueError is raised in case the locale name
cannot be parsed.
The language code corresponds to RFC 1766.... | Parses the locale code for localename and returns the
result as tuple (language code, encoding). | def _parse_localename(localename):
""" Parses the locale code for localename and returns the
result as tuple (language code, encoding).
The localename is normalized and passed through the locale
alias engine. A ValueError is raised in case the locale name
cannot be parsed.
... | [
"def",
"_parse_localename",
"(",
"localename",
")",
":",
"code",
"=",
"normalize",
"(",
"localename",
")",
"if",
"'@'",
"in",
"code",
":",
"# Deal with locale modifiers",
"code",
",",
"modifier",
"=",
"code",
".",
"split",
"(",
"'@'",
",",
"1",
")",
"if",
... | [
461,
0
] | [
489,
55
] | python | en | ['en', 'en', 'en'] | True |
_build_localename | (localetuple) | Builds a locale code from the given tuple (language code,
encoding).
No aliasing or normalizing takes place.
| Builds a locale code from the given tuple (language code,
encoding). | def _build_localename(localetuple):
""" Builds a locale code from the given tuple (language code,
encoding).
No aliasing or normalizing takes place.
"""
try:
language, encoding = localetuple
if language is None:
language = 'C'
if encoding is None:
... | [
"def",
"_build_localename",
"(",
"localetuple",
")",
":",
"try",
":",
"language",
",",
"encoding",
"=",
"localetuple",
"if",
"language",
"is",
"None",
":",
"language",
"=",
"'C'",
"if",
"encoding",
"is",
"None",
":",
"return",
"language",
"else",
":",
"ret... | [
491,
0
] | [
509,
115
] | python | en | ['en', 'en', 'en'] | True |
getdefaultlocale | (envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')) | Tries to determine the default locale settings and returns
them as tuple (language code, encoding).
According to POSIX, a program which has not called
setlocale(LC_ALL, "") runs using the portable 'C' locale.
Calling setlocale(LC_ALL, "") lets it use the default locale as
defin... | Tries to determine the default locale settings and returns
them as tuple (language code, encoding). | def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
""" Tries to determine the default locale settings and returns
them as tuple (language code, encoding).
According to POSIX, a program which has not called
setlocale(LC_ALL, "") runs using the portable 'C' locale.
... | [
"def",
"getdefaultlocale",
"(",
"envvars",
"=",
"(",
"'LC_ALL'",
",",
"'LC_CTYPE'",
",",
"'LANG'",
",",
"'LANGUAGE'",
")",
")",
":",
"try",
":",
"# check if it's supported by the _locale module",
"import",
"_locale",
"code",
",",
"encoding",
"=",
"_locale",
".",
... | [
511,
0
] | [
561,
40
] | python | en | ['en', 'en', 'en'] | True |
getlocale | (category=LC_CTYPE) | Returns the current setting for the given locale category as
tuple (language code, encoding).
category may be one of the LC_* value except LC_ALL. It
defaults to LC_CTYPE.
Except for the code 'C', the language code corresponds to RFC
1766. code and encoding can be None in cas... | Returns the current setting for the given locale category as
tuple (language code, encoding). | def getlocale(category=LC_CTYPE):
""" Returns the current setting for the given locale category as
tuple (language code, encoding).
category may be one of the LC_* value except LC_ALL. It
defaults to LC_CTYPE.
Except for the code 'C', the language code corresponds to RFC
1... | [
"def",
"getlocale",
"(",
"category",
"=",
"LC_CTYPE",
")",
":",
"localename",
"=",
"_setlocale",
"(",
"category",
")",
"if",
"category",
"==",
"LC_ALL",
"and",
"';'",
"in",
"localename",
":",
"raise",
"TypeError",
"(",
"'category LC_ALL is not supported'",
")",
... | [
564,
0
] | [
580,
40
] | python | en | ['en', 'en', 'en'] | True |
setlocale | (category, locale=None) | Set the locale for the given category. The locale can be
a string, an iterable of two strings (language code and encoding),
or None.
Iterables are converted to strings using the locale aliasing
engine. Locale strings are passed directly to the C lib.
category may be given as... | Set the locale for the given category. The locale can be
a string, an iterable of two strings (language code and encoding),
or None. | def setlocale(category, locale=None):
""" Set the locale for the given category. The locale can be
a string, an iterable of two strings (language code and encoding),
or None.
Iterables are converted to strings using the locale aliasing
engine. Locale strings are passed directly t... | [
"def",
"setlocale",
"(",
"category",
",",
"locale",
"=",
"None",
")",
":",
"if",
"locale",
"and",
"not",
"isinstance",
"(",
"locale",
",",
"_builtin_str",
")",
":",
"# convert to string",
"locale",
"=",
"normalize",
"(",
"_build_localename",
"(",
"locale",
"... | [
582,
0
] | [
597,
39
] | python | en | ['en', 'en', 'en'] | True |
resetlocale | (category=LC_ALL) | Sets the locale for category to the default setting.
The default setting is determined by calling
getdefaultlocale(). category defaults to LC_ALL.
| Sets the locale for category to the default setting. | def resetlocale(category=LC_ALL):
""" Sets the locale for category to the default setting.
The default setting is determined by calling
getdefaultlocale(). category defaults to LC_ALL.
"""
_setlocale(category, _build_localename(getdefaultlocale())) | [
"def",
"resetlocale",
"(",
"category",
"=",
"LC_ALL",
")",
":",
"_setlocale",
"(",
"category",
",",
"_build_localename",
"(",
"getdefaultlocale",
"(",
")",
")",
")"
] | [
599,
0
] | [
607,
63
] | python | en | ['en', 'en', 'en'] | True |
_print_locale | () | Test function.
| Test function.
| def _print_locale():
""" Test function.
"""
categories = {}
def _init_categories(categories=categories):
for k,v in globals().items():
if k[:3] == 'LC_':
categories[k] = v
_init_categories()
del categories['LC_ALL']
print('Locale defaults as determined b... | [
"def",
"_print_locale",
"(",
")",
":",
"categories",
"=",
"{",
"}",
"def",
"_init_categories",
"(",
"categories",
"=",
"categories",
")",
":",
"for",
"k",
",",
"v",
"in",
"globals",
"(",
")",
".",
"items",
"(",
")",
":",
"if",
"k",
"[",
":",
"3",
... | [
1658,
0
] | [
1712,
19
] | python | en | ['en', 'en', 'en'] | False |
SolverState.concretizeExp | (self, f, pathenv) |
Expression concretization.
|
Expression concretization.
| def concretizeExp(self, f, pathenv):
"""
Expression concretization.
"""
f = fast.AST.fexpr_cast(f)
# Get transitive closure of variables mentioned in both the labels and
# the policies.
# TODO: Make this more efficient.
vars_needed = f.vars()
for ... | [
"def",
"concretizeExp",
"(",
"self",
",",
"f",
",",
"pathenv",
")",
":",
"f",
"=",
"fast",
".",
"AST",
".",
"fexpr_cast",
"(",
"f",
")",
"# Get transitive closure of variables mentioned in both the labels and",
"# the policies.",
"# TODO: Make this more efficient.",
"va... | [
83,
4
] | [
134,
34
] | python | en | ['en', 'error', 'th'] | False |
property_name | (property: str, index: int) | The Freshdesk API is currently pretty broken: statuses are customizable
but the API will only tell you the number associated with the status, not
the name. While we engage the Freshdesk developers about exposing this
information through the API, since only FlightCar uses this integration,
hardcode their... | The Freshdesk API is currently pretty broken: statuses are customizable
but the API will only tell you the number associated with the status, not
the name. While we engage the Freshdesk developers about exposing this
information through the API, since only FlightCar uses this integration,
hardcode their... | def property_name(property: str, index: int) -> str:
"""The Freshdesk API is currently pretty broken: statuses are customizable
but the API will only tell you the number associated with the status, not
the name. While we engage the Freshdesk developers about exposing this
information through the API, si... | [
"def",
"property_name",
"(",
"property",
":",
"str",
",",
"index",
":",
"int",
")",
"->",
"str",
":",
"statuses",
"=",
"[",
"\"\"",
",",
"\"\"",
",",
"\"Open\"",
",",
"\"Pending\"",
",",
"\"Resolved\"",
",",
"\"Closed\"",
",",
"\"Waiting on Customer\"",
",... | [
44,
0
] | [
70,
15
] | python | en | ['en', 'en', 'en'] | True |
parse_freshdesk_event | (event_string: str) | These are always of the form "{ticket_action:created}" or
"{status:{from:4,to:6}}". Note the lack of string quoting: this isn't
valid JSON so we have to parse it ourselves.
| These are always of the form "{ticket_action:created}" or
"{status:{from:4,to:6}}". Note the lack of string quoting: this isn't
valid JSON so we have to parse it ourselves.
| def parse_freshdesk_event(event_string: str) -> List[str]:
"""These are always of the form "{ticket_action:created}" or
"{status:{from:4,to:6}}". Note the lack of string quoting: this isn't
valid JSON so we have to parse it ourselves.
"""
data = event_string.replace("{", "").replace("}", "").replace... | [
"def",
"parse_freshdesk_event",
"(",
"event_string",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"data",
"=",
"event_string",
".",
"replace",
"(",
"\"{\"",
",",
"\"\"",
")",
".",
"replace",
"(",
"\"}\"",
",",
"\"\"",
")",
".",
"replace",
"(",
... | [
73,
0
] | [
92,
9
] | python | en | ['en', 'en', 'en'] | True |
format_freshdesk_note_message | (ticket: TicketDict, event_info: List[str]) | There are public (visible to customers) and private note types. | There are public (visible to customers) and private note types. | def format_freshdesk_note_message(ticket: TicketDict, event_info: List[str]) -> str:
"""There are public (visible to customers) and private note types."""
note_type = event_info[1]
content = NOTE_TEMPLATE.format(
name=ticket.requester_name,
email=ticket.requester_email,
note_type=not... | [
"def",
"format_freshdesk_note_message",
"(",
"ticket",
":",
"TicketDict",
",",
"event_info",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"note_type",
"=",
"event_info",
"[",
"1",
"]",
"content",
"=",
"NOTE_TEMPLATE",
".",
"format",
"(",
"name",
"=... | [
95,
0
] | [
106,
18
] | python | en | ['en', 'en', 'en'] | True |
format_freshdesk_property_change_message | (ticket: TicketDict, event_info: List[str]) | Freshdesk will only tell us the first event to match our webhook
configuration, so if we change multiple properties, we only get the before
and after data for the first one.
| Freshdesk will only tell us the first event to match our webhook
configuration, so if we change multiple properties, we only get the before
and after data for the first one.
| def format_freshdesk_property_change_message(ticket: TicketDict, event_info: List[str]) -> str:
"""Freshdesk will only tell us the first event to match our webhook
configuration, so if we change multiple properties, we only get the before
and after data for the first one.
"""
content = PROPERTY_CHAN... | [
"def",
"format_freshdesk_property_change_message",
"(",
"ticket",
":",
"TicketDict",
",",
"event_info",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"content",
"=",
"PROPERTY_CHANGE_TEMPLATE",
".",
"format",
"(",
"name",
"=",
"ticket",
".",
"requester_na... | [
109,
0
] | [
124,
18
] | python | en | ['en', 'en', 'en'] | True |
format_freshdesk_ticket_creation_message | (ticket: TicketDict) | They send us the description as HTML. | They send us the description as HTML. | def format_freshdesk_ticket_creation_message(ticket: TicketDict) -> str:
"""They send us the description as HTML."""
cleaned_description = convert_html_to_markdown(ticket.description)
content = TICKET_CREATION_TEMPLATE.format(
name=ticket.requester_name,
email=ticket.requester_email,
... | [
"def",
"format_freshdesk_ticket_creation_message",
"(",
"ticket",
":",
"TicketDict",
")",
"->",
"str",
":",
"cleaned_description",
"=",
"convert_html_to_markdown",
"(",
"ticket",
".",
"description",
")",
"content",
"=",
"TICKET_CREATION_TEMPLATE",
".",
"format",
"(",
... | [
127,
0
] | [
141,
18
] | python | en | ['en', 'en', 'en'] | True |
merge_setting | (request_setting, session_setting, dict_class=OrderedDict) | Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
| Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
| def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
"""Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
"""
... | [
"def",
"merge_setting",
"(",
"request_setting",
",",
"session_setting",
",",
"dict_class",
"=",
"OrderedDict",
")",
":",
"if",
"session_setting",
"is",
"None",
":",
"return",
"request_setting",
"if",
"request_setting",
"is",
"None",
":",
"return",
"session_setting",... | [
49,
0
] | [
77,
25
] | python | en | ['en', 'en', 'en'] | True |
merge_hooks | (request_hooks, session_hooks, dict_class=OrderedDict) | Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
| Properly merges both requests and session hooks. | def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
"""Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
"""
if session_hooks is None or session_hooks.get('response') == []:
... | [
"def",
"merge_hooks",
"(",
"request_hooks",
",",
"session_hooks",
",",
"dict_class",
"=",
"OrderedDict",
")",
":",
"if",
"session_hooks",
"is",
"None",
"or",
"session_hooks",
".",
"get",
"(",
"'response'",
")",
"==",
"[",
"]",
":",
"return",
"request_hooks",
... | [
80,
0
] | [
92,
66
] | python | en | ['en', 'en', 'en'] | True |
session | () |
Returns a :class:`Session` for context-management.
.. deprecated:: 1.0.0
This method has been deprecated since version 1.0.0 and is only kept for
backwards compatibility. New code should use :class:`~requests.sessions.Session`
to create a session. This may be removed at a future date.... |
Returns a :class:`Session` for context-management. | def session():
"""
Returns a :class:`Session` for context-management.
.. deprecated:: 1.0.0
This method has been deprecated since version 1.0.0 and is only kept for
backwards compatibility. New code should use :class:`~requests.sessions.Session`
to create a session. This may be rem... | [
"def",
"session",
"(",
")",
":",
"return",
"Session",
"(",
")"
] | [
756,
0
] | [
768,
20
] | python | en | ['en', 'error', 'th'] | False |
SessionRedirectMixin.get_redirect_target | (self, resp) | Receives a Response. Returns a redirect URI or ``None`` | Receives a Response. Returns a redirect URI or ``None`` | def get_redirect_target(self, resp):
"""Receives a Response. Returns a redirect URI or ``None``"""
# Due to the nature of how requests processes redirects this method will
# be called at least once upon the original response and at least twice
# on each subsequent redirect response (if a... | [
"def",
"get_redirect_target",
"(",
"self",
",",
"resp",
")",
":",
"# Due to the nature of how requests processes redirects this method will",
"# be called at least once upon the original response and at least twice",
"# on each subsequent redirect response (if any).",
"# If a custom mixin is u... | [
97,
4
] | [
116,
19
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.should_strip_auth | (self, old_url, new_url) | Decide whether Authorization header should be removed when redirecting | Decide whether Authorization header should be removed when redirecting | def should_strip_auth(self, old_url, new_url):
"""Decide whether Authorization header should be removed when redirecting"""
old_parsed = urlparse(old_url)
new_parsed = urlparse(new_url)
if old_parsed.hostname != new_parsed.hostname:
return True
# Special case: allow h... | [
"def",
"should_strip_auth",
"(",
"self",
",",
"old_url",
",",
"new_url",
")",
":",
"old_parsed",
"=",
"urlparse",
"(",
"old_url",
")",
"new_parsed",
"=",
"urlparse",
"(",
"new_url",
")",
"if",
"old_parsed",
".",
"hostname",
"!=",
"new_parsed",
".",
"hostname... | [
118,
4
] | [
141,
45
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.resolve_redirects | (self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs) | Receives a Response. Returns a generator of Responses or Requests. | Receives a Response. Returns a generator of Responses or Requests. | def resolve_redirects(self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):
"""Receives a Response. Returns a generator of Responses or Requests."""
hist = [] # keep track of history
url = self.get... | [
"def",
"resolve_redirects",
"(",
"self",
",",
"resp",
",",
"req",
",",
"stream",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"verify",
"=",
"True",
",",
"cert",
"=",
"None",
",",
"proxies",
"=",
"None",
",",
"yield_requests",
"=",
"False",
",",
"... | [
143,
4
] | [
251,
26
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_auth | (self, prepared_request, response) | When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
| When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
| def rebuild_auth(self, prepared_request, response):
"""When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
"""
headers = pr... | [
"def",
"rebuild_auth",
"(",
"self",
",",
"prepared_request",
",",
"response",
")",
":",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
".",
"url",
"if",
"'Authorization'",
"in",
"headers",
"and",
"self",
".",
"should_strip_au... | [
253,
4
] | [
269,
51
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_proxies | (self, prepared_request, proxies) | This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect).
... | This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect). | def rebuild_proxies(self, prepared_request, proxies):
"""This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in c... | [
"def",
"rebuild_proxies",
"(",
"self",
",",
"prepared_request",
",",
"proxies",
")",
":",
"proxies",
"=",
"proxies",
"if",
"proxies",
"is",
"not",
"None",
"else",
"{",
"}",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
"... | [
272,
4
] | [
311,
26
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_method | (self, prepared_request, response) | When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
| When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
| def rebuild_method(self, prepared_request, response):
"""When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
"""
method = prepared_request.method
# https://tools.ietf.org/html/rfc7231#section-6.4.4
if response... | [
"def",
"rebuild_method",
"(",
"self",
",",
"prepared_request",
",",
"response",
")",
":",
"method",
"=",
"prepared_request",
".",
"method",
"# https://tools.ietf.org/html/rfc7231#section-6.4.4",
"if",
"response",
".",
"status_code",
"==",
"codes",
".",
"see_other",
"a... | [
313,
4
] | [
333,
40
] | python | en | ['en', 'en', 'en'] | True |
Session.prepare_request | (self, request) | Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class:`Request` instance to prepare with this
... | Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`. | def prepare_request(self, request):
"""Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class... | [
"def",
"prepare_request",
"(",
"self",
",",
"request",
")",
":",
"cookies",
"=",
"request",
".",
"cookies",
"or",
"{",
"}",
"# Bootstrap CookieJar.",
"if",
"not",
"isinstance",
"(",
"cookies",
",",
"cookielib",
".",
"CookieJar",
")",
":",
"cookies",
"=",
"... | [
422,
4
] | [
460,
16
] | python | en | ['en', 'co', 'en'] | True |
Session.request | (self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None) | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the... | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object. | def request(self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None):
"""Constructs a :class:`Request <Request>`, prepares it and... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"cookies",
"=",
"None",
",",
"files",
"=",
"None",
",",
"auth",
"=",
"None",
",",
"timeout",
"=",
"N... | [
462,
4
] | [
531,
19
] | python | en | ['en', 'en', 'en'] | True |
Session.get | (self, url, **kwargs) | r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a GET request. Returns :class:`Response` object. | def get(self, url, **kwargs):
r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects',... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'GET'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
533,
4
] | [
542,
49
] | python | en | ['en', 'lb', 'en'] | True |
Session.options | (self, url, **kwargs) | r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a OPTIONS request. Returns :class:`Response` object. | def options(self, url, **kwargs):
r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_red... | [
"def",
"options",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'OPTIONS'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
544,
4
] | [
553,
53
] | python | en | ['en', 'en', 'en'] | True |
Session.head | (self, url, **kwargs) | r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a HEAD request. Returns :class:`Response` object. | def head(self, url, **kwargs):
r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects... | [
"def",
"head",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"False",
")",
"return",
"self",
".",
"request",
"(",
"'HEAD'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
555,
4
] | [
564,
50
] | python | en | ['en', 'lb', 'en'] | True |
Session.post | (self, url, data=None, json=None, **kwargs) | r"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json to send in the bo... | r"""Sends a POST request. Returns :class:`Response` object. | def post(self, url, data=None, json=None, **kwargs):
r"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Req... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"json",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'POST'",
",",
"url",
",",
"data",
"=",
"data",
",",
"json",
"=",
"json",
",",... | [
566,
4
] | [
577,
72
] | python | en | ['en', 'lb', 'en'] | True |
Session.put | (self, url, data=None, **kwargs) | r"""Sends a PUT request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``re... | r"""Sends a PUT request. Returns :class:`Response` object. | def put(self, url, data=None, **kwargs):
r"""Sends a PUT request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'PUT'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
579,
4
] | [
589,
60
] | python | en | ['en', 'lb', 'en'] | True |
Session.patch | (self, url, data=None, **kwargs) | r"""Sends a PATCH request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``... | r"""Sends a PATCH request. Returns :class:`Response` object. | def patch(self, url, data=None, **kwargs):
r"""Sends a PATCH request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
... | [
"def",
"patch",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'PATCH'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
591,
4
] | [
601,
62
] | python | en | ['en', 'en', 'en'] | True |
Session.delete | (self, url, **kwargs) | r"""Sends a DELETE request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a DELETE request. Returns :class:`Response` object. | def delete(self, url, **kwargs):
r"""Sends a DELETE request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
return self.request('DELETE', ... | [
"def",
"delete",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'DELETE'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
603,
4
] | [
611,
52
] | python | en | ['en', 'en', 'en'] | True |
Session.send | (self, request, **kwargs) | Send a given PreparedRequest.
:rtype: requests.Response
| Send a given PreparedRequest. | def send(self, request, **kwargs):
"""Send a given PreparedRequest.
:rtype: requests.Response
"""
# Set defaults that the hooks can utilize to ensure they always have
# the correct parameters to reproduce the previous request.
kwargs.setdefault('stream', self.stream)
... | [
"def",
"send",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set defaults that the hooks can utilize to ensure they always have",
"# the correct parameters to reproduce the previous request.",
"kwargs",
".",
"setdefault",
"(",
"'stream'",
",",
"self",
"... | [
613,
4
] | [
686,
16
] | python | en | ['en', 'co', 'en'] | True |
Session.merge_environment_settings | (self, url, proxies, stream, verify, cert) |
Check the environment and merge it with some settings.
:rtype: dict
|
Check the environment and merge it with some settings. | def merge_environment_settings(self, url, proxies, stream, verify, cert):
"""
Check the environment and merge it with some settings.
:rtype: dict
"""
# Gather clues from the surrounding environment.
if self.trust_env:
# Set environment's proxies.
... | [
"def",
"merge_environment_settings",
"(",
"self",
",",
"url",
",",
"proxies",
",",
"stream",
",",
"verify",
",",
"cert",
")",
":",
"# Gather clues from the surrounding environment.",
"if",
"self",
".",
"trust_env",
":",
"# Set environment's proxies.",
"no_proxy",
"=",... | [
688,
4
] | [
715,
29
] | python | en | ['en', 'error', 'th'] | False |
Session.get_adapter | (self, url) |
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
|
Returns the appropriate connection adapter for the given URL. | def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
... | [
"def",
"get_adapter",
"(",
"self",
",",
"url",
")",
":",
"for",
"(",
"prefix",
",",
"adapter",
")",
"in",
"self",
".",
"adapters",
".",
"items",
"(",
")",
":",
"if",
"url",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"prefix",
".",
"lower",
"... | [
717,
4
] | [
729,
85
] | python | en | ['en', 'error', 'th'] | False |
Session.close | (self) | Closes all adapters and as such the session | Closes all adapters and as such the session | def close(self):
"""Closes all adapters and as such the session"""
for v in self.adapters.values():
v.close() | [
"def",
"close",
"(",
"self",
")",
":",
"for",
"v",
"in",
"self",
".",
"adapters",
".",
"values",
"(",
")",
":",
"v",
".",
"close",
"(",
")"
] | [
731,
4
] | [
734,
21
] | python | en | ['en', 'en', 'en'] | True |
Session.mount | (self, prefix, adapter) | Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
| Registers a connection adapter to a prefix. | def mount(self, prefix, adapter):
"""Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
"""
self.adapters[prefix] = adapter
keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]
for key in keys_to_move:
... | [
"def",
"mount",
"(",
"self",
",",
"prefix",
",",
"adapter",
")",
":",
"self",
".",
"adapters",
"[",
"prefix",
"]",
"=",
"adapter",
"keys_to_move",
"=",
"[",
"k",
"for",
"k",
"in",
"self",
".",
"adapters",
"if",
"len",
"(",
"k",
")",
"<",
"len",
"... | [
736,
4
] | [
745,
55
] | python | en | ['en', 'en', 'en'] | True |
rehash | (path, blocksize=1 << 20) | Return (encoded_digest, length) for path using hashlib.sha256() | Return (encoded_digest, length) for path using hashlib.sha256() | def rehash(path, blocksize=1 << 20):
# type: (text_type, int) -> Tuple[str, str]
"""Return (encoded_digest, length) for path using hashlib.sha256()"""
h, length = hash_file(path, blocksize)
digest = 'sha256=' + urlsafe_b64encode(
h.digest()
).decode('latin1').rstrip('=')
# unicode/str py... | [
"def",
"rehash",
"(",
"path",
",",
"blocksize",
"=",
"1",
"<<",
"20",
")",
":",
"# type: (text_type, int) -> Tuple[str, str]",
"h",
",",
"length",
"=",
"hash_file",
"(",
"path",
",",
"blocksize",
")",
"digest",
"=",
"'sha256='",
"+",
"urlsafe_b64encode",
"(",
... | [
103,
0
] | [
111,
32
] | python | cy | ['da', 'cy', 'en'] | False |
csv_io_kwargs | (mode) | Return keyword arguments to properly open a CSV file
in the given mode.
| Return keyword arguments to properly open a CSV file
in the given mode.
| def csv_io_kwargs(mode):
# type: (str) -> Dict[str, Any]
"""Return keyword arguments to properly open a CSV file
in the given mode.
"""
if PY2:
return {'mode': '{}b'.format(mode)}
else:
return {'mode': mode, 'newline': '', 'encoding': 'utf-8'} | [
"def",
"csv_io_kwargs",
"(",
"mode",
")",
":",
"# type: (str) -> Dict[str, Any]",
"if",
"PY2",
":",
"return",
"{",
"'mode'",
":",
"'{}b'",
".",
"format",
"(",
"mode",
")",
"}",
"else",
":",
"return",
"{",
"'mode'",
":",
"mode",
",",
"'newline'",
":",
"''... | [
114,
0
] | [
122,
65
] | python | en | ['en', 'en', 'en'] | True |
fix_script | (path) | Replace #!python with #!/path/to/python
Return True if file was changed.
| Replace #!python with #!/path/to/python
Return True if file was changed.
| def fix_script(path):
# type: (text_type) -> bool
"""Replace #!python with #!/path/to/python
Return True if file was changed.
"""
# XXX RECORD hashes will need to be updated
assert os.path.isfile(path)
with open(path, 'rb') as script:
firstline = script.readline()
if not fir... | [
"def",
"fix_script",
"(",
"path",
")",
":",
"# type: (text_type) -> bool",
"# XXX RECORD hashes will need to be updated",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"script",
":",
"firstline... | [
125,
0
] | [
143,
15
] | python | en | ['en', 'lt', 'en'] | True |
message_about_scripts_not_on_PATH | (scripts) | Determine if any scripts are not on PATH and format a warning.
Returns a warning message if one or more scripts are not on PATH,
otherwise None.
| Determine if any scripts are not on PATH and format a warning.
Returns a warning message if one or more scripts are not on PATH,
otherwise None.
| def message_about_scripts_not_on_PATH(scripts):
# type: (Sequence[str]) -> Optional[str]
"""Determine if any scripts are not on PATH and format a warning.
Returns a warning message if one or more scripts are not on PATH,
otherwise None.
"""
if not scripts:
return None
# Group script... | [
"def",
"message_about_scripts_not_on_PATH",
"(",
"scripts",
")",
":",
"# type: (Sequence[str]) -> Optional[str]",
"if",
"not",
"scripts",
":",
"return",
"None",
"# Group scripts by the path they were installed in",
"grouped_by_dir",
"=",
"collections",
".",
"defaultdict",
"(",
... | [
176,
0
] | [
244,
31
] | python | en | ['en', 'en', 'en'] | True |
_normalized_outrows | (outrows) | Normalize the given rows of a RECORD file.
Items in each row are converted into str. Rows are then sorted to make
the value more predictable for tests.
Each row is a 3-tuple (path, hash, size) and corresponds to a record of
a RECORD file (see PEP 376 and PEP 427 for details). For the rows
passed ... | Normalize the given rows of a RECORD file. | def _normalized_outrows(outrows):
# type: (Iterable[InstalledCSVRow]) -> List[Tuple[str, str, str]]
"""Normalize the given rows of a RECORD file.
Items in each row are converted into str. Rows are then sorted to make
the value more predictable for tests.
Each row is a 3-tuple (path, hash, size) an... | [
"def",
"_normalized_outrows",
"(",
"outrows",
")",
":",
"# type: (Iterable[InstalledCSVRow]) -> List[Tuple[str, str, str]]",
"# Normally, there should only be one row per path, in which case the",
"# second and third elements don't come into play when sorting.",
"# However, in cases in the wild wh... | [
247,
0
] | [
270,
5
] | python | en | ['en', 'en', 'en'] | True |
get_csv_rows_for_installed | (
old_csv_rows, # type: List[List[str]]
installed, # type: Dict[RecordPath, RecordPath]
changed, # type: Set[RecordPath]
generated, # type: List[str]
lib_dir, # type: str
) |
:param installed: A map from archive RECORD path to installation RECORD
path.
|
:param installed: A map from archive RECORD path to installation RECORD
path.
| def get_csv_rows_for_installed(
old_csv_rows, # type: List[List[str]]
installed, # type: Dict[RecordPath, RecordPath]
changed, # type: Set[RecordPath]
generated, # type: List[str]
lib_dir, # type: str
):
# type: (...) -> List[InstalledCSVRow]
"""
:param installed: A map from archive... | [
"def",
"get_csv_rows_for_installed",
"(",
"old_csv_rows",
",",
"# type: List[List[str]]",
"installed",
",",
"# type: Dict[RecordPath, RecordPath]",
"changed",
",",
"# type: Set[RecordPath]",
"generated",
",",
"# type: List[str]",
"lib_dir",
",",
"# type: str",
")",
":",
"# ty... | [
296,
0
] | [
326,
25
] | python | en | ['en', 'error', 'th'] | False |
get_console_script_specs | (console) |
Given the mapping from entrypoint name to callable, return the relevant
console script specs.
|
Given the mapping from entrypoint name to callable, return the relevant
console script specs.
| def get_console_script_specs(console):
# type: (Dict[str, str]) -> List[str]
"""
Given the mapping from entrypoint name to callable, return the relevant
console script specs.
"""
# Don't mutate caller's version
console = console.copy()
scripts_to_generate = []
# Special case pip an... | [
"def",
"get_console_script_specs",
"(",
"console",
")",
":",
"# type: (Dict[str, str]) -> List[str]",
"# Don't mutate caller's version",
"console",
"=",
"console",
".",
"copy",
"(",
")",
"scripts_to_generate",
"=",
"[",
"]",
"# Special case pip and setuptools to generate versio... | [
329,
0
] | [
412,
30
] | python | en | ['en', 'error', 'th'] | False |
_install_wheel | (
name, # type: str
wheel_zip, # type: ZipFile
wheel_path, # type: str
scheme, # type: Scheme
pycompile=True, # type: bool
warn_script_location=True, # type: bool
direct_url=None, # type: Optional[DirectUrl]
requested=False, # type: bool
) | Install a wheel.
:param name: Name of the project to install
:param wheel_zip: open ZipFile for wheel being installed
:param scheme: Distutils scheme dictating the install directories
:param req_description: String used in place of the requirement, for
logging
:param pycompile: Whether to b... | Install a wheel. | def _install_wheel(
name, # type: str
wheel_zip, # type: ZipFile
wheel_path, # type: str
scheme, # type: Scheme
pycompile=True, # type: bool
warn_script_location=True, # type: bool
direct_url=None, # type: Optional[DirectUrl]
requested=False, # type: bool
):
# type: (...) -> ... | [
"def",
"_install_wheel",
"(",
"name",
",",
"# type: str",
"wheel_zip",
",",
"# type: ZipFile",
"wheel_path",
",",
"# type: str",
"scheme",
",",
"# type: Scheme",
"pycompile",
"=",
"True",
",",
"# type: bool",
"warn_script_location",
"=",
"True",
",",
"# type: bool",
... | [
500,
0
] | [
823,
51
] | python | en | ['en', 'cy', 'en'] | True |
normcase | (s) | Normalize case of pathname. Has no effect under Posix | Normalize case of pathname. Has no effect under Posix | def normcase(s):
"""Normalize case of pathname. Has no effect under Posix"""
s = os.fspath(s)
if not isinstance(s, (bytes, str)):
raise TypeError("normcase() argument must be str or bytes, "
"not '{}'".format(s.__class__.__name__))
return s | [
"def",
"normcase",
"(",
"s",
")",
":",
"s",
"=",
"os",
".",
"fspath",
"(",
"s",
")",
"if",
"not",
"isinstance",
"(",
"s",
",",
"(",
"bytes",
",",
"str",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"normcase() argument must be str or bytes, \"",
"\"not '{... | [
51,
0
] | [
57,
12
] | python | en | ['en', 'en', 'en'] | True |
isabs | (s) | Test whether a path is absolute | Test whether a path is absolute | def isabs(s):
"""Test whether a path is absolute"""
s = os.fspath(s)
sep = _get_sep(s)
return s.startswith(sep) | [
"def",
"isabs",
"(",
"s",
")",
":",
"s",
"=",
"os",
".",
"fspath",
"(",
"s",
")",
"sep",
"=",
"_get_sep",
"(",
"s",
")",
"return",
"s",
".",
"startswith",
"(",
"sep",
")"
] | [
63,
0
] | [
67,
28
] | python | en | ['en', 'en', 'en'] | True |
join | (a, *p) | Join two or more pathname components, inserting '/' as needed.
If any component is an absolute path, all previous path components
will be discarded. An empty last part will result in a path that
ends with a separator. | Join two or more pathname components, inserting '/' as needed.
If any component is an absolute path, all previous path components
will be discarded. An empty last part will result in a path that
ends with a separator. | def join(a, *p):
"""Join two or more pathname components, inserting '/' as needed.
If any component is an absolute path, all previous path components
will be discarded. An empty last part will result in a path that
ends with a separator."""
a = os.fspath(a)
sep = _get_sep(a)
path = a
tr... | [
"def",
"join",
"(",
"a",
",",
"*",
"p",
")",
":",
"a",
"=",
"os",
".",
"fspath",
"(",
"a",
")",
"sep",
"=",
"_get_sep",
"(",
"a",
")",
"path",
"=",
"a",
"try",
":",
"if",
"not",
"p",
":",
"path",
"[",
":",
"0",
"]",
"+",
"sep",
"#23780: E... | [
74,
0
] | [
95,
15
] | python | en | ['en', 'en', 'en'] | True |
split | (p) | Split a pathname. Returns tuple "(head, tail)" where "tail" is
everything after the final slash. Either part may be empty. | Split a pathname. Returns tuple "(head, tail)" where "tail" is
everything after the final slash. Either part may be empty. | def split(p):
"""Split a pathname. Returns tuple "(head, tail)" where "tail" is
everything after the final slash. Either part may be empty."""
p = os.fspath(p)
sep = _get_sep(p)
i = p.rfind(sep) + 1
head, tail = p[:i], p[i:]
if head and head != sep*len(head):
head = head.rstrip(sep... | [
"def",
"split",
"(",
"p",
")",
":",
"p",
"=",
"os",
".",
"fspath",
"(",
"p",
")",
"sep",
"=",
"_get_sep",
"(",
"p",
")",
"i",
"=",
"p",
".",
"rfind",
"(",
"sep",
")",
"+",
"1",
"head",
",",
"tail",
"=",
"p",
"[",
":",
"i",
"]",
",",
"p"... | [
103,
0
] | [
112,
21
] | python | en | ['en', 'en', 'en'] | True |
splitdrive | (p) | Split a pathname into drive and path. On Posix, drive is always
empty. | Split a pathname into drive and path. On Posix, drive is always
empty. | def splitdrive(p):
"""Split a pathname into drive and path. On Posix, drive is always
empty."""
p = os.fspath(p)
return p[:0], p | [
"def",
"splitdrive",
"(",
"p",
")",
":",
"p",
"=",
"os",
".",
"fspath",
"(",
"p",
")",
"return",
"p",
"[",
":",
"0",
"]",
",",
"p"
] | [
134,
0
] | [
138,
19
] | python | en | ['en', 'en', 'en'] | True |
basename | (p) | Returns the final component of a pathname | Returns the final component of a pathname | def basename(p):
"""Returns the final component of a pathname"""
p = os.fspath(p)
sep = _get_sep(p)
i = p.rfind(sep) + 1
return p[i:] | [
"def",
"basename",
"(",
"p",
")",
":",
"p",
"=",
"os",
".",
"fspath",
"(",
"p",
")",
"sep",
"=",
"_get_sep",
"(",
"p",
")",
"i",
"=",
"p",
".",
"rfind",
"(",
"sep",
")",
"+",
"1",
"return",
"p",
"[",
"i",
":",
"]"
] | [
143,
0
] | [
148,
16
] | python | en | ['en', 'en', 'en'] | True |
dirname | (p) | Returns the directory component of a pathname | Returns the directory component of a pathname | def dirname(p):
"""Returns the directory component of a pathname"""
p = os.fspath(p)
sep = _get_sep(p)
i = p.rfind(sep) + 1
head = p[:i]
if head and head != sep*len(head):
head = head.rstrip(sep)
return head | [
"def",
"dirname",
"(",
"p",
")",
":",
"p",
"=",
"os",
".",
"fspath",
"(",
"p",
")",
"sep",
"=",
"_get_sep",
"(",
"p",
")",
"i",
"=",
"p",
".",
"rfind",
"(",
"sep",
")",
"+",
"1",
"head",
"=",
"p",
"[",
":",
"i",
"]",
"if",
"head",
"and",
... | [
153,
0
] | [
161,
15
] | python | en | ['en', 'en', 'en'] | True |
islink | (path) | Test whether a path is a symbolic link | Test whether a path is a symbolic link | def islink(path):
"""Test whether a path is a symbolic link"""
try:
st = os.lstat(path)
except (OSError, AttributeError):
return False
return stat.S_ISLNK(st.st_mode) | [
"def",
"islink",
"(",
"path",
")",
":",
"try",
":",
"st",
"=",
"os",
".",
"lstat",
"(",
"path",
")",
"except",
"(",
"OSError",
",",
"AttributeError",
")",
":",
"return",
"False",
"return",
"stat",
".",
"S_ISLNK",
"(",
"st",
".",
"st_mode",
")"
] | [
167,
0
] | [
173,
35
] | python | en | ['en', 'en', 'en'] | True |
lexists | (path) | Test whether a path exists. Returns True for broken symbolic links | Test whether a path exists. Returns True for broken symbolic links | def lexists(path):
"""Test whether a path exists. Returns True for broken symbolic links"""
try:
os.lstat(path)
except OSError:
return False
return True | [
"def",
"lexists",
"(",
"path",
")",
":",
"try",
":",
"os",
".",
"lstat",
"(",
"path",
")",
"except",
"OSError",
":",
"return",
"False",
"return",
"True"
] | [
177,
0
] | [
183,
15
] | python | en | ['en', 'en', 'en'] | True |
ismount | (path) | Test whether a path is a mount point | Test whether a path is a mount point | def ismount(path):
"""Test whether a path is a mount point"""
try:
s1 = os.lstat(path)
except OSError:
# It doesn't exist -- so not a mount point. :-)
return False
else:
# A symlink can never be a mount point
if stat.S_ISLNK(s1.st_mode):
return False
... | [
"def",
"ismount",
"(",
"path",
")",
":",
"try",
":",
"s1",
"=",
"os",
".",
"lstat",
"(",
"path",
")",
"except",
"OSError",
":",
"# It doesn't exist -- so not a mount point. :-)",
"return",
"False",
"else",
":",
"# A symlink can never be a mount point",
"if",
"stat... | [
189,
0
] | [
219,
16
] | python | en | ['en', 'en', 'en'] | True |
expanduser | (path) | Expand ~ and ~user constructions. If user or $HOME is unknown,
do nothing. | Expand ~ and ~user constructions. If user or $HOME is unknown,
do nothing. | def expanduser(path):
"""Expand ~ and ~user constructions. If user or $HOME is unknown,
do nothing."""
path = os.fspath(path)
if isinstance(path, bytes):
tilde = b'~'
else:
tilde = '~'
if not path.startswith(tilde):
return path
sep = _get_sep(path)
i = path.find(... | [
"def",
"expanduser",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"fspath",
"(",
"path",
")",
"if",
"isinstance",
"(",
"path",
",",
"bytes",
")",
":",
"tilde",
"=",
"b'~'",
"else",
":",
"tilde",
"=",
"'~'",
"if",
"not",
"path",
".",
"startswith",... | [
231,
0
] | [
267,
40
] | python | en | ['en', 'en', 'en'] | True |
expandvars | (path) | Expand shell variables of form $var and ${var}. Unknown variables
are left unchanged. | Expand shell variables of form $var and ${var}. Unknown variables
are left unchanged. | def expandvars(path):
"""Expand shell variables of form $var and ${var}. Unknown variables
are left unchanged."""
path = os.fspath(path)
global _varprog, _varprogb
if isinstance(path, bytes):
if b'$' not in path:
return path
if not _varprogb:
import re
... | [
"def",
"expandvars",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"fspath",
"(",
"path",
")",
"global",
"_varprog",
",",
"_varprogb",
"if",
"isinstance",
"(",
"path",
",",
"bytes",
")",
":",
"if",
"b'$'",
"not",
"in",
"path",
":",
"return",
"path",... | [
277,
0
] | [
323,
15
] | python | en | ['en', 'en', 'en'] | True |
normpath | (path) | Normalize path, eliminating double slashes, etc. | Normalize path, eliminating double slashes, etc. | def normpath(path):
"""Normalize path, eliminating double slashes, etc."""
path = os.fspath(path)
if isinstance(path, bytes):
sep = b'/'
empty = b''
dot = b'.'
dotdot = b'..'
else:
sep = '/'
empty = ''
dot = '.'
dotdot = '..'
if path ==... | [
"def",
"normpath",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"fspath",
"(",
"path",
")",
"if",
"isinstance",
"(",
"path",
",",
"bytes",
")",
":",
"sep",
"=",
"b'/'",
"empty",
"=",
"b''",
"dot",
"=",
"b'.'",
"dotdot",
"=",
"b'..'",
"else",
":... | [
330,
0
] | [
365,
22
] | python | en | ['fr', 'zu', 'en'] | False |
abspath | (path) | Return an absolute path. | Return an absolute path. | def abspath(path):
"""Return an absolute path."""
path = os.fspath(path)
if not isabs(path):
if isinstance(path, bytes):
cwd = os.getcwdb()
else:
cwd = os.getcwd()
path = join(cwd, path)
return normpath(path) | [
"def",
"abspath",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"fspath",
"(",
"path",
")",
"if",
"not",
"isabs",
"(",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"bytes",
")",
":",
"cwd",
"=",
"os",
".",
"getcwdb",
"(",
")",
"else... | [
368,
0
] | [
377,
25
] | python | en | ['en', 'gd', 'en'] | True |
realpath | (filename) | Return the canonical path of the specified filename, eliminating any
symbolic links encountered in the path. | Return the canonical path of the specified filename, eliminating any
symbolic links encountered in the path. | def realpath(filename):
"""Return the canonical path of the specified filename, eliminating any
symbolic links encountered in the path."""
filename = os.fspath(filename)
path, ok = _joinrealpath(filename[:0], filename, {})
return abspath(path) | [
"def",
"realpath",
"(",
"filename",
")",
":",
"filename",
"=",
"os",
".",
"fspath",
"(",
"filename",
")",
"path",
",",
"ok",
"=",
"_joinrealpath",
"(",
"filename",
"[",
":",
"0",
"]",
",",
"filename",
",",
"{",
"}",
")",
"return",
"abspath",
"(",
"... | [
383,
0
] | [
388,
24
] | python | en | ['en', 'en', 'en'] | True |
relpath | (path, start=None) | Return a relative version of a path | Return a relative version of a path | def relpath(path, start=None):
"""Return a relative version of a path"""
if not path:
raise ValueError("no path specified")
path = os.fspath(path)
if isinstance(path, bytes):
curdir = b'.'
sep = b'/'
pardir = b'..'
else:
curdir = '.'
sep = '/'
... | [
"def",
"relpath",
"(",
"path",
",",
"start",
"=",
"None",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"\"no path specified\"",
")",
"path",
"=",
"os",
".",
"fspath",
"(",
"path",
")",
"if",
"isinstance",
"(",
"path",
",",
"bytes",
... | [
445,
0
] | [
478,
13
] | python | en | ['en', 'co', 'en'] | True |
commonpath | (paths) | Given a sequence of path names, returns the longest common sub-path. | Given a sequence of path names, returns the longest common sub-path. | def commonpath(paths):
"""Given a sequence of path names, returns the longest common sub-path."""
if not paths:
raise ValueError('commonpath() arg is an empty sequence')
paths = tuple(map(os.fspath, paths))
if isinstance(paths[0], bytes):
sep = b'/'
curdir = b'.'
else:
... | [
"def",
"commonpath",
"(",
"paths",
")",
":",
"if",
"not",
"paths",
":",
"raise",
"ValueError",
"(",
"'commonpath() arg is an empty sequence'",
")",
"paths",
"=",
"tuple",
"(",
"map",
"(",
"os",
".",
"fspath",
",",
"paths",
")",
")",
"if",
"isinstance",
"("... | [
486,
0
] | [
521,
13
] | python | en | ['en', 'en', 'en'] | True |
record_xml_property | (request) | Add extra xml properties to the tag for the calling test.
The fixture is callable with ``(name, value)``, with value being automatically
xml-encoded.
| Add extra xml properties to the tag for the calling test.
The fixture is callable with ``(name, value)``, with value being automatically
xml-encoded.
| def record_xml_property(request):
"""Add extra xml properties to the tag for the calling test.
The fixture is callable with ``(name, value)``, with value being automatically
xml-encoded.
"""
request.node.warn(
code='C3',
message='record_xml_property is an experimental feature',
)... | [
"def",
"record_xml_property",
"(",
"request",
")",
":",
"request",
".",
"node",
".",
"warn",
"(",
"code",
"=",
"'C3'",
",",
"message",
"=",
"'record_xml_property is an experimental feature'",
",",
")",
"xml",
"=",
"getattr",
"(",
"request",
".",
"config",
",",... | [
198,
0
] | [
215,
32
] | python | en | ['en', 'en', 'en'] | True |
record_xml_attribute | (request) | Add extra xml attributes to the tag for the calling test.
The fixture is callable with ``(name, value)``, with value being automatically
xml-encoded
| Add extra xml attributes to the tag for the calling test.
The fixture is callable with ``(name, value)``, with value being automatically
xml-encoded
| def record_xml_attribute(request):
"""Add extra xml attributes to the tag for the calling test.
The fixture is callable with ``(name, value)``, with value being automatically
xml-encoded
"""
request.node.warn(
code='C3',
message='record_xml_attribute is an experimental feature',
... | [
"def",
"record_xml_attribute",
"(",
"request",
")",
":",
"request",
".",
"node",
".",
"warn",
"(",
"code",
"=",
"'C3'",
",",
"message",
"=",
"'record_xml_attribute is an experimental feature'",
",",
")",
"xml",
"=",
"getattr",
"(",
"request",
".",
"config",
",... | [
219,
0
] | [
236,
28
] | python | en | ['en', 'en', 'en'] | True |
_NodeReporter.make_properties_node | (self) | Return a Junit node containing custom properties, if any.
| Return a Junit node containing custom properties, if any.
| def make_properties_node(self):
"""Return a Junit node containing custom properties, if any.
"""
if self.properties:
return Junit.properties([
Junit.property(name=name, value=value)
for name, value in self.properties
])
return '' | [
"def",
"make_properties_node",
"(",
"self",
")",
":",
"if",
"self",
".",
"properties",
":",
"return",
"Junit",
".",
"properties",
"(",
"[",
"Junit",
".",
"property",
"(",
"name",
"=",
"name",
",",
"value",
"=",
"value",
")",
"for",
"name",
",",
"value"... | [
90,
4
] | [
98,
17
] | python | en | ['en', 'en', 'en'] | True |
LogXML.pytest_runtest_logreport | (self, report) | handle a setup/call/teardown report, generating the appropriate
xml tags as necessary.
note: due to plugins like xdist, this hook may be called in interlaced
order with reports from other nodes. for example:
usual call order:
-> setup node1
-> call node1
... | handle a setup/call/teardown report, generating the appropriate
xml tags as necessary. | def pytest_runtest_logreport(self, report):
"""handle a setup/call/teardown report, generating the appropriate
xml tags as necessary.
note: due to plugins like xdist, this hook may be called in interlaced
order with reports from other nodes. for example:
usual call order:
... | [
"def",
"pytest_runtest_logreport",
"(",
"self",
",",
"report",
")",
":",
"close_report",
"=",
"None",
"if",
"report",
".",
"passed",
":",
"if",
"report",
".",
"when",
"==",
"\"call\"",
":",
"# ignore setup/teardown",
"reporter",
"=",
"self",
".",
"_opentestcas... | [
342,
4
] | [
412,
54
] | python | en | ['en', 'en', 'en'] | True |
LogXML.update_testcase_duration | (self, report) | accumulates total duration for nodeid from given report and updates
the Junit.testcase with the new total if already created.
| accumulates total duration for nodeid from given report and updates
the Junit.testcase with the new total if already created.
| def update_testcase_duration(self, report):
"""accumulates total duration for nodeid from given report and updates
the Junit.testcase with the new total if already created.
"""
reporter = self.node_reporter(report)
reporter.duration += getattr(report, 'duration', 0.0) | [
"def",
"update_testcase_duration",
"(",
"self",
",",
"report",
")",
":",
"reporter",
"=",
"self",
".",
"node_reporter",
"(",
"report",
")",
"reporter",
".",
"duration",
"+=",
"getattr",
"(",
"report",
",",
"'duration'",
",",
"0.0",
")"
] | [
414,
4
] | [
419,
61
] | python | en | ['en', 'en', 'en'] | True |
LogXML._get_global_properties_node | (self) | Return a Junit node containing custom properties, if any.
| Return a Junit node containing custom properties, if any.
| def _get_global_properties_node(self):
"""Return a Junit node containing custom properties, if any.
"""
if self.global_properties:
return Junit.properties(
[
Junit.property(name=name, value=value)
for name, value in self.global_... | [
"def",
"_get_global_properties_node",
"(",
"self",
")",
":",
"if",
"self",
".",
"global_properties",
":",
"return",
"Junit",
".",
"properties",
"(",
"[",
"Junit",
".",
"property",
"(",
"name",
"=",
"name",
",",
"value",
"=",
"value",
")",
"for",
"name",
... | [
468,
4
] | [
478,
17
] | python | en | ['en', 'en', 'en'] | True |
transform_dict_observations | (observations) | Transform list of dict observations into a dict of lists. | Transform list of dict observations into a dict of lists. | def transform_dict_observations(observations):
"""Transform list of dict observations into a dict of lists."""
obs_dict = dict()
if isinstance(observations[0], (dict, OrderedDict)):
for key in observations[0].keys():
if not isinstance(observations[0][key], str):
obs_dict[... | [
"def",
"transform_dict_observations",
"(",
"observations",
")",
":",
"obs_dict",
"=",
"dict",
"(",
")",
"if",
"isinstance",
"(",
"observations",
"[",
"0",
"]",
",",
"(",
"dict",
",",
"OrderedDict",
")",
")",
":",
"for",
"key",
"in",
"observations",
"[",
... | [
22,
0
] | [
36,
19
] | python | en | ['en', 'en', 'en'] | True |
ActorState._env_set_curr_policy | (self) |
Most environments do not need to know index of the policy that currently collects experience.
But in rare cases it is necessary. Originally was implemented for DMLab to properly manage the level cache.
|
Most environments do not need to know index of the policy that currently collects experience.
But in rare cases it is necessary. Originally was implemented for DMLab to properly manage the level cache.
| def _env_set_curr_policy(self):
"""
Most environments do not need to know index of the policy that currently collects experience.
But in rare cases it is necessary. Originally was implemented for DMLab to properly manage the level cache.
"""
set_attr_if_exists(self.env.unwrapped,... | [
"def",
"_env_set_curr_policy",
"(",
"self",
")",
":",
"set_attr_if_exists",
"(",
"self",
".",
"env",
".",
"unwrapped",
",",
"'curr_policy_idx'",
",",
"self",
".",
"curr_policy_id",
")"
] | [
108,
4
] | [
113,
86
] | python | en | ['en', 'error', 'th'] | False |
ActorState._on_new_policy | (self, new_policy_id) | Called when the new policy is sampled for this actor. | Called when the new policy is sampled for this actor. | def _on_new_policy(self, new_policy_id):
"""Called when the new policy is sampled for this actor."""
self.curr_policy_id = new_policy_id
# we're switching to a different policy - reset the rnn hidden state
self._reset_rnn_state()
if self.cfg.with_pbt and self.pbt_reward_shaping[... | [
"def",
"_on_new_policy",
"(",
"self",
",",
"new_policy_id",
")",
":",
"self",
".",
"curr_policy_id",
"=",
"new_policy_id",
"# we're switching to a different policy - reset the rnn hidden state",
"self",
".",
"_reset_rnn_state",
"(",
")",
"if",
"self",
".",
"cfg",
".",
... | [
115,
4
] | [
123,
114
] | 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.