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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
user_passes_test | (test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME) |
Decorator for views that checks that the user passes the given test,
redirecting to the log-in page if necessary. The test should be a callable
that takes the user object and returns True if the user passes.
|
Decorator for views that checks that the user passes the given test,
redirecting to the log-in page if necessary. The test should be a callable
that takes the user object and returns True if the user passes.
| def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
"""
Decorator for views that checks that the user passes the given test,
redirecting to the log-in page if necessary. The test should be a callable
that takes the user object and returns True if the user passes.
... | [
"def",
"user_passes_test",
"(",
"test_func",
",",
"login_url",
"=",
"None",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
")",
":",
"def",
"decorator",
"(",
"view_func",
")",
":",
"@",
"wraps",
"(",
"view_func",
",",
"assigned",
"=",
"available_attrs",... | [
10,
0
] | [
37,
20
] | python | en | ['en', 'error', 'th'] | False |
login_required | (function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None) |
Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary.
|
Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary.
| def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None):
"""
Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary.
"""
actual_decorator = user_passes_test(
lambda u: u.is_authenticated(),
login_url=... | [
"def",
"login_required",
"(",
"function",
"=",
"None",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
",",
"login_url",
"=",
"None",
")",
":",
"actual_decorator",
"=",
"user_passes_test",
"(",
"lambda",
"u",
":",
"u",
".",
"is_authenticated",
"(",
")",
... | [
40,
0
] | [
52,
27
] | python | en | ['en', 'error', 'th'] | False |
permission_required | (perm, login_url=None, raise_exception=False) |
Decorator for views that checks whether a user has a particular permission
enabled, redirecting to the log-in page if necessary.
If the raise_exception parameter is given the PermissionDenied exception
is raised.
|
Decorator for views that checks whether a user has a particular permission
enabled, redirecting to the log-in page if necessary.
If the raise_exception parameter is given the PermissionDenied exception
is raised.
| def permission_required(perm, login_url=None, raise_exception=False):
"""
Decorator for views that checks whether a user has a particular permission
enabled, redirecting to the log-in page if necessary.
If the raise_exception parameter is given the PermissionDenied exception
is raised.
"""
d... | [
"def",
"permission_required",
"(",
"perm",
",",
"login_url",
"=",
"None",
",",
"raise_exception",
"=",
"False",
")",
":",
"def",
"check_perms",
"(",
"user",
")",
":",
"if",
"not",
"isinstance",
"(",
"perm",
",",
"(",
"list",
",",
"tuple",
")",
")",
":"... | [
55,
0
] | [
75,
61
] | python | en | ['en', 'error', 'th'] | False |
semantic | (x, center=True, max_val=1.0) |
Semantic adversarial examples.
https://arxiv.org/abs/1703.06857
Note: data must either be centered (so that the negative image can be
made by simple negation) or must be in the interval of [-1, 1]
Arguments
---------
center : bool
If true, assumes data has 0 mean so the nega... |
Semantic adversarial examples. | def semantic(x, center=True, max_val=1.0):
"""
Semantic adversarial examples.
https://arxiv.org/abs/1703.06857
Note: data must either be centered (so that the negative image can be
made by simple negation) or must be in the interval of [-1, 1]
Arguments
---------
center : bool
... | [
"def",
"semantic",
"(",
"x",
",",
"center",
"=",
"True",
",",
"max_val",
"=",
"1.0",
")",
":",
"if",
"self",
".",
"center",
":",
"return",
"x",
"*",
"-",
"1",
"return",
"self",
".",
"max_val",
"-",
"x"
] | [
5,
0
] | [
25,
27
] | python | en | ['en', 'error', 'th'] | False |
send_response_message | (
bot_id: int, message_info: Dict[str, Any], response_data: Dict[str, Any]
) |
bot_id is the user_id of the bot sending the response
message_info is used to address the message and should have these fields:
type - "stream" or "private"
display_recipient - like we have in other message events
topic - see get_topic_from_message_info
response_data is what the b... |
bot_id is the user_id of the bot sending the response | def send_response_message(
bot_id: int, message_info: Dict[str, Any], response_data: Dict[str, Any]
) -> None:
"""
bot_id is the user_id of the bot sending the response
message_info is used to address the message and should have these fields:
type - "stream" or "private"
display_recipie... | [
"def",
"send_response_message",
"(",
"bot_id",
":",
"int",
",",
"message_info",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"response_data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"message_type",
"=",
"message_info",
"[",
... | [
151,
0
] | [
198,
5
] | python | en | ['en', 'error', 'th'] | False |
do_rest_call | (
base_url: str,
event: Dict[str, Any],
service_handler: OutgoingWebhookServiceInterface,
) | Returns response of call if no exception occurs. | Returns response of call if no exception occurs. | def do_rest_call(
base_url: str,
event: Dict[str, Any],
service_handler: OutgoingWebhookServiceInterface,
) -> Optional[Response]:
"""Returns response of call if no exception occurs."""
try:
response = service_handler.make_request(
base_url,
event,
)
i... | [
"def",
"do_rest_call",
"(",
"base_url",
":",
"str",
",",
"event",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"service_handler",
":",
"OutgoingWebhookServiceInterface",
",",
")",
"->",
"Optional",
"[",
"Response",
"]",
":",
"try",
":",
"response",
"=",
... | [
305,
0
] | [
371,
19
] | python | en | ['en', 'en', 'en'] | True |
GenericOutgoingWebhookService.make_request | (self, base_url: str, event: Dict[str, Any]) |
We send a simple version of the message to outgoing
webhooks, since most of them really only need
`content` and a few other fields. We may eventually
allow certain bots to get more information, but
that's not a high priority. We do send the gravatar
info to the clients... |
We send a simple version of the message to outgoing
webhooks, since most of them really only need
`content` and a few other fields. We may eventually
allow certain bots to get more information, but
that's not a high priority. We do send the gravatar
info to the clients... | def make_request(self, base_url: str, event: Dict[str, Any]) -> Optional[Response]:
"""
We send a simple version of the message to outgoing
webhooks, since most of them really only need
`content` and a few other fields. We may eventually
allow certain bots to get more informatio... | [
"def",
"make_request",
"(",
"self",
",",
"base_url",
":",
"str",
",",
"event",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Optional",
"[",
"Response",
"]",
":",
"message_dict",
"=",
"MessageDict",
".",
"finalize_payload",
"(",
"event",
"[",
"... | [
50,
4
] | [
76,
61
] | python | en | ['en', 'error', 'th'] | False |
kml | (request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS) |
This view generates KML for the given app label, model, and field name.
The model's default manager must be GeoManager, and the field name
must be that of a geographic field.
|
This view generates KML for the given app label, model, and field name. | def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS):
"""
This view generates KML for the given app label, model, and field name.
The model's default manager must be GeoManager, and the field name
must be that of a geographic field.
"""
placemarks = []
try... | [
"def",
"kml",
"(",
"request",
",",
"label",
",",
"model",
",",
"field_name",
"=",
"None",
",",
"compress",
"=",
"False",
",",
"using",
"=",
"DEFAULT_DB_ALIAS",
")",
":",
"placemarks",
"=",
"[",
"]",
"try",
":",
"klass",
"=",
"apps",
".",
"get_model",
... | [
10,
0
] | [
53,
67
] | python | en | ['en', 'error', 'th'] | False |
kmz | (request, label, model, field_name=None, using=DEFAULT_DB_ALIAS) |
This view returns KMZ for the given app label, model, and field name.
|
This view returns KMZ for the given app label, model, and field name.
| def kmz(request, label, model, field_name=None, using=DEFAULT_DB_ALIAS):
"""
This view returns KMZ for the given app label, model, and field name.
"""
return kml(request, label, model, field_name, compress=True, using=using) | [
"def",
"kmz",
"(",
"request",
",",
"label",
",",
"model",
",",
"field_name",
"=",
"None",
",",
"using",
"=",
"DEFAULT_DB_ALIAS",
")",
":",
"return",
"kml",
"(",
"request",
",",
"label",
",",
"model",
",",
"field_name",
",",
"compress",
"=",
"True",
","... | [
56,
0
] | [
60,
77
] | python | en | ['en', 'error', 'th'] | False |
Driver.__init__ | (self, dr_input) |
Initialize an GDAL/OGR driver on either a string or integer input.
|
Initialize an GDAL/OGR driver on either a string or integer input.
| def __init__(self, dr_input):
"""
Initialize an GDAL/OGR driver on either a string or integer input.
"""
if isinstance(dr_input, str):
# If a string name of the driver was passed in
self.ensure_registered()
# Checking the alias dictionary (case-insens... | [
"def",
"__init__",
"(",
"self",
",",
"dr_input",
")",
":",
"if",
"isinstance",
"(",
"dr_input",
",",
"str",
")",
":",
"# If a string name of the driver was passed in",
"self",
".",
"ensure_registered",
"(",
")",
"# Checking the alias dictionary (case-insensitive) to see i... | [
33,
4
] | [
67,
25
] | python | en | ['en', 'error', 'th'] | False |
Driver.ensure_registered | (cls) |
Attempt to register all the data source drivers.
|
Attempt to register all the data source drivers.
| def ensure_registered(cls):
"""
Attempt to register all the data source drivers.
"""
# Only register all if the driver counts are 0 (or else all drivers
# will be registered over and over again)
if not vcapi.get_driver_count():
vcapi.register_all()
if ... | [
"def",
"ensure_registered",
"(",
"cls",
")",
":",
"# Only register all if the driver counts are 0 (or else all drivers",
"# will be registered over and over again)",
"if",
"not",
"vcapi",
".",
"get_driver_count",
"(",
")",
":",
"vcapi",
".",
"register_all",
"(",
")",
"if",
... | [
73,
4
] | [
82,
32
] | python | en | ['en', 'error', 'th'] | False |
Driver.driver_count | (cls) |
Return the number of GDAL/OGR data source drivers registered.
|
Return the number of GDAL/OGR data source drivers registered.
| def driver_count(cls):
"""
Return the number of GDAL/OGR data source drivers registered.
"""
return vcapi.get_driver_count() + rcapi.get_driver_count() | [
"def",
"driver_count",
"(",
"cls",
")",
":",
"return",
"vcapi",
".",
"get_driver_count",
"(",
")",
"+",
"rcapi",
".",
"get_driver_count",
"(",
")"
] | [
85,
4
] | [
89,
66
] | python | en | ['en', 'error', 'th'] | False |
Driver.name | (self) |
Return description/name string for this driver.
|
Return description/name string for this driver.
| def name(self):
"""
Return description/name string for this driver.
"""
return force_str(rcapi.get_driver_description(self.ptr)) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"force_str",
"(",
"rcapi",
".",
"get_driver_description",
"(",
"self",
".",
"ptr",
")",
")"
] | [
92,
4
] | [
96,
64
] | python | en | ['en', 'error', 'th'] | False |
EmailBackend.open | (self) |
Ensure an open connection to the email server. Return whether or not a
new connection was required (True or False) or None if an exception
passed silently.
|
Ensure an open connection to the email server. Return whether or not a
new connection was required (True or False) or None if an exception
passed silently.
| def open(self):
"""
Ensure an open connection to the email server. Return whether or not a
new connection was required (True or False) or None if an exception
passed silently.
"""
if self.connection:
# Nothing to do if the connection is already open.
... | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"connection",
":",
"# Nothing to do if the connection is already open.",
"return",
"False",
"# If local_hostname is not specified, socket.getfqdn() gets used.",
"# For performance, we use the cached FQDN for local_hostname.",
"... | [
40,
4
] | [
72,
21
] | python | en | ['en', 'error', 'th'] | False |
EmailBackend.close | (self) | Close the connection to the email server. | Close the connection to the email server. | def close(self):
"""Close the connection to the email server."""
if self.connection is None:
return
try:
try:
self.connection.quit()
except (ssl.SSLError, smtplib.SMTPServerDisconnected):
# This happens when calling quit() on a ... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"connection",
"is",
"None",
":",
"return",
"try",
":",
"try",
":",
"self",
".",
"connection",
".",
"quit",
"(",
")",
"except",
"(",
"ssl",
".",
"SSLError",
",",
"smtplib",
".",
"SMTPServerDisc... | [
74,
4
] | [
91,
34
] | python | en | ['en', 'en', 'en'] | True |
EmailBackend.send_messages | (self, email_messages) |
Send one or more EmailMessage objects and return the number of email
messages sent.
|
Send one or more EmailMessage objects and return the number of email
messages sent.
| def send_messages(self, email_messages):
"""
Send one or more EmailMessage objects and return the number of email
messages sent.
"""
if not email_messages:
return 0
with self._lock:
new_conn_created = self.open()
if not self.connection ... | [
"def",
"send_messages",
"(",
"self",
",",
"email_messages",
")",
":",
"if",
"not",
"email_messages",
":",
"return",
"0",
"with",
"self",
".",
"_lock",
":",
"new_conn_created",
"=",
"self",
".",
"open",
"(",
")",
"if",
"not",
"self",
".",
"connection",
"o... | [
93,
4
] | [
113,
23
] | python | en | ['en', 'error', 'th'] | False |
EmailBackend._send | (self, email_message) | A helper method that does the actual sending. | A helper method that does the actual sending. | def _send(self, email_message):
"""A helper method that does the actual sending."""
if not email_message.recipients():
return False
encoding = email_message.encoding or settings.DEFAULT_CHARSET
from_email = sanitize_address(email_message.from_email, encoding)
recipien... | [
"def",
"_send",
"(",
"self",
",",
"email_message",
")",
":",
"if",
"not",
"email_message",
".",
"recipients",
"(",
")",
":",
"return",
"False",
"encoding",
"=",
"email_message",
".",
"encoding",
"or",
"settings",
".",
"DEFAULT_CHARSET",
"from_email",
"=",
"s... | [
115,
4
] | [
129,
19
] | 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 |
_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 |
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.
"""
# Get the file to write information about this requirement.
entry_path = self._entry_path(req.link)
# Try reading from the file. If it exists and can be read fro... | [
"def",
"add",
"(",
"self",
",",
"req",
")",
":",
"# type: (InstallRequirement) -> None",
"# Get the file to write information about this requirement.",
"entry_path",
"=",
"self",
".",
"_entry_path",
"(",
"req",
".",
"link",
")",
"# Try reading from the file. If it exists and ... | [
95,
4
] | [
125,
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.
"""
# Delete the created file and the corresponding entries.
os.unlink(self._entry_path(req.link))
self._entries.remove(req)
logger.debug('Removed %s... | [
"def",
"remove",
"(",
"self",
",",
"req",
")",
":",
"# type: (InstallRequirement) -> None",
"# Delete the created file and the corresponding entries.",
"os",
".",
"unlink",
"(",
"self",
".",
"_entry_path",
"(",
"req",
".",
"link",
")",
")",
"self",
".",
"_entries",
... | [
127,
4
] | [
136,
73
] | python | en | ['en', 'en', 'en'] | True |
CleverHansTest.assertClose | (self, x, y, *args, **kwargs) | Assert that `x` and `y` have close to the same value | Assert that `x` and `y` have close to the same value | def assertClose(self, x, y, *args, **kwargs):
"""Assert that `x` and `y` have close to the same value"""
# self.assertTrue(np.allclose(x, y)) doesn't give a useful message
# on failure
assert np.allclose(x, y, *args, **kwargs), (x, y) | [
"def",
"assertClose",
"(",
"self",
",",
"x",
",",
"y",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# self.assertTrue(np.allclose(x, y)) doesn't give a useful message",
"# on failure",
"assert",
"np",
".",
"allclose",
"(",
"x",
",",
"y",
",",
"*",
"... | [
27,
4
] | [
31,
57
] | python | en | ['en', 'en', 'en'] | True |
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 |
WKBReader.read | (self, wkb) | Return a GEOSGeometry for the given WKB buffer. | Return a GEOSGeometry for the given WKB buffer. | def read(self, wkb):
"Return a GEOSGeometry for the given WKB buffer."
return GEOSGeometry(super().read(wkb)) | [
"def",
"read",
"(",
"self",
",",
"wkb",
")",
":",
"return",
"GEOSGeometry",
"(",
"super",
"(",
")",
".",
"read",
"(",
"wkb",
")",
")"
] | [
15,
4
] | [
17,
46
] | python | en | ['en', 'en', 'en'] | True |
WKTReader.read | (self, wkt) | Return a GEOSGeometry for the given WKT string. | Return a GEOSGeometry for the given WKT string. | def read(self, wkt):
"Return a GEOSGeometry for the given WKT string."
return GEOSGeometry(super().read(wkt)) | [
"def",
"read",
"(",
"self",
",",
"wkt",
")",
":",
"return",
"GEOSGeometry",
"(",
"super",
"(",
")",
".",
"read",
"(",
"wkt",
")",
")"
] | [
21,
4
] | [
23,
46
] | python | en | ['en', 'en', 'en'] | True |
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 |
TestEvaluation.test_cache | (self) | test_cache: Test that _CorrectFactory can be cached | test_cache: Test that _CorrectFactory can be cached | def test_cache(self):
"""test_cache: Test that _CorrectFactory can be cached"""
model = Model()
factory_1 = _CorrectFactory(model)
factory_2 = _CorrectFactory(model)
cache = {}
cache[factory_1] = True
self.assertTrue(factory_2 in cache) | [
"def",
"test_cache",
"(",
"self",
")",
":",
"model",
"=",
"Model",
"(",
")",
"factory_1",
"=",
"_CorrectFactory",
"(",
"model",
")",
"factory_2",
"=",
"_CorrectFactory",
"(",
"model",
")",
"cache",
"=",
"{",
"}",
"cache",
"[",
"factory_1",
"]",
"=",
"T... | [
9,
4
] | [
16,
43
] | python | en | ['en', 'en', 'en'] | True |
bytes_to_text | (s, encoding) |
Convert bytes objects to strings, using the given encoding. Illegally
encoded input characters are replaced with Unicode "unknown" codepoint
(\ufffd).
Return any non-bytes objects without change.
|
Convert bytes objects to strings, using the given encoding. Illegally
encoded input characters are replaced with Unicode "unknown" codepoint
(\ufffd). | def bytes_to_text(s, encoding):
"""
Convert bytes objects to strings, using the given encoding. Illegally
encoded input characters are replaced with Unicode "unknown" codepoint
(\ufffd).
Return any non-bytes objects without change.
"""
if isinstance(s, bytes):
return str(s, encoding... | [
"def",
"bytes_to_text",
"(",
"s",
",",
"encoding",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"bytes",
")",
":",
"return",
"str",
"(",
"s",
",",
"encoding",
",",
"'replace'",
")",
"else",
":",
"return",
"s"
] | [
559,
0
] | [
570,
16
] | python | en | ['en', 'error', 'th'] | False |
split_domain_port | (host) |
Return a (domain, port) tuple from a given host.
Returned domain is lowercased. If the host is invalid, the domain will be
empty.
|
Return a (domain, port) tuple from a given host. | def split_domain_port(host):
"""
Return a (domain, port) tuple from a given host.
Returned domain is lowercased. If the host is invalid, the domain will be
empty.
"""
host = host.lower()
if not host_validation_re.match(host):
return '', ''
if host[-1] == ']':
# It's an... | [
"def",
"split_domain_port",
"(",
"host",
")",
":",
"host",
"=",
"host",
".",
"lower",
"(",
")",
"if",
"not",
"host_validation_re",
".",
"match",
"(",
"host",
")",
":",
"return",
"''",
",",
"''",
"if",
"host",
"[",
"-",
"1",
"]",
"==",
"']'",
":",
... | [
573,
0
] | [
592,
23
] | python | en | ['en', 'error', 'th'] | False |
validate_host | (host, allowed_hosts) |
Validate the given host for this site.
Check that the host looks valid and matches a host or host pattern in the
given list of ``allowed_hosts``. Any pattern beginning with a period
matches a domain and all its subdomains (e.g. ``.example.com`` matches
``example.com`` and any subdomain), ``*`` mat... |
Validate the given host for this site. | def validate_host(host, allowed_hosts):
"""
Validate the given host for this site.
Check that the host looks valid and matches a host or host pattern in the
given list of ``allowed_hosts``. Any pattern beginning with a period
matches a domain and all its subdomains (e.g. ``.example.com`` matches
... | [
"def",
"validate_host",
"(",
"host",
",",
"allowed_hosts",
")",
":",
"return",
"any",
"(",
"pattern",
"==",
"'*'",
"or",
"is_same_domain",
"(",
"host",
",",
"pattern",
")",
"for",
"pattern",
"in",
"allowed_hosts",
")"
] | [
595,
0
] | [
610,
92
] | python | en | ['en', 'error', 'th'] | False |
HttpRequest._set_content_type_params | (self, meta) | Set content_type, content_params, and encoding. | Set content_type, content_params, and encoding. | def _set_content_type_params(self, meta):
"""Set content_type, content_params, and encoding."""
self.content_type, self.content_params = cgi.parse_header(meta.get('CONTENT_TYPE', ''))
if 'charset' in self.content_params:
try:
codecs.lookup(self.content_params['charset... | [
"def",
"_set_content_type_params",
"(",
"self",
",",
"meta",
")",
":",
"self",
".",
"content_type",
",",
"self",
".",
"content_params",
"=",
"cgi",
".",
"parse_header",
"(",
"meta",
".",
"get",
"(",
"'CONTENT_TYPE'",
",",
"''",
")",
")",
"if",
"'charset'",... | [
73,
4
] | [
82,
62
] | python | en | ['en', 'en', 'en'] | True |
HttpRequest._get_raw_host | (self) |
Return the HTTP host using the environment or request headers. Skip
allowed hosts protection, so may return an insecure host.
|
Return the HTTP host using the environment or request headers. Skip
allowed hosts protection, so may return an insecure host.
| def _get_raw_host(self):
"""
Return the HTTP host using the environment or request headers. Skip
allowed hosts protection, so may return an insecure host.
"""
# We try three options, in order of decreasing preference.
if settings.USE_X_FORWARDED_HOST and (
... | [
"def",
"_get_raw_host",
"(",
"self",
")",
":",
"# We try three options, in order of decreasing preference.",
"if",
"settings",
".",
"USE_X_FORWARDED_HOST",
"and",
"(",
"'HTTP_X_FORWARDED_HOST'",
"in",
"self",
".",
"META",
")",
":",
"host",
"=",
"self",
".",
"META",
... | [
84,
4
] | [
101,
19
] | python | en | ['en', 'error', 'th'] | False |
HttpRequest.get_host | (self) | Return the HTTP host using the environment or request headers. | Return the HTTP host using the environment or request headers. | def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
... | [
"def",
"get_host",
"(",
"self",
")",
":",
"host",
"=",
"self",
".",
"_get_raw_host",
"(",
")",
"# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.",
"allowed_hosts",
"=",
"settings",
".",
"ALLOWED_HOSTS",
"if",
"settings",
".",
"DEBUG",
"and",
"no... | [
103,
4
] | [
121,
37
] | python | en | ['en', 'en', 'en'] | True |
HttpRequest.get_port | (self) | Return the port number for the request as a string. | Return the port number for the request as a string. | def get_port(self):
"""Return the port number for the request as a string."""
if settings.USE_X_FORWARDED_PORT and 'HTTP_X_FORWARDED_PORT' in self.META:
port = self.META['HTTP_X_FORWARDED_PORT']
else:
port = self.META['SERVER_PORT']
return str(port) | [
"def",
"get_port",
"(",
"self",
")",
":",
"if",
"settings",
".",
"USE_X_FORWARDED_PORT",
"and",
"'HTTP_X_FORWARDED_PORT'",
"in",
"self",
".",
"META",
":",
"port",
"=",
"self",
".",
"META",
"[",
"'HTTP_X_FORWARDED_PORT'",
"]",
"else",
":",
"port",
"=",
"self"... | [
123,
4
] | [
129,
24
] | python | en | ['en', 'en', 'en'] | True |
HttpRequest.get_signed_cookie | (self, key, default=RAISE_ERROR, salt='', max_age=None) |
Attempt to return a signed cookie. If the signature fails or the
cookie has expired, raise an exception, unless the `default` argument
is provided, in which case return that value.
|
Attempt to return a signed cookie. If the signature fails or the
cookie has expired, raise an exception, unless the `default` argument
is provided, in which case return that value.
| def get_signed_cookie(self, key, default=RAISE_ERROR, salt='', max_age=None):
"""
Attempt to return a signed cookie. If the signature fails or the
cookie has expired, raise an exception, unless the `default` argument
is provided, in which case return that value.
"""
try:... | [
"def",
"get_signed_cookie",
"(",
"self",
",",
"key",
",",
"default",
"=",
"RAISE_ERROR",
",",
"salt",
"=",
"''",
",",
"max_age",
"=",
"None",
")",
":",
"try",
":",
"cookie_value",
"=",
"self",
".",
"COOKIES",
"[",
"key",
"]",
"except",
"KeyError",
":",... | [
146,
4
] | [
167,
20
] | python | en | ['en', 'error', 'th'] | False |
HttpRequest.get_raw_uri | (self) |
Return an absolute URI from variables available in this request. Skip
allowed hosts protection, so may return insecure URI.
|
Return an absolute URI from variables available in this request. Skip
allowed hosts protection, so may return insecure URI.
| def get_raw_uri(self):
"""
Return an absolute URI from variables available in this request. Skip
allowed hosts protection, so may return insecure URI.
"""
return '{scheme}://{host}{path}'.format(
scheme=self.scheme,
host=self._get_raw_host(),
p... | [
"def",
"get_raw_uri",
"(",
"self",
")",
":",
"return",
"'{scheme}://{host}{path}'",
".",
"format",
"(",
"scheme",
"=",
"self",
".",
"scheme",
",",
"host",
"=",
"self",
".",
"_get_raw_host",
"(",
")",
",",
"path",
"=",
"self",
".",
"get_full_path",
"(",
"... | [
169,
4
] | [
178,
9
] | python | en | ['en', 'error', 'th'] | False |
HttpRequest.build_absolute_uri | (self, location=None) |
Build an absolute URI from the location and the variables available in
this request. If no ``location`` is specified, build the absolute URI
using request.get_full_path(). If the location is absolute, convert it
to an RFC 3987 compliant URI and return it. If location is relative or
... |
Build an absolute URI from the location and the variables available in
this request. If no ``location`` is specified, build the absolute URI
using request.get_full_path(). If the location is absolute, convert it
to an RFC 3987 compliant URI and return it. If location is relative or
... | def build_absolute_uri(self, location=None):
"""
Build an absolute URI from the location and the variables available in
this request. If no ``location`` is specified, build the absolute URI
using request.get_full_path(). If the location is absolute, convert it
to an RFC 3987 comp... | [
"def",
"build_absolute_uri",
"(",
"self",
",",
"location",
"=",
"None",
")",
":",
"if",
"location",
"is",
"None",
":",
"# Make it an absolute url (but schemeless and domainless) for the",
"# edge case that the path starts with '//'.",
"location",
"=",
"'//%s'",
"%",
"self",... | [
180,
4
] | [
211,
35
] | python | en | ['en', 'error', 'th'] | False |
HttpRequest._get_scheme | (self) |
Hook for subclasses like WSGIRequest to implement. Return 'http' by
default.
|
Hook for subclasses like WSGIRequest to implement. Return 'http' by
default.
| def _get_scheme(self):
"""
Hook for subclasses like WSGIRequest to implement. Return 'http' by
default.
"""
return 'http' | [
"def",
"_get_scheme",
"(",
"self",
")",
":",
"return",
"'http'"
] | [
217,
4
] | [
222,
21
] | python | en | ['en', 'error', 'th'] | False |
HttpRequest.encoding | (self, val) |
Set the encoding used for GET/POST accesses. If the GET or POST
dictionary has already been created, remove and recreate it on the
next access (so that it is decoded correctly).
|
Set the encoding used for GET/POST accesses. If the GET or POST
dictionary has already been created, remove and recreate it on the
next access (so that it is decoded correctly).
| def encoding(self, val):
"""
Set the encoding used for GET/POST accesses. If the GET or POST
dictionary has already been created, remove and recreate it on the
next access (so that it is decoded correctly).
"""
self._encoding = val
if hasattr(self, 'GET'):
... | [
"def",
"encoding",
"(",
"self",
",",
"val",
")",
":",
"self",
".",
"_encoding",
"=",
"val",
"if",
"hasattr",
"(",
"self",
",",
"'GET'",
")",
":",
"del",
"self",
".",
"GET",
"if",
"hasattr",
"(",
"self",
",",
"'_post'",
")",
":",
"del",
"self",
".... | [
249,
4
] | [
259,
26
] | python | en | ['en', 'error', 'th'] | False |
HttpRequest.parse_file_upload | (self, META, post_data) | Return a tuple of (POST QueryDict, FILES MultiValueDict). | Return a tuple of (POST QueryDict, FILES MultiValueDict). | def parse_file_upload(self, META, post_data):
"""Return a tuple of (POST QueryDict, FILES MultiValueDict)."""
self.upload_handlers = ImmutableList(
self.upload_handlers,
warning="You cannot alter upload handlers after the upload has been processed."
)
parser = Mul... | [
"def",
"parse_file_upload",
"(",
"self",
",",
"META",
",",
"post_data",
")",
":",
"self",
".",
"upload_handlers",
"=",
"ImmutableList",
"(",
"self",
".",
"upload_handlers",
",",
"warning",
"=",
"\"You cannot alter upload handlers after the upload has been processed.\"",
... | [
278,
4
] | [
285,
29
] | python | en | ['en', 'la', 'en'] | True |
HttpRequest._load_post_and_files | (self) | Populate self._post and self._files if the content-type is a form type | Populate self._post and self._files if the content-type is a form type | def _load_post_and_files(self):
"""Populate self._post and self._files if the content-type is a form type"""
if self.method != 'POST':
self._post, self._files = QueryDict(encoding=self._encoding), MultiValueDict()
return
if self._read_started and not hasattr(self, '_body'... | [
"def",
"_load_post_and_files",
"(",
"self",
")",
":",
"if",
"self",
".",
"method",
"!=",
"'POST'",
":",
"self",
".",
"_post",
",",
"self",
".",
"_files",
"=",
"QueryDict",
"(",
"encoding",
"=",
"self",
".",
"_encoding",
")",
",",
"MultiValueDict",
"(",
... | [
309,
4
] | [
336,
90
] | python | en | ['en', 'en', 'en'] | True |
HttpHeaders.__getitem__ | (self, key) | Allow header lookup using underscores in place of hyphens. | Allow header lookup using underscores in place of hyphens. | def __getitem__(self, key):
"""Allow header lookup using underscores in place of hyphens."""
return super().__getitem__(key.replace('_', '-')) | [
"def",
"__getitem__",
"(",
"self",
",",
"key",
")",
":",
"return",
"super",
"(",
")",
".",
"__getitem__",
"(",
"key",
".",
"replace",
"(",
"'_'",
",",
"'-'",
")",
")"
] | [
385,
4
] | [
387,
57
] | python | en | ['en', 'en', 'en'] | True |
QueryDict.fromkeys | (cls, iterable, value='', mutable=False, encoding=None) |
Return a new QueryDict with keys (may be repeated) from an iterable and
values from value.
|
Return a new QueryDict with keys (may be repeated) from an iterable and
values from value.
| def fromkeys(cls, iterable, value='', mutable=False, encoding=None):
"""
Return a new QueryDict with keys (may be repeated) from an iterable and
values from value.
"""
q = cls('', mutable=True, encoding=encoding)
for key in iterable:
q.appendlist(key, value)
... | [
"def",
"fromkeys",
"(",
"cls",
",",
"iterable",
",",
"value",
"=",
"''",
",",
"mutable",
"=",
"False",
",",
"encoding",
"=",
"None",
")",
":",
"q",
"=",
"cls",
"(",
"''",
",",
"mutable",
"=",
"True",
",",
"encoding",
"=",
"encoding",
")",
"for",
... | [
439,
4
] | [
449,
16
] | python | en | ['en', 'error', 'th'] | False |
QueryDict.copy | (self) | Return a mutable copy of this object. | Return a mutable copy of this object. | def copy(self):
"""Return a mutable copy of this object."""
return self.__deepcopy__({}) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__deepcopy__",
"(",
"{",
"}",
")"
] | [
522,
4
] | [
524,
36
] | python | en | ['en', 'en', 'en'] | True |
QueryDict.urlencode | (self, safe=None) |
Return an encoded string of all query string arguments.
`safe` specifies characters which don't require quoting, for example::
>>> q = QueryDict(mutable=True)
>>> q['next'] = '/a&b/'
>>> q.urlencode()
'next=%2Fa%26b%2F'
>>> q.urlencode(safe=... |
Return an encoded string of all query string arguments. | def urlencode(self, safe=None):
"""
Return an encoded string of all query string arguments.
`safe` specifies characters which don't require quoting, for example::
>>> q = QueryDict(mutable=True)
>>> q['next'] = '/a&b/'
>>> q.urlencode()
'next=%2F... | [
"def",
"urlencode",
"(",
"self",
",",
"safe",
"=",
"None",
")",
":",
"output",
"=",
"[",
"]",
"if",
"safe",
":",
"safe",
"=",
"safe",
".",
"encode",
"(",
"self",
".",
"encoding",
")",
"def",
"encode",
"(",
"k",
",",
"v",
")",
":",
"return",
"'%... | [
526,
4
] | [
553,
31
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteCreation.sql_indexes_for_field | (self, model, f, style) | Return any spatial index creation SQL for the field. | Return any spatial index creation SQL for the field. | def sql_indexes_for_field(self, model, f, style):
"Return any spatial index creation SQL for the field."
from django.contrib.gis.db.models.fields import GeometryField
output = super(SpatiaLiteCreation, self).sql_indexes_for_field(model, f, style)
if isinstance(f, GeometryField):
... | [
"def",
"sql_indexes_for_field",
"(",
"self",
",",
"model",
",",
"f",
",",
"style",
")",
":",
"from",
"django",
".",
"contrib",
".",
"gis",
".",
"db",
".",
"models",
".",
"fields",
"import",
"GeometryField",
"output",
"=",
"super",
"(",
"SpatiaLiteCreation"... | [
5,
4
] | [
31,
21
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.