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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
TestGetRealmAndStreamsForArchiving.fix_ordering_of_result | (self, result: List[Tuple[Realm, List[Stream]]]) |
This is a helper for giving the structure returned by get_realms_and_streams_for_archiving
a consistent ordering.
|
This is a helper for giving the structure returned by get_realms_and_streams_for_archiving
a consistent ordering.
| def fix_ordering_of_result(self, result: List[Tuple[Realm, List[Stream]]]) -> None:
"""
This is a helper for giving the structure returned by get_realms_and_streams_for_archiving
a consistent ordering.
"""
# Sort the list of tuples by realm id:
result.sort(key=lambda x: x... | [
"def",
"fix_ordering_of_result",
"(",
"self",
",",
"result",
":",
"List",
"[",
"Tuple",
"[",
"Realm",
",",
"List",
"[",
"Stream",
"]",
"]",
"]",
")",
"->",
"None",
":",
"# Sort the list of tuples by realm id:",
"result",
".",
"sort",
"(",
"key",
"=",
"lamb... | [
894,
4
] | [
904,
59
] | python | en | ['en', 'error', 'th'] | False |
TestGetRealmAndStreamsForArchiving.simple_get_realms_and_streams_for_archiving | (self) |
This is an implementation of the function we're testing, but using the obvious,
unoptimized algorithm. We can use this for additional verification of correctness,
by comparing the output of the two implementations.
|
This is an implementation of the function we're testing, but using the obvious,
unoptimized algorithm. We can use this for additional verification of correctness,
by comparing the output of the two implementations.
| def simple_get_realms_and_streams_for_archiving(self) -> List[Tuple[Realm, List[Stream]]]:
"""
This is an implementation of the function we're testing, but using the obvious,
unoptimized algorithm. We can use this for additional verification of correctness,
by comparing the output of the... | [
"def",
"simple_get_realms_and_streams_for_archiving",
"(",
"self",
")",
"->",
"List",
"[",
"Tuple",
"[",
"Realm",
",",
"List",
"[",
"Stream",
"]",
"]",
"]",
":",
"result",
"=",
"[",
"]",
"for",
"realm",
"in",
"Realm",
".",
"objects",
".",
"all",
"(",
"... | [
906,
4
] | [
927,
21
] | python | en | ['en', 'error', 'th'] | False |
TestDoDeleteMessages.test_old_event_format_processed_correctly | (self) |
do_delete_messages used to send events with users in dict format {"id": <int>}.
We have a block in process_notification to deal with that old format, that should be
deleted in a later release. This test is meant to ensure correctness of that block.
|
do_delete_messages used to send events with users in dict format {"id": <int>}.
We have a block in process_notification to deal with that old format, that should be
deleted in a later release. This test is meant to ensure correctness of that block.
| def test_old_event_format_processed_correctly(self) -> None:
"""
do_delete_messages used to send events with users in dict format {"id": <int>}.
We have a block in process_notification to deal with that old format, that should be
deleted in a later release. This test is meant to ensure c... | [
"def",
"test_old_event_format_processed_correctly",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"cordelia",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
... | [
1064,
4
] | [
1087,
74
] | python | en | ['en', 'error', 'th'] | False |
timeout | (timeout: float, func: Callable[[], ResultT]) | Call the function in a separate thread.
Return its return value, or raise an exception,
within approximately 'timeout' seconds.
The function may receive a TimeoutExpired exception
anywhere in its code, which could have arbitrary
unsafe effects (resources not released, etc.).
It might also fail ... | Call the function in a separate thread.
Return its return value, or raise an exception,
within approximately 'timeout' seconds. | def timeout(timeout: float, func: Callable[[], ResultT]) -> ResultT:
"""Call the function in a separate thread.
Return its return value, or raise an exception,
within approximately 'timeout' seconds.
The function may receive a TimeoutExpired exception
anywhere in its code, which could have arbitrar... | [
"def",
"timeout",
"(",
"timeout",
":",
"float",
",",
"func",
":",
"Callable",
"[",
"[",
"]",
",",
"ResultT",
"]",
")",
"->",
"ResultT",
":",
"class",
"TimeoutThread",
"(",
"threading",
".",
"Thread",
")",
":",
"def",
"__init__",
"(",
"self",
")",
"->... | [
20,
0
] | [
95,
24
] | python | en | ['en', 'en', 'en'] | True |
_have_cython | () |
Return True if Cython can be imported.
|
Return True if Cython can be imported.
| def _have_cython():
"""
Return True if Cython can be imported.
"""
cython_impl = 'Cython.Distutils.build_ext'
try:
# from (cython_impl) import build_ext
__import__(cython_impl, fromlist=['build_ext']).build_ext
return True
except Exception:
pass
return False | [
"def",
"_have_cython",
"(",
")",
":",
"cython_impl",
"=",
"'Cython.Distutils.build_ext'",
"try",
":",
"# from (cython_impl) import build_ext",
"__import__",
"(",
"cython_impl",
",",
"fromlist",
"=",
"[",
"'build_ext'",
"]",
")",
".",
"build_ext",
"return",
"True",
"... | [
9,
0
] | [
20,
16
] | python | en | ['en', 'error', 'th'] | False |
Extension._convert_pyx_sources_to_lang | (self) |
Replace sources with .pyx extensions to sources with the target
language extension. This mechanism allows language authors to supply
pre-converted sources but to prefer the .pyx sources.
|
Replace sources with .pyx extensions to sources with the target
language extension. This mechanism allows language authors to supply
pre-converted sources but to prefer the .pyx sources.
| def _convert_pyx_sources_to_lang(self):
"""
Replace sources with .pyx extensions to sources with the target
language extension. This mechanism allows language authors to supply
pre-converted sources but to prefer the .pyx sources.
"""
if _have_cython():
# the ... | [
"def",
"_convert_pyx_sources_to_lang",
"(",
"self",
")",
":",
"if",
"_have_cython",
"(",
")",
":",
"# the build has Cython, so allow it to compile the .pyx files",
"return",
"lang",
"=",
"self",
".",
"language",
"or",
"''",
"target_ext",
"=",
"'.cpp'",
"if",
"lang",
... | [
38,
4
] | [
50,
51
] | python | en | ['en', 'error', 'th'] | False |
TestRaises.test_raises_cyclic_reference | (self, method) |
Ensure pytest.raises does not leave a reference cycle (#1965).
|
Ensure pytest.raises does not leave a reference cycle (#1965).
| def test_raises_cyclic_reference(self, method):
"""
Ensure pytest.raises does not leave a reference cycle (#1965).
"""
import gc
class T(object):
def __call__(self):
raise ValueError
t = T()
if method == 'function':
pytest... | [
"def",
"test_raises_cyclic_reference",
"(",
"self",
",",
"method",
")",
":",
"import",
"gc",
"class",
"T",
"(",
"object",
")",
":",
"def",
"__call__",
"(",
"self",
")",
":",
"raise",
"ValueError",
"t",
"=",
"T",
"(",
")",
"if",
"method",
"==",
"'functi... | [
94,
4
] | [
118,
35
] | python | en | ['en', 'error', 'th'] | False |
TestRaises.test_raises_match_wrong_type | (self) | Raising an exception with the wrong type and match= given.
pytest should throw the unexpected exception - the pattern match is not
really relevant if we got a different exception.
| Raising an exception with the wrong type and match= given. | def test_raises_match_wrong_type(self):
"""Raising an exception with the wrong type and match= given.
pytest should throw the unexpected exception - the pattern match is not
really relevant if we got a different exception.
"""
with pytest.raises(ValueError):
with pyt... | [
"def",
"test_raises_match_wrong_type",
"(",
"self",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"IndexError",
",",
"match",
"=",
"'nomatch'",
")",
":",
"int",
"(",
"'asdf'",
")"
] | [
135,
4
] | [
143,
27
] | python | en | ['en', 'en', 'en'] | True |
setup_bash_profile | () | Select a bash profile file to add setup code to. | Select a bash profile file to add setup code to. | def setup_bash_profile() -> None:
"""Select a bash profile file to add setup code to."""
BASH_PROFILES = [
os.path.expanduser(p) for p in ("~/.bash_profile", "~/.bash_login", "~/.profile")
]
def clear_old_profile() -> None:
# An earlier version of this script would output a fresh .bash... | [
"def",
"setup_bash_profile",
"(",
")",
"->",
"None",
":",
"BASH_PROFILES",
"=",
"[",
"os",
".",
"path",
".",
"expanduser",
"(",
"p",
")",
"for",
"p",
"in",
"(",
"\"~/.bash_profile\"",
",",
"\"~/.bash_login\"",
",",
"\"~/.profile\"",
")",
"]",
"def",
"clear... | [
103,
0
] | [
138,
45
] | python | en | ['en', 'sm', 'en'] | True |
finder | (package) |
Return a resource finder for a package.
:param package: The name of the package.
:return: A :class:`ResourceFinder` instance for the package.
|
Return a resource finder for a package.
:param package: The name of the package.
:return: A :class:`ResourceFinder` instance for the package.
| def finder(package):
"""
Return a resource finder for a package.
:param package: The name of the package.
:return: A :class:`ResourceFinder` instance for the package.
"""
if package in _finder_cache:
result = _finder_cache[package]
else:
if package not in sys.modules:
... | [
"def",
"finder",
"(",
"package",
")",
":",
"if",
"package",
"in",
"_finder_cache",
":",
"result",
"=",
"_finder_cache",
"[",
"package",
"]",
"else",
":",
"if",
"package",
"not",
"in",
"sys",
".",
"modules",
":",
"__import__",
"(",
"package",
")",
"module... | [
309,
0
] | [
331,
17
] | python | en | ['en', 'error', 'th'] | False |
finder_for_path | (path) |
Return a resource finder for a path, which should represent a container.
:param path: The path.
:return: A :class:`ResourceFinder` instance for the path.
|
Return a resource finder for a path, which should represent a container. | def finder_for_path(path):
"""
Return a resource finder for a path, which should represent a container.
:param path: The path.
:return: A :class:`ResourceFinder` instance for the path.
"""
result = None
# calls any path hooks, gets importer into cache
pkgutil.get_importer(path)
load... | [
"def",
"finder_for_path",
"(",
"path",
")",
":",
"result",
"=",
"None",
"# calls any path hooks, gets importer into cache",
"pkgutil",
".",
"get_importer",
"(",
"path",
")",
"loader",
"=",
"sys",
".",
"path_importer_cache",
".",
"get",
"(",
"path",
")",
"finder",
... | [
337,
0
] | [
354,
17
] | python | en | ['en', 'error', 'th'] | False |
ResourceCache.is_stale | (self, resource, path) |
Is the cache stale for the given resource?
:param resource: The :class:`Resource` being cached.
:param path: The path of the resource in the cache.
:return: True if the cache is stale.
|
Is the cache stale for the given resource? | def is_stale(self, resource, path):
"""
Is the cache stale for the given resource?
:param resource: The :class:`Resource` being cached.
:param path: The path of the resource in the cache.
:return: True if the cache is stale.
"""
# Cache invalidation is a hard pro... | [
"def",
"is_stale",
"(",
"self",
",",
"resource",
",",
"path",
")",
":",
"# Cache invalidation is a hard problem :-)",
"return",
"True"
] | [
34,
4
] | [
43,
19
] | python | en | ['en', 'error', 'th'] | False |
ResourceCache.get | (self, resource) |
Get a resource into the cache,
:param resource: A :class:`Resource` instance.
:return: The pathname of the resource in the cache.
|
Get a resource into the cache, | def get(self, resource):
"""
Get a resource into the cache,
:param resource: A :class:`Resource` instance.
:return: The pathname of the resource in the cache.
"""
prefix, path = resource.finder.get_cache_info(resource)
if prefix is None:
result = path... | [
"def",
"get",
"(",
"self",
",",
"resource",
")",
":",
"prefix",
",",
"path",
"=",
"resource",
".",
"finder",
".",
"get_cache_info",
"(",
"resource",
")",
"if",
"prefix",
"is",
"None",
":",
"result",
"=",
"path",
"else",
":",
"result",
"=",
"os",
".",... | [
45,
4
] | [
68,
21
] | python | en | ['en', 'error', 'th'] | False |
Resource.as_stream | (self) |
Get the resource as a stream.
This is not a property to make it obvious that it returns a new stream
each time.
|
Get the resource as a stream. | def as_stream(self):
"""
Get the resource as a stream.
This is not a property to make it obvious that it returns a new stream
each time.
"""
return self.finder.get_stream(self) | [
"def",
"as_stream",
"(",
"self",
")",
":",
"return",
"self",
".",
"finder",
".",
"get_stream",
"(",
"self",
")"
] | [
85,
4
] | [
92,
43
] | python | en | ['en', 'error', 'th'] | False |
SecurityGroupsViewTests.test_update_security_groups_post | (self) | Ensure that we can change a group name.
The name must not be restricted to alphanumeric characters.
bug #1233501 Security group names cannot contain at characters
bug #1224576 Security group names cannot contain spaces
| Ensure that we can change a group name. | def test_update_security_groups_post(self):
"""Ensure that we can change a group name.
The name must not be restricted to alphanumeric characters.
bug #1233501 Security group names cannot contain at characters
bug #1224576 Security group names cannot contain spaces
"""
s... | [
"def",
"test_update_security_groups_post",
"(",
"self",
")",
":",
"sec_group",
"=",
"self",
".",
"security_groups",
".",
"first",
"(",
")",
"sec_group",
".",
"name",
"=",
"\"@new name\"",
"self",
".",
"mock_security_group_update",
".",
"return_value",
"=",
"sec_gr... | [
213,
4
] | [
236,
47
] | python | en | ['en', 'en', 'en'] | True |
SecurityGroupsViewTests.test_create_security_groups_special_chars | (self) | Ensure non-alphanumeric characters can be used as a group name.
bug #1233501 Security group names cannot contain at characters
bug #1224576 Security group names cannot contain spaces
| Ensure non-alphanumeric characters can be used as a group name. | def test_create_security_groups_special_chars(self):
"""Ensure non-alphanumeric characters can be used as a group name.
bug #1233501 Security group names cannot contain at characters
bug #1224576 Security group names cannot contain spaces
"""
sg_name = b'@group name-\xe3\x82\xb3... | [
"def",
"test_create_security_groups_special_chars",
"(",
"self",
")",
":",
"sg_name",
"=",
"b'@group name-\\xe3\\x82\\xb3'",
".",
"decode",
"(",
"'utf8'",
")",
"self",
".",
"_create_security_group",
"(",
"sg_name",
"=",
"sg_name",
")"
] | [
245,
4
] | [
252,
52
] | python | en | ['en', 'en', 'en'] | True |
YoHookTests.test_yo_message | (self) |
Yo App sends notification whenever user receives a new Yo from another user.
|
Yo App sends notification whenever user receives a new Yo from another user.
| def test_yo_message(self) -> None:
"""
Yo App sends notification whenever user receives a new Yo from another user.
"""
cordelia = self.example_user("cordelia")
self.url = self.build_webhook_url(
email=cordelia.email,
username="IAGO",
user_ip="... | [
"def",
"test_yo_message",
"(",
"self",
")",
"->",
"None",
":",
"cordelia",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"self",
".",
"url",
"=",
"self",
".",
"build_webhook_url",
"(",
"email",
"=",
"cordelia",
".",
"email",
",",
"username",
... | [
10,
4
] | [
23,
9
] | python | en | ['en', 'error', 'th'] | False |
canonicalize_version | (_version) |
This is very similar to Version.__str__, but has one subtle difference
with the way it handles the release segment.
|
This is very similar to Version.__str__, but has one subtle difference
with the way it handles the release segment.
| def canonicalize_version(_version):
# type: (str) -> Union[Version, str]
"""
This is very similar to Version.__str__, but has one subtle difference
with the way it handles the release segment.
"""
try:
version = Version(_version)
except InvalidVersion:
# Legacy versions cann... | [
"def",
"canonicalize_version",
"(",
"_version",
")",
":",
"# type: (str) -> Union[Version, str]",
"try",
":",
"version",
"=",
"Version",
"(",
"_version",
")",
"except",
"InvalidVersion",
":",
"# Legacy versions cannot be normalized",
"return",
"_version",
"parts",
"=",
... | [
25,
0
] | [
64,
25
] | python | en | ['en', 'error', 'th'] | False |
Command.handle_pip_version_check | (self, options) |
This is a no-op so that commands by default do not do the pip version
check.
|
This is a no-op so that commands by default do not do the pip version
check.
| def handle_pip_version_check(self, options):
# type: (Values) -> None
"""
This is a no-op so that commands by default do not do the pip version
check.
"""
# Make sure we do the pip version check if the index_group options
# are present.
assert not hasattr(... | [
"def",
"handle_pip_version_check",
"(",
"self",
",",
"options",
")",
":",
"# type: (Values) -> None",
"# Make sure we do the pip version check if the index_group options",
"# are present.",
"assert",
"not",
"hasattr",
"(",
"options",
",",
"'no_index'",
")"
] | [
97,
4
] | [
105,
47
] | python | en | ['en', 'error', 'th'] | False |
MongoAuthentication.__init__ | (self, mongodb_uri: str) | Class initialised by fetching MongoDB URI from env | Class initialised by fetching MongoDB URI from env | def __init__(self, mongodb_uri: str) -> None:
"""Class initialised by fetching MongoDB URI from env"""
self.mongo_client: str = mongodb_uri | [
"def",
"__init__",
"(",
"self",
",",
"mongodb_uri",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"mongo_client",
":",
"str",
"=",
"mongodb_uri"
] | [
8,
4
] | [
10,
44
] | python | en | ['en', 'en', 'en'] | True |
MongoAuthentication.connect | (self) | Connect to MongoDB instance using provided URI | Connect to MongoDB instance using provided URI | def connect(self) -> MongoClient:
"""Connect to MongoDB instance using provided URI"""
try:
mongo_client: MongoClient = MongoClient(self.mongo_client)
mongo_client.admin.command("ismaster")
return mongo_client
except MongoErrors.ConnectionFailure:
... | [
"def",
"connect",
"(",
"self",
")",
"->",
"MongoClient",
":",
"try",
":",
"mongo_client",
":",
"MongoClient",
"=",
"MongoClient",
"(",
"self",
".",
"mongo_client",
")",
"mongo_client",
".",
"admin",
".",
"command",
"(",
"\"ismaster\"",
")",
"return",
"mongo_... | [
12,
4
] | [
19,
41
] | python | en | ['en', 'en', 'en'] | True |
AbcParserTest.compare_to_abc2midi_and_metadata | (
self, midi_path, expected_metadata, expected_expanded_metadata, test) | Compare parsing results to the abc2midi "reference" implementation. | Compare parsing results to the abc2midi "reference" implementation. | def compare_to_abc2midi_and_metadata(
self, midi_path, expected_metadata, expected_expanded_metadata, test):
"""Compare parsing results to the abc2midi "reference" implementation."""
# Compare section annotations and groups before expanding.
self.compare_proto_list(expected_metadata.section_annotation... | [
"def",
"compare_to_abc2midi_and_metadata",
"(",
"self",
",",
"midi_path",
",",
"expected_metadata",
",",
"expected_expanded_metadata",
",",
"test",
")",
":",
"# Compare section annotations and groups before expanding.",
"self",
".",
"compare_proto_list",
"(",
"expected_metadata... | [
37,
2
] | [
74,
74
] | python | en | ['en', 'en', 'en'] | True |
memory_managment | (classes, fine_tune_size) | ------------------------------------------------------------ | ------------------------------------------------------------ | def memory_managment(classes, fine_tune_size):
dir_root_gt = '/media/mmlab/dataset/global_dataset/Classification_dataset/train/'
xml_dir_list = []
img_dir_list = []
xml_dir_temp = dir_root_gt + '*.png'
xml_dir_list = xml_dir_list + glob(xml_dir_temp)
for _img_dir in xml_dir_list:
... | [
"def",
"memory_managment",
"(",
"classes",
",",
"fine_tune_size",
")",
":",
"dir_root_gt",
"=",
"'/media/mmlab/dataset/global_dataset/Classification_dataset/train/'",
"xml_dir_list",
"=",
"[",
"]",
"img_dir_list",
"=",
"[",
"]",
"xml_dir_temp",
"=",
"dir_root_gt",
"+",
... | [
106,
0
] | [
129,
27
] | python | en | ['en', 'ja', 'hi'] | False |
convert_markdown_syntax | (text: str, regex: str, zulip_keyword: str) |
Returns:
1. For strikethrough formatting: This maps Slack's '~strike~' to Zulip's '~~strike~~'
2. For bold formatting: This maps Slack's '*bold*' to Zulip's '**bold**'
3. For italic formatting: This maps Slack's '_italic_' to Zulip's '*italic*'
|
Returns:
1. For strikethrough formatting: This maps Slack's '~strike~' to Zulip's '~~strike~~'
2. For bold formatting: This maps Slack's '*bold*' to Zulip's '**bold**'
3. For italic formatting: This maps Slack's '_italic_' to Zulip's '*italic*'
| def convert_markdown_syntax(text: str, regex: str, zulip_keyword: str) -> str:
"""
Returns:
1. For strikethrough formatting: This maps Slack's '~strike~' to Zulip's '~~strike~~'
2. For bold formatting: This maps Slack's '*bold*' to Zulip's '**bold**'
3. For italic formatting: This maps Slack's '_ita... | [
"def",
"convert_markdown_syntax",
"(",
"text",
":",
"str",
",",
"regex",
":",
"str",
",",
"zulip_keyword",
":",
"str",
")",
"->",
"str",
":",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"regex",
",",
"text",
",",
"re",
".",
"VERBOSE",
")",
":",... | [
140,
0
] | [
157,
15
] | python | en | ['en', 'error', 'th'] | False |
convert_link_format | (text: str) |
1. Converts '<https://foo.com>' to 'https://foo.com'
2. Converts '<https://foo.com|foo>' to 'https://foo.com|foo'
|
1. Converts '<https://foo.com>' to 'https://foo.com'
2. Converts '<https://foo.com|foo>' to 'https://foo.com|foo'
| def convert_link_format(text: str) -> Tuple[str, bool]:
"""
1. Converts '<https://foo.com>' to 'https://foo.com'
2. Converts '<https://foo.com|foo>' to 'https://foo.com|foo'
"""
has_link = False
for match in re.finditer(LINK_REGEX, text, re.VERBOSE):
converted_text = match.group(0).repla... | [
"def",
"convert_link_format",
"(",
"text",
":",
"str",
")",
"->",
"Tuple",
"[",
"str",
",",
"bool",
"]",
":",
"has_link",
"=",
"False",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"LINK_REGEX",
",",
"text",
",",
"re",
".",
"VERBOSE",
")",
":",
... | [
160,
0
] | [
170,
25
] | python | en | ['en', 'error', 'th'] | False |
convert_mailto_format | (text: str) |
1. Converts '<mailto:foo@foo.com>' to 'mailto:foo@foo.com'
2. Converts '<mailto:foo@foo.com|foo@foo.com>' to 'mailto:foo@foo.com'
|
1. Converts '<mailto:foo | def convert_mailto_format(text: str) -> Tuple[str, bool]:
"""
1. Converts '<mailto:foo@foo.com>' to 'mailto:foo@foo.com'
2. Converts '<mailto:foo@foo.com|foo@foo.com>' to 'mailto:foo@foo.com'
"""
has_link = False
for match in re.finditer(SLACK_MAILTO_REGEX, text, re.VERBOSE):
has_link = ... | [
"def",
"convert_mailto_format",
"(",
"text",
":",
"str",
")",
"->",
"Tuple",
"[",
"str",
",",
"bool",
"]",
":",
"has_link",
"=",
"False",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"SLACK_MAILTO_REGEX",
",",
"text",
",",
"re",
".",
"VERBOSE",
")... | [
173,
0
] | [
182,
25
] | python | en | ['en', 'error', 'th'] | False |
get_auth_params_from_request | (request) | Extracts properties needed by novaclient call from the request object.
These will be used to memoize the calls to novaclient.
| Extracts properties needed by novaclient call from the request object. | def get_auth_params_from_request(request):
"""Extracts properties needed by novaclient call from the request object.
These will be used to memoize the calls to novaclient.
"""
return (
request.user.username,
request.user.token.id,
request.user.tenant_id,
request.user.tok... | [
"def",
"get_auth_params_from_request",
"(",
"request",
")",
":",
"return",
"(",
"request",
".",
"user",
".",
"username",
",",
"request",
".",
"user",
".",
"token",
".",
"id",
",",
"request",
".",
"user",
".",
"tenant_id",
",",
"request",
".",
"user",
"."... | [
105,
0
] | [
117,
5
] | python | en | ['en', 'en', 'en'] | True |
RoleAssignmentsTable.get_object_id | (self, datum) | Identifier of the role assignment. | Identifier of the role assignment. | def get_object_id(self, datum):
"""Identifier of the role assignment."""
# Role assignment doesn't have identifier so one will be created
# from the identifier of scope, user and role. This will guaranty the
# unicity.
scope_id = ""
if "project" in datum.scope:
... | [
"def",
"get_object_id",
"(",
"self",
",",
"datum",
")",
":",
"# Role assignment doesn't have identifier so one will be created",
"# from the identifier of scope, user and role. This will guaranty the",
"# unicity.",
"scope_id",
"=",
"\"\"",
"if",
"\"project\"",
"in",
"datum",
"."... | [
84,
4
] | [
102,
67
] | python | en | ['en', 'en', 'en'] | True |
all_suffixes | () | Returns a list of all recognized module suffixes for this process | Returns a list of all recognized module suffixes for this process | def all_suffixes():
"""Returns a list of all recognized module suffixes for this process"""
return SOURCE_SUFFIXES + BYTECODE_SUFFIXES + EXTENSION_SUFFIXES | [
"def",
"all_suffixes",
"(",
")",
":",
"return",
"SOURCE_SUFFIXES",
"+",
"BYTECODE_SUFFIXES",
"+",
"EXTENSION_SUFFIXES"
] | [
18,
0
] | [
20,
67
] | python | en | ['en', 'en', 'en'] | True |
DmlabGymEnv.format_obs_dict | (self, env_obs_dict) | SampleFactory traditionally uses 'obs' key for the 'main' observation. | SampleFactory traditionally uses 'obs' key for the 'main' observation. | def format_obs_dict(self, env_obs_dict):
"""SampleFactory traditionally uses 'obs' key for the 'main' observation."""
env_obs_dict['obs'] = env_obs_dict.pop(self.main_observation)
instr = env_obs_dict.get(self.instructions_observation)
self.instructions[:] = 0
if instr is not No... | [
"def",
"format_obs_dict",
"(",
"self",
",",
"env_obs_dict",
")",
":",
"env_obs_dict",
"[",
"'obs'",
"]",
"=",
"env_obs_dict",
".",
"pop",
"(",
"self",
".",
"main_observation",
")",
"instr",
"=",
"env_obs_dict",
".",
"get",
"(",
"self",
".",
"instructions_obs... | [
155,
4
] | [
168,
27
] | python | en | ['en', 'en', 'en'] | True |
DmlabGymEnv.fetch | (self, key, pk3_path) | Environment object itself acts as a proxy to the global level cache. | Environment object itself acts as a proxy to the global level cache. | def fetch(self, key, pk3_path):
"""Environment object itself acts as a proxy to the global level cache."""
if not self.env_uses_level_cache:
self.env_uses_level_cache = True
# log.debug('Env %s uses level cache!', self.level_name)
path = join(self.level_cache_path, key)
... | [
"def",
"fetch",
"(",
"self",
",",
"key",
",",
"pk3_path",
")",
":",
"if",
"not",
"self",
".",
"env_uses_level_cache",
":",
"self",
".",
"env_uses_level_cache",
"=",
"True",
"# log.debug('Env %s uses level cache!', self.level_name)",
"path",
"=",
"join",
"(",
"self... | [
223,
4
] | [
237,
24
] | python | en | ['en', 'en', 'en'] | True |
DmlabGymEnv.write | (self, key, pk3_path) | Environment object itself acts as a proxy to the global level cache. | Environment object itself acts as a proxy to the global level cache. | def write(self, key, pk3_path):
"""Environment object itself acts as a proxy to the global level cache."""
log.debug('Add new level to cache! Level %s seed %r key %s', self.level_name, self.last_reset_seed, key)
self.curr_cache.add_new_level(self.level, self.last_reset_seed, key, pk3_path) | [
"def",
"write",
"(",
"self",
",",
"key",
",",
"pk3_path",
")",
":",
"log",
".",
"debug",
"(",
"'Add new level to cache! Level %s seed %r key %s'",
",",
"self",
".",
"level_name",
",",
"self",
".",
"last_reset_seed",
",",
"key",
")",
"self",
".",
"curr_cache",
... | [
239,
4
] | [
242,
86
] | python | en | ['en', 'en', 'en'] | True |
ResultPresenter.represent | (self) |
Осуществляется преобразование результата выполнения запускаемого
объекта в нужный вид
|
Осуществляется преобразование результата выполнения запускаемого
объекта в нужный вид
| def represent(self):
"""
Осуществляется преобразование результата выполнения запускаемого
объекта в нужный вид
""" | [
"def",
"represent",
"(",
"self",
")",
":"
] | [
20,
4
] | [
24,
11
] | python | en | ['en', 'error', 'th'] | False |
MetaExtension.extendMarkdown | (self, md, md_globals) | Add MetaPreprocessor to Markdown instance. | Add MetaPreprocessor to Markdown instance. | def extendMarkdown(self, md, md_globals):
""" Add MetaPreprocessor to Markdown instance. """
md.preprocessors.add("meta", MetaPreprocessor(md), "_begin") | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
",",
"md_globals",
")",
":",
"md",
".",
"preprocessors",
".",
"add",
"(",
"\"meta\"",
",",
"MetaPreprocessor",
"(",
"md",
")",
",",
"\"_begin\"",
")"
] | [
51,
4
] | [
54,
68
] | python | en | ['en', 'en', 'en'] | True |
MetaPreprocessor.run | (self, lines) | Parse Meta-Data and store in Markdown.Meta. | Parse Meta-Data and store in Markdown.Meta. | def run(self, lines):
""" Parse Meta-Data and store in Markdown.Meta. """
meta = {}
key = None
while 1:
line = lines.pop(0)
if line.strip() == '':
break # blank line - done
m1 = META_RE.match(line)
if m1:
key... | [
"def",
"run",
"(",
"self",
",",
"lines",
")",
":",
"meta",
"=",
"{",
"}",
"key",
"=",
"None",
"while",
"1",
":",
"line",
"=",
"lines",
".",
"pop",
"(",
"0",
")",
"if",
"line",
".",
"strip",
"(",
")",
"==",
"''",
":",
"break",
"# blank line - do... | [
60,
4
] | [
81,
20
] | python | en | ['en', 'id', 'en'] | True |
autolabel | (rects) | Attach a text label above each bar in *rects*, displaying its height. | Attach a text label above each bar in *rects*, displaying its height. | def autolabel(rects):
"""Attach a text label above each bar in *rects*, displaying its height."""
for rect in rects:
height = rect.get_height()
ax.annotate('{}'.format(height),
xy=(rect.get_x() + rect.get_width() / 2, height),
xytext=(0, 3), # 3 points ve... | [
"def",
"autolabel",
"(",
"rects",
")",
":",
"for",
"rect",
"in",
"rects",
":",
"height",
"=",
"rect",
".",
"get_height",
"(",
")",
"ax",
".",
"annotate",
"(",
"'{}'",
".",
"format",
"(",
"height",
")",
",",
"xy",
"=",
"(",
"rect",
".",
"get_x",
"... | [
51,
0
] | [
59,
45
] | python | en | ['en', 'en', 'en'] | True |
RealmTest.test_do_set_realm_name_caching | (self) | The main complicated thing about setting realm names is fighting the
cache, and we start by populating the cache for Hamlet, and we end
by checking the cache to ensure that the new value is there. | The main complicated thing about setting realm names is fighting the
cache, and we start by populating the cache for Hamlet, and we end
by checking the cache to ensure that the new value is there. | def test_do_set_realm_name_caching(self) -> None:
"""The main complicated thing about setting realm names is fighting the
cache, and we start by populating the cache for Hamlet, and we end
by checking the cache to ensure that the new value is there."""
realm = get_realm("zulip")
... | [
"def",
"test_do_set_realm_name_caching",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"new_name",
"=",
"\"Zed You Elle Eye Pea\"",
"do_set_realm_property",
"(",
"realm",
",",
"\"name\"",
",",
"new_name",
",",
"acting_user",
... | [
58,
4
] | [
66,
91
] | python | en | ['en', 'en', 'en'] | True |
RealmTest.test_do_deactivate_realm_clears_user_realm_cache | (self) | The main complicated thing about deactivating realm names is
updating the cache, and we start by populating the cache for
Hamlet, and we end by checking the cache to ensure that his
realm appears to be deactivated. You can make this test fail
by disabling cache.flush_realm(). | The main complicated thing about deactivating realm names is
updating the cache, and we start by populating the cache for
Hamlet, and we end by checking the cache to ensure that his
realm appears to be deactivated. You can make this test fail
by disabling cache.flush_realm(). | def test_do_deactivate_realm_clears_user_realm_cache(self) -> None:
"""The main complicated thing about deactivating realm names is
updating the cache, and we start by populating the cache for
Hamlet, and we end by checking the cache to ensure that his
realm appears to be deactivated. Y... | [
"def",
"test_do_deactivate_realm_clears_user_realm_cache",
"(",
"self",
")",
"->",
"None",
":",
"hamlet_id",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
".",
"id",
"get_user_profile_by_id",
"(",
"hamlet_id",
")",
"realm",
"=",
"get_realm",
"(",
"\"zu... | [
174,
4
] | [
185,
47
] | python | en | ['en', 'en', 'en'] | True |
RealmTest.test_do_change_realm_subdomain_clears_user_realm_cache | (self) | The main complicated thing about changing realm subdomains is
updating the cache, and we start by populating the cache for
Hamlet, and we end by checking the cache to ensure that his
realm appears to be deactivated. You can make this test fail
by disabling cache.flush_realm(). | The main complicated thing about changing realm subdomains is
updating the cache, and we start by populating the cache for
Hamlet, and we end by checking the cache to ensure that his
realm appears to be deactivated. You can make this test fail
by disabling cache.flush_realm(). | def test_do_change_realm_subdomain_clears_user_realm_cache(self) -> None:
"""The main complicated thing about changing realm subdomains is
updating the cache, and we start by populating the cache for
Hamlet, and we end by checking the cache to ensure that his
realm appears to be deactiva... | [
"def",
"test_do_change_realm_subdomain_clears_user_realm_cache",
"(",
"self",
")",
"->",
"None",
":",
"hamlet_id",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
".",
"id",
"user",
"=",
"get_user_profile_by_id",
"(",
"hamlet_id",
")",
"realm",
"=",
"get... | [
187,
4
] | [
210,
59
] | python | en | ['en', 'en', 'en'] | True |
RealmTest.test_do_deactivate_realm_on_deactivated_realm | (self) | Ensure early exit is working in realm deactivation | Ensure early exit is working in realm deactivation | def test_do_deactivate_realm_on_deactivated_realm(self) -> None:
"""Ensure early exit is working in realm deactivation"""
realm = get_realm("zulip")
self.assertFalse(realm.deactivated)
do_deactivate_realm(realm, acting_user=None)
self.assertTrue(realm.deactivated)
do_de... | [
"def",
"test_do_deactivate_realm_on_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"self",
".",
"assertFalse",
"(",
"realm",
".",
"deactivated",
")",
"do_deactivate_realm",
"(",
"realm",
",",
"acting_user... | [
240,
4
] | [
249,
42
] | python | en | ['en', 'en', 'en'] | True |
RealmTest.test_do_set_deactivated_redirect_on_deactivated_realm | (self) | Ensure that the redirect url is working when deactivating realm | Ensure that the redirect url is working when deactivating realm | def test_do_set_deactivated_redirect_on_deactivated_realm(self) -> None:
"""Ensure that the redirect url is working when deactivating realm"""
realm = get_realm("zulip")
redirect_url = "new_server.zulip.com"
do_deactivate_realm(realm, acting_user=None)
self.assertTrue(realm.deac... | [
"def",
"test_do_set_deactivated_redirect_on_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"redirect_url",
"=",
"\"new_server.zulip.com\"",
"do_deactivate_realm",
"(",
"realm",
",",
"acting_user",
"=",
"None",
... | [
251,
4
] | [
264,
69
] | python | en | ['en', 'en', 'en'] | True |
RealmAPITest.do_test_realm_update_api | (self, name: str) | Test updating realm properties.
If new realm properties have been added to the Realm model but the
test_values dict below has not been updated, this will raise an
assertion error.
| Test updating realm properties. | def do_test_realm_update_api(self, name: str) -> None:
"""Test updating realm properties.
If new realm properties have been added to the Realm model but the
test_values dict below has not been updated, this will raise an
assertion error.
"""
bool_tests: List[bool] = [Fa... | [
"def",
"do_test_realm_update_api",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"None",
":",
"bool_tests",
":",
"List",
"[",
"bool",
"]",
"=",
"[",
"False",
",",
"True",
"]",
"test_values",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"dict",
... | [
850,
4
] | [
943,
59
] | python | en | ['en', 'en', 'en'] | True |
RealmAPITest.test_update_realm_allow_message_editing | (self) | Tests updating the realm property 'allow_message_editing'. | Tests updating the realm property 'allow_message_editing'. | def test_update_realm_allow_message_editing(self) -> None:
"""Tests updating the realm property 'allow_message_editing'."""
self.set_up_db("allow_message_editing", False)
self.set_up_db("message_content_edit_limit_seconds", 0)
self.set_up_db("allow_community_topic_editing", False)
... | [
"def",
"test_update_realm_allow_message_editing",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"set_up_db",
"(",
"\"allow_message_editing\"",
",",
"False",
")",
"self",
".",
"set_up_db",
"(",
"\"message_content_edit_limit_seconds\"",
",",
"0",
")",
"self",
".",... | [
950,
4
] | [
972,
68
] | python | en | ['en', 'en', 'en'] | True |
RealmAPITest.test_update_realm_allow_message_deleting | (self) | Tests updating the realm property 'allow_message_deleting'. | Tests updating the realm property 'allow_message_deleting'. | def test_update_realm_allow_message_deleting(self) -> None:
"""Tests updating the realm property 'allow_message_deleting'."""
self.set_up_db("allow_message_deleting", True)
self.set_up_db("message_content_delete_limit_seconds", 0)
realm = self.update_with_api("allow_message_deleting", Fa... | [
"def",
"test_update_realm_allow_message_deleting",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"set_up_db",
"(",
"\"allow_message_deleting\"",
",",
"True",
")",
"self",
".",
"set_up_db",
"(",
"\"message_content_delete_limit_seconds\"",
",",
"0",
")",
"realm",
... | [
974,
4
] | [
987,
73
] | python | en | ['en', 'en', 'en'] | True |
remove_unused_versions_dir | (args: argparse.Namespace) | Deletes cache data from obsolete Yarn versions.
Yarn does not provide an interface for removing obsolete data from
~/.cache/yarn for packages that you haven't installed in years; but one
can always remove the cache entirely.
| Deletes cache data from obsolete Yarn versions. | def remove_unused_versions_dir(args: argparse.Namespace) -> None:
"""Deletes cache data from obsolete Yarn versions.
Yarn does not provide an interface for removing obsolete data from
~/.cache/yarn for packages that you haven't installed in years; but one
can always remove the cache entirely.
"""
... | [
"def",
"remove_unused_versions_dir",
"(",
"args",
":",
"argparse",
".",
"Namespace",
")",
"->",
"None",
":",
"current_version_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"YARN_CACHE_PATH",
",",
"CURRENT_VERSION",
")",
"try",
":",
"dirs_to_purge",
"=",
"set... | [
14,
0
] | [
40,
5
] | python | en | ['en', 'en', 'en'] | True |
ProjectConfig.config_project_local_path | (self) | Metecho never uses the local path | Metecho never uses the local path | def config_project_local_path(self):
""" Metecho never uses the local path """
return | [
"def",
"config_project_local_path",
"(",
"self",
")",
":",
"return"
] | [
26,
4
] | [
28,
14
] | python | en | ['en', 'en', 'en'] | True |
MetechoUniversalConfig.config_global_path | (self) | Metecho never uses the global path | Metecho never uses the global path | def config_global_path(self):
""" Metecho never uses the global path """
return | [
"def",
"config_global_path",
"(",
"self",
")",
":",
"return"
] | [
59,
4
] | [
61,
14
] | python | en | ['en', 'en', 'en'] | True |
TableProcessor.run | (self, parent, blocks) | Parse a table block and build table. | Parse a table block and build table. | def run(self, parent, blocks):
""" Parse a table block and build table. """
block = blocks.pop(0).split('\n')
header = block[:2]
rows = block[2:]
# Get format type (bordered by pipes or not)
border = False
if header[0].startswith('|'):
border = True
... | [
"def",
"run",
"(",
"self",
",",
"parent",
",",
"blocks",
")",
":",
"block",
"=",
"blocks",
".",
"pop",
"(",
"0",
")",
".",
"split",
"(",
"'\\n'",
")",
"header",
"=",
"block",
"[",
":",
"2",
"]",
"rows",
"=",
"block",
"[",
"2",
":",
"]",
"# Ge... | [
29,
4
] | [
55,
54
] | python | en | ['en', 'en', 'en'] | True |
TableProcessor._build_row | (self, row, parent, align, border) | Given a row of text, build table cells. | Given a row of text, build table cells. | def _build_row(self, row, parent, align, border):
""" Given a row of text, build table cells. """
tr = etree.SubElement(parent, 'tr')
tag = 'td'
if parent.tag == 'thead':
tag = 'th'
cells = self._split_row(row, border)
# We use align here rather than cells to ... | [
"def",
"_build_row",
"(",
"self",
",",
"row",
",",
"parent",
",",
"align",
",",
"border",
")",
":",
"tr",
"=",
"etree",
".",
"SubElement",
"(",
"parent",
",",
"'tr'",
")",
"tag",
"=",
"'td'",
"if",
"parent",
".",
"tag",
"==",
"'thead'",
":",
"tag",... | [
57,
4
] | [
73,
33
] | python | en | ['en', 'en', 'en'] | True |
TableProcessor._split_row | (self, row, border) | split a row of text into list of cells. | split a row of text into list of cells. | def _split_row(self, row, border):
""" split a row of text into list of cells. """
if border:
if row.startswith('|'):
row = row[1:]
if row.endswith('|'):
row = row[:-1]
return row.split('|') | [
"def",
"_split_row",
"(",
"self",
",",
"row",
",",
"border",
")",
":",
"if",
"border",
":",
"if",
"row",
".",
"startswith",
"(",
"'|'",
")",
":",
"row",
"=",
"row",
"[",
"1",
":",
"]",
"if",
"row",
".",
"endswith",
"(",
"'|'",
")",
":",
"row",
... | [
75,
4
] | [
82,
29
] | python | en | ['en', 'en', 'en'] | True |
TableExtension.extendMarkdown | (self, md, md_globals) | Add an instance of TableProcessor to BlockParser. | Add an instance of TableProcessor to BlockParser. | def extendMarkdown(self, md, md_globals):
""" Add an instance of TableProcessor to BlockParser. """
md.parser.blockprocessors.add('table',
TableProcessor(md.parser),
'<hashheader') | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
",",
"md_globals",
")",
":",
"md",
".",
"parser",
".",
"blockprocessors",
".",
"add",
"(",
"'table'",
",",
"TableProcessor",
"(",
"md",
".",
"parser",
")",
",",
"'<hashheader'",
")"
] | [
88,
4
] | [
92,
52
] | python | en | ['en', 'en', 'en'] | True |
NavigationAccordionRegion._click_menu_item | (self, text, loc_craft_func, get_selected_func=None,
src_elem=None) | Click on menu item if not selected.
Menu animation that visualize transition from one selection to
another take some time - if clicked on item during this animation
nothing happens, therefore it is necessary to wait for the transition
to complete first.
Third-level menus are ha... | Click on menu item if not selected. | def _click_menu_item(self, text, loc_craft_func, get_selected_func=None,
src_elem=None):
"""Click on menu item if not selected.
Menu animation that visualize transition from one selection to
another take some time - if clicked on item during this animation
nothi... | [
"def",
"_click_menu_item",
"(",
"self",
",",
"text",
",",
"loc_craft_func",
",",
"get_selected_func",
"=",
"None",
",",
"src_elem",
"=",
"None",
")",
":",
"is_already_within_required_item",
"=",
"False",
"selected_item",
"=",
"None",
"if",
"get_selected_func",
"is... | [
101,
4
] | [
147,
28
] | python | en | ['en', 'en', 'en'] | True |
DropDownMenuRegion.is_open | (self) | Returns True if drop down menu is open, otherwise False. | Returns True if drop down menu is open, otherwise False. | def is_open(self):
"""Returns True if drop down menu is open, otherwise False."""
return "open" in self.src_elem.get_attribute('class') | [
"def",
"is_open",
"(",
"self",
")",
":",
"return",
"\"open\"",
"in",
"self",
".",
"src_elem",
".",
"get_attribute",
"(",
"'class'",
")"
] | [
202,
4
] | [
204,
61
] | python | en | ['en', 'en', 'en'] | True |
DropDownMenuRegion.open | (self) | Opens menu by clicking on the first child of the source element. | Opens menu by clicking on the first child of the source element. | def open(self):
"""Opens menu by clicking on the first child of the source element."""
if self.is_open() is False:
dropdown = self._get_element(*self._dropdown_locator)
# NOTE(tsufiev): there is an issue with clicking dropdowns too fast
# after page has been loaded -... | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_open",
"(",
")",
"is",
"False",
":",
"dropdown",
"=",
"self",
".",
"_get_element",
"(",
"*",
"self",
".",
"_dropdown_locator",
")",
"# NOTE(tsufiev): there is an issue with clicking dropdowns too fast",
... | [
206,
4
] | [
222,
73
] | python | en | ['en', 'en', 'en'] | True |
TocExtension.slugify | (self, value) | Slugify a string, to make it URL friendly. | Slugify a string, to make it URL friendly. | def slugify(self, value):
""" Slugify a string, to make it URL friendly. """
import unicodedata
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
return re.sub('[-\s]+','-',value) | [
"def",
"slugify",
"(",
"self",
",",
"value",
")",
":",
"import",
"unicodedata",
"value",
"=",
"unicodedata",
".",
"normalize",
"(",
"'NFKD'",
",",
"value",
")",
".",
"encode",
"(",
"'ascii'",
",",
"'ignore'",
")",
"value",
"=",
"unicode",
"(",
"re",
".... | [
122,
4
] | [
127,
41
] | python | en | ['en', 'cy', 'en'] | True |
add_ratelimit_rule | (range_seconds: int, num_requests: int, domain: str = "api_by_user") | Add a rate-limiting rule to the ratelimiter | Add a rate-limiting rule to the ratelimiter | def add_ratelimit_rule(range_seconds: int, num_requests: int, domain: str = "api_by_user") -> None:
"Add a rate-limiting rule to the ratelimiter"
global rules
if domain not in rules:
# If we don't have any rules for domain yet, the domain key needs to be
# added to the rules dictionary.
... | [
"def",
"add_ratelimit_rule",
"(",
"range_seconds",
":",
"int",
",",
"num_requests",
":",
"int",
",",
"domain",
":",
"str",
"=",
"\"api_by_user\"",
")",
"->",
"None",
":",
"global",
"rules",
"if",
"domain",
"not",
"in",
"rules",
":",
"# If we don't have any rul... | [
139,
0
] | [
149,
42
] | python | en | ['en', 'en', 'en'] | True |
RateLimitedObject.block_access | (self, seconds: int) | Manually blocks an entity for the desired number of seconds | Manually blocks an entity for the desired number of seconds | def block_access(self, seconds: int) -> None:
"Manually blocks an entity for the desired number of seconds"
self.backend.block_access(self.key(), seconds) | [
"def",
"block_access",
"(",
"self",
",",
"seconds",
":",
"int",
")",
"->",
"None",
":",
"self",
".",
"backend",
".",
"block_access",
"(",
"self",
".",
"key",
"(",
")",
",",
"seconds",
")"
] | [
66,
4
] | [
68,
54
] | python | en | ['en', 'en', 'en'] | True |
RateLimitedObject.max_api_calls | (self) | Returns the API rate limit for the highest limit | Returns the API rate limit for the highest limit | def max_api_calls(self) -> int:
"Returns the API rate limit for the highest limit"
return self.get_rules()[-1][1] | [
"def",
"max_api_calls",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"get_rules",
"(",
")",
"[",
"-",
"1",
"]",
"[",
"1",
"]"
] | [
76,
4
] | [
78,
38
] | python | en | ['en', 'en', 'en'] | True |
RateLimitedObject.max_api_window | (self) | Returns the API time window for the highest limit | Returns the API time window for the highest limit | def max_api_window(self) -> int:
"Returns the API time window for the highest limit"
return self.get_rules()[-1][0] | [
"def",
"max_api_window",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"get_rules",
"(",
")",
"[",
"-",
"1",
"]",
"[",
"0",
"]"
] | [
80,
4
] | [
82,
38
] | python | en | ['en', 'en', 'en'] | True |
RateLimitedObject.api_calls_left | (self) | Returns how many API calls in this range this client has, as well as when
the rate-limit will be reset to 0 | Returns how many API calls in this range this client has, as well as when
the rate-limit will be reset to 0 | def api_calls_left(self) -> Tuple[int, float]:
"""Returns how many API calls in this range this client has, as well as when
the rate-limit will be reset to 0"""
max_window = self.max_api_window()
max_calls = self.max_api_calls()
return self.backend.get_api_calls_left(self.key(), ... | [
"def",
"api_calls_left",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"float",
"]",
":",
"max_window",
"=",
"self",
".",
"max_api_window",
"(",
")",
"max_calls",
"=",
"self",
".",
"max_api_calls",
"(",
")",
"return",
"self",
".",
"backend",
".",
"... | [
84,
4
] | [
89,
81
] | python | en | ['en', 'en', 'en'] | True |
RateLimitedObject.get_rules | (self) |
This is a simple wrapper meant to protect against having to deal with
an empty list of rules, as it would require fiddling with that special case
all around this system. "9999 max request per seconds" should be a good proxy
for "no rules".
|
This is a simple wrapper meant to protect against having to deal with
an empty list of rules, as it would require fiddling with that special case
all around this system. "9999 max request per seconds" should be a good proxy
for "no rules".
| def get_rules(self) -> List[Tuple[int, int]]:
"""
This is a simple wrapper meant to protect against having to deal with
an empty list of rules, as it would require fiddling with that special case
all around this system. "9999 max request per seconds" should be a good proxy
for "n... | [
"def",
"get_rules",
"(",
"self",
")",
"->",
"List",
"[",
"Tuple",
"[",
"int",
",",
"int",
"]",
"]",
":",
"rules_list",
"=",
"self",
".",
"rules",
"(",
")",
"return",
"rules_list",
"or",
"[",
"(",
"1",
",",
"9999",
")",
"]"
] | [
91,
4
] | [
99,
40
] | python | en | ['en', 'error', 'th'] | False |
RateLimiterBackend.block_access | (cls, entity_key: str, seconds: int) | Manually blocks an entity for the desired number of seconds | Manually blocks an entity for the desired number of seconds | def block_access(cls, entity_key: str, seconds: int) -> None:
"Manually blocks an entity for the desired number of seconds" | [
"def",
"block_access",
"(",
"cls",
",",
"entity_key",
":",
"str",
",",
"seconds",
":",
"int",
")",
"->",
"None",
":"
] | [
162,
4
] | [
163,
69
] | python | en | ['en', 'en', 'en'] | True |
TornadoInMemoryRateLimiterBackend.need_to_limit | (cls, entity_key: str, time_window: int, max_count: int) |
Returns a tuple of `(rate_limited, time_till_free)`.
For simplicity, we have loosened the semantics here from
- each key may make atmost `count * (t / window)` request within any t
time interval.
to
- each key may make atmost `count * [(t / window) + 1]` request within... |
Returns a tuple of `(rate_limited, time_till_free)`.
For simplicity, we have loosened the semantics here from
- each key may make atmost `count * (t / window)` request within any t
time interval.
to
- each key may make atmost `count * [(t / window) + 1]` request within... | def need_to_limit(cls, entity_key: str, time_window: int, max_count: int) -> Tuple[bool, float]:
"""
Returns a tuple of `(rate_limited, time_till_free)`.
For simplicity, we have loosened the semantics here from
- each key may make atmost `count * (t / window)` request within any t
... | [
"def",
"need_to_limit",
"(",
"cls",
",",
"entity_key",
":",
"str",
",",
"time_window",
":",
"int",
",",
"max_count",
":",
"int",
")",
"->",
"Tuple",
"[",
"bool",
",",
"float",
"]",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"# Remove all timestamp... | [
224,
4
] | [
254,
25
] | python | en | ['en', 'error', 'th'] | False |
RedisRateLimiterBackend.block_access | (cls, entity_key: str, seconds: int) | Manually blocks an entity for the desired number of seconds | Manually blocks an entity for the desired number of seconds | def block_access(cls, entity_key: str, seconds: int) -> None:
"Manually blocks an entity for the desired number of seconds"
_, _, blocking_key = cls.get_keys(entity_key)
with client.pipeline() as pipe:
pipe.set(blocking_key, 1)
pipe.expire(blocking_key, seconds)
... | [
"def",
"block_access",
"(",
"cls",
",",
"entity_key",
":",
"str",
",",
"seconds",
":",
"int",
")",
"->",
"None",
":",
"_",
",",
"_",
",",
"blocking_key",
"=",
"cls",
".",
"get_keys",
"(",
"entity_key",
")",
"with",
"client",
".",
"pipeline",
"(",
")"... | [
318,
4
] | [
324,
26
] | python | en | ['en', 'en', 'en'] | True |
RedisRateLimiterBackend.is_ratelimited | (cls, entity_key: str, rules: List[Tuple[int, int]]) | Returns a tuple of (rate_limited, time_till_free) | Returns a tuple of (rate_limited, time_till_free) | def is_ratelimited(cls, entity_key: str, rules: List[Tuple[int, int]]) -> Tuple[bool, float]:
"Returns a tuple of (rate_limited, time_till_free)"
assert rules
list_key, set_key, blocking_key = cls.get_keys(entity_key)
# Go through the rules from shortest to longest,
# seeing if ... | [
"def",
"is_ratelimited",
"(",
"cls",
",",
"entity_key",
":",
"str",
",",
"rules",
":",
"List",
"[",
"Tuple",
"[",
"int",
",",
"int",
"]",
"]",
")",
"->",
"Tuple",
"[",
"bool",
",",
"float",
"]",
":",
"assert",
"rules",
"list_key",
",",
"set_key",
"... | [
367,
4
] | [
409,
25
] | python | en | ['en', 'en', 'en'] | True |
RedisRateLimiterBackend.incr_ratelimit | (cls, entity_key: str, max_api_calls: int, max_api_window: int) | Increases the rate-limit for the specified entity | Increases the rate-limit for the specified entity | def incr_ratelimit(cls, entity_key: str, max_api_calls: int, max_api_window: int) -> None:
"""Increases the rate-limit for the specified entity"""
list_key, set_key, _ = cls.get_keys(entity_key)
now = time.time()
# Start Redis transaction
with client.pipeline() as pipe:
... | [
"def",
"incr_ratelimit",
"(",
"cls",
",",
"entity_key",
":",
"str",
",",
"max_api_calls",
":",
"int",
",",
"max_api_window",
":",
"int",
")",
"->",
"None",
":",
"list_key",
",",
"set_key",
",",
"_",
"=",
"cls",
".",
"get_keys",
"(",
"entity_key",
")",
... | [
412,
4
] | [
463,
28
] | python | en | ['en', 'en', 'en'] | True |
_build_pack_info_from_dones | (dones: torch.Tensor, T: int) |
Create the indexing info needed to make the PackedSequence based on the dones.
PackedSequences are PyTorch's way of supporting a single RNN forward
call where each input in the batch can have an arbitrary sequence length
They work as follows: Given the sequences [c], [x, y, z], [a, b],
we generat... |
Create the indexing info needed to make the PackedSequence based on the dones. | def _build_pack_info_from_dones(dones: torch.Tensor, T: int) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
"""
Create the indexing info needed to make the PackedSequence based on the dones.
PackedSequences are PyTorch's way of supporting a single RNN forward
call where... | [
"def",
"_build_pack_info_from_dones",
"(",
"dones",
":",
"torch",
".",
"Tensor",
",",
"T",
":",
"int",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
",",
"torch",... | [
36,
0
] | [
132,
88
] | python | en | ['en', 'error', 'th'] | False |
build_rnn_inputs | (x, dones_cpu, rnn_states, T: int) |
Create a PackedSequence input for an RNN such that each
set of steps that are part of the same episode are all part of
a batch in the PackedSequence.
Use the returned select_inds and build_core_out_from_seq to invert this.
:param x: A (N*T, -1) tensor of the data to build the PackedSequence out of
... |
Create a PackedSequence input for an RNN such that each
set of steps that are part of the same episode are all part of
a batch in the PackedSequence.
Use the returned select_inds and build_core_out_from_seq to invert this.
:param x: A (N*T, -1) tensor of the data to build the PackedSequence out of
... | def build_rnn_inputs(x, dones_cpu, rnn_states, T: int):
"""
Create a PackedSequence input for an RNN such that each
set of steps that are part of the same episode are all part of
a batch in the PackedSequence.
Use the returned select_inds and build_core_out_from_seq to invert this.
:param x: A (... | [
"def",
"build_rnn_inputs",
"(",
"x",
",",
"dones_cpu",
",",
"rnn_states",
",",
"T",
":",
"int",
")",
":",
"rollout_starts",
",",
"is_new_episode",
",",
"select_inds",
",",
"batch_sizes",
",",
"sorted_indices",
"=",
"_build_pack_info_from_dones",
"(",
"dones_cpu",
... | [
135,
0
] | [
175,
50
] | python | en | ['en', 'error', 'th'] | False |
LearnerWorker._calculate_gae | (self, buffer) |
Calculate advantages using Generalized Advantage Estimation.
This is leftover the from previous version of the algorithm.
Perhaps should be re-implemented in PyTorch tensors, similar to V-trace for uniformity.
|
Calculate advantages using Generalized Advantage Estimation.
This is leftover the from previous version of the algorithm.
Perhaps should be re-implemented in PyTorch tensors, similar to V-trace for uniformity.
| def _calculate_gae(self, buffer):
"""
Calculate advantages using Generalized Advantage Estimation.
This is leftover the from previous version of the algorithm.
Perhaps should be re-implemented in PyTorch tensors, similar to V-trace for uniformity.
"""
rewards = torch.sta... | [
"def",
"_calculate_gae",
"(",
"self",
",",
"buffer",
")",
":",
"rewards",
"=",
"torch",
".",
"stack",
"(",
"buffer",
".",
"rewards",
")",
".",
"numpy",
"(",
")",
".",
"squeeze",
"(",
")",
"# [E, T]",
"dones",
"=",
"torch",
".",
"stack",
"(",
"buffer"... | [
294,
4
] | [
329,
21
] | python | en | ['en', 'error', 'th'] | False |
LearnerWorker._get_minibatches | (self, batch_size, experience_size) | Generating minibatches for training. | Generating minibatches for training. | def _get_minibatches(self, batch_size, experience_size):
"""Generating minibatches for training."""
assert self.cfg.rollout % self.cfg.recurrence == 0
assert experience_size % batch_size == 0, f'experience size: {experience_size}, batch size: {batch_size}'
if self.cfg.num_batches_per_it... | [
"def",
"_get_minibatches",
"(",
"self",
",",
"batch_size",
",",
"experience_size",
")",
":",
"assert",
"self",
".",
"cfg",
".",
"rollout",
"%",
"self",
".",
"cfg",
".",
"recurrence",
"==",
"0",
"assert",
"experience_size",
"%",
"batch_size",
"==",
"0",
","... | [
449,
4
] | [
469,
26
] | python | en | ['en', 'en', 'en'] | True |
LearnerWorker._after_optimizer_step | (self) | A hook to be called after each optimizer step. | A hook to be called after each optimizer step. | def _after_optimizer_step(self):
"""A hook to be called after each optimizer step."""
self.train_step += 1
self._maybe_save() | [
"def",
"_after_optimizer_step",
"(",
"self",
")",
":",
"self",
".",
"train_step",
"+=",
"1",
"self",
".",
"_maybe_save",
"(",
")"
] | [
496,
4
] | [
499,
26
] | python | en | ['en', 'en', 'en'] | True |
LearnerWorker._update_pbt | (self) | To be called from the training loop, same thread that updates the model! | To be called from the training loop, same thread that updates the model! | def _update_pbt(self):
"""To be called from the training loop, same thread that updates the model!"""
with self.pbt_mutex:
if self.load_policy_id is not None:
assert self.cfg.with_pbt
log.debug('Learner %d loads policy from %d', self.policy_id, self.load_poli... | [
"def",
"_update_pbt",
"(",
"self",
")",
":",
"with",
"self",
".",
"pbt_mutex",
":",
"if",
"self",
".",
"load_policy_id",
"is",
"not",
"None",
":",
"assert",
"self",
".",
"cfg",
".",
"with_pbt",
"log",
".",
"debug",
"(",
"'Learner %d loads policy from %d'",
... | [
875,
4
] | [
896,
35
] | python | en | ['en', 'en', 'en'] | True |
isString | (s) | Check if it's string | Check if it's string | def isString(s):
""" Check if it's string """
return isinstance(s, unicode) or isinstance(s, str) | [
"def",
"isString",
"(",
"s",
")",
":",
"return",
"isinstance",
"(",
"s",
",",
"unicode",
")",
"or",
"isinstance",
"(",
"s",
",",
"str",
")"
] | [
3,
0
] | [
5,
55
] | python | en | ['en', 'en', 'en'] | True |
Treeprocessor.run | (self, root) |
Subclasses of Treeprocessor should implement a `run` method, which
takes a root ElementTree. This method can return another ElementTree
object, and the existing root ElementTree will be replaced, or it can
modify the current tree and return None.
|
Subclasses of Treeprocessor should implement a `run` method, which
takes a root ElementTree. This method can return another ElementTree
object, and the existing root ElementTree will be replaced, or it can
modify the current tree and return None.
| def run(self, root):
"""
Subclasses of Treeprocessor should implement a `run` method, which
takes a root ElementTree. This method can return another ElementTree
object, and the existing root ElementTree will be replaced, or it can
modify the current tree and return None.
... | [
"def",
"run",
"(",
"self",
",",
"root",
")",
":",
"pass"
] | [
23,
4
] | [
30,
12
] | python | en | ['en', 'error', 'th'] | False |
InlineProcessor.__makePlaceholder | (self, type) | Generate a placeholder | Generate a placeholder | def __makePlaceholder(self, type):
""" Generate a placeholder """
id = "%04d" % len(self.stashed_nodes)
hash = markdown.INLINE_PLACEHOLDER % id
return hash, id | [
"def",
"__makePlaceholder",
"(",
"self",
",",
"type",
")",
":",
"id",
"=",
"\"%04d\"",
"%",
"len",
"(",
"self",
".",
"stashed_nodes",
")",
"hash",
"=",
"markdown",
".",
"INLINE_PLACEHOLDER",
"%",
"id",
"return",
"hash",
",",
"id"
] | [
46,
4
] | [
50,
23
] | python | en | ['en', 'en', 'en'] | True |
InlineProcessor.__findPlaceholder | (self, data, index) |
Extract id from data string, start from index
Keyword arguments:
* data: string
* index: index, from which we start search
Returns: placeholder id and string index, after the found placeholder.
|
Extract id from data string, start from index | def __findPlaceholder(self, data, index):
"""
Extract id from data string, start from index
Keyword arguments:
* data: string
* index: index, from which we start search
Returns: placeholder id and string index, after the found placeholder.
"""
m = self... | [
"def",
"__findPlaceholder",
"(",
"self",
",",
"data",
",",
"index",
")",
":",
"m",
"=",
"self",
".",
"__placeholder_re",
".",
"search",
"(",
"data",
",",
"index",
")",
"if",
"m",
":",
"return",
"m",
".",
"group",
"(",
"1",
")",
",",
"m",
".",
"en... | [
52,
4
] | [
68,
34
] | python | en | ['en', 'error', 'th'] | False |
InlineProcessor.__stashNode | (self, node, type) | Add node to stash | Add node to stash | def __stashNode(self, node, type):
""" Add node to stash """
placeholder, id = self.__makePlaceholder(type)
self.stashed_nodes[id] = node
return placeholder | [
"def",
"__stashNode",
"(",
"self",
",",
"node",
",",
"type",
")",
":",
"placeholder",
",",
"id",
"=",
"self",
".",
"__makePlaceholder",
"(",
"type",
")",
"self",
".",
"stashed_nodes",
"[",
"id",
"]",
"=",
"node",
"return",
"placeholder"
] | [
70,
4
] | [
74,
26
] | python | en | ['en', 'de', 'en'] | True |
InlineProcessor.__handleInline | (self, data, patternIndex=0) |
Process string with inline patterns and replace it
with placeholders
Keyword arguments:
* data: A line of Markdown text
* patternIndex: The index of the inlinePattern to start with
Returns: String with placeholders.
|
Process string with inline patterns and replace it
with placeholders | def __handleInline(self, data, patternIndex=0):
"""
Process string with inline patterns and replace it
with placeholders
Keyword arguments:
* data: A line of Markdown text
* patternIndex: The index of the inlinePattern to start with
Returns: String with placeho... | [
"def",
"__handleInline",
"(",
"self",
",",
"data",
",",
"patternIndex",
"=",
"0",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"markdown",
".",
"AtomicString",
")",
":",
"startIndex",
"=",
"0",
"while",
"patternIndex",
"<",
"len",
"(",
"self",
... | [
76,
4
] | [
97,
19
] | python | en | ['en', 'error', 'th'] | False |
InlineProcessor.__processElementText | (self, node, subnode, isText=True) |
Process placeholders in Element.text or Element.tail
of Elements popped from self.stashed_nodes.
Keywords arguments:
* node: parent node
* subnode: processing node
* isText: bool variable, True - it's text, False - it's tail
Returns: None
|
Process placeholders in Element.text or Element.tail
of Elements popped from self.stashed_nodes. | def __processElementText(self, node, subnode, isText=True):
"""
Process placeholders in Element.text or Element.tail
of Elements popped from self.stashed_nodes.
Keywords arguments:
* node: parent node
* subnode: processing node
* isText: bool variable, True - it... | [
"def",
"__processElementText",
"(",
"self",
",",
"node",
",",
"subnode",
",",
"isText",
"=",
"True",
")",
":",
"if",
"isText",
":",
"text",
"=",
"subnode",
".",
"text",
"subnode",
".",
"text",
"=",
"None",
"else",
":",
"text",
"=",
"subnode",
".",
"t... | [
99,
4
] | [
130,
38
] | python | en | ['en', 'error', 'th'] | False |
InlineProcessor.__processPlaceholders | (self, data, parent) |
Process string with placeholders and generate ElementTree tree.
Keyword arguments:
* data: string with placeholders instead of ElementTree elements.
* parent: Element, which contains processing inline data
Returns: list with ElementTree elements with applied inline patterns.
... |
Process string with placeholders and generate ElementTree tree. | def __processPlaceholders(self, data, parent):
"""
Process string with placeholders and generate ElementTree tree.
Keyword arguments:
* data: string with placeholders instead of ElementTree elements.
* parent: Element, which contains processing inline data
Returns: lis... | [
"def",
"__processPlaceholders",
"(",
"self",
",",
"data",
",",
"parent",
")",
":",
"def",
"linkText",
"(",
"text",
")",
":",
"if",
"text",
":",
"if",
"result",
":",
"if",
"result",
"[",
"-",
"1",
"]",
".",
"tail",
":",
"result",
"[",
"-",
"1",
"]... | [
132,
4
] | [
195,
21
] | python | en | ['en', 'error', 'th'] | False |
InlineProcessor.__applyPattern | (self, pattern, data, patternIndex, startIndex=0) |
Check if the line fits the pattern, create the necessary
elements, add it to stashed_nodes.
Keyword arguments:
* data: the text to be processed
* pattern: the pattern to be checked
* patternIndex: index of current pattern
* startIndex: string index, from which ... |
Check if the line fits the pattern, create the necessary
elements, add it to stashed_nodes. | def __applyPattern(self, pattern, data, patternIndex, startIndex=0):
"""
Check if the line fits the pattern, create the necessary
elements, add it to stashed_nodes.
Keyword arguments:
* data: the text to be processed
* pattern: the pattern to be checked
* patter... | [
"def",
"__applyPattern",
"(",
"self",
",",
"pattern",
",",
"data",
",",
"patternIndex",
",",
"startIndex",
"=",
"0",
")",
":",
"match",
"=",
"pattern",
".",
"getCompiledRegExp",
"(",
")",
".",
"match",
"(",
"data",
"[",
"startIndex",
":",
"]",
")",
"le... | [
197,
4
] | [
239,
70
] | python | en | ['en', 'error', 'th'] | False |
InlineProcessor.run | (self, tree) | Apply inline patterns to a parsed Markdown tree.
Iterate over ElementTree, find elements with inline tag, apply inline
patterns and append newly created Elements to tree. If you don't
want process your data with inline paterns, instead of normal string,
use subclass AtomicString:
... | Apply inline patterns to a parsed Markdown tree. | def run(self, tree):
"""Apply inline patterns to a parsed Markdown tree.
Iterate over ElementTree, find elements with inline tag, apply inline
patterns and append newly created Elements to tree. If you don't
want process your data with inline paterns, instead of normal string,
... | [
"def",
"run",
"(",
"self",
",",
"tree",
")",
":",
"self",
".",
"stashed_nodes",
"=",
"{",
"}",
"stack",
"=",
"[",
"tree",
"]",
"while",
"stack",
":",
"currElement",
"=",
"stack",
".",
"pop",
"(",
")",
"insertQueue",
"=",
"[",
"]",
"for",
"child",
... | [
241,
4
] | [
295,
19
] | python | en | ['en', 'en', 'en'] | True |
PrettifyTreeprocessor._prettifyETree | (self, elem) | Recursively add linebreaks to ElementTree children. | Recursively add linebreaks to ElementTree children. | def _prettifyETree(self, elem):
""" Recursively add linebreaks to ElementTree children. """
i = "\n"
if markdown.isBlockLevel(elem.tag) and elem.tag not in ['code', 'pre']:
if (not elem.text or not elem.text.strip()) \
and len(elem) and markdown.isBlockLevel(elem... | [
"def",
"_prettifyETree",
"(",
"self",
",",
"elem",
")",
":",
"i",
"=",
"\"\\n\"",
"if",
"markdown",
".",
"isBlockLevel",
"(",
"elem",
".",
"tag",
")",
"and",
"elem",
".",
"tag",
"not",
"in",
"[",
"'code'",
",",
"'pre'",
"]",
":",
"if",
"(",
"not",
... | [
301,
4
] | [
315,
25
] | python | en | ['en', 'de', 'en'] | True |
PrettifyTreeprocessor.run | (self, root) | Add linebreaks to ElementTree root object. | Add linebreaks to ElementTree root object. | def run(self, root):
""" Add linebreaks to ElementTree root object. """
self._prettifyETree(root)
# Do <br />'s seperately as they are often in the middle of
# inline content and missed by _prettifyETree.
brs = root.getiterator('br')
for br in brs:
if not br.... | [
"def",
"run",
"(",
"self",
",",
"root",
")",
":",
"self",
".",
"_prettifyETree",
"(",
"root",
")",
"# Do <br />'s seperately as they are often in the middle of",
"# inline content and missed by _prettifyETree.",
"brs",
"=",
"root",
".",
"getiterator",
"(",
"'br'",
")",
... | [
317,
4
] | [
328,
42
] | python | en | ['en', 'fy', 'en'] | True |
compatible_tags | () |
Return (pyver, abi, arch) tuples compatible with this Python.
|
Return (pyver, abi, arch) tuples compatible with this Python.
| def compatible_tags():
"""
Return (pyver, abi, arch) tuples compatible with this Python.
"""
versions = [VER_SUFFIX]
major = VER_SUFFIX[0]
for minor in range(sys.version_info[1] - 1, - 1, -1):
versions.append(''.join([major, str(minor)]))
abis = []
for suffix, _, _ in imp.get_su... | [
"def",
"compatible_tags",
"(",
")",
":",
"versions",
"=",
"[",
"VER_SUFFIX",
"]",
"major",
"=",
"VER_SUFFIX",
"[",
"0",
"]",
"for",
"minor",
"in",
"range",
"(",
"sys",
".",
"version_info",
"[",
"1",
"]",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
")... | [
940,
0
] | [
999,
22
] | python | en | ['en', 'error', 'th'] | False |
Wheel.__init__ | (self, filename=None, sign=False, verify=False) |
Initialise an instance using a (valid) filename.
|
Initialise an instance using a (valid) filename.
| def __init__(self, filename=None, sign=False, verify=False):
"""
Initialise an instance using a (valid) filename.
"""
self.sign = sign
self.should_verify = verify
self.buildver = ''
self.pyver = [PYVER]
self.abi = ['none']
self.arch = ['any']
... | [
"def",
"__init__",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"sign",
"=",
"False",
",",
"verify",
"=",
"False",
")",
":",
"self",
".",
"sign",
"=",
"sign",
"self",
".",
"should_verify",
"=",
"verify",
"self",
".",
"buildver",
"=",
"''",
"self",... | [
144,
4
] | [
183,
49
] | python | en | ['en', 'error', 'th'] | False |
Wheel.filename | (self) |
Build and return a filename from the various components.
|
Build and return a filename from the various components.
| def filename(self):
"""
Build and return a filename from the various components.
"""
if self.buildver:
buildver = '-' + self.buildver
else:
buildver = ''
pyver = '.'.join(self.pyver)
abi = '.'.join(self.abi)
arch = '.'.join(self.arc... | [
"def",
"filename",
"(",
"self",
")",
":",
"if",
"self",
".",
"buildver",
":",
"buildver",
"=",
"'-'",
"+",
"self",
".",
"buildver",
"else",
":",
"buildver",
"=",
"''",
"pyver",
"=",
"'.'",
".",
"join",
"(",
"self",
".",
"pyver",
")",
"abi",
"=",
... | [
186,
4
] | [
200,
58
] | python | en | ['en', 'error', 'th'] | False |
Wheel.build | (self, paths, tags=None, wheel_version=None) |
Build a wheel from files in specified paths, and use any specified tags
when determining the name of the wheel.
|
Build a wheel from files in specified paths, and use any specified tags
when determining the name of the wheel.
| def build(self, paths, tags=None, wheel_version=None):
"""
Build a wheel from files in specified paths, and use any specified tags
when determining the name of the wheel.
"""
if tags is None:
tags = {}
libkey = list(filter(lambda o: o in paths, ('purelib', 'p... | [
"def",
"build",
"(",
"self",
",",
"paths",
",",
"tags",
"=",
"None",
",",
"wheel_version",
"=",
"None",
")",
":",
"if",
"tags",
"is",
"None",
":",
"tags",
"=",
"{",
"}",
"libkey",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"o",
":",
"o",
"in",
... | [
333,
4
] | [
447,
23
] | python | en | ['en', 'error', 'th'] | False |
Wheel.skip_entry | (self, arcname) |
Determine whether an archive entry should be skipped when verifying
or installing.
|
Determine whether an archive entry should be skipped when verifying
or installing.
| def skip_entry(self, arcname):
"""
Determine whether an archive entry should be skipped when verifying
or installing.
"""
# The signature file won't be in RECORD,
# and we don't currently don't do anything with it
# We also skip directories, as they won't be in R... | [
"def",
"skip_entry",
"(",
"self",
",",
"arcname",
")",
":",
"# The signature file won't be in RECORD,",
"# and we don't currently don't do anything with it",
"# We also skip directories, as they won't be in RECORD",
"# either. See:",
"#",
"# https://github.com/pypa/wheel/issues/294",
"#... | [
449,
4
] | [
463,
53
] | python | en | ['en', 'error', 'th'] | False |
Wheel.install | (self, paths, maker, **kwargs) |
Install a wheel to the specified paths. If kwarg ``warner`` is
specified, it should be a callable, which will be called with two
tuples indicating the wheel version of this software and the wheel
version in the file, if there is a discrepancy in the versions.
This can be used to... |
Install a wheel to the specified paths. If kwarg ``warner`` is
specified, it should be a callable, which will be called with two
tuples indicating the wheel version of this software and the wheel
version in the file, if there is a discrepancy in the versions.
This can be used to... | def install(self, paths, maker, **kwargs):
"""
Install a wheel to the specified paths. If kwarg ``warner`` is
specified, it should be a callable, which will be called with two
tuples indicating the wheel version of this software and the wheel
version in the file, if there is a di... | [
"def",
"install",
"(",
"self",
",",
"paths",
",",
"maker",
",",
"*",
"*",
"kwargs",
")",
":",
"dry_run",
"=",
"maker",
".",
"dry_run",
"warner",
"=",
"kwargs",
".",
"get",
"(",
"'warner'",
")",
"lib_only",
"=",
"kwargs",
".",
"get",
"(",
"'lib_only'"... | [
465,
4
] | [
693,
38
] | python | en | ['en', 'error', 'th'] | False |
Wheel.is_compatible | (self) |
Determine if a wheel is compatible with the running system.
|
Determine if a wheel is compatible with the running system.
| def is_compatible(self):
"""
Determine if a wheel is compatible with the running system.
"""
return is_compatible(self) | [
"def",
"is_compatible",
"(",
"self",
")",
":",
"return",
"is_compatible",
"(",
"self",
")"
] | [
738,
4
] | [
742,
34
] | python | en | ['en', 'error', 'th'] | False |
Wheel.is_mountable | (self) |
Determine if a wheel is asserted as mountable by its metadata.
|
Determine if a wheel is asserted as mountable by its metadata.
| def is_mountable(self):
"""
Determine if a wheel is asserted as mountable by its metadata.
"""
return True | [
"def",
"is_mountable",
"(",
"self",
")",
":",
"return",
"True"
] | [
744,
4
] | [
748,
19
] | python | en | ['en', 'error', 'th'] | False |
Wheel.update | (self, modifier, dest_dir=None, **kwargs) |
Update the contents of a wheel in a generic way. The modifier should
be a callable which expects a dictionary argument: its keys are
archive-entry paths, and its values are absolute filesystem paths
where the contents the corresponding archive entries can be found. The
modifier ... |
Update the contents of a wheel in a generic way. The modifier should
be a callable which expects a dictionary argument: its keys are
archive-entry paths, and its values are absolute filesystem paths
where the contents the corresponding archive entries can be found. The
modifier ... | def update(self, modifier, dest_dir=None, **kwargs):
"""
Update the contents of a wheel in a generic way. The modifier should
be a callable which expects a dictionary argument: its keys are
archive-entry paths, and its values are absolute filesystem paths
where the contents the c... | [
"def",
"update",
"(",
"self",
",",
"modifier",
",",
"dest_dir",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"get_version",
"(",
"path_map",
",",
"info_dir",
")",
":",
"version",
"=",
"path",
"=",
"None",
"key",
"=",
"'%s/%s'",
"%",
"(",
... | [
839,
4
] | [
938,
23
] | python | en | ['en', 'error', 'th'] | False |
SemaphoreHookTests.get_unknown_event | (self, fixture_name: str) | Return modified payload with revision.reference_type changed | Return modified payload with revision.reference_type changed | def get_unknown_event(self, fixture_name: str) -> str:
"""Return modified payload with revision.reference_type changed"""
fixture_data = orjson.loads(
self.webhook_fixture_data("semaphore", fixture_name, file_type="json")
)
fixture_data["revision"]["reference_type"] = "unknow... | [
"def",
"get_unknown_event",
"(",
"self",
",",
"fixture_name",
":",
"str",
")",
"->",
"str",
":",
"fixture_data",
"=",
"orjson",
".",
"loads",
"(",
"self",
".",
"webhook_fixture_data",
"(",
"\"semaphore\"",
",",
"fixture_name",
",",
"file_type",
"=",
"\"json\""... | [
131,
4
] | [
137,
27
] | python | en | ['en', 'en', 'en'] | True |
pack | (directory, dest_dir, build_number) | Repack a previously unpacked wheel directory into a new wheel file.
The .dist-info/WHEEL file must contain one or more tags so that the target
wheel file name can be determined.
:param directory: The unpacked wheel directory
:param dest_dir: Destination directory (defaults to the current directory)
... | Repack a previously unpacked wheel directory into a new wheel file. | def pack(directory, dest_dir, build_number):
"""Repack a previously unpacked wheel directory into a new wheel file.
The .dist-info/WHEEL file must contain one or more tags so that the target
wheel file name can be determined.
:param directory: The unpacked wheel directory
:param dest_dir: Destinat... | [
"def",
"pack",
"(",
"directory",
",",
"dest_dir",
",",
"build_number",
")",
":",
"# Find the .dist-info directory",
"dist_info_dirs",
"=",
"[",
"fn",
"for",
"fn",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"("... | [
13,
0
] | [
78,
15
] | python | en | ['en', 'en', 'en'] | True |
msvc9_find_vcvarsall | (version) |
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone
compiler build for Python
(VCForPython / Microsoft Visual C++ Compiler for Python 2.7).
Fall back to original behavior when the standalone compiler is not
available.
Redirect the path of "vcvarsall.bat".
Parameters
... |
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone
compiler build for Python
(VCForPython / Microsoft Visual C++ Compiler for Python 2.7). | def msvc9_find_vcvarsall(version):
"""
Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone
compiler build for Python
(VCForPython / Microsoft Visual C++ Compiler for Python 2.7).
Fall back to original behavior when the standalone compiler is not
available.
Redirect the p... | [
"def",
"msvc9_find_vcvarsall",
"(",
"version",
")",
":",
"vc_base",
"=",
"r'Software\\%sMicrosoft\\DevDiv\\VCForPython\\%0.1f'",
"key",
"=",
"vc_base",
"%",
"(",
"''",
",",
"version",
")",
"try",
":",
"# Per-user installs register the compiler path here",
"productdir",
"=... | [
63,
0
] | [
102,
55
] | python | en | ['en', 'error', 'th'] | False |
msvc9_query_vcvarsall | (ver, arch='x86', *args, **kwargs) |
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra
Microsoft Visual C++ 9.0 and 10.0 compilers.
Set environment without use of "vcvarsall.bat".
Parameters
----------
ver: float
Required Microsoft Visual C++ version.
arch: str
Target architecture.
Retu... |
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra
Microsoft Visual C++ 9.0 and 10.0 compilers. | def msvc9_query_vcvarsall(ver, arch='x86', *args, **kwargs):
"""
Patched "distutils.msvc9compiler.query_vcvarsall" for support extra
Microsoft Visual C++ 9.0 and 10.0 compilers.
Set environment without use of "vcvarsall.bat".
Parameters
----------
ver: float
Required Microsoft Visu... | [
"def",
"msvc9_query_vcvarsall",
"(",
"ver",
",",
"arch",
"=",
"'x86'",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Try to get environment from vcvarsall.bat (Classical way)",
"try",
":",
"orig",
"=",
"get_unpatched",
"(",
"msvc9_query_vcvarsall",
")",
... | [
105,
0
] | [
140,
13
] | python | en | ['en', 'error', 'th'] | False |
_msvc14_find_vc2015 | () | Python 3.8 "distutils/_msvccompiler.py" backport | Python 3.8 "distutils/_msvccompiler.py" backport | def _msvc14_find_vc2015():
"""Python 3.8 "distutils/_msvccompiler.py" backport"""
try:
key = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE,
r"Software\Microsoft\VisualStudio\SxS\VC7",
0,
winreg.KEY_READ | winreg.KEY_WOW64_32KEY
)
except OSError:
... | [
"def",
"_msvc14_find_vc2015",
"(",
")",
":",
"try",
":",
"key",
"=",
"winreg",
".",
"OpenKey",
"(",
"winreg",
".",
"HKEY_LOCAL_MACHINE",
",",
"r\"Software\\Microsoft\\VisualStudio\\SxS\\VC7\"",
",",
"0",
",",
"winreg",
".",
"KEY_READ",
"|",
"winreg",
".",
"KEY_W... | [
143,
0
] | [
170,
33
] | python | ceb | ['fi', 'ceb', 'en'] | False |
_msvc14_find_vc2017 | () | Python 3.8 "distutils/_msvccompiler.py" backport
Returns "15, path" based on the result of invoking vswhere.exe
If no install is found, returns "None, None"
The version is returned to avoid unnecessarily changing the function
result. It may be ignored when the path is not None.
If vswhere.exe is ... | Python 3.8 "distutils/_msvccompiler.py" backport | def _msvc14_find_vc2017():
"""Python 3.8 "distutils/_msvccompiler.py" backport
Returns "15, path" based on the result of invoking vswhere.exe
If no install is found, returns "None, None"
The version is returned to avoid unnecessarily changing the function
result. It may be ignored when the path is... | [
"def",
"_msvc14_find_vc2017",
"(",
")",
":",
"root",
"=",
"environ",
".",
"get",
"(",
"\"ProgramFiles(x86)\"",
")",
"or",
"environ",
".",
"get",
"(",
"\"ProgramFiles\"",
")",
"if",
"not",
"root",
":",
"return",
"None",
",",
"None",
"try",
":",
"path",
"=... | [
173,
0
] | [
205,
21
] | python | ceb | ['fi', 'ceb', 'en'] | False |
_msvc14_find_vcvarsall | (plat_spec) | Python 3.8 "distutils/_msvccompiler.py" backport | Python 3.8 "distutils/_msvccompiler.py" backport | def _msvc14_find_vcvarsall(plat_spec):
"""Python 3.8 "distutils/_msvccompiler.py" backport"""
_, best_dir = _msvc14_find_vc2017()
vcruntime = None
if plat_spec in PLAT_SPEC_TO_RUNTIME:
vcruntime_plat = PLAT_SPEC_TO_RUNTIME[plat_spec]
else:
vcruntime_plat = 'x64' if 'amd64' in plat_s... | [
"def",
"_msvc14_find_vcvarsall",
"(",
"plat_spec",
")",
":",
"_",
",",
"best_dir",
"=",
"_msvc14_find_vc2017",
"(",
")",
"vcruntime",
"=",
"None",
"if",
"plat_spec",
"in",
"PLAT_SPEC_TO_RUNTIME",
":",
"vcruntime_plat",
"=",
"PLAT_SPEC_TO_RUNTIME",
"[",
"plat_spec",
... | [
216,
0
] | [
252,
31
] | python | ceb | ['fi', 'ceb', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.