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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
AggregatingLocator.__init__ | (self, *locators, **kwargs) |
Initialise an instance.
:param locators: The list of locators to search.
:param kwargs: Passed to the superclass constructor,
except for:
* merge - if False (the default), the first successful
search from any of the locator... |
Initialise an instance. | def __init__(self, *locators, **kwargs):
"""
Initialise an instance.
:param locators: The list of locators to search.
:param kwargs: Passed to the superclass constructor,
except for:
* merge - if False (the default), the first successful
... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"locators",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"merge",
"=",
"kwargs",
".",
"pop",
"(",
"'merge'",
",",
"False",
")",
"self",
".",
"locators",
"=",
"locators",
"super",
"(",
"AggregatingLocator",
... | [
969,
4
] | [
983,
58
] | python | en | ['en', 'error', 'th'] | False |
AggregatingLocator.get_distribution_names | (self) |
Return all the distribution names known to this locator.
|
Return all the distribution names known to this locator.
| def get_distribution_names(self):
"""
Return all the distribution names known to this locator.
"""
result = set()
for locator in self.locators:
try:
result |= locator.get_distribution_names()
except NotImplementedError:
pass... | [
"def",
"get_distribution_names",
"(",
"self",
")",
":",
"result",
"=",
"set",
"(",
")",
"for",
"locator",
"in",
"self",
".",
"locators",
":",
"try",
":",
"result",
"|=",
"locator",
".",
"get_distribution_names",
"(",
")",
"except",
"NotImplementedError",
":"... | [
1041,
4
] | [
1051,
21
] | python | en | ['en', 'error', 'th'] | False |
DependencyFinder.__init__ | (self, locator=None) |
Initialise an instance, using the specified locator
to locate distributions.
|
Initialise an instance, using the specified locator
to locate distributions.
| def __init__(self, locator=None):
"""
Initialise an instance, using the specified locator
to locate distributions.
"""
self.locator = locator or default_locator
self.scheme = get_scheme(self.locator.scheme) | [
"def",
"__init__",
"(",
"self",
",",
"locator",
"=",
"None",
")",
":",
"self",
".",
"locator",
"=",
"locator",
"or",
"default_locator",
"self",
".",
"scheme",
"=",
"get_scheme",
"(",
"self",
".",
"locator",
".",
"scheme",
")"
] | [
1072,
4
] | [
1078,
53
] | python | en | ['en', 'error', 'th'] | False |
DependencyFinder.add_distribution | (self, dist) |
Add a distribution to the finder. This will update internal information
about who provides what.
:param dist: The distribution to add.
|
Add a distribution to the finder. This will update internal information
about who provides what.
:param dist: The distribution to add.
| def add_distribution(self, dist):
"""
Add a distribution to the finder. This will update internal information
about who provides what.
:param dist: The distribution to add.
"""
logger.debug('adding distribution %s', dist)
name = dist.key
self.dists_by_name... | [
"def",
"add_distribution",
"(",
"self",
",",
"dist",
")",
":",
"logger",
".",
"debug",
"(",
"'adding distribution %s'",
",",
"dist",
")",
"name",
"=",
"dist",
".",
"key",
"self",
".",
"dists_by_name",
"[",
"name",
"]",
"=",
"dist",
"self",
".",
"dists",
... | [
1080,
4
] | [
1093,
70
] | python | en | ['en', 'error', 'th'] | False |
DependencyFinder.remove_distribution | (self, dist) |
Remove a distribution from the finder. This will update internal
information about who provides what.
:param dist: The distribution to remove.
|
Remove a distribution from the finder. This will update internal
information about who provides what.
:param dist: The distribution to remove.
| def remove_distribution(self, dist):
"""
Remove a distribution from the finder. This will update internal
information about who provides what.
:param dist: The distribution to remove.
"""
logger.debug('removing distribution %s', dist)
name = dist.key
del s... | [
"def",
"remove_distribution",
"(",
"self",
",",
"dist",
")",
":",
"logger",
".",
"debug",
"(",
"'removing distribution %s'",
",",
"dist",
")",
"name",
"=",
"dist",
".",
"key",
"del",
"self",
".",
"dists_by_name",
"[",
"name",
"]",
"del",
"self",
".",
"di... | [
1095,
4
] | [
1111,
39
] | python | en | ['en', 'error', 'th'] | False |
DependencyFinder.get_matcher | (self, reqt) |
Get a version matcher for a requirement.
:param reqt: The requirement
:type reqt: str
:return: A version matcher (an instance of
:class:`distlib.version.Matcher`).
|
Get a version matcher for a requirement.
:param reqt: The requirement
:type reqt: str
:return: A version matcher (an instance of
:class:`distlib.version.Matcher`).
| def get_matcher(self, reqt):
"""
Get a version matcher for a requirement.
:param reqt: The requirement
:type reqt: str
:return: A version matcher (an instance of
:class:`distlib.version.Matcher`).
"""
try:
matcher = self.scheme.matcher... | [
"def",
"get_matcher",
"(",
"self",
",",
"reqt",
")",
":",
"try",
":",
"matcher",
"=",
"self",
".",
"scheme",
".",
"matcher",
"(",
"reqt",
")",
"except",
"UnsupportedVersionError",
":",
"# pragma: no cover",
"# XXX compat-mode if cannot read the version",
"name",
"... | [
1113,
4
] | [
1127,
22
] | python | en | ['en', 'error', 'th'] | False |
DependencyFinder.find_providers | (self, reqt) |
Find the distributions which can fulfill a requirement.
:param reqt: The requirement.
:type reqt: str
:return: A set of distribution which can fulfill the requirement.
|
Find the distributions which can fulfill a requirement. | def find_providers(self, reqt):
"""
Find the distributions which can fulfill a requirement.
:param reqt: The requirement.
:type reqt: str
:return: A set of distribution which can fulfill the requirement.
"""
matcher = self.get_matcher(reqt)
name = matche... | [
"def",
"find_providers",
"(",
"self",
",",
"reqt",
")",
":",
"matcher",
"=",
"self",
".",
"get_matcher",
"(",
"reqt",
")",
"name",
"=",
"matcher",
".",
"key",
"# case-insensitive",
"result",
"=",
"set",
"(",
")",
"provided",
"=",
"self",
".",
"provided",... | [
1129,
4
] | [
1151,
21
] | python | en | ['en', 'error', 'th'] | False |
DependencyFinder.try_to_replace | (self, provider, other, problems) |
Attempt to replace one provider with another. This is typically used
when resolving dependencies from multiple sources, e.g. A requires
(B >= 1.0) while C requires (B >= 1.1).
For successful replacement, ``provider`` must meet all the requirements
which ``other`` fulfills.
... |
Attempt to replace one provider with another. This is typically used
when resolving dependencies from multiple sources, e.g. A requires
(B >= 1.0) while C requires (B >= 1.1). | def try_to_replace(self, provider, other, problems):
"""
Attempt to replace one provider with another. This is typically used
when resolving dependencies from multiple sources, e.g. A requires
(B >= 1.0) while C requires (B >= 1.1).
For successful replacement, ``provider`` must ... | [
"def",
"try_to_replace",
"(",
"self",
",",
"provider",
",",
"other",
",",
"problems",
")",
":",
"rlist",
"=",
"self",
".",
"reqts",
"[",
"other",
"]",
"unmatched",
"=",
"set",
"(",
")",
"for",
"s",
"in",
"rlist",
":",
"matcher",
"=",
"self",
".",
"... | [
1153,
4
] | [
1191,
21
] | python | en | ['en', 'error', 'th'] | False |
DependencyFinder.find | (self, requirement, meta_extras=None, prereleases=False) |
Find a distribution and all distributions it depends on.
:param requirement: The requirement specifying the distribution to
find, or a Distribution instance.
:param meta_extras: A list of meta extras such as :test:, :build: and
so on.
... |
Find a distribution and all distributions it depends on. | def find(self, requirement, meta_extras=None, prereleases=False):
"""
Find a distribution and all distributions it depends on.
:param requirement: The requirement specifying the distribution to
find, or a Distribution instance.
:param meta_extras: A list of m... | [
"def",
"find",
"(",
"self",
",",
"requirement",
",",
"meta_extras",
"=",
"None",
",",
"prereleases",
"=",
"False",
")",
":",
"self",
".",
"provided",
"=",
"{",
"}",
"self",
".",
"dists",
"=",
"{",
"}",
"self",
".",
"dists_by_name",
"=",
"{",
"}",
"... | [
1193,
4
] | [
1301,
30
] | python | en | ['en', 'error', 'th'] | False |
_mark_method_skipped | (meth, reason) | Decorate to mark method as skipped.
This marks method as skipped by replacing the actual method with wrapper
that raises the testtools.testcase.TestSkipped exception.
| Decorate to mark method as skipped. | def _mark_method_skipped(meth, reason):
"""Decorate to mark method as skipped.
This marks method as skipped by replacing the actual method with wrapper
that raises the testtools.testcase.TestSkipped exception.
"""
@functools.wraps(meth)
def wrapper(*args, **kwargs):
raise testtools.tes... | [
"def",
"_mark_method_skipped",
"(",
"meth",
",",
"reason",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"meth",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"testtools",
".",
"testcase",
".",
"TestSkipped",
"("... | [
42,
0
] | [
53,
18
] | python | en | ['en', 'en', 'en'] | True |
_mark_class_skipped | (cls, reason) | Mark every test method of the class as skipped. | Mark every test method of the class as skipped. | def _mark_class_skipped(cls, reason):
"""Mark every test method of the class as skipped."""
tests = [attr for attr in dir(cls) if _is_test_method_name(attr) or
_is_test_fixture(attr)]
for test in tests:
method = getattr(cls, test)
if callable(method):
setattr(cls, te... | [
"def",
"_mark_class_skipped",
"(",
"cls",
",",
"reason",
")",
":",
"tests",
"=",
"[",
"attr",
"for",
"attr",
"in",
"dir",
"(",
"cls",
")",
"if",
"_is_test_method_name",
"(",
"attr",
")",
"or",
"_is_test_fixture",
"(",
"attr",
")",
"]",
"for",
"test",
"... | [
56,
0
] | [
64,
14
] | python | en | ['en', 'en', 'en'] | True |
_get_skip_method | (obj) | Make sure that we can decorate both methods and classes. | Make sure that we can decorate both methods and classes. | def _get_skip_method(obj):
"""Make sure that we can decorate both methods and classes."""
if inspect.isclass(obj):
if not _is_test_cls(obj):
raise ValueError(NOT_TEST_OBJECT_ERROR_MSG)
return _mark_class_skipped
else:
if not _is_test_method_name(obj.__name__):
... | [
"def",
"_get_skip_method",
"(",
"obj",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"obj",
")",
":",
"if",
"not",
"_is_test_cls",
"(",
"obj",
")",
":",
"raise",
"ValueError",
"(",
"NOT_TEST_OBJECT_ERROR_MSG",
")",
"return",
"_mark_class_skipped",
"else",
... | [
71,
0
] | [
80,
35
] | python | en | ['en', 'en', 'en'] | True |
services_required | (*req_services) | Decorator for marking test's service requirements.
If requirements are not met in the configuration file
test is marked as skipped.
Usage:
from openstack_dashboard.test.integration_tests.tests import decorators
@decorators.services_required("sahara")
class TestLogin(helpers.BaseTestCase):
... | Decorator for marking test's service requirements. | def services_required(*req_services):
"""Decorator for marking test's service requirements.
If requirements are not met in the configuration file
test is marked as skipped.
Usage:
from openstack_dashboard.test.integration_tests.tests import decorators
@decorators.services_required("sahara")
... | [
"def",
"services_required",
"(",
"*",
"req_services",
")",
":",
"def",
"actual_decoration",
"(",
"obj",
")",
":",
"skip_method",
"=",
"_get_skip_method",
"(",
"obj",
")",
"# get available services from configuration",
"avail_services",
"=",
"config",
".",
"get_config"... | [
83,
0
] | [
120,
28
] | python | en | ['en', 'en', 'en'] | True |
_parse_compound_config_option_value | (option_name) | Parses the value of a given config option.
The section name of the option is separated from option name by '.'.
| Parses the value of a given config option. | def _parse_compound_config_option_value(option_name):
"""Parses the value of a given config option.
The section name of the option is separated from option name by '.'.
"""
name_parts = option_name.split('.')
name_parts.reverse()
option = config.get_config()
while name_parts:
option... | [
"def",
"_parse_compound_config_option_value",
"(",
"option_name",
")",
":",
"name_parts",
"=",
"option_name",
".",
"split",
"(",
"'.'",
")",
"name_parts",
".",
"reverse",
"(",
")",
"option",
"=",
"config",
".",
"get_config",
"(",
")",
"while",
"name_parts",
":... | [
123,
0
] | [
133,
17
] | python | en | ['en', 'en', 'en'] | True |
skip_because | (**kwargs) | Decorator for skipping tests hitting known bugs
Usage:
from openstack_dashboard.test.integration_tests.tests import decorators
class TestDashboardHelp(helpers.TestCase):
@decorators.skip_because(bugs=["1234567"])
def test_dashboard_help_redirection(self):
.
.
.
... | Decorator for skipping tests hitting known bugs | def skip_because(**kwargs):
"""Decorator for skipping tests hitting known bugs
Usage:
from openstack_dashboard.test.integration_tests.tests import decorators
class TestDashboardHelp(helpers.TestCase):
@decorators.skip_because(bugs=["1234567"])
def test_dashboard_help_redirection(self)... | [
"def",
"skip_because",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"actual_decoration",
"(",
"obj",
")",
":",
"skip_method",
"=",
"_get_skip_method",
"(",
"obj",
")",
"bugs",
"=",
"kwargs",
".",
"get",
"(",
"\"bugs\"",
")",
"if",
"bugs",
"and",
"isinstance... | [
150,
0
] | [
174,
28
] | python | en | ['en', 'en', 'en'] | True |
attach_video | (func) | Notify test runner to attach test video in any case | Notify test runner to attach test video in any case | def attach_video(func):
"""Notify test runner to attach test video in any case"""
@functools.wraps(func)
def wrapper(self, *args, **kwgs):
self._need_attach_video = True
return func(self, *args, **kwgs)
return wrapper | [
"def",
"attach_video",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwgs",
")",
":",
"self",
".",
"_need_attach_video",
"=",
"True",
"return",
"func",
"(",
... | [
177,
0
] | [
185,
18
] | python | en | ['en', 'en', 'en'] | True |
Attention.forward | (self, x) |
Parameters
----------
x : torch.Tensor
Shape `(n_samples, n_patches + 1, dim)`.
Returns
-------
torch.Tensor
Shape `(n_samples, n_patches + 1, dim)`.
|
Parameters
----------
x : torch.Tensor
Shape `(n_samples, n_patches + 1, dim)`.
Returns
-------
torch.Tensor
Shape `(n_samples, n_patches + 1, dim)`.
| def forward(self, x):
"""
Parameters
----------
x : torch.Tensor
Shape `(n_samples, n_patches + 1, dim)`.
Returns
-------
torch.Tensor
Shape `(n_samples, n_patches + 1, dim)`.
"""
batch_size, n_patches, dim = x.shape
... | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"batch_size",
",",
"n_patches",
",",
"dim",
"=",
"x",
".",
"shape",
"if",
"dim",
"!=",
"dim",
":",
"raise",
"ValueError",
"qkv",
"=",
"self",
".",
"qkv",
"(",
"x",
")",
"# batch_size, n_patches + 1, 3 ... | [
80,
4
] | [
111,
18
] | python | en | ['en', 'error', 'th'] | False |
MLP.forward | (self, x) | Run forward pass.
Parameters
----------
x : torch.Tensor
Shape `(batch_size, n_patches + 1, in_features)`.
Returns
-------
torch.Tensor
Shape `(batch_size, n_patches +1, out_features)`
| Run forward pass.
Parameters
----------
x : torch.Tensor
Shape `(batch_size, n_patches + 1, in_features)`.
Returns
-------
torch.Tensor
Shape `(batch_size, n_patches +1, out_features)`
| def forward(self, x):
"""Run forward pass.
Parameters
----------
x : torch.Tensor
Shape `(batch_size, n_patches + 1, in_features)`.
Returns
-------
torch.Tensor
Shape `(batch_size, n_patches +1, out_features)`
"""
x = self.f... | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"x",
"=",
"self",
".",
"fc1",
"(",
"x",
")",
"# (batch_size, n_patches + 1, hidden_features)",
"x",
"=",
"self",
".",
"act",
"(",
"x",
")",
"# (batch_size, n_patches + 1, hidden_features)",
"x",
"=",
"self",
... | [
144,
4
] | [
163,
16
] | python | en | ['fr', 'ha', 'en'] | False |
VisionTransformerBlock.forward | (self, x) | Run forward pass.
Parameters
----------
x : torch.Tensor
Shape `(batch_size, n_patches + 1, dim)`.
Returns
-------
torch.Tensor
Shape `(batch_size, n_patches + 1, dim)`.
| Run forward pass.
Parameters
----------
x : torch.Tensor
Shape `(batch_size, n_patches + 1, dim)`.
Returns
-------
torch.Tensor
Shape `(batch_size, n_patches + 1, dim)`.
| def forward(self, x):
"""Run forward pass.
Parameters
----------
x : torch.Tensor
Shape `(batch_size, n_patches + 1, dim)`.
Returns
-------
torch.Tensor
Shape `(batch_size, n_patches + 1, dim)`.
"""
x = x + self.attn(self.no... | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"x",
"=",
"x",
"+",
"self",
".",
"attn",
"(",
"self",
".",
"norm1",
"(",
"x",
")",
")",
"x",
"=",
"x",
"+",
"self",
".",
"mlp",
"(",
"self",
".",
"norm2",
"(",
"x",
")",
")",
"return",
"x... | [
207,
4
] | [
221,
16
] | python | en | ['fr', 'ha', 'en'] | False |
VisionTransformer.forward | (self, x) | Run the forward pass.
Parameters
----------
x : torch.Tensor
Shape `(n_samples, in_chans, img_size, img_size)`.
Returns
-------
logits : torch.Tensor
Logits over all the classes - `(n_samples, n_classes)`.
| Run the forward pass.
Parameters
----------
x : torch.Tensor
Shape `(n_samples, in_chans, img_size, img_size)`.
Returns
-------
logits : torch.Tensor
Logits over all the classes - `(n_samples, n_classes)`.
| def forward(self, x):
"""Run the forward pass.
Parameters
----------
x : torch.Tensor
Shape `(n_samples, in_chans, img_size, img_size)`.
Returns
-------
logits : torch.Tensor
Logits over all the classes - `(n_samples, n_classes)`.
"... | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"n_samples",
"=",
"x",
".",
"shape",
"[",
"0",
"]",
"x",
"=",
"self",
".",
"patch_embed",
"(",
"x",
")",
"cls_token",
"=",
"self",
".",
"cls_token",
".",
"expand",
"(",
"n_samples",
",",
"-",
"1"... | [
311,
4
] | [
340,
16
] | python | en | ['en', 'gd', 'en'] | True |
RequirementTracker.add | (self, req) | Add an InstallRequirement to build tracking.
| Add an InstallRequirement to build tracking.
| def add(self, req):
# type: (InstallRequirement) -> None
"""Add an InstallRequirement to build tracking.
"""
assert req.link
# Get the file to write information about this requirement.
entry_path = self._entry_path(req.link)
# Try reading from the file. If it ex... | [
"def",
"add",
"(",
"self",
",",
"req",
")",
":",
"# type: (InstallRequirement) -> None",
"assert",
"req",
".",
"link",
"# Get the file to write information about this requirement.",
"entry_path",
"=",
"self",
".",
"_entry_path",
"(",
"req",
".",
"link",
")",
"# Try re... | [
92,
4
] | [
123,
69
] | python | en | ['en', 'en', 'en'] | True |
RequirementTracker.remove | (self, req) | Remove an InstallRequirement from build tracking.
| Remove an InstallRequirement from build tracking.
| def remove(self, req):
# type: (InstallRequirement) -> None
"""Remove an InstallRequirement from build tracking.
"""
assert req.link
# Delete the created file and the corresponding entries.
os.unlink(self._entry_path(req.link))
self._entries.remove(req)
... | [
"def",
"remove",
"(",
"self",
",",
"req",
")",
":",
"# type: (InstallRequirement) -> None",
"assert",
"req",
".",
"link",
"# Delete the created file and the corresponding entries.",
"os",
".",
"unlink",
"(",
"self",
".",
"_entry_path",
"(",
"req",
".",
"link",
")",
... | [
125,
4
] | [
135,
73
] | python | en | ['en', 'en', 'en'] | True |
install.initialize_options | (self) | Initializes options. | Initializes options. | def initialize_options(self):
"""Initializes options."""
# High-level options: these select both an installation base
# and scheme.
self.prefix = None
self.exec_prefix = None
self.home = None
self.user = 0
# These select only the installation base; it's u... | [
"def",
"initialize_options",
"(",
"self",
")",
":",
"# High-level options: these select both an installation base",
"# and scheme.",
"self",
".",
"prefix",
"=",
"None",
"self",
".",
"exec_prefix",
"=",
"None",
"self",
".",
"home",
"=",
"None",
"self",
".",
"user",
... | [
159,
4
] | [
228,
26
] | python | en | ['en', 'en', 'en'] | False |
install.finalize_options | (self) | Finalizes options. | Finalizes options. | def finalize_options(self):
"""Finalizes options."""
# This method (and its helpers, like 'finalize_unix()',
# 'finalize_other()', and 'select_scheme()') is where the default
# installation directories for modules, extension modules, and
# anything else we care to install from a ... | [
"def",
"finalize_options",
"(",
"self",
")",
":",
"# This method (and its helpers, like 'finalize_unix()',",
"# 'finalize_other()', and 'select_scheme()') is where the default",
"# installation directories for modules, extension modules, and",
"# anything else we care to install from a Python modu... | [
237,
4
] | [
382,
62
] | python | en | ['en', 'en', 'en'] | False |
install.dump_dirs | (self, msg) | Dumps the list of user options. | Dumps the list of user options. | def dump_dirs(self, msg):
"""Dumps the list of user options."""
if not DEBUG:
return
from distutils.fancy_getopt import longopt_xlate
log.debug(msg + ":")
for opt in self.user_options:
opt_name = opt[0]
if opt_name[-1] == "=":
o... | [
"def",
"dump_dirs",
"(",
"self",
",",
"msg",
")",
":",
"if",
"not",
"DEBUG",
":",
"return",
"from",
"distutils",
".",
"fancy_getopt",
"import",
"longopt_xlate",
"log",
".",
"debug",
"(",
"msg",
"+",
"\":\"",
")",
"for",
"opt",
"in",
"self",
".",
"user_... | [
387,
4
] | [
404,
48
] | python | en | ['en', 'en', 'en'] | True |
install.finalize_unix | (self) | Finalizes options for posix platforms. | Finalizes options for posix platforms. | def finalize_unix(self):
"""Finalizes options for posix platforms."""
if self.install_base is not None or self.install_platbase is not None:
if ((self.install_lib is None and
self.install_purelib is None and
self.install_platlib is None) or
s... | [
"def",
"finalize_unix",
"(",
"self",
")",
":",
"if",
"self",
".",
"install_base",
"is",
"not",
"None",
"or",
"self",
".",
"install_platbase",
"is",
"not",
"None",
":",
"if",
"(",
"(",
"self",
".",
"install_lib",
"is",
"None",
"and",
"self",
".",
"insta... | [
406,
4
] | [
444,
45
] | python | en | ['en', 'en', 'en'] | True |
install.finalize_other | (self) | Finalizes options for non-posix platforms | Finalizes options for non-posix platforms | def finalize_other(self):
"""Finalizes options for non-posix platforms"""
if self.user:
if self.install_userbase is None:
raise DistutilsPlatformError(
"User base directory is not specified")
self.install_base = self.install_platbase = self.ins... | [
"def",
"finalize_other",
"(",
"self",
")",
":",
"if",
"self",
".",
"user",
":",
"if",
"self",
".",
"install_userbase",
"is",
"None",
":",
"raise",
"DistutilsPlatformError",
"(",
"\"User base directory is not specified\"",
")",
"self",
".",
"install_base",
"=",
"... | [
446,
4
] | [
466,
76
] | python | en | ['en', 'en', 'en'] | True |
install.select_scheme | (self, name) | Sets the install directories by applying the install schemes. | Sets the install directories by applying the install schemes. | def select_scheme(self, name):
"""Sets the install directories by applying the install schemes."""
# it's the caller's problem if they supply a bad name!
if (hasattr(sys, 'pypy_version_info') and
not name.endswith(('_user', '_home'))):
if os.name == 'nt':
... | [
"def",
"select_scheme",
"(",
"self",
",",
"name",
")",
":",
"# it's the caller's problem if they supply a bad name!",
"if",
"(",
"hasattr",
"(",
"sys",
",",
"'pypy_version_info'",
")",
"and",
"not",
"name",
".",
"endswith",
"(",
"(",
"'_user'",
",",
"'_home'",
"... | [
468,
4
] | [
481,
52
] | python | en | ['en', 'en', 'en'] | True |
install.expand_basedirs | (self) | Calls `os.path.expanduser` on install_base, install_platbase and
root. | Calls `os.path.expanduser` on install_base, install_platbase and
root. | def expand_basedirs(self):
"""Calls `os.path.expanduser` on install_base, install_platbase and
root."""
self._expand_attrs(['install_base', 'install_platbase', 'root']) | [
"def",
"expand_basedirs",
"(",
"self",
")",
":",
"self",
".",
"_expand_attrs",
"(",
"[",
"'install_base'",
",",
"'install_platbase'",
",",
"'root'",
"]",
")"
] | [
492,
4
] | [
495,
72
] | python | en | ['en', 'en', 'en'] | True |
install.expand_dirs | (self) | Calls `os.path.expanduser` on install dirs. | Calls `os.path.expanduser` on install dirs. | def expand_dirs(self):
"""Calls `os.path.expanduser` on install dirs."""
self._expand_attrs(['install_purelib', 'install_platlib',
'install_lib', 'install_headers',
'install_scripts', 'install_data',]) | [
"def",
"expand_dirs",
"(",
"self",
")",
":",
"self",
".",
"_expand_attrs",
"(",
"[",
"'install_purelib'",
",",
"'install_platlib'",
",",
"'install_lib'",
",",
"'install_headers'",
",",
"'install_scripts'",
",",
"'install_data'",
",",
"]",
")"
] | [
497,
4
] | [
501,
64
] | python | en | ['en', 'en', 'en'] | True |
install.convert_paths | (self, *names) | Call `convert_path` over `names`. | Call `convert_path` over `names`. | def convert_paths(self, *names):
"""Call `convert_path` over `names`."""
for name in names:
attr = "install_" + name
setattr(self, attr, convert_path(getattr(self, attr))) | [
"def",
"convert_paths",
"(",
"self",
",",
"*",
"names",
")",
":",
"for",
"name",
"in",
"names",
":",
"attr",
"=",
"\"install_\"",
"+",
"name",
"setattr",
"(",
"self",
",",
"attr",
",",
"convert_path",
"(",
"getattr",
"(",
"self",
",",
"attr",
")",
")... | [
503,
4
] | [
507,
66
] | python | en | ['en', 'en', 'en'] | True |
install.handle_extra_path | (self) | Set `path_file` and `extra_dirs` using `extra_path`. | Set `path_file` and `extra_dirs` using `extra_path`. | def handle_extra_path(self):
"""Set `path_file` and `extra_dirs` using `extra_path`."""
if self.extra_path is None:
self.extra_path = self.distribution.extra_path
if self.extra_path is not None:
log.warn(
"Distribution option extra_path is deprecated. "
... | [
"def",
"handle_extra_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"extra_path",
"is",
"None",
":",
"self",
".",
"extra_path",
"=",
"self",
".",
"distribution",
".",
"extra_path",
"if",
"self",
".",
"extra_path",
"is",
"not",
"None",
":",
"log",
".",
... | [
509,
4
] | [
541,
36
] | python | en | ['en', 'en', 'en'] | True |
install.change_roots | (self, *names) | Change the install directories pointed by name using root. | Change the install directories pointed by name using root. | def change_roots(self, *names):
"""Change the install directories pointed by name using root."""
for name in names:
attr = "install_" + name
setattr(self, attr, change_root(self.root, getattr(self, attr))) | [
"def",
"change_roots",
"(",
"self",
",",
"*",
"names",
")",
":",
"for",
"name",
"in",
"names",
":",
"attr",
"=",
"\"install_\"",
"+",
"name",
"setattr",
"(",
"self",
",",
"attr",
",",
"change_root",
"(",
"self",
".",
"root",
",",
"getattr",
"(",
"sel... | [
543,
4
] | [
547,
76
] | python | en | ['en', 'en', 'en'] | True |
install.create_home_path | (self) | Create directories under ~. | Create directories under ~. | def create_home_path(self):
"""Create directories under ~."""
if not self.user:
return
home = convert_path(os.path.expanduser("~"))
for name, path in self.config_vars.items():
if path.startswith(home) and not os.path.isdir(path):
self.debug_print("... | [
"def",
"create_home_path",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"user",
":",
"return",
"home",
"=",
"convert_path",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~\"",
")",
")",
"for",
"name",
",",
"path",
"in",
"self",
".",
"config_... | [
549,
4
] | [
557,
40
] | python | de | ['de', 'de', 'en'] | True |
install.run | (self) | Runs the command. | Runs the command. | def run(self):
"""Runs the command."""
# Obviously have to build before we can install
if not self.skip_build:
self.run_command('build')
# If we built for any other platform, we can't install.
build_plat = self.distribution.get_command_obj('build').plat_name
... | [
"def",
"run",
"(",
"self",
")",
":",
"# Obviously have to build before we can install",
"if",
"not",
"self",
".",
"skip_build",
":",
"self",
".",
"run_command",
"(",
"'build'",
")",
"# If we built for any other platform, we can't install.",
"build_plat",
"=",
"self",
".... | [
561,
4
] | [
603,
40
] | python | en | ['en', 'it', 'en'] | True |
install.create_path_file | (self) | Creates the .pth file | Creates the .pth file | def create_path_file(self):
"""Creates the .pth file"""
filename = os.path.join(self.install_libbase,
self.path_file + ".pth")
if self.install_path_file:
self.execute(write_file,
(filename, [self.extra_dirs]),
... | [
"def",
"create_path_file",
"(",
"self",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"install_libbase",
",",
"self",
".",
"path_file",
"+",
"\".pth\"",
")",
"if",
"self",
".",
"install_path_file",
":",
"self",
".",
"execut... | [
605,
4
] | [
614,
62
] | python | en | ['en', 'sm', 'en'] | True |
install.get_outputs | (self) | Assembles the outputs of all the sub-commands. | Assembles the outputs of all the sub-commands. | def get_outputs(self):
"""Assembles the outputs of all the sub-commands."""
outputs = []
for cmd_name in self.get_sub_commands():
cmd = self.get_finalized_command(cmd_name)
# Add the contents of cmd.get_outputs(), ensuring
# that outputs doesn't contain duplic... | [
"def",
"get_outputs",
"(",
"self",
")",
":",
"outputs",
"=",
"[",
"]",
"for",
"cmd_name",
"in",
"self",
".",
"get_sub_commands",
"(",
")",
":",
"cmd",
"=",
"self",
".",
"get_finalized_command",
"(",
"cmd_name",
")",
"# Add the contents of cmd.get_outputs(), ensu... | [
619,
4
] | [
634,
22
] | python | en | ['en', 'en', 'en'] | True |
install.get_inputs | (self) | Returns the inputs of all the sub-commands | Returns the inputs of all the sub-commands | def get_inputs(self):
"""Returns the inputs of all the sub-commands"""
# XXX gee, this looks familiar ;-(
inputs = []
for cmd_name in self.get_sub_commands():
cmd = self.get_finalized_command(cmd_name)
inputs.extend(cmd.get_inputs())
return inputs | [
"def",
"get_inputs",
"(",
"self",
")",
":",
"# XXX gee, this looks familiar ;-(",
"inputs",
"=",
"[",
"]",
"for",
"cmd_name",
"in",
"self",
".",
"get_sub_commands",
"(",
")",
":",
"cmd",
"=",
"self",
".",
"get_finalized_command",
"(",
"cmd_name",
")",
"inputs"... | [
636,
4
] | [
644,
21
] | python | en | ['en', 'en', 'en'] | True |
install.has_lib | (self) | Returns true if the current distribution has any Python
modules to install. | Returns true if the current distribution has any Python
modules to install. | def has_lib(self):
"""Returns true if the current distribution has any Python
modules to install."""
return (self.distribution.has_pure_modules() or
self.distribution.has_ext_modules()) | [
"def",
"has_lib",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"distribution",
".",
"has_pure_modules",
"(",
")",
"or",
"self",
".",
"distribution",
".",
"has_ext_modules",
"(",
")",
")"
] | [
648,
4
] | [
652,
52
] | python | en | ['en', 'en', 'en'] | True |
install.has_headers | (self) | Returns true if the current distribution has any headers to
install. | Returns true if the current distribution has any headers to
install. | def has_headers(self):
"""Returns true if the current distribution has any headers to
install."""
return self.distribution.has_headers() | [
"def",
"has_headers",
"(",
"self",
")",
":",
"return",
"self",
".",
"distribution",
".",
"has_headers",
"(",
")"
] | [
654,
4
] | [
657,
46
] | python | en | ['en', 'en', 'en'] | True |
install.has_scripts | (self) | Returns true if the current distribution has any scripts to.
install. | Returns true if the current distribution has any scripts to.
install. | def has_scripts(self):
"""Returns true if the current distribution has any scripts to.
install."""
return self.distribution.has_scripts() | [
"def",
"has_scripts",
"(",
"self",
")",
":",
"return",
"self",
".",
"distribution",
".",
"has_scripts",
"(",
")"
] | [
659,
4
] | [
662,
46
] | python | en | ['en', 'en', 'en'] | True |
install.has_data | (self) | Returns true if the current distribution has any data to.
install. | Returns true if the current distribution has any data to.
install. | def has_data(self):
"""Returns true if the current distribution has any data to.
install."""
return self.distribution.has_data_files() | [
"def",
"has_data",
"(",
"self",
")",
":",
"return",
"self",
".",
"distribution",
".",
"has_data_files",
"(",
")"
] | [
664,
4
] | [
667,
49
] | python | en | ['en', 'en', 'en'] | True |
GroupBase._call_network_api | (self, request, data) | Call the underlying network API: Nova-network or Neutron.
Used in children classes to create or update a group.
| Call the underlying network API: Nova-network or Neutron. | def _call_network_api(self, request, data):
"""Call the underlying network API: Nova-network or Neutron.
Used in children classes to create or update a group.
"""
raise NotImplementedError() | [
"def",
"_call_network_api",
"(",
"self",
",",
"request",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
58,
4
] | [
63,
35
] | python | en | ['en', 'no', 'en'] | True |
_find_egg_info | (directory) | Find an .egg-info subdirectory in `directory`.
| Find an .egg-info subdirectory in `directory`.
| def _find_egg_info(directory):
# type: (str) -> str
"""Find an .egg-info subdirectory in `directory`.
"""
filenames = [
f for f in os.listdir(directory) if f.endswith(".egg-info")
]
if not filenames:
raise InstallationError(
"No .egg-info directory found in {}".forma... | [
"def",
"_find_egg_info",
"(",
"directory",
")",
":",
"# type: (str) -> str",
"filenames",
"=",
"[",
"f",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
"if",
"f",
".",
"endswith",
"(",
"\".egg-info\"",
")",
"]",
"if",
"not",
"filenames",
... | [
18,
0
] | [
38,
48
] | python | en | ['en', 'en', 'en'] | True |
generate_metadata | (
build_env, # type: BuildEnvironment
setup_py_path, # type: str
source_dir, # type: str
isolated, # type: bool
details, # type: str
) | Generate metadata using setup.py-based defacto mechanisms.
Returns the generated metadata directory.
| Generate metadata using setup.py-based defacto mechanisms. | def generate_metadata(
build_env, # type: BuildEnvironment
setup_py_path, # type: str
source_dir, # type: str
isolated, # type: bool
details, # type: str
):
# type: (...) -> str
"""Generate metadata using setup.py-based defacto mechanisms.
Returns the generated metadata directory.
... | [
"def",
"generate_metadata",
"(",
"build_env",
",",
"# type: BuildEnvironment",
"setup_py_path",
",",
"# type: str",
"source_dir",
",",
"# type: str",
"isolated",
",",
"# type: bool",
"details",
",",
"# type: str",
")",
":",
"# type: (...) -> str",
"logger",
".",
"debug"... | [
41,
0
] | [
76,
39
] | python | en | ['en', 'zu', 'en'] | True |
is_iterable | (obj) |
Are we being asked to look up a list of things, instead of a single thing?
We check for the `__iter__` attribute so that this can cover types that
don't have to be known by this module, such as NumPy arrays.
Strings, however, should be considered as atomic values to look up, not
iterables. The sam... |
Are we being asked to look up a list of things, instead of a single thing?
We check for the `__iter__` attribute so that this can cover types that
don't have to be known by this module, such as NumPy arrays. | def is_iterable(obj):
"""
Are we being asked to look up a list of things, instead of a single thing?
We check for the `__iter__` attribute so that this can cover types that
don't have to be known by this module, such as NumPy arrays.
Strings, however, should be considered as atomic values to look u... | [
"def",
"is_iterable",
"(",
"obj",
")",
":",
"return",
"(",
"hasattr",
"(",
"obj",
",",
"\"__iter__\"",
")",
"and",
"not",
"isinstance",
"(",
"obj",
",",
"str",
")",
"and",
"not",
"isinstance",
"(",
"obj",
",",
"tuple",
")",
")"
] | [
21,
0
] | [
38,
5
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__len__ | (self) |
Returns the number of unique elements in the ordered set
Example:
>>> len(OrderedSet([]))
0
>>> len(OrderedSet([1, 2]))
2
|
Returns the number of unique elements in the ordered set | def __len__(self):
"""
Returns the number of unique elements in the ordered set
Example:
>>> len(OrderedSet([]))
0
>>> len(OrderedSet([1, 2]))
2
"""
return len(self.items) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"items",
")"
] | [
57,
4
] | [
67,
30
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__getitem__ | (self, index) |
Get the item at a given index.
If `index` is a slice, you will get back that slice of items, as a
new OrderedSet.
If `index` is a list or a similar iterable, you'll get a list of
items corresponding to those indices. This is similar to NumPy's
"fancy indexing". The res... |
Get the item at a given index. | def __getitem__(self, index):
"""
Get the item at a given index.
If `index` is a slice, you will get back that slice of items, as a
new OrderedSet.
If `index` is a list or a similar iterable, you'll get a list of
items corresponding to those indices. This is similar to ... | [
"def",
"__getitem__",
"(",
"self",
",",
"index",
")",
":",
"if",
"isinstance",
"(",
"index",
",",
"slice",
")",
"and",
"index",
"==",
"SLICE_ALL",
":",
"return",
"self",
".",
"copy",
"(",
")",
"elif",
"is_iterable",
"(",
"index",
")",
":",
"return",
... | [
69,
4
] | [
98,
82
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.copy | (self) |
Return a shallow copy of this object.
Example:
>>> this = OrderedSet([1, 2, 3])
>>> other = this.copy()
>>> this == other
True
>>> this is other
False
|
Return a shallow copy of this object. | def copy(self):
"""
Return a shallow copy of this object.
Example:
>>> this = OrderedSet([1, 2, 3])
>>> other = this.copy()
>>> this == other
True
>>> this is other
False
"""
return self.__class__(self) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
")"
] | [
100,
4
] | [
112,
35
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__contains__ | (self, key) |
Test if the item is in this ordered set
Example:
>>> 1 in OrderedSet([1, 3, 2])
True
>>> 5 in OrderedSet([1, 3, 2])
False
|
Test if the item is in this ordered set | def __contains__(self, key):
"""
Test if the item is in this ordered set
Example:
>>> 1 in OrderedSet([1, 3, 2])
True
>>> 5 in OrderedSet([1, 3, 2])
False
"""
return key in self.map | [
"def",
"__contains__",
"(",
"self",
",",
"key",
")",
":",
"return",
"key",
"in",
"self",
".",
"map"
] | [
132,
4
] | [
142,
30
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.add | (self, key) |
Add `key` as an item to this OrderedSet, then return its index.
If `key` is already in the OrderedSet, return the index it already
had.
Example:
>>> oset = OrderedSet()
>>> oset.append(3)
0
>>> print(oset)
OrderedSet([3])
... |
Add `key` as an item to this OrderedSet, then return its index. | def add(self, key):
"""
Add `key` as an item to this OrderedSet, then return its index.
If `key` is already in the OrderedSet, return the index it already
had.
Example:
>>> oset = OrderedSet()
>>> oset.append(3)
0
>>> print(oset)
... | [
"def",
"add",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"map",
":",
"self",
".",
"map",
"[",
"key",
"]",
"=",
"len",
"(",
"self",
".",
"items",
")",
"self",
".",
"items",
".",
"append",
"(",
"key",
")",
"return... | [
144,
4
] | [
161,
28
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.update | (self, sequence) |
Update the set with the given iterable sequence, then return the index
of the last element inserted.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.update([3, 1, 5, 1, 4])
4
>>> print(oset)
OrderedSet([1, 2, 3, 5, 4])
|
Update the set with the given iterable sequence, then return the index
of the last element inserted. | def update(self, sequence):
"""
Update the set with the given iterable sequence, then return the index
of the last element inserted.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.update([3, 1, 5, 1, 4])
4
>>> print(oset)
O... | [
"def",
"update",
"(",
"self",
",",
"sequence",
")",
":",
"item_index",
"=",
"None",
"try",
":",
"for",
"item",
"in",
"sequence",
":",
"item_index",
"=",
"self",
".",
"add",
"(",
"item",
")",
"except",
"TypeError",
":",
"raise",
"ValueError",
"(",
"\"Ar... | [
165,
4
] | [
185,
25
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.index | (self, key) |
Get the index of a given entry, raising an IndexError if it's not
present.
`key` can be an iterable of entries that is not a string, in which case
this returns a list of indices.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.index(2)
1
... |
Get the index of a given entry, raising an IndexError if it's not
present. | def index(self, key):
"""
Get the index of a given entry, raising an IndexError if it's not
present.
`key` can be an iterable of entries that is not a string, in which case
this returns a list of indices.
Example:
>>> oset = OrderedSet([1, 2, 3])
... | [
"def",
"index",
"(",
"self",
",",
"key",
")",
":",
"if",
"is_iterable",
"(",
"key",
")",
":",
"return",
"[",
"self",
".",
"index",
"(",
"subkey",
")",
"for",
"subkey",
"in",
"key",
"]",
"return",
"self",
".",
"map",
"[",
"key",
"]"
] | [
187,
4
] | [
202,
28
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.pop | (self) |
Remove and return the last element from the set.
Raises KeyError if the set is empty.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.pop()
3
|
Remove and return the last element from the set. | def pop(self):
"""
Remove and return the last element from the set.
Raises KeyError if the set is empty.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.pop()
3
"""
if not self.items:
raise KeyError("Set is empty")
... | [
"def",
"pop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"items",
":",
"raise",
"KeyError",
"(",
"\"Set is empty\"",
")",
"elem",
"=",
"self",
".",
"items",
"[",
"-",
"1",
"]",
"del",
"self",
".",
"items",
"[",
"-",
"1",
"]",
"del",
"self",... | [
208,
4
] | [
225,
19
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.discard | (self, key) |
Remove an element. Do not raise an exception if absent.
The MutableSet mixin uses this to implement the .remove() method, which
*does* raise an error when asked to remove a non-existent item.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.discard(2)
... |
Remove an element. Do not raise an exception if absent. | def discard(self, key):
"""
Remove an element. Do not raise an exception if absent.
The MutableSet mixin uses this to implement the .remove() method, which
*does* raise an error when asked to remove a non-existent item.
Example:
>>> oset = OrderedSet([1, 2, 3])
... | [
"def",
"discard",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
":",
"i",
"=",
"self",
".",
"map",
"[",
"key",
"]",
"del",
"self",
".",
"items",
"[",
"i",
"]",
"del",
"self",
".",
"map",
"[",
"key",
"]",
"for",
"k",
",",
"v"... | [
227,
4
] | [
249,
39
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.clear | (self) |
Remove all items from this OrderedSet.
|
Remove all items from this OrderedSet.
| def clear(self):
"""
Remove all items from this OrderedSet.
"""
del self.items[:]
self.map.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"del",
"self",
".",
"items",
"[",
":",
"]",
"self",
".",
"map",
".",
"clear",
"(",
")"
] | [
251,
4
] | [
256,
24
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__iter__ | (self) |
Example:
>>> list(iter(OrderedSet([1, 2, 3])))
[1, 2, 3]
|
Example:
>>> list(iter(OrderedSet([1, 2, 3])))
[1, 2, 3]
| def __iter__(self):
"""
Example:
>>> list(iter(OrderedSet([1, 2, 3])))
[1, 2, 3]
"""
return iter(self.items) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"iter",
"(",
"self",
".",
"items",
")"
] | [
258,
4
] | [
264,
31
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__reversed__ | (self) |
Example:
>>> list(reversed(OrderedSet([1, 2, 3])))
[3, 2, 1]
|
Example:
>>> list(reversed(OrderedSet([1, 2, 3])))
[3, 2, 1]
| def __reversed__(self):
"""
Example:
>>> list(reversed(OrderedSet([1, 2, 3])))
[3, 2, 1]
"""
return reversed(self.items) | [
"def",
"__reversed__",
"(",
"self",
")",
":",
"return",
"reversed",
"(",
"self",
".",
"items",
")"
] | [
266,
4
] | [
272,
35
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.__eq__ | (self, other) |
Returns true if the containers have the same items. If `other` is a
Sequence, then order is checked, otherwise it is ignored.
Example:
>>> oset = OrderedSet([1, 3, 2])
>>> oset == [1, 3, 2]
True
>>> oset == [1, 2, 3]
False
... |
Returns true if the containers have the same items. If `other` is a
Sequence, then order is checked, otherwise it is ignored. | def __eq__(self, other):
"""
Returns true if the containers have the same items. If `other` is a
Sequence, then order is checked, otherwise it is ignored.
Example:
>>> oset = OrderedSet([1, 3, 2])
>>> oset == [1, 3, 2]
True
>>> oset == [1,... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"# In Python 2 deque is not a Sequence, so treat it as one for",
"# consistent behavior with Python 3.",
"if",
"isinstance",
"(",
"other",
",",
"(",
"Sequence",
",",
"deque",
")",
")",
":",
"# Check that this OrderedSe... | [
279,
4
] | [
307,
44
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.union | (self, *sets) |
Combines all unique items.
Each items order is defined by its first appearance.
Example:
>>> oset = OrderedSet.union(OrderedSet([3, 1, 4, 1, 5]), [1, 3], [2, 0])
>>> print(oset)
OrderedSet([3, 1, 4, 5, 2, 0])
>>> oset.union([8, 9])
Or... |
Combines all unique items.
Each items order is defined by its first appearance. | def union(self, *sets):
"""
Combines all unique items.
Each items order is defined by its first appearance.
Example:
>>> oset = OrderedSet.union(OrderedSet([3, 1, 4, 1, 5]), [1, 3], [2, 0])
>>> print(oset)
OrderedSet([3, 1, 4, 5, 2, 0])
>>... | [
"def",
"union",
"(",
"self",
",",
"*",
"sets",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"isinstance",
"(",
"self",
",",
"OrderedSet",
")",
"else",
"OrderedSet",
"containers",
"=",
"map",
"(",
"list",
",",
"it",
".",
"chain",
"(",
"[",
... | [
309,
4
] | [
326,
25
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.intersection | (self, *sets) |
Returns elements in common between all sets. Order is defined only
by the first set.
Example:
>>> oset = OrderedSet.intersection(OrderedSet([0, 1, 2, 3]), [1, 2, 3])
>>> print(oset)
OrderedSet([1, 2, 3])
>>> oset.intersection([2, 4, 5], [1, 2, 3,... |
Returns elements in common between all sets. Order is defined only
by the first set. | def intersection(self, *sets):
"""
Returns elements in common between all sets. Order is defined only
by the first set.
Example:
>>> oset = OrderedSet.intersection(OrderedSet([0, 1, 2, 3]), [1, 2, 3])
>>> print(oset)
OrderedSet([1, 2, 3])
... | [
"def",
"intersection",
"(",
"self",
",",
"*",
"sets",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"isinstance",
"(",
"self",
",",
"OrderedSet",
")",
"else",
"OrderedSet",
"if",
"sets",
":",
"common",
"=",
"set",
".",
"intersection",
"(",
"*",... | [
332,
4
] | [
352,
25
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.difference | (self, *sets) |
Returns all elements that are in this set but not the others.
Example:
>>> OrderedSet([1, 2, 3]).difference(OrderedSet([2]))
OrderedSet([1, 3])
>>> OrderedSet([1, 2, 3]).difference(OrderedSet([2]), OrderedSet([3]))
OrderedSet([1])
>>> Ordered... |
Returns all elements that are in this set but not the others. | def difference(self, *sets):
"""
Returns all elements that are in this set but not the others.
Example:
>>> OrderedSet([1, 2, 3]).difference(OrderedSet([2]))
OrderedSet([1, 3])
>>> OrderedSet([1, 2, 3]).difference(OrderedSet([2]), OrderedSet([3]))
... | [
"def",
"difference",
"(",
"self",
",",
"*",
"sets",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"sets",
":",
"other",
"=",
"set",
".",
"union",
"(",
"*",
"map",
"(",
"set",
",",
"sets",
")",
")",
"items",
"=",
"(",
"item",
"for",
"ite... | [
354,
4
] | [
374,
25
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.issubset | (self, other) |
Report whether another set contains this set.
Example:
>>> OrderedSet([1, 2, 3]).issubset({1, 2})
False
>>> OrderedSet([1, 2, 3]).issubset({1, 2, 3, 4})
True
>>> OrderedSet([1, 2, 3]).issubset({1, 4, 3, 5})
False
|
Report whether another set contains this set. | def issubset(self, other):
"""
Report whether another set contains this set.
Example:
>>> OrderedSet([1, 2, 3]).issubset({1, 2})
False
>>> OrderedSet([1, 2, 3]).issubset({1, 2, 3, 4})
True
>>> OrderedSet([1, 2, 3]).issubset({1, 4, 3, 5... | [
"def",
"issubset",
"(",
"self",
",",
"other",
")",
":",
"if",
"len",
"(",
"self",
")",
">",
"len",
"(",
"other",
")",
":",
"# Fast check for obvious cases",
"return",
"False",
"return",
"all",
"(",
"item",
"in",
"other",
"for",
"item",
"in",
"self",
")... | [
376,
4
] | [
390,
50
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.issuperset | (self, other) |
Report whether this set contains another set.
Example:
>>> OrderedSet([1, 2]).issuperset([1, 2, 3])
False
>>> OrderedSet([1, 2, 3, 4]).issuperset({1, 2, 3})
True
>>> OrderedSet([1, 4, 3, 5]).issuperset({1, 2, 3})
False
|
Report whether this set contains another set. | def issuperset(self, other):
"""
Report whether this set contains another set.
Example:
>>> OrderedSet([1, 2]).issuperset([1, 2, 3])
False
>>> OrderedSet([1, 2, 3, 4]).issuperset({1, 2, 3})
True
>>> OrderedSet([1, 4, 3, 5]).issuperset(... | [
"def",
"issuperset",
"(",
"self",
",",
"other",
")",
":",
"if",
"len",
"(",
"self",
")",
"<",
"len",
"(",
"other",
")",
":",
"# Fast check for obvious cases",
"return",
"False",
"return",
"all",
"(",
"item",
"in",
"self",
"for",
"item",
"in",
"other",
... | [
392,
4
] | [
406,
50
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.symmetric_difference | (self, other) |
Return the symmetric difference of two OrderedSets as a new set.
That is, the new set will contain all elements that are in exactly
one of the sets.
Their order will be preserved, with elements from `self` preceding
elements from `other`.
Example:
>>> this ... |
Return the symmetric difference of two OrderedSets as a new set.
That is, the new set will contain all elements that are in exactly
one of the sets. | def symmetric_difference(self, other):
"""
Return the symmetric difference of two OrderedSets as a new set.
That is, the new set will contain all elements that are in exactly
one of the sets.
Their order will be preserved, with elements from `self` preceding
elements fro... | [
"def",
"symmetric_difference",
"(",
"self",
",",
"other",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"isinstance",
"(",
"self",
",",
"OrderedSet",
")",
"else",
"OrderedSet",
"diff1",
"=",
"cls",
"(",
"self",
")",
".",
"difference",
"(",
"other... | [
408,
4
] | [
426,
33
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet._update_items | (self, items) |
Replace the 'items' list of this OrderedSet with a new one, updating
self.map accordingly.
|
Replace the 'items' list of this OrderedSet with a new one, updating
self.map accordingly.
| def _update_items(self, items):
"""
Replace the 'items' list of this OrderedSet with a new one, updating
self.map accordingly.
"""
self.items = items
self.map = {item: idx for (idx, item) in enumerate(items)} | [
"def",
"_update_items",
"(",
"self",
",",
"items",
")",
":",
"self",
".",
"items",
"=",
"items",
"self",
".",
"map",
"=",
"{",
"item",
":",
"idx",
"for",
"(",
"idx",
",",
"item",
")",
"in",
"enumerate",
"(",
"items",
")",
"}"
] | [
428,
4
] | [
434,
66
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.difference_update | (self, *sets) |
Update this OrderedSet to remove items from one or more other sets.
Example:
>>> this = OrderedSet([1, 2, 3])
>>> this.difference_update(OrderedSet([2, 4]))
>>> print(this)
OrderedSet([1, 3])
>>> this = OrderedSet([1, 2, 3, 4, 5])
... |
Update this OrderedSet to remove items from one or more other sets. | def difference_update(self, *sets):
"""
Update this OrderedSet to remove items from one or more other sets.
Example:
>>> this = OrderedSet([1, 2, 3])
>>> this.difference_update(OrderedSet([2, 4]))
>>> print(this)
OrderedSet([1, 3])
>>... | [
"def",
"difference_update",
"(",
"self",
",",
"*",
"sets",
")",
":",
"items_to_remove",
"=",
"set",
"(",
")",
"for",
"other",
"in",
"sets",
":",
"items_to_remove",
"|=",
"set",
"(",
"other",
")",
"self",
".",
"_update_items",
"(",
"[",
"item",
"for",
"... | [
436,
4
] | [
454,
88
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.intersection_update | (self, other) |
Update this OrderedSet to keep only items in another set, preserving
their order in this set.
Example:
>>> this = OrderedSet([1, 4, 3, 5, 7])
>>> other = OrderedSet([9, 7, 1, 3, 2])
>>> this.intersection_update(other)
>>> print(this)
... |
Update this OrderedSet to keep only items in another set, preserving
their order in this set. | def intersection_update(self, other):
"""
Update this OrderedSet to keep only items in another set, preserving
their order in this set.
Example:
>>> this = OrderedSet([1, 4, 3, 5, 7])
>>> other = OrderedSet([9, 7, 1, 3, 2])
>>> this.intersection_updat... | [
"def",
"intersection_update",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"set",
"(",
"other",
")",
"self",
".",
"_update_items",
"(",
"[",
"item",
"for",
"item",
"in",
"self",
".",
"items",
"if",
"item",
"in",
"other",
"]",
")"
] | [
456,
4
] | [
469,
74
] | python | en | ['en', 'error', 'th'] | False |
OrderedSet.symmetric_difference_update | (self, other) |
Update this OrderedSet to remove items from another set, then
add items from the other set that were not present in this set.
Example:
>>> this = OrderedSet([1, 4, 3, 5, 7])
>>> other = OrderedSet([9, 7, 1, 3, 2])
>>> this.symmetric_difference_update(other)
... |
Update this OrderedSet to remove items from another set, then
add items from the other set that were not present in this set. | def symmetric_difference_update(self, other):
"""
Update this OrderedSet to remove items from another set, then
add items from the other set that were not present in this set.
Example:
>>> this = OrderedSet([1, 4, 3, 5, 7])
>>> other = OrderedSet([9, 7, 1, 3, 2])... | [
"def",
"symmetric_difference_update",
"(",
"self",
",",
"other",
")",
":",
"items_to_add",
"=",
"[",
"item",
"for",
"item",
"in",
"other",
"if",
"item",
"not",
"in",
"self",
"]",
"items_to_remove",
"=",
"set",
"(",
"other",
")",
"self",
".",
"_update_items... | [
471,
4
] | [
487,
9
] | python | en | ['en', 'error', 'th'] | False |
DepList.add | (self, *items) |
Add items to be sorted.
@param items: One or more items to be added.
@type items: I{item}
@return: self
@rtype: L{DepList}
|
Add items to be sorted.
| def add(self, *items):
"""
Add items to be sorted.
@param items: One or more items to be added.
@type items: I{item}
@return: self
@rtype: L{DepList}
"""
for item in items:
self.unsorted.append(item)
key = item[0]
self.i... | [
"def",
"add",
"(",
"self",
",",
"*",
"items",
")",
":",
"for",
"item",
"in",
"items",
":",
"self",
".",
"unsorted",
".",
"append",
"(",
"item",
")",
"key",
"=",
"item",
"[",
"0",
"]",
"self",
".",
"index",
"[",
"key",
"]",
"=",
"item",
"return"... | [
51,
4
] | [
63,
19
] | python | en | ['en', 'error', 'th'] | False |
DepList.sort | (self) |
Sort the list based on dependancies.
@return: The sorted items.
@rtype: list
|
Sort the list based on dependancies.
| def sort(self):
"""
Sort the list based on dependancies.
@return: The sorted items.
@rtype: list
"""
self.sorted = list()
self.pushed = set()
for item in self.unsorted:
popped = []
self.push(item)
while len(s... | [
"def",
"sort",
"(",
"self",
")",
":",
"self",
".",
"sorted",
"=",
"list",
"(",
")",
"self",
".",
"pushed",
"=",
"set",
"(",
")",
"for",
"item",
"in",
"self",
".",
"unsorted",
":",
"popped",
"=",
"[",
"]",
"self",
".",
"push",
"(",
"item",
")",
... | [
65,
4
] | [
91,
26
] | python | en | ['en', 'error', 'th'] | False |
DepList.top | (self) |
Get the item at the top of the stack.
@return: The top item.
@rtype: (item, iter)
|
Get the item at the top of the stack.
| def top(self):
"""
Get the item at the top of the stack.
@return: The top item.
@rtype: (item, iter)
"""
return self.stack[-1] | [
"def",
"top",
"(",
"self",
")",
":",
"return",
"self",
".",
"stack",
"[",
"-",
"1",
"]"
] | [
93,
4
] | [
99,
29
] | python | en | ['en', 'error', 'th'] | False |
DepList.push | (self, item) |
Push and item onto the sorting stack.
@param item: An item to push.
@type item: I{item}
@return: The number of items pushed.
@rtype: int
|
Push and item onto the sorting stack.
| def push(self, item):
"""
Push and item onto the sorting stack.
@param item: An item to push.
@type item: I{item}
@return: The number of items pushed.
@rtype: int
"""
if item in self.pushed:
return
frame = (item, iter(item[1]))
... | [
"def",
"push",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
"in",
"self",
".",
"pushed",
":",
"return",
"frame",
"=",
"(",
"item",
",",
"iter",
"(",
"item",
"[",
"1",
"]",
")",
")",
"self",
".",
"stack",
".",
"append",
"(",
"frame",
")",
... | [
101,
4
] | [
113,
29
] | python | en | ['en', 'error', 'th'] | False |
DepList.pop | (self) |
Pop the top item off the stack and append
it to the sorted list.
@return: The popped item.
@rtype: I{item}
|
Pop the top item off the stack and append
it to the sorted list.
| def pop(self):
"""
Pop the top item off the stack and append
it to the sorted list.
@return: The popped item.
@rtype: I{item}
"""
try:
frame = self.stack.pop()
return frame[0]
except:
pass | [
"def",
"pop",
"(",
"self",
")",
":",
"try",
":",
"frame",
"=",
"self",
".",
"stack",
".",
"pop",
"(",
")",
"return",
"frame",
"[",
"0",
"]",
"except",
":",
"pass"
] | [
115,
4
] | [
126,
16
] | python | en | ['en', 'error', 'th'] | False |
build_user_profile | (
avatar_source: str,
date_joined: Any,
delivery_email: str,
email: str,
full_name: str,
id: int,
is_active: bool,
role: int,
is_mirror_dummy: bool,
realm_id: int,
short_name: str,
timezone: Optional[str],
) |
Even though short_name is no longer in the Zulip
UserProfile, it's helpful to have it in our import
dictionaries for legacy reasons.
|
Even though short_name is no longer in the Zulip
UserProfile, it's helpful to have it in our import
dictionaries for legacy reasons.
| def build_user_profile(
avatar_source: str,
date_joined: Any,
delivery_email: str,
email: str,
full_name: str,
id: int,
is_active: bool,
role: int,
is_mirror_dummy: bool,
realm_id: int,
short_name: str,
timezone: Optional[str],
) -> ZerverFieldsT:
obj = UserProfile(
... | [
"def",
"build_user_profile",
"(",
"avatar_source",
":",
"str",
",",
"date_joined",
":",
"Any",
",",
"delivery_email",
":",
"str",
",",
"email",
":",
"str",
",",
"full_name",
":",
"str",
",",
"id",
":",
"int",
",",
"is_active",
":",
"bool",
",",
"role",
... | [
77,
0
] | [
112,
14
] | python | en | ['en', 'error', 'th'] | False |
make_subscriber_map | (zerver_subscription: List[ZerverFieldsT]) |
This can be convenient for building up UserMessage
rows.
|
This can be convenient for building up UserMessage
rows.
| def make_subscriber_map(zerver_subscription: List[ZerverFieldsT]) -> Dict[int, Set[int]]:
"""
This can be convenient for building up UserMessage
rows.
"""
subscriber_map: Dict[int, Set[int]] = {}
for sub in zerver_subscription:
user_id = sub["user_profile"]
recipient_id = sub["re... | [
"def",
"make_subscriber_map",
"(",
"zerver_subscription",
":",
"List",
"[",
"ZerverFieldsT",
"]",
")",
"->",
"Dict",
"[",
"int",
",",
"Set",
"[",
"int",
"]",
"]",
":",
"subscriber_map",
":",
"Dict",
"[",
"int",
",",
"Set",
"[",
"int",
"]",
"]",
"=",
... | [
136,
0
] | [
149,
25
] | python | en | ['en', 'error', 'th'] | False |
build_public_stream_subscriptions | (
zerver_userprofile: List[ZerverFieldsT],
zerver_recipient: List[ZerverFieldsT],
zerver_stream: List[ZerverFieldsT],
) |
This function was only used for HipChat, but it may apply to
future conversions. We often did't get full subscriber data in
the HipChat export, so this function just autosubscribes all
users to every public stream. This returns a list of Subscription
dicts.
|
This function was only used for HipChat, but it may apply to
future conversions. We often did't get full subscriber data in
the HipChat export, so this function just autosubscribes all
users to every public stream. This returns a list of Subscription
dicts.
| def build_public_stream_subscriptions(
zerver_userprofile: List[ZerverFieldsT],
zerver_recipient: List[ZerverFieldsT],
zerver_stream: List[ZerverFieldsT],
) -> List[ZerverFieldsT]:
"""
This function was only used for HipChat, but it may apply to
future conversions. We often did't get full subsc... | [
"def",
"build_public_stream_subscriptions",
"(",
"zerver_userprofile",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"zerver_recipient",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"zerver_stream",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
")",
"->",
"List",
... | [
190,
0
] | [
223,
24
] | python | en | ['en', 'error', 'th'] | False |
build_recipients | (
zerver_userprofile: Iterable[ZerverFieldsT],
zerver_stream: Iterable[ZerverFieldsT],
zerver_huddle: Iterable[ZerverFieldsT] = [],
) |
This function was only used HipChat import, this function may be
required for future conversions. The Slack and Gitter conversions do it more
tightly integrated with creating other objects.
|
This function was only used HipChat import, this function may be
required for future conversions. The Slack and Gitter conversions do it more
tightly integrated with creating other objects.
| def build_recipients(
zerver_userprofile: Iterable[ZerverFieldsT],
zerver_stream: Iterable[ZerverFieldsT],
zerver_huddle: Iterable[ZerverFieldsT] = [],
) -> List[ZerverFieldsT]:
"""
This function was only used HipChat import, this function may be
required for future conversions. The Slack and Gi... | [
"def",
"build_recipients",
"(",
"zerver_userprofile",
":",
"Iterable",
"[",
"ZerverFieldsT",
"]",
",",
"zerver_stream",
":",
"Iterable",
"[",
"ZerverFieldsT",
"]",
",",
"zerver_huddle",
":",
"Iterable",
"[",
"ZerverFieldsT",
"]",
"=",
"[",
"]",
",",
")",
"->",... | [
320,
0
] | [
365,
21
] | python | en | ['en', 'error', 'th'] | False |
build_attachment | (
realm_id: int,
message_ids: Set[int],
user_id: int,
fileinfo: ZerverFieldsT,
s3_path: str,
zerver_attachment: List[ZerverFieldsT],
) |
This function should be passed a 'fileinfo' dictionary, which contains
information about 'size', 'created' (created time) and ['name'] (filename).
|
This function should be passed a 'fileinfo' dictionary, which contains
information about 'size', 'created' (created time) and ['name'] (filename).
| def build_attachment(
realm_id: int,
message_ids: Set[int],
user_id: int,
fileinfo: ZerverFieldsT,
s3_path: str,
zerver_attachment: List[ZerverFieldsT],
) -> None:
"""
This function should be passed a 'fileinfo' dictionary, which contains
information about 'size', 'created' (created ... | [
"def",
"build_attachment",
"(",
"realm_id",
":",
"int",
",",
"message_ids",
":",
"Set",
"[",
"int",
"]",
",",
"user_id",
":",
"int",
",",
"fileinfo",
":",
"ZerverFieldsT",
",",
"s3_path",
":",
"str",
",",
"zerver_attachment",
":",
"List",
"[",
"ZerverField... | [
519,
0
] | [
547,
45
] | python | en | ['en', 'error', 'th'] | False |
process_avatars | (
avatar_list: List[ZerverFieldsT],
avatar_dir: str,
realm_id: int,
threads: int,
size_url_suffix: str = "",
) |
This function gets the avatar of the user and saves it in the
user's avatar directory with both the extensions '.png' and '.original'
Required parameters:
1. avatar_list: List of avatars to be mapped in avatars records.json file
2. avatar_dir: Folder where the downloaded avatars are saved
3. r... |
This function gets the avatar of the user and saves it in the
user's avatar directory with both the extensions '.png' and '.original'
Required parameters: | def process_avatars(
avatar_list: List[ZerverFieldsT],
avatar_dir: str,
realm_id: int,
threads: int,
size_url_suffix: str = "",
) -> List[ZerverFieldsT]:
"""
This function gets the avatar of the user and saves it in the
user's avatar directory with both the extensions '.png' and '.origin... | [
"def",
"process_avatars",
"(",
"avatar_list",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"avatar_dir",
":",
"str",
",",
"realm_id",
":",
"int",
",",
"threads",
":",
"int",
",",
"size_url_suffix",
":",
"str",
"=",
"\"\"",
",",
")",
"->",
"List",
"[",
... | [
562,
0
] | [
611,
45
] | python | en | ['en', 'error', 'th'] | False |
write_avatar_png | (avatar_folder: str, realm_id: int, user_id: int, bits: bytes) |
Use this function for conversions like HipChat where
the bits for the .png file come in something like
a users.json file, and where we don't have to
fetch avatar images externally.
|
Use this function for conversions like HipChat where
the bits for the .png file come in something like
a users.json file, and where we don't have to
fetch avatar images externally.
| def write_avatar_png(avatar_folder: str, realm_id: int, user_id: int, bits: bytes) -> ZerverFieldsT:
"""
Use this function for conversions like HipChat where
the bits for the .png file come in something like
a users.json file, and where we don't have to
fetch avatar images externally.
"""
av... | [
"def",
"write_avatar_png",
"(",
"avatar_folder",
":",
"str",
",",
"realm_id",
":",
"int",
",",
"user_id",
":",
"int",
",",
"bits",
":",
"bytes",
")",
"->",
"ZerverFieldsT",
":",
"avatar_hash",
"=",
"user_avatar_path_from_ids",
"(",
"user_profile_id",
"=",
"use... | [
614,
0
] | [
642,
19
] | python | en | ['en', 'error', 'th'] | False |
process_uploads | (
upload_list: List[ZerverFieldsT], upload_dir: str, threads: int
) |
This function downloads the uploads and saves it in the realm's upload directory.
Required parameters:
1. upload_list: List of uploads to be mapped in uploads records.json file
2. upload_dir: Folder where the downloaded uploads are saved
|
This function downloads the uploads and saves it in the realm's upload directory.
Required parameters: | def process_uploads(
upload_list: List[ZerverFieldsT], upload_dir: str, threads: int
) -> List[ZerverFieldsT]:
"""
This function downloads the uploads and saves it in the realm's upload directory.
Required parameters:
1. upload_list: List of uploads to be mapped in uploads records.json file
2. ... | [
"def",
"process_uploads",
"(",
"upload_list",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"upload_dir",
":",
"str",
",",
"threads",
":",
"int",
")",
"->",
"List",
"[",
"ZerverFieldsT",
"]",
":",
"logging",
".",
"info",
"(",
"\"######### GETTING ATTACHMENTS ##... | [
679,
0
] | [
702,
22
] | python | en | ['en', 'error', 'th'] | False |
process_emojis | (
zerver_realmemoji: List[ZerverFieldsT],
emoji_dir: str,
emoji_url_map: ZerverFieldsT,
threads: int,
) |
This function downloads the custom emojis and saves in the output emoji folder.
Required parameters:
1. zerver_realmemoji: List of all RealmEmoji objects to be imported
2. emoji_dir: Folder where the downloaded emojis are saved
3. emoji_url_map: Maps emoji name to its url
|
This function downloads the custom emojis and saves in the output emoji folder.
Required parameters: | def process_emojis(
zerver_realmemoji: List[ZerverFieldsT],
emoji_dir: str,
emoji_url_map: ZerverFieldsT,
threads: int,
) -> List[ZerverFieldsT]:
"""
This function downloads the custom emojis and saves in the output emoji folder.
Required parameters:
1. zerver_realmemoji: List of all Re... | [
"def",
"process_emojis",
"(",
"zerver_realmemoji",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"emoji_dir",
":",
"str",
",",
"emoji_url_map",
":",
"ZerverFieldsT",
",",
"threads",
":",
"int",
",",
")",
"->",
"List",
"[",
"ZerverFieldsT",
"]",
":",
"emoji_re... | [
727,
0
] | [
765,
24
] | python | en | ['en', 'error', 'th'] | False |
parse_wininst_info | (wininfo_name, egginfo_name) | Extract metadata from filenames.
Extracts the 4 metadataitems needed (name, version, pyversion, arch) from
the installer filename and the name of the egg-info directory embedded in
the zipfile (if any).
The egginfo filename has the format::
name-ver(-pyver)(-arch).egg-info
The installer ... | Extract metadata from filenames. | def parse_wininst_info(wininfo_name, egginfo_name):
"""Extract metadata from filenames.
Extracts the 4 metadataitems needed (name, version, pyversion, arch) from
the installer filename and the name of the egg-info directory embedded in
the zipfile (if any).
The egginfo filename has the format::
... | [
"def",
"parse_wininst_info",
"(",
"wininfo_name",
",",
"egginfo_name",
")",
":",
"egginfo",
"=",
"None",
"if",
"egginfo_name",
":",
"egginfo",
"=",
"egg_info_re",
".",
"search",
"(",
"egginfo_name",
")",
"if",
"not",
"egginfo",
":",
"raise",
"ValueError",
"(",... | [
90,
0
] | [
158,
75
] | python | en | ['en', 'en', 'en'] | True |
IndexView.get_queryset | (self) |
Return the last five published questions (not including those set to be
published in the future).
|
Return the last five published questions (not including those set to be
published in the future).
| def get_queryset(self):
"""
Return the last five published questions (not including those set to be
published in the future).
"""
return Question.objects.filter(
pub_date__lte=timezone.now()
).order_by('-pub_date')[:5] | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"return",
"Question",
".",
"objects",
".",
"filter",
"(",
"pub_date__lte",
"=",
"timezone",
".",
"now",
"(",
")",
")",
".",
"order_by",
"(",
"'-pub_date'",
")",
"[",
":",
"5",
"]"
] | [
12,
4
] | [
19,
35
] | python | en | ['en', 'error', 'th'] | False |
DetailView.get_queryset | (self) |
Update the model, excluding any questions that aren't published yet.
|
Update the model, excluding any questions that aren't published yet.
| def get_queryset(self):
"""
Update the model, excluding any questions that aren't published yet.
"""
return Question.objects.filter(pub_date__lte=timezone.now()) | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"return",
"Question",
".",
"objects",
".",
"filter",
"(",
"pub_date__lte",
"=",
"timezone",
".",
"now",
"(",
")",
")"
] | [
24,
4
] | [
28,
68
] | python | en | ['en', 'error', 'th'] | False |
ResultsView.get_queryset | (self) |
Excludes any questions that aren't published yet.
|
Excludes any questions that aren't published yet.
| def get_queryset(self):
"""
Excludes any questions that aren't published yet.
"""
return Question.objects.filter(pub_date__lte=timezone.now()) | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"return",
"Question",
".",
"objects",
".",
"filter",
"(",
"pub_date__lte",
"=",
"timezone",
".",
"now",
"(",
")",
")"
] | [
33,
4
] | [
37,
68
] | python | en | ['en', 'error', 'th'] | False |
tostr | (object, encoding=None) | get a unicode safe string representation of an object | get a unicode safe string representation of an object | def tostr(object, encoding=None):
""" get a unicode safe string representation of an object """
if isinstance(object, basestring):
if encoding is None:
return object
else:
return object.encode(encoding)
if isinstance(object, tuple):
s = ['(']
for item ... | [
"def",
"tostr",
"(",
"object",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"object",
",",
"basestring",
")",
":",
"if",
"encoding",
"is",
"None",
":",
"return",
"object",
"else",
":",
"return",
"object",
".",
"encode",
"(",
"encodi... | [
94,
0
] | [
139,
26
] | python | en | ['en', 'en', 'en'] | True |
shellfilter | (value) | Replace HTML chars for shell usage. | Replace HTML chars for shell usage. | def shellfilter(value):
"""Replace HTML chars for shell usage."""
replacements = {'\\': '\\\\',
'`': '\\`',
"'": "\\'",
'"': '\\"'}
for search, repl in replacements.items():
value = value.replace(search, repl)
return safestring.mark_saf... | [
"def",
"shellfilter",
"(",
"value",
")",
":",
"replacements",
"=",
"{",
"'\\\\'",
":",
"'\\\\\\\\'",
",",
"'`'",
":",
"'\\\\`'",
",",
"\"'\"",
":",
"\"\\\\'\"",
",",
"'\"'",
":",
"'\\\\\"'",
"}",
"for",
"search",
",",
"repl",
"in",
"replacements",
".",
... | [
21,
0
] | [
29,
38
] | python | en | ['en', 'en', 'en'] | True |
volume_list_paged | (request, search_opts=None, marker=None, paginate=False,
sort_dir="desc") | List volumes with pagination.
To see all volumes in the cloud as an admin you can pass in a special
search option: {'all_tenants': 1}
| List volumes with pagination. | def volume_list_paged(request, search_opts=None, marker=None, paginate=False,
sort_dir="desc"):
"""List volumes with pagination.
To see all volumes in the cloud as an admin you can pass in a special
search option: {'all_tenants': 1}
"""
has_more_data = False
has_prev_data ... | [
"def",
"volume_list_paged",
"(",
"request",
",",
"search_opts",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"paginate",
"=",
"False",
",",
"sort_dir",
"=",
"\"desc\"",
")",
":",
"has_more_data",
"=",
"False",
"has_prev_data",
"=",
"False",
"volumes",
"=",
... | [
316,
0
] | [
355,
48
] | python | en | ['en', 'en', 'en'] | True |
volume_backup_supported | (request) | This method will determine if cinder supports backup. | This method will determine if cinder supports backup. | def volume_backup_supported(request):
"""This method will determine if cinder supports backup."""
# TODO(lcheng) Cinder does not expose the information if cinder
# backup is configured yet. This is a workaround until that
# capability is available.
# https://bugs.launchpad.net/cinder/+bug/1334856
... | [
"def",
"volume_backup_supported",
"(",
"request",
")",
":",
"# TODO(lcheng) Cinder does not expose the information if cinder",
"# backup is configured yet. This is a workaround until that",
"# capability is available.",
"# https://bugs.launchpad.net/cinder/+bug/1334856",
"return",
"utils",
"... | [
562,
0
] | [
568,
78
] | python | en | ['en', 'en', 'en'] | True |
extension_supported | (request, extension_name) | This method will determine if Cinder supports a given extension name. | This method will determine if Cinder supports a given extension name. | def extension_supported(request, extension_name):
"""This method will determine if Cinder supports a given extension name."""
for extension in list_extensions(request):
if extension.name == extension_name:
return True
return False | [
"def",
"extension_supported",
"(",
"request",
",",
"extension_name",
")",
":",
"for",
"extension",
"in",
"list_extensions",
"(",
"request",
")",
":",
"if",
"extension",
".",
"name",
"==",
"extension_name",
":",
"return",
"True",
"return",
"False"
] | [
928,
0
] | [
933,
16
] | python | en | ['en', 'en', 'en'] | True |
transfer_list | (request, detailed=True, search_opts=None) | List volume transfers.
To see all volumes transfers as an admin pass in a special
search option: {'all_tenants': 1}
| List volume transfers. | def transfer_list(request, detailed=True, search_opts=None):
"""List volume transfers.
To see all volumes transfers as an admin pass in a special
search option: {'all_tenants': 1}
"""
c_client = cinderclient(request)
try:
return [VolumeTransfer(v) for v in c_client.transfers.list(
... | [
"def",
"transfer_list",
"(",
"request",
",",
"detailed",
"=",
"True",
",",
"search_opts",
"=",
"None",
")",
":",
"c_client",
"=",
"cinderclient",
"(",
"request",
")",
"try",
":",
"return",
"[",
"VolumeTransfer",
"(",
"v",
")",
"for",
"v",
"in",
"c_client... | [
937,
0
] | [
949,
17
] | python | en | ['nl', 'et', 'en'] | False |
TestArchiveMessagesGeneral.test_expired_messages_in_each_realm | (self) | General test for archiving expired messages properly with
multiple realms involved | General test for archiving expired messages properly with
multiple realms involved | def test_expired_messages_in_each_realm(self) -> None:
"""General test for archiving expired messages properly with
multiple realms involved"""
# Make some expired messages in MIT:
expired_mit_msg_ids = self._make_mit_messages(
5,
timezone_now() - timedelta(days=M... | [
"def",
"test_expired_messages_in_each_realm",
"(",
"self",
")",
"->",
"None",
":",
"# Make some expired messages in MIT:",
"expired_mit_msg_ids",
"=",
"self",
".",
"_make_mit_messages",
"(",
"5",
",",
"timezone_now",
"(",
")",
"-",
"timedelta",
"(",
"days",
"=",
"MI... | [
206,
4
] | [
235,
72
] | python | en | ['en', 'en', 'en'] | True |
TestArchiveMessagesGeneral.test_expired_messages_in_one_realm | (self) | Test with a retention policy set for only the MIT realm | Test with a retention policy set for only the MIT realm | def test_expired_messages_in_one_realm(self) -> None:
"""Test with a retention policy set for only the MIT realm"""
self._set_realm_message_retention_value(self.zulip_realm, -1)
# Make some expired messages in MIT:
expired_mit_msg_ids = self._make_mit_messages(
5,
... | [
"def",
"test_expired_messages_in_one_realm",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_set_realm_message_retention_value",
"(",
"self",
".",
"zulip_realm",
",",
"-",
"1",
")",
"# Make some expired messages in MIT:",
"expired_mit_msg_ids",
"=",
"self",
".",
"... | [
237,
4
] | [
271,
83
] | python | en | ['en', 'en', 'en'] | True |
TestArchiveMessagesGeneral.test_cross_realm_personal_message_archiving | (self) | Check that cross-realm personal messages get correctly archived. | Check that cross-realm personal messages get correctly archived. | def test_cross_realm_personal_message_archiving(self) -> None:
"""Check that cross-realm personal messages get correctly archived."""
msg_ids = [self._send_cross_realm_personal_message() for i in range(1, 7)]
usermsg_ids = self._get_usermessage_ids(msg_ids)
# Make the message expired on ... | [
"def",
"test_cross_realm_personal_message_archiving",
"(",
"self",
")",
"->",
"None",
":",
"msg_ids",
"=",
"[",
"self",
".",
"_send_cross_realm_personal_message",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"7",
")",
"]",
"usermsg_ids",
"=",
"self",
... | [
299,
4
] | [
307,
55
] | python | en | ['en', 'en', 'en'] | True |
TestArchiveMessagesGeneral.test_archiving_interrupted | (self) | Check that queries get rolled back to a consistent state
if archiving gets interrupted in the middle of processing a chunk. | Check that queries get rolled back to a consistent state
if archiving gets interrupted in the middle of processing a chunk. | def test_archiving_interrupted(self) -> None:
"""Check that queries get rolled back to a consistent state
if archiving gets interrupted in the middle of processing a chunk."""
expired_msg_ids = self._make_expired_zulip_messages(7)
expired_usermsg_ids = self._get_usermessage_ids(expired_m... | [
"def",
"test_archiving_interrupted",
"(",
"self",
")",
"->",
"None",
":",
"expired_msg_ids",
"=",
"self",
".",
"_make_expired_zulip_messages",
"(",
"7",
")",
"expired_usermsg_ids",
"=",
"self",
".",
"_get_usermessage_ids",
"(",
"expired_msg_ids",
")",
"# Insert an exc... | [
309,
4
] | [
335,
13
] | python | en | ['en', 'en', 'en'] | True |
TestArchiveMessagesGeneral.test_archive_message_tool | (self) | End-to-end test of the archiving tool, directly calling
archive_messages. | End-to-end test of the archiving tool, directly calling
archive_messages. | def test_archive_message_tool(self) -> None:
"""End-to-end test of the archiving tool, directly calling
archive_messages."""
# Make some expired messages in MIT:
expired_mit_msg_ids = self._make_mit_messages(
5,
timezone_now() - timedelta(days=MIT_REALM_DAYS + 1),... | [
"def",
"test_archive_message_tool",
"(",
"self",
")",
"->",
"None",
":",
"# Make some expired messages in MIT:",
"expired_mit_msg_ids",
"=",
"self",
".",
"_make_mit_messages",
"(",
"5",
",",
"timezone_now",
"(",
")",
"-",
"timedelta",
"(",
"days",
"=",
"MIT_REALM_DA... | [
337,
4
] | [
366,
72
] | python | en | ['en', 'en', 'en'] | True |
TestArchiveMessagesGeneral.test_archiving_attachments | (self) | End-to-end test for the logic for archiving attachments. This test
is hard to read without first reading _send_messages_with_attachments | End-to-end test for the logic for archiving attachments. This test
is hard to read without first reading _send_messages_with_attachments | def test_archiving_attachments(self) -> None:
"""End-to-end test for the logic for archiving attachments. This test
is hard to read without first reading _send_messages_with_attachments"""
msgs_ids = self._send_messages_with_attachments()
# First, confirm deleting the oldest message
... | [
"def",
"test_archiving_attachments",
"(",
"self",
")",
"->",
"None",
":",
"msgs_ids",
"=",
"self",
".",
"_send_messages_with_attachments",
"(",
")",
"# First, confirm deleting the oldest message",
"# (`expired_message_id`) creates ArchivedAttachment objects",
"# and associates that... | [
368,
4
] | [
428,
9
] | python | en | ['en', 'en', 'en'] | True |
MoveMessageToArchiveGeneral.test_archiving_messages_multiple_realms | (self) |
Verifies that move_messages_to_archive works correctly
if called on messages in multiple realms.
|
Verifies that move_messages_to_archive works correctly
if called on messages in multiple realms.
| def test_archiving_messages_multiple_realms(self) -> None:
"""
Verifies that move_messages_to_archive works correctly
if called on messages in multiple realms.
"""
iago = self.example_user("iago")
othello = self.example_user("othello")
cordelia = self.lear_user("... | [
"def",
"test_archiving_messages_multiple_realms",
"(",
"self",
")",
"->",
"None",
":",
"iago",
"=",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
"othello",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"cordelia",
"=",
"self",
".",
"lear_use... | [
628,
4
] | [
649,
56
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.