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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
create_cookie | (name, value, **kwargs) | Make a cookie from underspecified parameters.
By default, the pair of `name` and `value` will be set for the domain ''
and sent on every request (this is sometimes called a "supercookie").
| Make a cookie from underspecified parameters. | def create_cookie(name, value, **kwargs):
"""Make a cookie from underspecified parameters.
By default, the pair of `name` and `value` will be set for the domain ''
and sent on every request (this is sometimes called a "supercookie").
"""
result = {
'version': 0,
'name': name,
... | [
"def",
"create_cookie",
"(",
"name",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"{",
"'version'",
":",
"0",
",",
"'name'",
":",
"name",
",",
"'value'",
":",
"value",
",",
"'port'",
":",
"None",
",",
"'domain'",
":",
"''",
",",
... | [
440,
0
] | [
473,
37
] | python | en | ['en', 'en', 'en'] | True |
morsel_to_cookie | (morsel) | Convert a Morsel object into a Cookie containing the one k/v pair. | Convert a Morsel object into a Cookie containing the one k/v pair. | def morsel_to_cookie(morsel):
"""Convert a Morsel object into a Cookie containing the one k/v pair."""
expires = None
if morsel['max-age']:
try:
expires = int(time.time() + int(morsel['max-age']))
except ValueError:
raise TypeError('max-age: %s must be integer' % mor... | [
"def",
"morsel_to_cookie",
"(",
"morsel",
")",
":",
"expires",
"=",
"None",
"if",
"morsel",
"[",
"'max-age'",
"]",
":",
"try",
":",
"expires",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
"+",
"int",
"(",
"morsel",
"[",
"'max-age'",
"]",
")",
")... | [
476,
0
] | [
504,
5
] | python | en | ['en', 'en', 'en'] | True |
cookiejar_from_dict | (cookie_dict, cookiejar=None, overwrite=True) | Returns a CookieJar from a key/value dictionary.
:param cookie_dict: Dict of key/values to insert into CookieJar.
:param cookiejar: (optional) A cookiejar to add the cookies to.
:param overwrite: (optional) If False, will not replace cookies
already in the jar with new ones.
:rtype: CookieJar
... | Returns a CookieJar from a key/value dictionary. | def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True):
"""Returns a CookieJar from a key/value dictionary.
:param cookie_dict: Dict of key/values to insert into CookieJar.
:param cookiejar: (optional) A cookiejar to add the cookies to.
:param overwrite: (optional) If False, will not repl... | [
"def",
"cookiejar_from_dict",
"(",
"cookie_dict",
",",
"cookiejar",
"=",
"None",
",",
"overwrite",
"=",
"True",
")",
":",
"if",
"cookiejar",
"is",
"None",
":",
"cookiejar",
"=",
"RequestsCookieJar",
"(",
")",
"if",
"cookie_dict",
"is",
"not",
"None",
":",
... | [
507,
0
] | [
525,
20
] | python | en | ['en', 'en', 'en'] | True |
merge_cookies | (cookiejar, cookies) | Add cookies to cookiejar and returns a merged CookieJar.
:param cookiejar: CookieJar object to add the cookies to.
:param cookies: Dictionary or CookieJar object to be added.
:rtype: CookieJar
| Add cookies to cookiejar and returns a merged CookieJar. | def merge_cookies(cookiejar, cookies):
"""Add cookies to cookiejar and returns a merged CookieJar.
:param cookiejar: CookieJar object to add the cookies to.
:param cookies: Dictionary or CookieJar object to be added.
:rtype: CookieJar
"""
if not isinstance(cookiejar, cookielib.CookieJar):
... | [
"def",
"merge_cookies",
"(",
"cookiejar",
",",
"cookies",
")",
":",
"if",
"not",
"isinstance",
"(",
"cookiejar",
",",
"cookielib",
".",
"CookieJar",
")",
":",
"raise",
"ValueError",
"(",
"'You can only merge into CookieJar'",
")",
"if",
"isinstance",
"(",
"cooki... | [
528,
0
] | [
548,
20
] | python | en | ['en', 'af', 'en'] | True |
MockRequest.add_header | (self, key, val) | cookielib has no legitimate use for this method; add it back if you find one. | cookielib has no legitimate use for this method; add it back if you find one. | def add_header(self, key, val):
"""cookielib has no legitimate use for this method; add it back if you find one."""
raise NotImplementedError("Cookie headers should be added with add_unredirected_header()") | [
"def",
"add_header",
"(",
"self",
",",
"key",
",",
"val",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Cookie headers should be added with add_unredirected_header()\"",
")"
] | [
73,
4
] | [
75,
98
] | python | en | ['en', 'en', 'en'] | True |
MockResponse.__init__ | (self, headers) | Make a MockResponse for `cookielib` to read.
:param headers: a httplib.HTTPMessage or analogous carrying the headers
| Make a MockResponse for `cookielib` to read. | def __init__(self, headers):
"""Make a MockResponse for `cookielib` to read.
:param headers: a httplib.HTTPMessage or analogous carrying the headers
"""
self._headers = headers | [
"def",
"__init__",
"(",
"self",
",",
"headers",
")",
":",
"self",
".",
"_headers",
"=",
"headers"
] | [
103,
4
] | [
108,
31
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.get | (self, name, default=None, domain=None, path=None) | Dict-like get() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.
.. warning:: operation is O(n), not O(1).
| Dict-like get() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains. | def get(self, name, default=None, domain=None, path=None):
"""Dict-like get() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.
.. warning:: operation is O(n), not O(1).
"""
try:
... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
",",
"domain",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"_find_no_duplicates",
"(",
"name",
",",
"domain",
",",
"path",
")",
"except",
"... | [
188,
4
] | [
198,
26
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.set | (self, name, value, **kwargs) | Dict-like set() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.
| Dict-like set() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.
| def set(self, name, value, **kwargs):
"""Dict-like set() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.
"""
# support client code that unsets cookies by assignment of a None value:
if... | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"# support client code that unsets cookies by assignment of a None value:",
"if",
"value",
"is",
"None",
":",
"remove_cookie_by_name",
"(",
"self",
",",
"name",
",",
"domain",... | [
200,
4
] | [
215,
16
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.iterkeys | (self) | Dict-like iterkeys() that returns an iterator of names of cookies
from the jar.
.. seealso:: itervalues() and iteritems().
| Dict-like iterkeys() that returns an iterator of names of cookies
from the jar. | def iterkeys(self):
"""Dict-like iterkeys() that returns an iterator of names of cookies
from the jar.
.. seealso:: itervalues() and iteritems().
"""
for cookie in iter(self):
yield cookie.name | [
"def",
"iterkeys",
"(",
"self",
")",
":",
"for",
"cookie",
"in",
"iter",
"(",
"self",
")",
":",
"yield",
"cookie",
".",
"name"
] | [
217,
4
] | [
224,
29
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.keys | (self) | Dict-like keys() that returns a list of names of cookies from the
jar.
.. seealso:: values() and items().
| Dict-like keys() that returns a list of names of cookies from the
jar. | def keys(self):
"""Dict-like keys() that returns a list of names of cookies from the
jar.
.. seealso:: values() and items().
"""
return list(self.iterkeys()) | [
"def",
"keys",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"iterkeys",
"(",
")",
")"
] | [
226,
4
] | [
232,
36
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.itervalues | (self) | Dict-like itervalues() that returns an iterator of values of cookies
from the jar.
.. seealso:: iterkeys() and iteritems().
| Dict-like itervalues() that returns an iterator of values of cookies
from the jar. | def itervalues(self):
"""Dict-like itervalues() that returns an iterator of values of cookies
from the jar.
.. seealso:: iterkeys() and iteritems().
"""
for cookie in iter(self):
yield cookie.value | [
"def",
"itervalues",
"(",
"self",
")",
":",
"for",
"cookie",
"in",
"iter",
"(",
"self",
")",
":",
"yield",
"cookie",
".",
"value"
] | [
234,
4
] | [
241,
30
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.values | (self) | Dict-like values() that returns a list of values of cookies from the
jar.
.. seealso:: keys() and items().
| Dict-like values() that returns a list of values of cookies from the
jar. | def values(self):
"""Dict-like values() that returns a list of values of cookies from the
jar.
.. seealso:: keys() and items().
"""
return list(self.itervalues()) | [
"def",
"values",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"itervalues",
"(",
")",
")"
] | [
243,
4
] | [
249,
38
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.iteritems | (self) | Dict-like iteritems() that returns an iterator of name-value tuples
from the jar.
.. seealso:: iterkeys() and itervalues().
| Dict-like iteritems() that returns an iterator of name-value tuples
from the jar. | def iteritems(self):
"""Dict-like iteritems() that returns an iterator of name-value tuples
from the jar.
.. seealso:: iterkeys() and itervalues().
"""
for cookie in iter(self):
yield cookie.name, cookie.value | [
"def",
"iteritems",
"(",
"self",
")",
":",
"for",
"cookie",
"in",
"iter",
"(",
"self",
")",
":",
"yield",
"cookie",
".",
"name",
",",
"cookie",
".",
"value"
] | [
251,
4
] | [
258,
43
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.items | (self) | Dict-like items() that returns a list of name-value tuples from the
jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a
vanilla python dict of key value pairs.
.. seealso:: keys() and values().
| Dict-like items() that returns a list of name-value tuples from the
jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a
vanilla python dict of key value pairs. | def items(self):
"""Dict-like items() that returns a list of name-value tuples from the
jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a
vanilla python dict of key value pairs.
.. seealso:: keys() and values().
"""
return list(self.iteritems()) | [
"def",
"items",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"iteritems",
"(",
")",
")"
] | [
260,
4
] | [
267,
37
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.list_domains | (self) | Utility method to list all the domains in the jar. | Utility method to list all the domains in the jar. | def list_domains(self):
"""Utility method to list all the domains in the jar."""
domains = []
for cookie in iter(self):
if cookie.domain not in domains:
domains.append(cookie.domain)
return domains | [
"def",
"list_domains",
"(",
"self",
")",
":",
"domains",
"=",
"[",
"]",
"for",
"cookie",
"in",
"iter",
"(",
"self",
")",
":",
"if",
"cookie",
".",
"domain",
"not",
"in",
"domains",
":",
"domains",
".",
"append",
"(",
"cookie",
".",
"domain",
")",
"... | [
269,
4
] | [
275,
22
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.list_paths | (self) | Utility method to list all the paths in the jar. | Utility method to list all the paths in the jar. | def list_paths(self):
"""Utility method to list all the paths in the jar."""
paths = []
for cookie in iter(self):
if cookie.path not in paths:
paths.append(cookie.path)
return paths | [
"def",
"list_paths",
"(",
"self",
")",
":",
"paths",
"=",
"[",
"]",
"for",
"cookie",
"in",
"iter",
"(",
"self",
")",
":",
"if",
"cookie",
".",
"path",
"not",
"in",
"paths",
":",
"paths",
".",
"append",
"(",
"cookie",
".",
"path",
")",
"return",
"... | [
277,
4
] | [
283,
20
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.multiple_domains | (self) | Returns True if there are multiple domains in the jar.
Returns False otherwise.
:rtype: bool
| Returns True if there are multiple domains in the jar.
Returns False otherwise. | def multiple_domains(self):
"""Returns True if there are multiple domains in the jar.
Returns False otherwise.
:rtype: bool
"""
domains = []
for cookie in iter(self):
if cookie.domain is not None and cookie.domain in domains:
return True
... | [
"def",
"multiple_domains",
"(",
"self",
")",
":",
"domains",
"=",
"[",
"]",
"for",
"cookie",
"in",
"iter",
"(",
"self",
")",
":",
"if",
"cookie",
".",
"domain",
"is",
"not",
"None",
"and",
"cookie",
".",
"domain",
"in",
"domains",
":",
"return",
"Tru... | [
285,
4
] | [
296,
20
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.get_dict | (self, domain=None, path=None) | Takes as an argument an optional domain and path and returns a plain
old Python dict of name-value pairs of cookies that meet the
requirements.
:rtype: dict
| Takes as an argument an optional domain and path and returns a plain
old Python dict of name-value pairs of cookies that meet the
requirements. | def get_dict(self, domain=None, path=None):
"""Takes as an argument an optional domain and path and returns a plain
old Python dict of name-value pairs of cookies that meet the
requirements.
:rtype: dict
"""
dictionary = {}
for cookie in iter(self):
i... | [
"def",
"get_dict",
"(",
"self",
",",
"domain",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"dictionary",
"=",
"{",
"}",
"for",
"cookie",
"in",
"iter",
"(",
"self",
")",
":",
"if",
"(",
"(",
"domain",
"is",
"None",
"or",
"cookie",
".",
"domai... | [
298,
4
] | [
312,
25
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.__getitem__ | (self, name) | Dict-like __getitem__() for compatibility with client code. Throws
exception if there are more than one cookie with name. In that case,
use the more explicit get() method instead.
.. warning:: operation is O(n), not O(1).
| Dict-like __getitem__() for compatibility with client code. Throws
exception if there are more than one cookie with name. In that case,
use the more explicit get() method instead. | def __getitem__(self, name):
"""Dict-like __getitem__() for compatibility with client code. Throws
exception if there are more than one cookie with name. In that case,
use the more explicit get() method instead.
.. warning:: operation is O(n), not O(1).
"""
return self._... | [
"def",
"__getitem__",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"_find_no_duplicates",
"(",
"name",
")"
] | [
320,
4
] | [
327,
45
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.__setitem__ | (self, name, value) | Dict-like __setitem__ for compatibility with client code. Throws
exception if there is already a cookie of that name in the jar. In that
case, use the more explicit set() method instead.
| Dict-like __setitem__ for compatibility with client code. Throws
exception if there is already a cookie of that name in the jar. In that
case, use the more explicit set() method instead.
| def __setitem__(self, name, value):
"""Dict-like __setitem__ for compatibility with client code. Throws
exception if there is already a cookie of that name in the jar. In that
case, use the more explicit set() method instead.
"""
self.set(name, value) | [
"def",
"__setitem__",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"set",
"(",
"name",
",",
"value",
")"
] | [
329,
4
] | [
334,
29
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.__delitem__ | (self, name) | Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s
``remove_cookie_by_name()``.
| Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s
``remove_cookie_by_name()``.
| def __delitem__(self, name):
"""Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s
``remove_cookie_by_name()``.
"""
remove_cookie_by_name(self, name) | [
"def",
"__delitem__",
"(",
"self",
",",
"name",
")",
":",
"remove_cookie_by_name",
"(",
"self",
",",
"name",
")"
] | [
336,
4
] | [
340,
41
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.update | (self, other) | Updates this jar with cookies from another CookieJar or dict-like | Updates this jar with cookies from another CookieJar or dict-like | def update(self, other):
"""Updates this jar with cookies from another CookieJar or dict-like"""
if isinstance(other, cookielib.CookieJar):
for cookie in other:
self.set_cookie(copy.copy(cookie))
else:
super(RequestsCookieJar, self).update(other) | [
"def",
"update",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"cookielib",
".",
"CookieJar",
")",
":",
"for",
"cookie",
"in",
"other",
":",
"self",
".",
"set_cookie",
"(",
"copy",
".",
"copy",
"(",
"cookie",
")",
")",
... | [
347,
4
] | [
353,
56
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar._find | (self, name, domain=None, path=None) | Requests uses this method internally to get cookie values.
If there are conflicting cookies, _find arbitrarily chooses one.
See _find_no_duplicates if you want an exception thrown if there are
conflicting cookies.
:param name: a string containing name of cookie
:param domain: (... | Requests uses this method internally to get cookie values. | def _find(self, name, domain=None, path=None):
"""Requests uses this method internally to get cookie values.
If there are conflicting cookies, _find arbitrarily chooses one.
See _find_no_duplicates if you want an exception thrown if there are
conflicting cookies.
:param name: a... | [
"def",
"_find",
"(",
"self",
",",
"name",
",",
"domain",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"for",
"cookie",
"in",
"iter",
"(",
"self",
")",
":",
"if",
"cookie",
".",
"name",
"==",
"name",
":",
"if",
"domain",
"is",
"None",
"or",
... | [
355,
4
] | [
373,
76
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar._find_no_duplicates | (self, name, domain=None, path=None) | Both ``__get_item__`` and ``get`` call this function: it's never
used elsewhere in Requests.
:param name: a string containing name of cookie
:param domain: (optional) string containing domain of cookie
:param path: (optional) string containing path of cookie
:raises KeyError: if... | Both ``__get_item__`` and ``get`` call this function: it's never
used elsewhere in Requests. | def _find_no_duplicates(self, name, domain=None, path=None):
"""Both ``__get_item__`` and ``get`` call this function: it's never
used elsewhere in Requests.
:param name: a string containing name of cookie
:param domain: (optional) string containing domain of cookie
:param path: ... | [
"def",
"_find_no_duplicates",
"(",
"self",
",",
"name",
",",
"domain",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"toReturn",
"=",
"None",
"for",
"cookie",
"in",
"iter",
"(",
"self",
")",
":",
"if",
"cookie",
".",
"name",
"==",
"name",
":",
"... | [
375,
4
] | [
398,
76
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.__getstate__ | (self) | Unlike a normal CookieJar, this class is pickleable. | Unlike a normal CookieJar, this class is pickleable. | def __getstate__(self):
"""Unlike a normal CookieJar, this class is pickleable."""
state = self.__dict__.copy()
# remove the unpickleable RLock object
state.pop('_cookies_lock')
return state | [
"def",
"__getstate__",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"__dict__",
".",
"copy",
"(",
")",
"# remove the unpickleable RLock object",
"state",
".",
"pop",
"(",
"'_cookies_lock'",
")",
"return",
"state"
] | [
400,
4
] | [
405,
20
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.__setstate__ | (self, state) | Unlike a normal CookieJar, this class is pickleable. | Unlike a normal CookieJar, this class is pickleable. | def __setstate__(self, state):
"""Unlike a normal CookieJar, this class is pickleable."""
self.__dict__.update(state)
if '_cookies_lock' not in self.__dict__:
self._cookies_lock = threading.RLock() | [
"def",
"__setstate__",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"__dict__",
".",
"update",
"(",
"state",
")",
"if",
"'_cookies_lock'",
"not",
"in",
"self",
".",
"__dict__",
":",
"self",
".",
"_cookies_lock",
"=",
"threading",
".",
"RLock",
"(",
... | [
407,
4
] | [
411,
50
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.copy | (self) | Return a copy of this RequestsCookieJar. | Return a copy of this RequestsCookieJar. | def copy(self):
"""Return a copy of this RequestsCookieJar."""
new_cj = RequestsCookieJar()
new_cj.set_policy(self.get_policy())
new_cj.update(self)
return new_cj | [
"def",
"copy",
"(",
"self",
")",
":",
"new_cj",
"=",
"RequestsCookieJar",
"(",
")",
"new_cj",
".",
"set_policy",
"(",
"self",
".",
"get_policy",
"(",
")",
")",
"new_cj",
".",
"update",
"(",
"self",
")",
"return",
"new_cj"
] | [
413,
4
] | [
418,
21
] | python | en | ['en', 'en', 'en'] | True |
RequestsCookieJar.get_policy | (self) | Return the CookiePolicy instance used. | Return the CookiePolicy instance used. | def get_policy(self):
"""Return the CookiePolicy instance used."""
return self._policy | [
"def",
"get_policy",
"(",
"self",
")",
":",
"return",
"self",
".",
"_policy"
] | [
420,
4
] | [
422,
27
] | python | en | ['en', 'en', 'en'] | True |
create_package_set_from_installed | (**kwargs) | Converts a list of distributions into a PackageSet.
| Converts a list of distributions into a PackageSet.
| def create_package_set_from_installed(**kwargs):
# type: (**Any) -> Tuple[PackageSet, bool]
"""Converts a list of distributions into a PackageSet.
"""
# Default to using all packages installed on the system
if kwargs == {}:
kwargs = {"local_only": False, "skip": ()}
package_set = {}
... | [
"def",
"create_package_set_from_installed",
"(",
"*",
"*",
"kwargs",
")",
":",
"# type: (**Any) -> Tuple[PackageSet, bool]",
"# Default to using all packages installed on the system",
"if",
"kwargs",
"==",
"{",
"}",
":",
"kwargs",
"=",
"{",
"\"local_only\"",
":",
"False",
... | [
36,
0
] | [
54,
32
] | python | en | ['en', 'en', 'en'] | True |
check_package_set | (package_set, should_ignore=None) | Check if a package set is consistent
If should_ignore is passed, it should be a callable that takes a
package name and returns a boolean.
| Check if a package set is consistent | def check_package_set(package_set, should_ignore=None):
# type: (PackageSet, Optional[Callable[[str], bool]]) -> CheckResult
"""Check if a package set is consistent
If should_ignore is passed, it should be a callable that takes a
package name and returns a boolean.
"""
missing = {}
conflic... | [
"def",
"check_package_set",
"(",
"package_set",
",",
"should_ignore",
"=",
"None",
")",
":",
"# type: (PackageSet, Optional[Callable[[str], bool]]) -> CheckResult",
"missing",
"=",
"{",
"}",
"conflicting",
"=",
"{",
"}",
"for",
"package_name",
"in",
"package_set",
":",
... | [
57,
0
] | [
98,
31
] | python | en | ['en', 'en', 'en'] | True |
check_install_conflicts | (to_install) | For checking if the dependency graph would be consistent after \
installing given requirements
| For checking if the dependency graph would be consistent after \
installing given requirements
| def check_install_conflicts(to_install):
# type: (List[InstallRequirement]) -> ConflictDetails
"""For checking if the dependency graph would be consistent after \
installing given requirements
"""
# Start from the current state
package_set, _ = create_package_set_from_installed()
# Install p... | [
"def",
"check_install_conflicts",
"(",
"to_install",
")",
":",
"# type: (List[InstallRequirement]) -> ConflictDetails",
"# Start from the current state",
"package_set",
",",
"_",
"=",
"create_package_set_from_installed",
"(",
")",
"# Install packages",
"would_be_installed",
"=",
... | [
101,
0
] | [
119,
5
] | python | en | ['en', 'en', 'en'] | True |
_simulate_installation_of | (to_install, package_set) | Computes the version of packages after installing to_install.
| Computes the version of packages after installing to_install.
| def _simulate_installation_of(to_install, package_set):
# type: (List[InstallRequirement], PackageSet) -> Set[str]
"""Computes the version of packages after installing to_install.
"""
# Keep track of packages that were installed
installed = set()
# Modify it as installing requirement_set would... | [
"def",
"_simulate_installation_of",
"(",
"to_install",
",",
"package_set",
")",
":",
"# type: (List[InstallRequirement], PackageSet) -> Set[str]",
"# Keep track of packages that were installed",
"installed",
"=",
"set",
"(",
")",
"# Modify it as installing requirement_set would (assumi... | [
122,
0
] | [
141,
20
] | python | en | ['en', 'en', 'en'] | True |
Cider.compute_score | (self, gts, res) |
Main function to compute CIDEr score
:param gts (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
res (dict) : dictionary with key <image> and value <tokenized reference sentence>
:return: cider (float) : computed CIDEr score for the co... |
Main function to compute CIDEr score
:param gts (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
res (dict) : dictionary with key <image> and value <tokenized reference sentence>
:return: cider (float) : computed CIDEr score for the co... | def compute_score(self, gts, res):
"""
Main function to compute CIDEr score
:param gts (dict) : dictionary with key <image> and value <tokenized hypothesis / candidate sentence>
res (dict) : dictionary with key <image> and value <tokenized reference sentence>
:return: c... | [
"def",
"compute_score",
"(",
"self",
",",
"gts",
",",
"res",
")",
":",
"assert",
"(",
"gts",
".",
"keys",
"(",
")",
"==",
"res",
".",
"keys",
"(",
")",
")",
"cider_scorer",
"=",
"CiderScorer",
"(",
"gts",
",",
"test",
"=",
"res",
",",
"n",
"=",
... | [
28,
4
] | [
38,
43
] | python | en | ['en', 'error', 'th'] | False |
get_default_compiler | (osname=None, platform=None) | Determine the default compiler to use for the given platform.
osname should be one of the standard Python OS names (i.e. the
ones returned by os.name) and platform the common value
returned by sys.platform for the platform in question.
The default values are os.name and sys.platform in cas... | Determine the default compiler to use for the given platform. | def get_default_compiler(osname=None, platform=None):
"""Determine the default compiler to use for the given platform.
osname should be one of the standard Python OS names (i.e. the
ones returned by os.name) and platform the common value
returned by sys.platform for the platform in question.
... | [
"def",
"get_default_compiler",
"(",
"osname",
"=",
"None",
",",
"platform",
"=",
"None",
")",
":",
"if",
"osname",
"is",
"None",
":",
"osname",
"=",
"os",
".",
"name",
"if",
"platform",
"is",
"None",
":",
"platform",
"=",
"sys",
".",
"platform",
"for",... | [
936,
0
] | [
955,
17
] | python | en | ['en', 'en', 'en'] | True |
show_compilers | () | Print list of available compilers (used by the "--help-compiler"
options to "build", "build_ext", "build_clib").
| Print list of available compilers (used by the "--help-compiler"
options to "build", "build_ext", "build_clib").
| def show_compilers():
"""Print list of available compilers (used by the "--help-compiler"
options to "build", "build_ext", "build_clib").
"""
# XXX this "knows" that the compiler option it's describing is
# "--compiler", which just happens to be the case for the three
# commands that use it.
... | [
"def",
"show_compilers",
"(",
")",
":",
"# XXX this \"knows\" that the compiler option it's describing is",
"# \"--compiler\", which just happens to be the case for the three",
"# commands that use it.",
"from",
"distutils",
".",
"fancy_getopt",
"import",
"FancyGetopt",
"compilers",
"=... | [
972,
0
] | [
986,
61
] | python | en | ['en', 'en', 'en'] | True |
new_compiler | (plat=None, compiler=None, verbose=0, dry_run=0, force=0) | Generate an instance of some CCompiler subclass for the supplied
platform/compiler combination. 'plat' defaults to 'os.name'
(eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
for that platform. Currently only 'posix' and 'nt' are supported, and
the default compilers are "traditional... | Generate an instance of some CCompiler subclass for the supplied
platform/compiler combination. 'plat' defaults to 'os.name'
(eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
for that platform. Currently only 'posix' and 'nt' are supported, and
the default compilers are "traditional... | def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
"""Generate an instance of some CCompiler subclass for the supplied
platform/compiler combination. 'plat' defaults to 'os.name'
(eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
for that platform. Currently o... | [
"def",
"new_compiler",
"(",
"plat",
"=",
"None",
",",
"compiler",
"=",
"None",
",",
"verbose",
"=",
"0",
",",
"dry_run",
"=",
"0",
",",
"force",
"=",
"0",
")",
":",
"if",
"plat",
"is",
"None",
":",
"plat",
"=",
"os",
".",
"name",
"try",
":",
"i... | [
989,
0
] | [
1031,
38
] | python | en | ['en', 'en', 'en'] | True |
gen_preprocess_options | (macros, include_dirs) | Generate C pre-processor options (-D, -U, -I) as used by at least
two types of compilers: the typical Unix compiler and Visual C++.
'macros' is the usual thing, a list of 1- or 2-tuples, where (name,)
means undefine (-U) macro 'name', and (name,value) means define (-D)
macro 'name' to 'value'. 'include... | Generate C pre-processor options (-D, -U, -I) as used by at least
two types of compilers: the typical Unix compiler and Visual C++.
'macros' is the usual thing, a list of 1- or 2-tuples, where (name,)
means undefine (-U) macro 'name', and (name,value) means define (-D)
macro 'name' to 'value'. 'include... | def gen_preprocess_options(macros, include_dirs):
"""Generate C pre-processor options (-D, -U, -I) as used by at least
two types of compilers: the typical Unix compiler and Visual C++.
'macros' is the usual thing, a list of 1- or 2-tuples, where (name,)
means undefine (-U) macro 'name', and (name,value)... | [
"def",
"gen_preprocess_options",
"(",
"macros",
",",
"include_dirs",
")",
":",
"# XXX it would be nice (mainly aesthetic, and so we don't generate",
"# stupid-looking command lines) to go over 'macros' and eliminate",
"# redundant definitions/undefinitions (ie. ensure that only the",
"# latest... | [
1034,
0
] | [
1076,
18
] | python | en | ['en', 'en', 'en'] | True |
gen_lib_options | (compiler, library_dirs, runtime_library_dirs, libraries) | Generate linker options for searching library directories and
linking with specific libraries. 'libraries' and 'library_dirs' are,
respectively, lists of library names (not filenames!) and search
directories. Returns a list of command-line options suitable for use
with some compiler (depending on the ... | Generate linker options for searching library directories and
linking with specific libraries. 'libraries' and 'library_dirs' are,
respectively, lists of library names (not filenames!) and search
directories. Returns a list of command-line options suitable for use
with some compiler (depending on the ... | def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries):
"""Generate linker options for searching library directories and
linking with specific libraries. 'libraries' and 'library_dirs' are,
respectively, lists of library names (not filenames!) and search
directories. Returns a l... | [
"def",
"gen_lib_options",
"(",
"compiler",
",",
"library_dirs",
",",
"runtime_library_dirs",
",",
"libraries",
")",
":",
"lib_opts",
"=",
"[",
"]",
"for",
"dir",
"in",
"library_dirs",
":",
"lib_opts",
".",
"append",
"(",
"compiler",
".",
"library_dir_option",
... | [
1079,
0
] | [
1115,
19
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_executables | (self, **kwargs) | Define the executables (and options for them) that will be run
to perform the various stages of compilation. The exact set of
executables that may be specified here depends on the compiler
class (via the 'executables' class attribute), but most will have:
compiler the C/C++ compi... | Define the executables (and options for them) that will be run
to perform the various stages of compilation. The exact set of
executables that may be specified here depends on the compiler
class (via the 'executables' class attribute), but most will have:
compiler the C/C++ compi... | def set_executables(self, **kwargs):
"""Define the executables (and options for them) that will be run
to perform the various stages of compilation. The exact set of
executables that may be specified here depends on the compiler
class (via the 'executables' class attribute), but most wi... | [
"def",
"set_executables",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Note that some CCompiler implementation classes will define class",
"# attributes 'cpp', 'cc', etc. with hard-coded executable names;",
"# this is appropriate when a compiler class is for exactly one",
"# compiler... | [
120,
4
] | [
150,
49
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._check_macro_definitions | (self, definitions) | Ensures that every element of 'definitions' is a valid macro
definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do
nothing if all definitions are OK, raise TypeError otherwise.
| Ensures that every element of 'definitions' is a valid macro
definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do
nothing if all definitions are OK, raise TypeError otherwise.
| def _check_macro_definitions(self, definitions):
"""Ensures that every element of 'definitions' is a valid macro
definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do
nothing if all definitions are OK, raise TypeError otherwise.
"""
for defn in definitions:
... | [
"def",
"_check_macro_definitions",
"(",
"self",
",",
"definitions",
")",
":",
"for",
"defn",
"in",
"definitions",
":",
"if",
"not",
"(",
"isinstance",
"(",
"defn",
",",
"tuple",
")",
"and",
"(",
"len",
"(",
"defn",
")",
"in",
"(",
"1",
",",
"2",
")",... | [
166,
4
] | [
178,
39
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.define_macro | (self, name, value=None) | Define a preprocessor macro for all compilations driven by this
compiler object. The optional parameter 'value' should be a
string; if it is not supplied, then the macro will be defined
without an explicit value and the exact outcome depends on the
compiler used (XXX true? does ANSI say... | Define a preprocessor macro for all compilations driven by this
compiler object. The optional parameter 'value' should be a
string; if it is not supplied, then the macro will be defined
without an explicit value and the exact outcome depends on the
compiler used (XXX true? does ANSI say... | def define_macro(self, name, value=None):
"""Define a preprocessor macro for all compilations driven by this
compiler object. The optional parameter 'value' should be a
string; if it is not supplied, then the macro will be defined
without an explicit value and the exact outcome depends ... | [
"def",
"define_macro",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"# Delete from the list of macro definitions/undefinitions if",
"# already there (so that this one will take precedence).",
"i",
"=",
"self",
".",
"_find_macro",
"(",
"name",
")",
"if",
... | [
183,
4
] | [
196,
41
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.undefine_macro | (self, name) | Undefine a preprocessor macro for all compilations driven by
this compiler object. If the same macro is defined by
'define_macro()' and undefined by 'undefine_macro()' the last call
takes precedence (including multiple redefinitions or
undefinitions). If the macro is redefined/undefine... | Undefine a preprocessor macro for all compilations driven by
this compiler object. If the same macro is defined by
'define_macro()' and undefined by 'undefine_macro()' the last call
takes precedence (including multiple redefinitions or
undefinitions). If the macro is redefined/undefine... | def undefine_macro(self, name):
"""Undefine a preprocessor macro for all compilations driven by
this compiler object. If the same macro is defined by
'define_macro()' and undefined by 'undefine_macro()' the last call
takes precedence (including multiple redefinitions or
undefini... | [
"def",
"undefine_macro",
"(",
"self",
",",
"name",
")",
":",
"# Delete from the list of macro definitions/undefinitions if",
"# already there (so that this one will take precedence).",
"i",
"=",
"self",
".",
"_find_macro",
"(",
"name",
")",
"if",
"i",
"is",
"not",
"None",... | [
198,
4
] | [
214,
34
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_include_dir | (self, dir) | Add 'dir' to the list of directories that will be searched for
header files. The compiler is instructed to search directories in
the order in which they are supplied by successive calls to
'add_include_dir()'.
| Add 'dir' to the list of directories that will be searched for
header files. The compiler is instructed to search directories in
the order in which they are supplied by successive calls to
'add_include_dir()'.
| def add_include_dir(self, dir):
"""Add 'dir' to the list of directories that will be searched for
header files. The compiler is instructed to search directories in
the order in which they are supplied by successive calls to
'add_include_dir()'.
"""
self.include_dirs.appe... | [
"def",
"add_include_dir",
"(",
"self",
",",
"dir",
")",
":",
"self",
".",
"include_dirs",
".",
"append",
"(",
"dir",
")"
] | [
216,
4
] | [
222,
37
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_include_dirs | (self, dirs) | Set the list of directories that will be searched to 'dirs' (a
list of strings). Overrides any preceding calls to
'add_include_dir()'; subsequence calls to 'add_include_dir()' add
to the list passed to 'set_include_dirs()'. This does not affect
any list of standard include directories ... | Set the list of directories that will be searched to 'dirs' (a
list of strings). Overrides any preceding calls to
'add_include_dir()'; subsequence calls to 'add_include_dir()' add
to the list passed to 'set_include_dirs()'. This does not affect
any list of standard include directories ... | def set_include_dirs(self, dirs):
"""Set the list of directories that will be searched to 'dirs' (a
list of strings). Overrides any preceding calls to
'add_include_dir()'; subsequence calls to 'add_include_dir()' add
to the list passed to 'set_include_dirs()'. This does not affect
... | [
"def",
"set_include_dirs",
"(",
"self",
",",
"dirs",
")",
":",
"self",
".",
"include_dirs",
"=",
"dirs",
"[",
":",
"]"
] | [
224,
4
] | [
232,
35
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_library | (self, libname) | Add 'libname' to the list of libraries that will be included in
all links driven by this compiler object. Note that 'libname'
should *not* be the name of a file containing a library, but the
name of the library itself: the actual filename will be inferred by
the linker, the compiler, or... | Add 'libname' to the list of libraries that will be included in
all links driven by this compiler object. Note that 'libname'
should *not* be the name of a file containing a library, but the
name of the library itself: the actual filename will be inferred by
the linker, the compiler, or... | def add_library(self, libname):
"""Add 'libname' to the list of libraries that will be included in
all links driven by this compiler object. Note that 'libname'
should *not* be the name of a file containing a library, but the
name of the library itself: the actual filename will be infer... | [
"def",
"add_library",
"(",
"self",
",",
"libname",
")",
":",
"self",
".",
"libraries",
".",
"append",
"(",
"libname",
")"
] | [
234,
4
] | [
248,
38
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_libraries | (self, libnames) | Set the list of libraries to be included in all links driven by
this compiler object to 'libnames' (a list of strings). This does
not affect any standard system libraries that the linker may
include by default.
| Set the list of libraries to be included in all links driven by
this compiler object to 'libnames' (a list of strings). This does
not affect any standard system libraries that the linker may
include by default.
| def set_libraries(self, libnames):
"""Set the list of libraries to be included in all links driven by
this compiler object to 'libnames' (a list of strings). This does
not affect any standard system libraries that the linker may
include by default.
"""
self.libraries = l... | [
"def",
"set_libraries",
"(",
"self",
",",
"libnames",
")",
":",
"self",
".",
"libraries",
"=",
"libnames",
"[",
":",
"]"
] | [
250,
4
] | [
256,
36
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_library_dir | (self, dir) | Add 'dir' to the list of directories that will be searched for
libraries specified to 'add_library()' and 'set_libraries()'. The
linker will be instructed to search for libraries in the order they
are supplied to 'add_library_dir()' and/or 'set_library_dirs()'.
| Add 'dir' to the list of directories that will be searched for
libraries specified to 'add_library()' and 'set_libraries()'. The
linker will be instructed to search for libraries in the order they
are supplied to 'add_library_dir()' and/or 'set_library_dirs()'.
| def add_library_dir(self, dir):
"""Add 'dir' to the list of directories that will be searched for
libraries specified to 'add_library()' and 'set_libraries()'. The
linker will be instructed to search for libraries in the order they
are supplied to 'add_library_dir()' and/or 'set_library... | [
"def",
"add_library_dir",
"(",
"self",
",",
"dir",
")",
":",
"self",
".",
"library_dirs",
".",
"append",
"(",
"dir",
")"
] | [
258,
4
] | [
264,
37
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_library_dirs | (self, dirs) | Set the list of library search directories to 'dirs' (a list of
strings). This does not affect any standard library search path
that the linker may search by default.
| Set the list of library search directories to 'dirs' (a list of
strings). This does not affect any standard library search path
that the linker may search by default.
| def set_library_dirs(self, dirs):
"""Set the list of library search directories to 'dirs' (a list of
strings). This does not affect any standard library search path
that the linker may search by default.
"""
self.library_dirs = dirs[:] | [
"def",
"set_library_dirs",
"(",
"self",
",",
"dirs",
")",
":",
"self",
".",
"library_dirs",
"=",
"dirs",
"[",
":",
"]"
] | [
266,
4
] | [
271,
35
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_runtime_library_dir | (self, dir) | Add 'dir' to the list of directories that will be searched for
shared libraries at runtime.
| Add 'dir' to the list of directories that will be searched for
shared libraries at runtime.
| def add_runtime_library_dir(self, dir):
"""Add 'dir' to the list of directories that will be searched for
shared libraries at runtime.
"""
self.runtime_library_dirs.append(dir) | [
"def",
"add_runtime_library_dir",
"(",
"self",
",",
"dir",
")",
":",
"self",
".",
"runtime_library_dirs",
".",
"append",
"(",
"dir",
")"
] | [
273,
4
] | [
277,
45
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_runtime_library_dirs | (self, dirs) | Set the list of directories to search for shared libraries at
runtime to 'dirs' (a list of strings). This does not affect any
standard search path that the runtime linker may search by
default.
| Set the list of directories to search for shared libraries at
runtime to 'dirs' (a list of strings). This does not affect any
standard search path that the runtime linker may search by
default.
| def set_runtime_library_dirs(self, dirs):
"""Set the list of directories to search for shared libraries at
runtime to 'dirs' (a list of strings). This does not affect any
standard search path that the runtime linker may search by
default.
"""
self.runtime_library_dirs = ... | [
"def",
"set_runtime_library_dirs",
"(",
"self",
",",
"dirs",
")",
":",
"self",
".",
"runtime_library_dirs",
"=",
"dirs",
"[",
":",
"]"
] | [
279,
4
] | [
285,
43
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.add_link_object | (self, object) | Add 'object' to the list of object files (or analogues, such as
explicitly named library files or the output of "resource
compilers") to be included in every link driven by this compiler
object.
| Add 'object' to the list of object files (or analogues, such as
explicitly named library files or the output of "resource
compilers") to be included in every link driven by this compiler
object.
| def add_link_object(self, object):
"""Add 'object' to the list of object files (or analogues, such as
explicitly named library files or the output of "resource
compilers") to be included in every link driven by this compiler
object.
"""
self.objects.append(object) | [
"def",
"add_link_object",
"(",
"self",
",",
"object",
")",
":",
"self",
".",
"objects",
".",
"append",
"(",
"object",
")"
] | [
287,
4
] | [
293,
35
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.set_link_objects | (self, objects) | Set the list of object files (or analogues) to be included in
every link to 'objects'. This does not affect any standard object
files that the linker may include by default (such as system
libraries).
| Set the list of object files (or analogues) to be included in
every link to 'objects'. This does not affect any standard object
files that the linker may include by default (such as system
libraries).
| def set_link_objects(self, objects):
"""Set the list of object files (or analogues) to be included in
every link to 'objects'. This does not affect any standard object
files that the linker may include by default (such as system
libraries).
"""
self.objects = objects[:] | [
"def",
"set_link_objects",
"(",
"self",
",",
"objects",
")",
":",
"self",
".",
"objects",
"=",
"objects",
"[",
":",
"]"
] | [
295,
4
] | [
301,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._setup_compile | (self, outdir, macros, incdirs, sources, depends,
extra) | Process arguments and decide which source files to compile. | Process arguments and decide which source files to compile. | def _setup_compile(self, outdir, macros, incdirs, sources, depends,
extra):
"""Process arguments and decide which source files to compile."""
if outdir is None:
outdir = self.output_dir
elif not isinstance(outdir, str):
raise TypeError("'output_dir'... | [
"def",
"_setup_compile",
"(",
"self",
",",
"outdir",
",",
"macros",
",",
"incdirs",
",",
"sources",
",",
"depends",
",",
"extra",
")",
":",
"if",
"outdir",
"is",
"None",
":",
"outdir",
"=",
"self",
".",
"output_dir",
"elif",
"not",
"isinstance",
"(",
"... | [
309,
4
] | [
350,
53
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._fix_compile_args | (self, output_dir, macros, include_dirs) | Typecheck and fix-up some of the arguments to the 'compile()'
method, and return fixed-up values. Specifically: if 'output_dir'
is None, replaces it with 'self.output_dir'; ensures that 'macros'
is a list, and augments it with 'self.macros'; ensures that
'include_dirs' is a list, and au... | Typecheck and fix-up some of the arguments to the 'compile()'
method, and return fixed-up values. Specifically: if 'output_dir'
is None, replaces it with 'self.output_dir'; ensures that 'macros'
is a list, and augments it with 'self.macros'; ensures that
'include_dirs' is a list, and au... | def _fix_compile_args(self, output_dir, macros, include_dirs):
"""Typecheck and fix-up some of the arguments to the 'compile()'
method, and return fixed-up values. Specifically: if 'output_dir'
is None, replaces it with 'self.output_dir'; ensures that 'macros'
is a list, and augments it... | [
"def",
"_fix_compile_args",
"(",
"self",
",",
"output_dir",
",",
"macros",
",",
"include_dirs",
")",
":",
"if",
"output_dir",
"is",
"None",
":",
"output_dir",
"=",
"self",
".",
"output_dir",
"elif",
"not",
"isinstance",
"(",
"output_dir",
",",
"str",
")",
... | [
361,
4
] | [
391,
47
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._prep_compile | (self, sources, output_dir, depends=None) | Decide which souce files must be recompiled.
Determine the list of object files corresponding to 'sources',
and figure out which ones really need to be recompiled.
Return a list of all object files and a dictionary telling
which source files can be skipped.
| Decide which souce files must be recompiled. | def _prep_compile(self, sources, output_dir, depends=None):
"""Decide which souce files must be recompiled.
Determine the list of object files corresponding to 'sources',
and figure out which ones really need to be recompiled.
Return a list of all object files and a dictionary telling
... | [
"def",
"_prep_compile",
"(",
"self",
",",
"sources",
",",
"output_dir",
",",
"depends",
"=",
"None",
")",
":",
"# Get the list of expected output (object) files",
"objects",
"=",
"self",
".",
"object_filenames",
"(",
"sources",
",",
"output_dir",
"=",
"output_dir",
... | [
393,
4
] | [
407,
26
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._fix_object_args | (self, objects, output_dir) | Typecheck and fix up some arguments supplied to various methods.
Specifically: ensure that 'objects' is a list; if output_dir is
None, replace with self.output_dir. Return fixed versions of
'objects' and 'output_dir'.
| Typecheck and fix up some arguments supplied to various methods.
Specifically: ensure that 'objects' is a list; if output_dir is
None, replace with self.output_dir. Return fixed versions of
'objects' and 'output_dir'.
| def _fix_object_args(self, objects, output_dir):
"""Typecheck and fix up some arguments supplied to various methods.
Specifically: ensure that 'objects' is a list; if output_dir is
None, replace with self.output_dir. Return fixed versions of
'objects' and 'output_dir'.
"""
... | [
"def",
"_fix_object_args",
"(",
"self",
",",
"objects",
",",
"output_dir",
")",
":",
"if",
"not",
"isinstance",
"(",
"objects",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"'objects' must be a list or tuple of strings\"",
")",
"... | [
409,
4
] | [
424,
36
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._fix_lib_args | (self, libraries, library_dirs, runtime_library_dirs) | Typecheck and fix up some of the arguments supplied to the
'link_*' methods. Specifically: ensure that all arguments are
lists, and augment them with their permanent versions
(eg. 'self.libraries' augments 'libraries'). Return a tuple with
fixed versions of all arguments.
| Typecheck and fix up some of the arguments supplied to the
'link_*' methods. Specifically: ensure that all arguments are
lists, and augment them with their permanent versions
(eg. 'self.libraries' augments 'libraries'). Return a tuple with
fixed versions of all arguments.
| def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs):
"""Typecheck and fix up some of the arguments supplied to the
'link_*' methods. Specifically: ensure that all arguments are
lists, and augment them with their permanent versions
(eg. 'self.libraries' augments 'libra... | [
"def",
"_fix_lib_args",
"(",
"self",
",",
"libraries",
",",
"library_dirs",
",",
"runtime_library_dirs",
")",
":",
"if",
"libraries",
"is",
"None",
":",
"libraries",
"=",
"self",
".",
"libraries",
"elif",
"isinstance",
"(",
"libraries",
",",
"(",
"list",
","... | [
426,
4
] | [
458,
62
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._need_link | (self, objects, output_file) | Return true if we need to relink the files listed in 'objects'
to recreate 'output_file'.
| Return true if we need to relink the files listed in 'objects'
to recreate 'output_file'.
| def _need_link(self, objects, output_file):
"""Return true if we need to relink the files listed in 'objects'
to recreate 'output_file'.
"""
if self.force:
return True
else:
if self.dry_run:
newer = newer_group (objects, output_file, missin... | [
"def",
"_need_link",
"(",
"self",
",",
"objects",
",",
"output_file",
")",
":",
"if",
"self",
".",
"force",
":",
"return",
"True",
"else",
":",
"if",
"self",
".",
"dry_run",
":",
"newer",
"=",
"newer_group",
"(",
"objects",
",",
"output_file",
",",
"mi... | [
460,
4
] | [
471,
24
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.detect_language | (self, sources) | Detect the language of a given file, or list of files. Uses
language_map, and language_order to do the job.
| Detect the language of a given file, or list of files. Uses
language_map, and language_order to do the job.
| def detect_language(self, sources):
"""Detect the language of a given file, or list of files. Uses
language_map, and language_order to do the job.
"""
if not isinstance(sources, list):
sources = [sources]
lang = None
index = len(self.language_order)
fo... | [
"def",
"detect_language",
"(",
"self",
",",
"sources",
")",
":",
"if",
"not",
"isinstance",
"(",
"sources",
",",
"list",
")",
":",
"sources",
"=",
"[",
"sources",
"]",
"lang",
"=",
"None",
"index",
"=",
"len",
"(",
"self",
".",
"language_order",
")",
... | [
473,
4
] | [
491,
19
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.preprocess | (self, source, output_file=None, macros=None,
include_dirs=None, extra_preargs=None, extra_postargs=None) | Preprocess a single C/C++ source file, named in 'source'.
Output will be written to file named 'output_file', or stdout if
'output_file' not supplied. 'macros' is a list of macro
definitions as for 'compile()', which will augment the macros set
with 'define_macro()' and 'undefine_macro(... | Preprocess a single C/C++ source file, named in 'source'.
Output will be written to file named 'output_file', or stdout if
'output_file' not supplied. 'macros' is a list of macro
definitions as for 'compile()', which will augment the macros set
with 'define_macro()' and 'undefine_macro(... | def preprocess(self, source, output_file=None, macros=None,
include_dirs=None, extra_preargs=None, extra_postargs=None):
"""Preprocess a single C/C++ source file, named in 'source'.
Output will be written to file named 'output_file', or stdout if
'output_file' not supplied. '... | [
"def",
"preprocess",
"(",
"self",
",",
"source",
",",
"output_file",
"=",
"None",
",",
"macros",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"extra_preargs",
"=",
"None",
",",
"extra_postargs",
"=",
"None",
")",
":",
"pass"
] | [
497,
4
] | [
508,
12
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.compile | (self, sources, output_dir=None, macros=None,
include_dirs=None, debug=0, extra_preargs=None,
extra_postargs=None, depends=None) | Compile one or more source files.
'sources' must be a list of filenames, most likely C/C++
files, but in reality anything that can be handled by a
particular compiler and compiler class (eg. MSVCCompiler can
handle resource files in 'sources'). Return a list of object
filenames... | Compile one or more source files. | def compile(self, sources, output_dir=None, macros=None,
include_dirs=None, debug=0, extra_preargs=None,
extra_postargs=None, depends=None):
"""Compile one or more source files.
'sources' must be a list of filenames, most likely C/C++
files, but in reality anythi... | [
"def",
"compile",
"(",
"self",
",",
"sources",
",",
"output_dir",
"=",
"None",
",",
"macros",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"debug",
"=",
"0",
",",
"extra_preargs",
"=",
"None",
",",
"extra_postargs",
"=",
"None",
",",
"depends",
... | [
510,
4
] | [
576,
22
] | python | en | ['en', 'en', 'en'] | True |
CCompiler._compile | (self, obj, src, ext, cc_args, extra_postargs, pp_opts) | Compile 'src' to product 'obj'. | Compile 'src' to product 'obj'. | def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
"""Compile 'src' to product 'obj'."""
# A concrete compiler class that does not override compile()
# should implement _compile().
pass | [
"def",
"_compile",
"(",
"self",
",",
"obj",
",",
"src",
",",
"ext",
",",
"cc_args",
",",
"extra_postargs",
",",
"pp_opts",
")",
":",
"# A concrete compiler class that does not override compile()",
"# should implement _compile().",
"pass"
] | [
578,
4
] | [
582,
12
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.create_static_lib | (self, objects, output_libname, output_dir=None,
debug=0, target_lang=None) | Link a bunch of stuff together to create a static library file.
The "bunch of stuff" consists of the list of object files supplied
as 'objects', the extra object files supplied to
'add_link_object()' and/or 'set_link_objects()', the libraries
supplied to 'add_library()' and/or 'set_libra... | Link a bunch of stuff together to create a static library file.
The "bunch of stuff" consists of the list of object files supplied
as 'objects', the extra object files supplied to
'add_link_object()' and/or 'set_link_objects()', the libraries
supplied to 'add_library()' and/or 'set_libra... | def create_static_lib(self, objects, output_libname, output_dir=None,
debug=0, target_lang=None):
"""Link a bunch of stuff together to create a static library file.
The "bunch of stuff" consists of the list of object files supplied
as 'objects', the extra object files s... | [
"def",
"create_static_lib",
"(",
"self",
",",
"objects",
",",
"output_libname",
",",
"output_dir",
"=",
"None",
",",
"debug",
"=",
"0",
",",
"target_lang",
"=",
"None",
")",
":",
"pass"
] | [
584,
4
] | [
608,
12
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.link | (self,
target_desc,
objects,
output_filename,
output_dir=None,
libraries=None,
library_dirs=None,
runtime_library_dirs=None,
export_symbols=None,
debug=0,
extra_preargs=None,
ex... | Link a bunch of stuff together to create an executable or
shared library file.
The "bunch of stuff" consists of the list of object files supplied
as 'objects'. 'output_filename' should be a filename. If
'output_dir' is supplied, 'output_filename' is relative to it
(i.e. 'outpu... | Link a bunch of stuff together to create an executable or
shared library file. | def link(self,
target_desc,
objects,
output_filename,
output_dir=None,
libraries=None,
library_dirs=None,
runtime_library_dirs=None,
export_symbols=None,
debug=0,
extra_preargs=None,
... | [
"def",
"link",
"(",
"self",
",",
"target_desc",
",",
"objects",
",",
"output_filename",
",",
"output_dir",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"runtime_library_dirs",
"=",
"None",
",",
"export_symbols",
"=",
"No... | [
616,
4
] | [
673,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.library_dir_option | (self, dir) | Return the compiler option to add 'dir' to the list of
directories searched for libraries.
| Return the compiler option to add 'dir' to the list of
directories searched for libraries.
| def library_dir_option(self, dir):
"""Return the compiler option to add 'dir' to the list of
directories searched for libraries.
"""
raise NotImplementedError | [
"def",
"library_dir_option",
"(",
"self",
",",
"dir",
")",
":",
"raise",
"NotImplementedError"
] | [
741,
4
] | [
745,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.runtime_library_dir_option | (self, dir) | Return the compiler option to add 'dir' to the list of
directories searched for runtime libraries.
| Return the compiler option to add 'dir' to the list of
directories searched for runtime libraries.
| def runtime_library_dir_option(self, dir):
"""Return the compiler option to add 'dir' to the list of
directories searched for runtime libraries.
"""
raise NotImplementedError | [
"def",
"runtime_library_dir_option",
"(",
"self",
",",
"dir",
")",
":",
"raise",
"NotImplementedError"
] | [
747,
4
] | [
751,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.library_option | (self, lib) | Return the compiler option to add 'lib' to the list of libraries
linked into the shared library or executable.
| Return the compiler option to add 'lib' to the list of libraries
linked into the shared library or executable.
| def library_option(self, lib):
"""Return the compiler option to add 'lib' to the list of libraries
linked into the shared library or executable.
"""
raise NotImplementedError | [
"def",
"library_option",
"(",
"self",
",",
"lib",
")",
":",
"raise",
"NotImplementedError"
] | [
753,
4
] | [
757,
33
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.has_function | (self, funcname, includes=None, include_dirs=None,
libraries=None, library_dirs=None) | Return a boolean indicating whether funcname is supported on
the current platform. The optional arguments can be used to
augment the compilation environment.
| Return a boolean indicating whether funcname is supported on
the current platform. The optional arguments can be used to
augment the compilation environment.
| def has_function(self, funcname, includes=None, include_dirs=None,
libraries=None, library_dirs=None):
"""Return a boolean indicating whether funcname is supported on
the current platform. The optional arguments can be used to
augment the compilation environment.
""... | [
"def",
"has_function",
"(",
"self",
",",
"funcname",
",",
"includes",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
")",
":",
"# this can't be included at module scope because it tries to",
"# import ... | [
759,
4
] | [
801,
19
] | python | en | ['en', 'en', 'en'] | True |
CCompiler.find_library_file | (self, dirs, lib, debug=0) | Search the specified list of directories for a static or shared
library file 'lib' and return the full path to that file. If
'debug' true, look for a debugging version (if that makes sense on
the current platform). Return None if 'lib' wasn't found in any of
the specified directories.
... | Search the specified list of directories for a static or shared
library file 'lib' and return the full path to that file. If
'debug' true, look for a debugging version (if that makes sense on
the current platform). Return None if 'lib' wasn't found in any of
the specified directories.
... | def find_library_file (self, dirs, lib, debug=0):
"""Search the specified list of directories for a static or shared
library file 'lib' and return the full path to that file. If
'debug' true, look for a debugging version (if that makes sense on
the current platform). Return None if 'li... | [
"def",
"find_library_file",
"(",
"self",
",",
"dirs",
",",
"lib",
",",
"debug",
"=",
"0",
")",
":",
"raise",
"NotImplementedError"
] | [
803,
4
] | [
810,
33
] | python | en | ['en', 'en', 'en'] | True |
_dnsname_match | (dn, hostname, max_wildcards=1) | Matching according to RFC 6125, section 6.4.3
http://tools.ietf.org/html/rfc6125#section-6.4.3
| Matching according to RFC 6125, section 6.4.3 | def _dnsname_match(dn, hostname, max_wildcards=1):
"""Matching according to RFC 6125, section 6.4.3
http://tools.ietf.org/html/rfc6125#section-6.4.3
"""
pats = []
if not dn:
return False
# Ported from python3-syntax:
# leftmost, *remainder = dn.split(r'.')
parts = dn.split(r"."... | [
"def",
"_dnsname_match",
"(",
"dn",
",",
"hostname",
",",
"max_wildcards",
"=",
"1",
")",
":",
"pats",
"=",
"[",
"]",
"if",
"not",
"dn",
":",
"return",
"False",
"# Ported from python3-syntax:",
"# leftmost, *remainder = dn.split(r'.')",
"parts",
"=",
"dn",
".",
... | [
24,
0
] | [
75,
30
] | python | en | ['en', 'en', 'en'] | True |
_ipaddress_match | (ipname, host_ip) | Exact matching of IP addresses.
RFC 6125 explicitly doesn't define an algorithm for this
(section 1.7.2 - "Out of Scope").
| Exact matching of IP addresses. | def _ipaddress_match(ipname, host_ip):
"""Exact matching of IP addresses.
RFC 6125 explicitly doesn't define an algorithm for this
(section 1.7.2 - "Out of Scope").
"""
# OpenSSL may add a trailing newline to a subjectAltName's IP address
# Divergence from upstream: ipaddress can't handle byte ... | [
"def",
"_ipaddress_match",
"(",
"ipname",
",",
"host_ip",
")",
":",
"# OpenSSL may add a trailing newline to a subjectAltName's IP address",
"# Divergence from upstream: ipaddress can't handle byte str",
"ip",
"=",
"ipaddress",
".",
"ip_address",
"(",
"_to_unicode",
"(",
"ipname"... | [
84,
0
] | [
93,
24
] | python | en | ['en', 'sn', 'en'] | True |
match_hostname | (cert, hostname) | Verify that *cert* (in decoded format as returned by
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
rules are followed, but IP addresses are not accepted for *hostname*.
CertificateError is raised on failure. On success, the function
returns nothing.
| Verify that *cert* (in decoded format as returned by
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
rules are followed, but IP addresses are not accepted for *hostname*. | def match_hostname(cert, hostname):
"""Verify that *cert* (in decoded format as returned by
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
rules are followed, but IP addresses are not accepted for *hostname*.
CertificateError is raised on failure. On success, the function
r... | [
"def",
"match_hostname",
"(",
"cert",
",",
"hostname",
")",
":",
"if",
"not",
"cert",
":",
"raise",
"ValueError",
"(",
"\"empty or no certificate, match_hostname needs a \"",
"\"SSL socket or SSL context with either \"",
"\"CERT_OPTIONAL or CERT_REQUIRED\"",
")",
"try",
":",
... | [
96,
0
] | [
159,
9
] | python | en | ['en', 'en', 'en'] | True |
StreamAdminTest.test_stream_message_retention_days_on_stream_creation | (self) |
Only admins can create streams with message_retention_days
with value other than None.
|
Only admins can create streams with message_retention_days
with value other than None.
| def test_stream_message_retention_days_on_stream_creation(self) -> None:
"""
Only admins can create streams with message_retention_days
with value other than None.
"""
admin = self.example_user("iago")
streams_raw: List[StreamDict] = [
{
"name... | [
"def",
"test_stream_message_retention_days_on_stream_creation",
"(",
"self",
")",
"->",
"None",
":",
"admin",
"=",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
"streams_raw",
":",
"List",
"[",
"StreamDict",
"]",
"=",
"[",
"{",
"\"name\"",
":",
"\"new_strea... | [
1295,
4
] | [
1355,
67
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.set_up_stream_for_archiving | (
self, stream_name: str, invite_only: bool = False, subscribed: bool = True
) |
Create a stream for archiving by an administrator.
|
Create a stream for archiving by an administrator.
| def set_up_stream_for_archiving(
self, stream_name: str, invite_only: bool = False, subscribed: bool = True
) -> Stream:
"""
Create a stream for archiving by an administrator.
"""
user_profile = self.example_user("hamlet")
self.login_user(user_profile)
stream ... | [
"def",
"set_up_stream_for_archiving",
"(",
"self",
",",
"stream_name",
":",
"str",
",",
"invite_only",
":",
"bool",
"=",
"False",
",",
"subscribed",
":",
"bool",
"=",
"True",
")",
"->",
"Stream",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
... | [
1357,
4
] | [
1373,
21
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.archive_stream | (self, stream: Stream) |
Archive the stream and assess the result.
|
Archive the stream and assess the result.
| def archive_stream(self, stream: Stream) -> None:
"""
Archive the stream and assess the result.
"""
active_name = stream.name
realm = stream.realm
stream_id = stream.id
# Simulate that a stream by the same name has already been
# deactivated, just to exer... | [
"def",
"archive_stream",
"(",
"self",
",",
"stream",
":",
"Stream",
")",
"->",
"None",
":",
"active_name",
"=",
"stream",
".",
"name",
"realm",
"=",
"stream",
".",
"realm",
"stream_id",
"=",
"stream",
".",
"id",
"# Simulate that a stream by the same name has alr... | [
1375,
4
] | [
1428,
95
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_you_must_be_realm_admin | (self) |
You must be on the realm to create a stream.
|
You must be on the realm to create a stream.
| def test_you_must_be_realm_admin(self) -> None:
"""
You must be on the realm to create a stream.
"""
user_profile = self.example_user("hamlet")
self.login_user(user_profile)
other_realm = do_create_realm(string_id="other", name="other")
stream = self.make_stream(... | [
"def",
"test_you_must_be_realm_admin",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"user_profile",
")",
"other_realm",
"=",
"do_create_realm",
"(",
"string_id",
"=... | [
1430,
4
] | [
1447,
59
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_delete_public_stream | (self) |
When an administrator deletes a public stream, that stream is not
visible to users at all anymore.
|
When an administrator deletes a public stream, that stream is not
visible to users at all anymore.
| def test_delete_public_stream(self) -> None:
"""
When an administrator deletes a public stream, that stream is not
visible to users at all anymore.
"""
stream = self.set_up_stream_for_archiving("newstream")
self.archive_stream(stream) | [
"def",
"test_delete_public_stream",
"(",
"self",
")",
"->",
"None",
":",
"stream",
"=",
"self",
".",
"set_up_stream_for_archiving",
"(",
"\"newstream\"",
")",
"self",
".",
"archive_stream",
"(",
"stream",
")"
] | [
1449,
4
] | [
1455,
35
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_delete_private_stream | (self) |
Administrators can delete private streams they are on.
|
Administrators can delete private streams they are on.
| def test_delete_private_stream(self) -> None:
"""
Administrators can delete private streams they are on.
"""
stream = self.set_up_stream_for_archiving("newstream", invite_only=True)
self.archive_stream(stream) | [
"def",
"test_delete_private_stream",
"(",
"self",
")",
"->",
"None",
":",
"stream",
"=",
"self",
".",
"set_up_stream_for_archiving",
"(",
"\"newstream\"",
",",
"invite_only",
"=",
"True",
")",
"self",
".",
"archive_stream",
"(",
"stream",
")"
] | [
1457,
4
] | [
1462,
35
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_archive_streams_youre_not_on | (self) |
Administrators can delete public streams they aren't on, including
private streams in their realm.
|
Administrators can delete public streams they aren't on, including
private streams in their realm.
| def test_archive_streams_youre_not_on(self) -> None:
"""
Administrators can delete public streams they aren't on, including
private streams in their realm.
"""
pub_stream = self.set_up_stream_for_archiving("pubstream", subscribed=False)
self.archive_stream(pub_stream)
... | [
"def",
"test_archive_streams_youre_not_on",
"(",
"self",
")",
"->",
"None",
":",
"pub_stream",
"=",
"self",
".",
"set_up_stream_for_archiving",
"(",
"\"pubstream\"",
",",
"subscribed",
"=",
"False",
")",
"self",
".",
"archive_stream",
"(",
"pub_stream",
")",
"priv... | [
1464,
4
] | [
1475,
40
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_cant_remove_others_from_stream | (self) |
If you're not an admin, you can't remove other people from streams.
|
If you're not an admin, you can't remove other people from streams.
| def test_cant_remove_others_from_stream(self) -> None:
"""
If you're not an admin, you can't remove other people from streams.
"""
result = self.attempt_unsubscribe_of_principal(
query_count=5,
target_users=[self.example_user("cordelia")],
is_realm_adm... | [
"def",
"test_cant_remove_others_from_stream",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"attempt_unsubscribe_of_principal",
"(",
"query_count",
"=",
"5",
",",
"target_users",
"=",
"[",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
... | [
1551,
4
] | [
1564,
89
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_realm_admin_remove_others_from_public_stream | (self) |
If you're a realm admin, you can remove people from public streams, even
those you aren't on.
|
If you're a realm admin, you can remove people from public streams, even
those you aren't on.
| def test_realm_admin_remove_others_from_public_stream(self) -> None:
"""
If you're a realm admin, you can remove people from public streams, even
those you aren't on.
"""
result = self.attempt_unsubscribe_of_principal(
query_count=16,
target_users=[self.ex... | [
"def",
"test_realm_admin_remove_others_from_public_stream",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"attempt_unsubscribe_of_principal",
"(",
"query_count",
"=",
"16",
",",
"target_users",
"=",
"[",
"self",
".",
"example_user",
"(",
"\"cordel... | [
1566,
4
] | [
1581,
53
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_realm_admin_remove_multiple_users_from_stream | (self) |
If you're a realm admin, you can remove multiple users from a stream.
TODO: We have too many queries for this situation--each additional
user leads to 4 more queries.
Fortunately, some of the extra work here is in
do_mark_stream_messages_as_read, which gets d... |
If you're a realm admin, you can remove multiple users from a stream. | def test_realm_admin_remove_multiple_users_from_stream(self) -> None:
"""
If you're a realm admin, you can remove multiple users from a stream.
TODO: We have too many queries for this situation--each additional
user leads to 4 more queries.
Fortunately, some of the ... | [
"def",
"test_realm_admin_remove_multiple_users_from_stream",
"(",
"self",
")",
"->",
"None",
":",
"target_users",
"=",
"[",
"self",
".",
"example_user",
"(",
"name",
")",
"for",
"name",
"in",
"[",
"\"cordelia\"",
",",
"\"prospero\"",
",",
"\"iago\"",
",",
"\"ham... | [
1583,
4
] | [
1608,
53
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_realm_admin_remove_others_from_subbed_private_stream | (self) |
If you're a realm admin, you can remove other people from private streams you
are on.
|
If you're a realm admin, you can remove other people from private streams you
are on.
| def test_realm_admin_remove_others_from_subbed_private_stream(self) -> None:
"""
If you're a realm admin, you can remove other people from private streams you
are on.
"""
result = self.attempt_unsubscribe_of_principal(
query_count=17,
target_users=[self.ex... | [
"def",
"test_realm_admin_remove_others_from_subbed_private_stream",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"attempt_unsubscribe_of_principal",
"(",
"query_count",
"=",
"17",
",",
"target_users",
"=",
"[",
"self",
".",
"example_user",
"(",
"... | [
1610,
4
] | [
1625,
53
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_realm_admin_remove_others_from_unsubbed_private_stream | (self) |
If you're a realm admin, you can remove people from private
streams you aren't on.
|
If you're a realm admin, you can remove people from private
streams you aren't on.
| def test_realm_admin_remove_others_from_unsubbed_private_stream(self) -> None:
"""
If you're a realm admin, you can remove people from private
streams you aren't on.
"""
result = self.attempt_unsubscribe_of_principal(
query_count=17,
target_users=[self.exa... | [
"def",
"test_realm_admin_remove_others_from_unsubbed_private_stream",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"attempt_unsubscribe_of_principal",
"(",
"query_count",
"=",
"17",
",",
"target_users",
"=",
"[",
"self",
".",
"example_user",
"(",
... | [
1627,
4
] | [
1643,
53
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_stream_admin_remove_others_from_public_stream | (self) |
You can remove others from public streams you're a stream administrator of.
|
You can remove others from public streams you're a stream administrator of.
| def test_stream_admin_remove_others_from_public_stream(self) -> None:
"""
You can remove others from public streams you're a stream administrator of.
"""
result = self.attempt_unsubscribe_of_principal(
query_count=16,
target_users=[self.example_user("cordelia")],
... | [
"def",
"test_stream_admin_remove_others_from_public_stream",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"attempt_unsubscribe_of_principal",
"(",
"query_count",
"=",
"16",
",",
"target_users",
"=",
"[",
"self",
".",
"example_user",
"(",
"\"corde... | [
1645,
4
] | [
1660,
53
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_stream_admin_remove_multiple_users_from_stream | (self) |
You can remove multiple users from public streams you're a stream administrator of.
|
You can remove multiple users from public streams you're a stream administrator of.
| def test_stream_admin_remove_multiple_users_from_stream(self) -> None:
"""
You can remove multiple users from public streams you're a stream administrator of.
"""
target_users = [
self.example_user(name) for name in ["cordelia", "prospero", "othello", "hamlet", "ZOE"]
... | [
"def",
"test_stream_admin_remove_multiple_users_from_stream",
"(",
"self",
")",
"->",
"None",
":",
"target_users",
"=",
"[",
"self",
".",
"example_user",
"(",
"name",
")",
"for",
"name",
"in",
"[",
"\"cordelia\"",
",",
"\"prospero\"",
",",
"\"othello\"",
",",
"\... | [
1662,
4
] | [
1681,
53
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_stream_admin_remove_others_from_private_stream | (self) |
You can remove others from private streams you're a stream administrator of.
|
You can remove others from private streams you're a stream administrator of.
| def test_stream_admin_remove_others_from_private_stream(self) -> None:
"""
You can remove others from private streams you're a stream administrator of.
"""
result = self.attempt_unsubscribe_of_principal(
query_count=17,
target_users=[self.example_user("cordelia")]... | [
"def",
"test_stream_admin_remove_others_from_private_stream",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"attempt_unsubscribe_of_principal",
"(",
"query_count",
"=",
"17",
",",
"target_users",
"=",
"[",
"self",
".",
"example_user",
"(",
"\"cord... | [
1683,
4
] | [
1698,
53
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_create_stream_policy_setting | (self) |
When realm.create_stream_policy setting is Realm.POLICY_MEMBERS_ONLY then
test that any user can create a stream.
When realm.create_stream_policy setting is Realm.POLICY_ADMINS_ONLY then
test that only admins can create a stream.
When realm.create_stream_policy setting is Real... |
When realm.create_stream_policy setting is Realm.POLICY_MEMBERS_ONLY then
test that any user can create a stream. | def test_create_stream_policy_setting(self) -> None:
"""
When realm.create_stream_policy setting is Realm.POLICY_MEMBERS_ONLY then
test that any user can create a stream.
When realm.create_stream_policy setting is Realm.POLICY_ADMINS_ONLY then
test that only admins can create a ... | [
"def",
"test_create_stream_policy_setting",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"user_profile",
".",
"date_joined",
"=",
"timezone_now",
"(",
")",
"user_profile",
".",
"save",
"(",
")",
... | [
1741,
4
] | [
1821,
67
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_invite_to_stream_by_invite_period_threshold | (self) |
Non admin users with account age greater or equal to the invite
to stream threshold should be able to invite others to a stream.
|
Non admin users with account age greater or equal to the invite
to stream threshold should be able to invite others to a stream.
| def test_invite_to_stream_by_invite_period_threshold(self) -> None:
"""
Non admin users with account age greater or equal to the invite
to stream threshold should be able to invite others to a stream.
"""
hamlet_user = self.example_user("hamlet")
hamlet_user.date_joined =... | [
"def",
"test_invite_to_stream_by_invite_period_threshold",
"(",
"self",
")",
"->",
"None",
":",
"hamlet_user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"hamlet_user",
".",
"date_joined",
"=",
"timezone_now",
"(",
")",
"hamlet_user",
".",
"save",
"... | [
1823,
4
] | [
1883,
9
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_remove_already_not_subbed | (self) |
Trying to unsubscribe someone who already isn't subscribed to a stream
fails gracefully.
|
Trying to unsubscribe someone who already isn't subscribed to a stream
fails gracefully.
| def test_remove_already_not_subbed(self) -> None:
"""
Trying to unsubscribe someone who already isn't subscribed to a stream
fails gracefully.
"""
result = self.attempt_unsubscribe_of_principal(
query_count=10,
target_users=[self.example_user("cordelia")],... | [
"def",
"test_remove_already_not_subbed",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"attempt_unsubscribe_of_principal",
"(",
"query_count",
"=",
"10",
",",
"target_users",
"=",
"[",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"]"... | [
1885,
4
] | [
1900,
53
] | python | en | ['en', 'error', 'th'] | False |
StreamAdminTest.test_remove_invalid_user | (self) |
Trying to unsubscribe an invalid user from a stream fails gracefully.
|
Trying to unsubscribe an invalid user from a stream fails gracefully.
| def test_remove_invalid_user(self) -> None:
"""
Trying to unsubscribe an invalid user from a stream fails gracefully.
"""
admin = self.example_user("iago")
self.login_user(admin)
self.assertTrue(admin.is_realm_admin)
stream_name = "hümbüǵ"
self.make_strea... | [
"def",
"test_remove_invalid_user",
"(",
"self",
")",
"->",
"None",
":",
"admin",
"=",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
"self",
".",
"login_user",
"(",
"admin",
")",
"self",
".",
"assertTrue",
"(",
"admin",
".",
"is_realm_admin",
")",
"str... | [
1902,
4
] | [
1922,
9
] | python | en | ['en', 'error', 'th'] | False |
SubscriptionPropertiesTest.test_set_stream_color | (self) |
A POST request to /api/v1/users/me/subscriptions/properties with stream_id and
color data sets the stream color, and for that stream only. Also, make sure that
any invalid hex color codes are bounced.
|
A POST request to /api/v1/users/me/subscriptions/properties with stream_id and
color data sets the stream color, and for that stream only. Also, make sure that
any invalid hex color codes are bounced.
| def test_set_stream_color(self) -> None:
"""
A POST request to /api/v1/users/me/subscriptions/properties with stream_id and
color data sets the stream color, and for that stream only. Also, make sure that
any invalid hex color codes are bounced.
"""
test_user = self.examp... | [
"def",
"test_set_stream_color",
"(",
"self",
")",
"->",
"None",
":",
"test_user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"test_user",
")",
"old_subs",
",",
"_",
"=",
"gather_subscriptions",
"(",
"test_user",
... | [
2348,
4
] | [
2372,
53
] | python | en | ['en', 'error', 'th'] | False |
OneHotEncoding.num_classes | (self) | The number of distinct event encodings.
Returns:
An int, the range of ints that can be returned by self.encode_event.
| The number of distinct event encodings. | def num_classes(self):
"""The number of distinct event encodings.
Returns:
An int, the range of ints that can be returned by self.encode_event.
"""
pass | [
"def",
"num_classes",
"(",
"self",
")",
":",
"pass"
] | [
60,
2
] | [
66,
8
] | python | en | ['en', 'en', 'en'] | True |
OneHotEncoding.default_event | (self) | An event value to use as a default.
Returns:
The default event value.
| An event value to use as a default. | def default_event(self):
"""An event value to use as a default.
Returns:
The default event value.
"""
pass | [
"def",
"default_event",
"(",
"self",
")",
":",
"pass"
] | [
69,
2
] | [
75,
8
] | python | en | ['en', 'en', 'en'] | True |
OneHotEncoding.encode_event | (self, event) | Convert from an event value to an encoding integer.
Args:
event: An event value to encode.
Returns:
An integer representing the encoded event, in range [0, self.num_classes).
| Convert from an event value to an encoding integer. | def encode_event(self, event):
"""Convert from an event value to an encoding integer.
Args:
event: An event value to encode.
Returns:
An integer representing the encoded event, in range [0, self.num_classes).
"""
pass | [
"def",
"encode_event",
"(",
"self",
",",
"event",
")",
":",
"pass"
] | [
78,
2
] | [
87,
8
] | python | en | ['en', 'en', 'en'] | True |
OneHotEncoding.decode_event | (self, index) | Convert from an encoding integer to an event value.
Args:
index: The encoding, an integer in the range [0, self.num_classes).
Returns:
The decoded event value.
| Convert from an encoding integer to an event value. | def decode_event(self, index):
"""Convert from an encoding integer to an event value.
Args:
index: The encoding, an integer in the range [0, self.num_classes).
Returns:
The decoded event value.
"""
pass | [
"def",
"decode_event",
"(",
"self",
",",
"index",
")",
":",
"pass"
] | [
90,
2
] | [
99,
8
] | python | en | ['en', 'en', 'en'] | True |
OneHotEncoding.event_to_num_steps | (self, unused_event) | Returns the number of time steps corresponding to an event value.
This is used for normalization when computing metrics. Subclasses with
variable step size should override this method.
Args:
unused_event: An event value for which to return the number of steps.
Returns:
The number of steps... | Returns the number of time steps corresponding to an event value. | def event_to_num_steps(self, unused_event):
"""Returns the number of time steps corresponding to an event value.
This is used for normalization when computing metrics. Subclasses with
variable step size should override this method.
Args:
unused_event: An event value for which to return the numbe... | [
"def",
"event_to_num_steps",
"(",
"self",
",",
"unused_event",
")",
":",
"return",
"1"
] | [
101,
2
] | [
114,
12
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.input_size | (self) | The size of the input vector used by this model.
Returns:
An integer, the length of the list returned by self.events_to_input.
| The size of the input vector used by this model. | def input_size(self):
"""The size of the input vector used by this model.
Returns:
An integer, the length of the list returned by self.events_to_input.
"""
pass | [
"def",
"input_size",
"(",
"self",
")",
":",
"pass"
] | [
147,
2
] | [
153,
8
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.num_classes | (self) | The range of labels used by this model.
Returns:
An integer, the range of integers that can be returned by
self.events_to_label.
| The range of labels used by this model. | def num_classes(self):
"""The range of labels used by this model.
Returns:
An integer, the range of integers that can be returned by
self.events_to_label.
"""
pass | [
"def",
"num_classes",
"(",
"self",
")",
":",
"pass"
] | [
156,
2
] | [
163,
8
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.default_event_label | (self) | The class label that represents a default event.
Returns:
An int, the class label that represents a default event.
| The class label that represents a default event. | def default_event_label(self):
"""The class label that represents a default event.
Returns:
An int, the class label that represents a default event.
"""
pass | [
"def",
"default_event_label",
"(",
"self",
")",
":",
"pass"
] | [
166,
2
] | [
172,
8
] | 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.