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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
FileList.global_include | (self, pattern) |
Include all files anywhere in the current directory that match the
pattern. This is very inefficient on large file trees.
|
Include all files anywhere in the current directory that match the
pattern. This is very inefficient on large file trees.
| def global_include(self, pattern):
"""
Include all files anywhere in the current directory that match the
pattern. This is very inefficient on large file trees.
"""
if self.allfiles is None:
self.findall()
match = translate_pattern(os.path.join('**', pattern))... | [
"def",
"global_include",
"(",
"self",
",",
"pattern",
")",
":",
"if",
"self",
".",
"allfiles",
"is",
"None",
":",
"self",
".",
"findall",
"(",
")",
"match",
"=",
"translate_pattern",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'**'",
",",
"pattern",
"... | [
443,
4
] | [
453,
26
] | python | en | ['en', 'error', 'th'] | False |
FileList.global_exclude | (self, pattern) |
Exclude all files anywhere that match the pattern.
|
Exclude all files anywhere that match the pattern.
| def global_exclude(self, pattern):
"""
Exclude all files anywhere that match the pattern.
"""
match = translate_pattern(os.path.join('**', pattern))
return self._remove_files(match.match) | [
"def",
"global_exclude",
"(",
"self",
",",
"pattern",
")",
":",
"match",
"=",
"translate_pattern",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'**'",
",",
"pattern",
")",
")",
"return",
"self",
".",
"_remove_files",
"(",
"match",
".",
"match",
")"
] | [
455,
4
] | [
460,
46
] | python | en | ['en', 'error', 'th'] | False |
FileList._repair | (self) |
Replace self.files with only safe paths
Because some owners of FileList manipulate the underlying
``files`` attribute directly, this method must be called to
repair those paths.
|
Replace self.files with only safe paths | def _repair(self):
"""
Replace self.files with only safe paths
Because some owners of FileList manipulate the underlying
``files`` attribute directly, this method must be called to
repair those paths.
"""
self.files = list(filter(self._safe_path, self.files)) | [
"def",
"_repair",
"(",
"self",
")",
":",
"self",
".",
"files",
"=",
"list",
"(",
"filter",
"(",
"self",
".",
"_safe_path",
",",
"self",
".",
"files",
")",
")"
] | [
473,
4
] | [
481,
62
] | python | en | ['en', 'error', 'th'] | False |
manifest_maker.write_manifest | (self) |
Write the file list in 'self.filelist' to the manifest file
named by 'self.manifest'.
|
Write the file list in 'self.filelist' to the manifest file
named by 'self.manifest'.
| def write_manifest(self):
"""
Write the file list in 'self.filelist' to the manifest file
named by 'self.manifest'.
"""
self.filelist._repair()
# Now _repairs should encodability, but not unicode
files = [self._manifest_normalize(f) for f in self.filelist.files]
... | [
"def",
"write_manifest",
"(",
"self",
")",
":",
"self",
".",
"filelist",
".",
"_repair",
"(",
")",
"# Now _repairs should encodability, but not unicode",
"files",
"=",
"[",
"self",
".",
"_manifest_normalize",
"(",
"f",
")",
"for",
"f",
"in",
"self",
".",
"file... | [
535,
4
] | [
545,
61
] | python | en | ['en', 'error', 'th'] | False |
manifest_maker._should_suppress_warning | (msg) |
suppress missing-file warnings from sdist
|
suppress missing-file warnings from sdist
| def _should_suppress_warning(msg):
"""
suppress missing-file warnings from sdist
"""
return re.match(r"standard file .*not found", msg) | [
"def",
"_should_suppress_warning",
"(",
"msg",
")",
":",
"return",
"re",
".",
"match",
"(",
"r\"standard file .*not found\"",
",",
"msg",
")"
] | [
552,
4
] | [
556,
58
] | python | en | ['en', 'error', 'th'] | False |
repackage_hidden | (h) | Wraps hidden states in new Variables, to detach them from their history. | Wraps hidden states in new Variables, to detach them from their history. | def repackage_hidden(h):
"""Wraps hidden states in new Variables, to detach them from their history."""
if type(h) == Variable:
return Variable(h.data)
else:
return tuple(repackage_hidden(v) for v in h) | [
"def",
"repackage_hidden",
"(",
"h",
")",
":",
"if",
"type",
"(",
"h",
")",
"==",
"Variable",
":",
"return",
"Variable",
"(",
"h",
".",
"data",
")",
"else",
":",
"return",
"tuple",
"(",
"repackage_hidden",
"(",
"v",
")",
"for",
"v",
"in",
"h",
")"
... | [
161,
0
] | [
166,
52
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClientMeta.get_transport_class | (
cls, label: str = None,
) | Return an appropriate transport class.
Args:
label: The name of the desired transport. If none is
provided, then the first transport in the registry is used.
Returns:
The transport class to use.
| Return an appropriate transport class. | def get_transport_class(
cls, label: str = None,
) -> Type[DashboardsServiceTransport]:
"""Return an appropriate transport class.
Args:
label: The name of the desired transport. If none is
provided, then the first transport in the registry is used.
Retur... | [
"def",
"get_transport_class",
"(",
"cls",
",",
"label",
":",
"str",
"=",
"None",
",",
")",
"->",
"Type",
"[",
"DashboardsServiceTransport",
"]",
":",
"# If a specific transport is requested, return that one.",
"if",
"label",
":",
"return",
"cls",
".",
"_transport_re... | [
56,
4
] | [
74,
59
] | python | en | ['en', 'lb', 'en'] | True |
DashboardsServiceClient._get_default_mtls_endpoint | (api_endpoint) | Convert api endpoint to mTLS endpoint.
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
Args:
api_endpoint (Optional[str]): the api endpoint to convert.
Returns:
str: converted m... | Convert api endpoint to mTLS endpoint.
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
Args:
api_endpoint (Optional[str]): the api endpoint to convert.
Returns:
str: converted m... | def _get_default_mtls_endpoint(api_endpoint):
"""Convert api endpoint to mTLS endpoint.
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
Args:
api_endpoint (Optional[str]): the api endpoint ... | [
"def",
"_get_default_mtls_endpoint",
"(",
"api_endpoint",
")",
":",
"if",
"not",
"api_endpoint",
":",
"return",
"api_endpoint",
"mtls_endpoint_re",
"=",
"re",
".",
"compile",
"(",
"r\"(?P<name>[^.]+)(?P<mtls>\\.mtls)?(?P<sandbox>\\.sandbox)?(?P<googledomain>\\.googleapis\\.com)?\... | [
83,
4
] | [
109,
78
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.from_service_account_file | (cls, filename: str, *args, **kwargs) | Creates an instance of this client using the provided credentials
file.
Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the con... | Creates an instance of this client using the provided credentials
file. | def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
file.
Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to pass ... | [
"def",
"from_service_account_file",
"(",
"cls",
",",
"filename",
":",
"str",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"credentials",
"=",
"service_account",
".",
"Credentials",
".",
"from_service_account_file",
"(",
"filename",
")",
"kwargs",
"[",
... | [
117,
4
] | [
132,
35
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.dashboard_path | (project: str, dashboard: str,) | Return a fully-qualified dashboard string. | Return a fully-qualified dashboard string. | def dashboard_path(project: str, dashboard: str,) -> str:
"""Return a fully-qualified dashboard string."""
return "projects/{project}/dashboards/{dashboard}".format(
project=project, dashboard=dashboard,
) | [
"def",
"dashboard_path",
"(",
"project",
":",
"str",
",",
"dashboard",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"projects/{project}/dashboards/{dashboard}\"",
".",
"format",
"(",
"project",
"=",
"project",
",",
"dashboard",
"=",
"dashboard",
",",
")... | [
137,
4
] | [
141,
9
] | python | cy | ['pt', 'cy', 'en'] | False |
DashboardsServiceClient.parse_dashboard_path | (path: str) | Parse a dashboard path into its component segments. | Parse a dashboard path into its component segments. | def parse_dashboard_path(path: str) -> Dict[str, str]:
"""Parse a dashboard path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)/dashboards/(?P<dashboard>.+?)$", path)
return m.groupdict() if m else {} | [
"def",
"parse_dashboard_path",
"(",
"path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"^projects/(?P<project>.+?)/dashboards/(?P<dashboard>.+?)$\"",
",",
"path",
")",
"return",
"m",
".",
"groupdict",... | [
144,
4
] | [
147,
41
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.__init__ | (
self,
*,
credentials: credentials.Credentials = None,
transport: Union[str, DashboardsServiceTransport] = None,
client_options: ClientOptions = None,
) | Instantiate the dashboards service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the cl... | Instantiate the dashboards service client. | def __init__(
self,
*,
credentials: credentials.Credentials = None,
transport: Union[str, DashboardsServiceTransport] = None,
client_options: ClientOptions = None,
) -> None:
"""Instantiate the dashboards service client.
Args:
credentials (Optiona... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"credentials",
":",
"credentials",
".",
"Credentials",
"=",
"None",
",",
"transport",
":",
"Union",
"[",
"str",
",",
"DashboardsServiceTransport",
"]",
"=",
"None",
",",
"client_options",
":",
"ClientOptions",
"... | [
149,
4
] | [
237,
13
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.create_dashboard | (
self,
request: dashboards_service.CreateDashboardRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Creates a new custom dashboard.
This method requires the ``monitoring.dashboards.create``
permission on the specified project. For more information, see
`Google Cloud IAM <https://cloud.google.com/iam>`__.
Args:
request (:class:`~.dashboards_service.CreateDashboardReque... | r"""Creates a new custom dashboard. | def create_dashboard(
self,
request: dashboards_service.CreateDashboardRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
r"""Creates a new custom dashbo... | [
"def",
"create_dashboard",
"(",
"self",
",",
"request",
":",
"dashboards_service",
".",
"CreateDashboardRequest",
"=",
"None",
",",
"*",
",",
"retry",
":",
"retries",
".",
"Retry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"timeout",
":",
"float",... | [
239,
4
] | [
289,
23
] | python | cy | ['pt', 'cy', 'en'] | False |
DashboardsServiceClient.list_dashboards | (
self,
request: dashboards_service.ListDashboardsRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Lists the existing dashboards.
This method requires the ``monitoring.dashboards.list``
permission on the specified project. For more information, see
`Google Cloud IAM <https://cloud.google.com/iam>`__.
Args:
request (:class:`~.dashboards_service.ListDashboardsRequest`)... | r"""Lists the existing dashboards. | def list_dashboards(
self,
request: dashboards_service.ListDashboardsRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDashboardsPager:
r"""Lists the existing das... | [
"def",
"list_dashboards",
"(",
"self",
",",
"request",
":",
"dashboards_service",
".",
"ListDashboardsRequest",
"=",
"None",
",",
"*",
",",
"retry",
":",
"retries",
".",
"Retry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"timeout",
":",
"float",
... | [
291,
4
] | [
347,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.get_dashboard | (
self,
request: dashboards_service.GetDashboardRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Fetches a specific dashboard.
This method requires the ``monitoring.dashboards.get``
permission on the specified dashboard. For more information, see
`Google Cloud IAM <https://cloud.google.com/iam>`__.
Args:
request (:class:`~.dashboards_service.GetDashboardRequest`):
... | r"""Fetches a specific dashboard. | def get_dashboard(
self,
request: dashboards_service.GetDashboardRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
r"""Fetches a specific dashboard.
... | [
"def",
"get_dashboard",
"(",
"self",
",",
"request",
":",
"dashboards_service",
".",
"GetDashboardRequest",
"=",
"None",
",",
"*",
",",
"retry",
":",
"retries",
".",
"Retry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"timeout",
":",
"float",
"="... | [
349,
4
] | [
399,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceClient.delete_dashboard | (
self,
request: dashboards_service.DeleteDashboardRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Deletes an existing custom dashboard.
This method requires the ``monitoring.dashboards.delete``
permission on the specified dashboard. For more information, see
`Google Cloud IAM <https://cloud.google.com/iam>`__.
Args:
request (:class:`~.dashboards_service.DeleteDashbo... | r"""Deletes an existing custom dashboard. | def delete_dashboard(
self,
request: dashboards_service.DeleteDashboardRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes an existing custom dashboard.
... | [
"def",
"delete_dashboard",
"(",
"self",
",",
"request",
":",
"dashboards_service",
".",
"DeleteDashboardRequest",
"=",
"None",
",",
"*",
",",
"retry",
":",
"retries",
".",
"Retry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"timeout",
":",
"float",... | [
401,
4
] | [
442,
9
] | python | en | ['en', 'cy', 'en'] | True |
DashboardsServiceClient.update_dashboard | (
self,
request: dashboards_service.UpdateDashboardRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) | r"""Replaces an existing custom dashboard with a new definition.
This method requires the ``monitoring.dashboards.update``
permission on the specified dashboard. For more information, see
`Google Cloud IAM <https://cloud.google.com/iam>`__.
Args:
request (:class:`~.dashboar... | r"""Replaces an existing custom dashboard with a new definition. | def update_dashboard(
self,
request: dashboards_service.UpdateDashboardRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> dashboard.Dashboard:
r"""Replaces an existing custom... | [
"def",
"update_dashboard",
"(",
"self",
",",
"request",
":",
"dashboards_service",
".",
"UpdateDashboardRequest",
"=",
"None",
",",
"*",
",",
"retry",
":",
"retries",
".",
"Retry",
"=",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"timeout",
":",
"float",... | [
444,
4
] | [
496,
23
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceTransport.__init__ | (
self,
*,
host: str = "monitoring.googleapis.com",
credentials: credentials.Credentials = None,
credentials_file: typing.Optional[str] = None,
scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
quota_project_id: typing.Optional[str] = None,
**kw... | Instantiate the transport.
Args:
host (Optional[str]): The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service;... | Instantiate the transport. | def __init__(
self,
*,
host: str = "monitoring.googleapis.com",
credentials: credentials.Credentials = None,
credentials_file: typing.Optional[str] = None,
scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
quota_project_id: typing.Optional[str] = None,
... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"host",
":",
"str",
"=",
"\"monitoring.googleapis.com\"",
",",
"credentials",
":",
"credentials",
".",
"Credentials",
"=",
"None",
",",
"credentials_file",
":",
"typing",
".",
"Optional",
"[",
"str",
"]",
"=",
... | [
51,
4
] | [
103,
37
] | python | en | ['en', 'en', 'en'] | True |
set_script_prefix | (prefix) |
Set the script prefix for the current thread.
|
Set the script prefix for the current thread.
| def set_script_prefix(prefix):
"""
Set the script prefix for the current thread.
"""
if not prefix.endswith('/'):
prefix += '/'
_prefixes.value = prefix | [
"def",
"set_script_prefix",
"(",
"prefix",
")",
":",
"if",
"not",
"prefix",
".",
"endswith",
"(",
"'/'",
")",
":",
"prefix",
"+=",
"'/'",
"_prefixes",
".",
"value",
"=",
"prefix"
] | [
97,
0
] | [
103,
28
] | python | en | ['en', 'error', 'th'] | False |
get_script_prefix | () |
Return the currently active script prefix. Useful for client code that
wishes to construct their own URLs manually (although accessing the request
instance is normally going to be a lot cleaner).
|
Return the currently active script prefix. Useful for client code that
wishes to construct their own URLs manually (although accessing the request
instance is normally going to be a lot cleaner).
| def get_script_prefix():
"""
Return the currently active script prefix. Useful for client code that
wishes to construct their own URLs manually (although accessing the request
instance is normally going to be a lot cleaner).
"""
return getattr(_prefixes, "value", '/') | [
"def",
"get_script_prefix",
"(",
")",
":",
"return",
"getattr",
"(",
"_prefixes",
",",
"\"value\"",
",",
"'/'",
")"
] | [
106,
0
] | [
112,
43
] | python | en | ['en', 'error', 'th'] | False |
clear_script_prefix | () |
Unset the script prefix for the current thread.
|
Unset the script prefix for the current thread.
| def clear_script_prefix():
"""
Unset the script prefix for the current thread.
"""
try:
del _prefixes.value
except AttributeError:
pass | [
"def",
"clear_script_prefix",
"(",
")",
":",
"try",
":",
"del",
"_prefixes",
".",
"value",
"except",
"AttributeError",
":",
"pass"
] | [
115,
0
] | [
122,
12
] | python | en | ['en', 'error', 'th'] | False |
set_urlconf | (urlconf_name) |
Set the URLconf for the current thread (overriding the default one in
settings). If urlconf_name is None, revert back to the default.
|
Set the URLconf for the current thread (overriding the default one in
settings). If urlconf_name is None, revert back to the default.
| def set_urlconf(urlconf_name):
"""
Set the URLconf for the current thread (overriding the default one in
settings). If urlconf_name is None, revert back to the default.
"""
if urlconf_name:
_urlconfs.value = urlconf_name
else:
if hasattr(_urlconfs, "value"):
del _urlc... | [
"def",
"set_urlconf",
"(",
"urlconf_name",
")",
":",
"if",
"urlconf_name",
":",
"_urlconfs",
".",
"value",
"=",
"urlconf_name",
"else",
":",
"if",
"hasattr",
"(",
"_urlconfs",
",",
"\"value\"",
")",
":",
"del",
"_urlconfs",
".",
"value"
] | [
125,
0
] | [
134,
31
] | python | en | ['en', 'error', 'th'] | False |
get_urlconf | (default=None) |
Return the root URLconf to use for the current thread if it has been
changed from the default one.
|
Return the root URLconf to use for the current thread if it has been
changed from the default one.
| def get_urlconf(default=None):
"""
Return the root URLconf to use for the current thread if it has been
changed from the default one.
"""
return getattr(_urlconfs, "value", default) | [
"def",
"get_urlconf",
"(",
"default",
"=",
"None",
")",
":",
"return",
"getattr",
"(",
"_urlconfs",
",",
"\"value\"",
",",
"default",
")"
] | [
137,
0
] | [
142,
47
] | python | en | ['en', 'error', 'th'] | False |
is_valid_path | (path, urlconf=None) |
Return the ResolverMatch if the given path resolves against the default URL
resolver, False otherwise. This is a convenience method to make working
with "is this a match?" cases easier, avoiding try...except blocks.
|
Return the ResolverMatch if the given path resolves against the default URL
resolver, False otherwise. This is a convenience method to make working
with "is this a match?" cases easier, avoiding try...except blocks.
| def is_valid_path(path, urlconf=None):
"""
Return the ResolverMatch if the given path resolves against the default URL
resolver, False otherwise. This is a convenience method to make working
with "is this a match?" cases easier, avoiding try...except blocks.
"""
try:
return resolve(path,... | [
"def",
"is_valid_path",
"(",
"path",
",",
"urlconf",
"=",
"None",
")",
":",
"try",
":",
"return",
"resolve",
"(",
"path",
",",
"urlconf",
")",
"except",
"Resolver404",
":",
"return",
"False"
] | [
145,
0
] | [
154,
20
] | python | en | ['en', 'error', 'th'] | False |
translate_url | (url, lang_code) |
Given a URL (absolute or relative), try to get its translated version in
the `lang_code` language (either by i18n_patterns or by translated regex).
Return the original URL if no translated version is found.
|
Given a URL (absolute or relative), try to get its translated version in
the `lang_code` language (either by i18n_patterns or by translated regex).
Return the original URL if no translated version is found.
| def translate_url(url, lang_code):
"""
Given a URL (absolute or relative), try to get its translated version in
the `lang_code` language (either by i18n_patterns or by translated regex).
Return the original URL if no translated version is found.
"""
parsed = urlsplit(url)
try:
# URL ... | [
"def",
"translate_url",
"(",
"url",
",",
"lang_code",
")",
":",
"parsed",
"=",
"urlsplit",
"(",
"url",
")",
"try",
":",
"# URL may be encoded.",
"match",
"=",
"resolve",
"(",
"unquote",
"(",
"parsed",
".",
"path",
")",
")",
"except",
"Resolver404",
":",
... | [
157,
0
] | [
178,
14
] | python | en | ['en', 'error', 'th'] | False |
quantize_float | (f, q) | Converts a float to closest non-zero int divisible by q. | Converts a float to closest non-zero int divisible by q. | def quantize_float(f, q):
"""Converts a float to closest non-zero int divisible by q."""
return int(round(f / q) * q) | [
"def",
"quantize_float",
"(",
"f",
",",
"q",
")",
":",
"return",
"int",
"(",
"round",
"(",
"f",
"/",
"q",
")",
"*",
"q",
")"
] | [
34,
0
] | [
36,
32
] | python | en | ['en', 'en', 'it'] | True |
adjust_ws_gs_comp | (ws, bms, gs) | Adjusts the compatibility of widths and groups. | Adjusts the compatibility of widths and groups. | def adjust_ws_gs_comp(ws, bms, gs):
"""Adjusts the compatibility of widths and groups."""
ws_bot = [int(w * b) for w, b in zip(ws, bms)]
gs = [min(g, w_bot) for g, w_bot in zip(gs, ws_bot)]
ws_bot = [quantize_float(w_bot, g) for w_bot, g in zip(ws_bot, gs)]
ws = [int(w_bot / b) for w_bot, b in zip(w... | [
"def",
"adjust_ws_gs_comp",
"(",
"ws",
",",
"bms",
",",
"gs",
")",
":",
"ws_bot",
"=",
"[",
"int",
"(",
"w",
"*",
"b",
")",
"for",
"w",
",",
"b",
"in",
"zip",
"(",
"ws",
",",
"bms",
")",
"]",
"gs",
"=",
"[",
"min",
"(",
"g",
",",
"w_bot",
... | [
39,
0
] | [
45,
17
] | python | en | ['en', 'en', 'en'] | True |
get_stages_from_blocks | (ws, rs) | Gets ws/ds of network at each stage from per block values. | Gets ws/ds of network at each stage from per block values. | def get_stages_from_blocks(ws, rs):
"""Gets ws/ds of network at each stage from per block values."""
ts = [
w != wp or r != rp
for w, wp, r, rp in zip(ws + [0], [0] + ws, rs + [0], [0] + rs)
]
s_ws = [w for w, t in zip(ws, ts[:-1]) if t]
s_ds = np.diff([d for d, t in zip(range(len(ts... | [
"def",
"get_stages_from_blocks",
"(",
"ws",
",",
"rs",
")",
":",
"ts",
"=",
"[",
"w",
"!=",
"wp",
"or",
"r",
"!=",
"rp",
"for",
"w",
",",
"wp",
",",
"r",
",",
"rp",
"in",
"zip",
"(",
"ws",
"+",
"[",
"0",
"]",
",",
"[",
"0",
"]",
"+",
"ws"... | [
48,
0
] | [
56,
21
] | python | en | ['en', 'en', 'en'] | True |
generate_regnet | (w_a, w_0, w_m, d, q=8) | Generates per block ws from RegNet parameters. | Generates per block ws from RegNet parameters. | def generate_regnet(w_a, w_0, w_m, d, q=8):
"""Generates per block ws from RegNet parameters."""
assert w_a >= 0 and w_0 > 0 and w_m > 1 and w_0 % q == 0
ws_cont = np.arange(d) * w_a + w_0
ks = np.round(np.log(ws_cont / w_0) / np.log(w_m))
ws = w_0 * np.power(w_m, ks)
ws = np.round(np.divide(ws,... | [
"def",
"generate_regnet",
"(",
"w_a",
",",
"w_0",
",",
"w_m",
",",
"d",
",",
"q",
"=",
"8",
")",
":",
"assert",
"w_a",
">=",
"0",
"and",
"w_0",
">",
"0",
"and",
"w_m",
">",
"1",
"and",
"w_0",
"%",
"q",
"==",
"0",
"ws_cont",
"=",
"np",
".",
... | [
59,
0
] | [
68,
45
] | python | en | ['en', 'id', 'it'] | False |
get_display_profile | (handle=None) |
(experimental) Fetches the profile for the current display device.
:returns: ``None`` if the profile is not known.
|
(experimental) Fetches the profile for the current display device. | def get_display_profile(handle=None):
"""
(experimental) Fetches the profile for the current display device.
:returns: ``None`` if the profile is not known.
"""
if sys.platform != "win32":
return None
from PIL import ImageWin
if isinstance(handle, ImageWin.HDC):
profile =... | [
"def",
"get_display_profile",
"(",
"handle",
"=",
"None",
")",
":",
"if",
"sys",
".",
"platform",
"!=",
"\"win32\"",
":",
"return",
"None",
"from",
"PIL",
"import",
"ImageWin",
"if",
"isinstance",
"(",
"handle",
",",
"ImageWin",
".",
"HDC",
")",
":",
"pr... | [
259,
0
] | [
277,
35
] | python | en | ['en', 'error', 'th'] | False |
profileToProfile | (
im,
inputProfile,
outputProfile,
renderingIntent=INTENT_PERCEPTUAL,
outputMode=None,
inPlace=False,
flags=0,
) |
(pyCMS) Applies an ICC transformation to a given image, mapping from
``inputProfile`` to ``outputProfile``.
If the input or output profiles specified are not valid filenames, a
:exc:`PyCMSError` will be raised. If ``inPlace`` is ``True`` and
``outputMode != im.mode``, a :exc:`PyCMSError` will be ... |
(pyCMS) Applies an ICC transformation to a given image, mapping from
``inputProfile`` to ``outputProfile``. | def profileToProfile(
im,
inputProfile,
outputProfile,
renderingIntent=INTENT_PERCEPTUAL,
outputMode=None,
inPlace=False,
flags=0,
):
"""
(pyCMS) Applies an ICC transformation to a given image, mapping from
``inputProfile`` to ``outputProfile``.
If the input or output profil... | [
"def",
"profileToProfile",
"(",
"im",
",",
"inputProfile",
",",
"outputProfile",
",",
"renderingIntent",
"=",
"INTENT_PERCEPTUAL",
",",
"outputMode",
"=",
"None",
",",
"inPlace",
"=",
"False",
",",
"flags",
"=",
"0",
",",
")",
":",
"if",
"outputMode",
"is",
... | [
293,
0
] | [
384,
16
] | python | en | ['en', 'error', 'th'] | False |
getOpenProfile | (profileFilename) |
(pyCMS) Opens an ICC profile file.
The PyCMSProfile object can be passed back into pyCMS for use in creating
transforms and such (as in ImageCms.buildTransformFromOpenProfiles()).
If ``profileFilename`` is not a valid filename for an ICC profile,
a :exc:`PyCMSError` will be raised.
:param pr... |
(pyCMS) Opens an ICC profile file. | def getOpenProfile(profileFilename):
"""
(pyCMS) Opens an ICC profile file.
The PyCMSProfile object can be passed back into pyCMS for use in creating
transforms and such (as in ImageCms.buildTransformFromOpenProfiles()).
If ``profileFilename`` is not a valid filename for an ICC profile,
a :exc... | [
"def",
"getOpenProfile",
"(",
"profileFilename",
")",
":",
"try",
":",
"return",
"ImageCmsProfile",
"(",
"profileFilename",
")",
"except",
"(",
"OSError",
",",
"TypeError",
",",
"ValueError",
")",
"as",
"v",
":",
"raise",
"PyCMSError",
"(",
"v",
")",
"from",... | [
387,
0
] | [
406,
34
] | python | en | ['en', 'error', 'th'] | False |
buildTransform | (
inputProfile,
outputProfile,
inMode,
outMode,
renderingIntent=INTENT_PERCEPTUAL,
flags=0,
) |
(pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the
``outputProfile``. Use applyTransform to apply the transform to a given
image.
If the input or output profiles specified are not valid filenames, a
:exc:`PyCMSError` will be raised. If an error occurs during creation
of t... |
(pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the
``outputProfile``. Use applyTransform to apply the transform to a given
image. | def buildTransform(
inputProfile,
outputProfile,
inMode,
outMode,
renderingIntent=INTENT_PERCEPTUAL,
flags=0,
):
"""
(pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the
``outputProfile``. Use applyTransform to apply the transform to a given
image.
If the... | [
"def",
"buildTransform",
"(",
"inputProfile",
",",
"outputProfile",
",",
"inMode",
",",
"outMode",
",",
"renderingIntent",
"=",
"INTENT_PERCEPTUAL",
",",
"flags",
"=",
"0",
",",
")",
":",
"if",
"not",
"isinstance",
"(",
"renderingIntent",
",",
"int",
")",
"o... | [
409,
0
] | [
487,
34
] | python | en | ['en', 'error', 'th'] | False |
buildProofTransform | (
inputProfile,
outputProfile,
proofProfile,
inMode,
outMode,
renderingIntent=INTENT_PERCEPTUAL,
proofRenderingIntent=INTENT_ABSOLUTE_COLORIMETRIC,
flags=FLAGS["SOFTPROOFING"],
) |
(pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the
``outputProfile``, but tries to simulate the result that would be
obtained on the ``proofProfile`` device.
If the input, output, or proof profiles specified are not valid
filenames, a :exc:`PyCMSError` will be raised.
If... |
(pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the
``outputProfile``, but tries to simulate the result that would be
obtained on the ``proofProfile`` device. | def buildProofTransform(
inputProfile,
outputProfile,
proofProfile,
inMode,
outMode,
renderingIntent=INTENT_PERCEPTUAL,
proofRenderingIntent=INTENT_ABSOLUTE_COLORIMETRIC,
flags=FLAGS["SOFTPROOFING"],
):
"""
(pyCMS) Builds an ICC transform mapping from the ``inputProfile`` to the
... | [
"def",
"buildProofTransform",
"(",
"inputProfile",
",",
"outputProfile",
",",
"proofProfile",
",",
"inMode",
",",
"outMode",
",",
"renderingIntent",
"=",
"INTENT_PERCEPTUAL",
",",
"proofRenderingIntent",
"=",
"INTENT_ABSOLUTE_COLORIMETRIC",
",",
"flags",
"=",
"FLAGS",
... | [
490,
0
] | [
598,
34
] | python | en | ['en', 'error', 'th'] | False |
applyTransform | (im, transform, inPlace=False) |
(pyCMS) Applies a transform to a given image.
If ``im.mode != transform.inMode``, a :exc:`PyCMSError` is raised.
If ``inPlace`` is ``True`` and ``transform.inMode != transform.outMode``, a
:exc:`PyCMSError` is raised.
If ``im.mode``, ``transform.inMode`` or ``transform.outMode`` is not
suppo... |
(pyCMS) Applies a transform to a given image. | def applyTransform(im, transform, inPlace=False):
"""
(pyCMS) Applies a transform to a given image.
If ``im.mode != transform.inMode``, a :exc:`PyCMSError` is raised.
If ``inPlace`` is ``True`` and ``transform.inMode != transform.outMode``, a
:exc:`PyCMSError` is raised.
If ``im.mode``, ``tra... | [
"def",
"applyTransform",
"(",
"im",
",",
"transform",
",",
"inPlace",
"=",
"False",
")",
":",
"try",
":",
"if",
"inPlace",
":",
"transform",
".",
"apply_in_place",
"(",
"im",
")",
"imOut",
"=",
"None",
"else",
":",
"imOut",
"=",
"transform",
".",
"appl... | [
605,
0
] | [
655,
16
] | python | en | ['en', 'error', 'th'] | False |
createProfile | (colorSpace, colorTemp=-1) |
(pyCMS) Creates a profile.
If colorSpace not in ``["LAB", "XYZ", "sRGB"]``,
a :exc:`PyCMSError` is raised.
If using LAB and ``colorTemp`` is not a positive integer,
a :exc:`PyCMSError` is raised.
If an error occurs while creating the profile,
a :exc:`PyCMSError` is raised.
Use this ... |
(pyCMS) Creates a profile. | def createProfile(colorSpace, colorTemp=-1):
"""
(pyCMS) Creates a profile.
If colorSpace not in ``["LAB", "XYZ", "sRGB"]``,
a :exc:`PyCMSError` is raised.
If using LAB and ``colorTemp`` is not a positive integer,
a :exc:`PyCMSError` is raised.
If an error occurs while creating the profil... | [
"def",
"createProfile",
"(",
"colorSpace",
",",
"colorTemp",
"=",
"-",
"1",
")",
":",
"if",
"colorSpace",
"not",
"in",
"[",
"\"LAB\"",
",",
"\"XYZ\"",
",",
"\"sRGB\"",
"]",
":",
"raise",
"PyCMSError",
"(",
"f\"Color space not supported for on-the-fly profile creat... | [
658,
0
] | [
704,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileName | (profile) |
(pyCMS) Gets the internal product name for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile,
a :exc:`PyCMSError` is raised If an error occurs while trying
to obtain the name tag, a :exc:`PyCMSError` is raised.
Use this function to obtain the INTERNAL nam... | def getProfileName(profile):
"""
(pyCMS) Gets the internal product name for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile,
a :exc:`PyCMSError` is raised If an error occurs while trying
to obtain the name tag, a :exc:`PyCMSError` is raised.
Use this... | [
"def",
"getProfileName",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"# do it in py... | [
707,
0
] | [
746,
34
] | python | en | ['en', 'error', 'th'] | False | |
getProfileInfo | (profile) |
(pyCMS) Gets the internal product information for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile,
a :exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the info tag,
a :exc:`PyCMSError` is raised.
Use this function to obtain the ... |
(pyCMS) Gets the internal product information for the given profile. | def getProfileInfo(profile):
"""
(pyCMS) Gets the internal product information for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile,
a :exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the info tag,
a :exc:`PyCMSError` is raised.
... | [
"def",
"getProfileInfo",
"(",
"profile",
")",
":",
"try",
":",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"# add an extra newline to preserve pyCMS compatibility",
"# Python, not... | [
749,
0
] | [
786,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileCopyright | (profile) |
(pyCMS) Gets the copyright for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the copyright tag,
a :exc:`PyCMSError` is raised.
Use this function to obtain the information st... |
(pyCMS) Gets the copyright for the given profile. | def getProfileCopyright(profile):
"""
(pyCMS) Gets the copyright for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the copyright tag,
a :exc:`PyCMSError` is raised.
Use t... | [
"def",
"getProfileCopyright",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"return",... | [
789,
0
] | [
814,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileManufacturer | (profile) |
(pyCMS) Gets the manufacturer for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the manufacturer tag, a
:exc:`PyCMSError` is raised.
Use this function to obtain the informat... |
(pyCMS) Gets the manufacturer for the given profile. | def getProfileManufacturer(profile):
"""
(pyCMS) Gets the manufacturer for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the manufacturer tag, a
:exc:`PyCMSError` is raised.
... | [
"def",
"getProfileManufacturer",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"retur... | [
817,
0
] | [
842,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileModel | (profile) |
(pyCMS) Gets the model for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the model tag,
a :exc:`PyCMSError` is raised.
Use this function to obtain the information stored in ... |
(pyCMS) Gets the model for the given profile. | def getProfileModel(profile):
"""
(pyCMS) Gets the model for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the model tag,
a :exc:`PyCMSError` is raised.
Use this function... | [
"def",
"getProfileModel",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"return",
"... | [
845,
0
] | [
871,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileDescription | (profile) |
(pyCMS) Gets the description for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the description tag,
a :exc:`PyCMSError` is raised.
Use this function to obtain the informatio... |
(pyCMS) Gets the description for the given profile. | def getProfileDescription(profile):
"""
(pyCMS) Gets the description for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the description tag,
a :exc:`PyCMSError` is raised.
... | [
"def",
"getProfileDescription",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"return... | [
874,
0
] | [
900,
34
] | python | en | ['en', 'error', 'th'] | False |
getDefaultIntent | (profile) |
(pyCMS) Gets the default intent name for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the default intent, a
:exc:`PyCMSError` is raised.
Use this function to determine the ... |
(pyCMS) Gets the default intent name for the given profile. | def getDefaultIntent(profile):
"""
(pyCMS) Gets the default intent name for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the default intent, a
:exc:`PyCMSError` is raised.
... | [
"def",
"getDefaultIntent",
"(",
"profile",
")",
":",
"try",
":",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"return",
"profile",
".",
"profile",
".",
"rendering_intent",
... | [
903,
0
] | [
939,
34
] | python | en | ['en', 'error', 'th'] | False |
isIntentSupported | (profile, intent, direction) |
(pyCMS) Checks if a given intent is supported.
Use this function to verify that you can use your desired
``intent`` with ``profile``, and that ``profile`` can be used for the
input/output/proof profile as you desire.
Some profiles are created specifically for one "direction", can cannot
be us... |
(pyCMS) Checks if a given intent is supported. | def isIntentSupported(profile, intent, direction):
"""
(pyCMS) Checks if a given intent is supported.
Use this function to verify that you can use your desired
``intent`` with ``profile``, and that ``profile`` can be used for the
input/output/proof profile as you desire.
Some profiles are crea... | [
"def",
"isIntentSupported",
"(",
"profile",
",",
"intent",
",",
"direction",
")",
":",
"try",
":",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"# FIXME: I get different resu... | [
942,
0
] | [
990,
34
] | python | en | ['en', 'error', 'th'] | False |
versions | () |
(pyCMS) Fetches versions.
|
(pyCMS) Fetches versions.
| def versions():
"""
(pyCMS) Fetches versions.
"""
return (VERSION, core.littlecms_version, sys.version.split()[0], Image.__version__) | [
"def",
"versions",
"(",
")",
":",
"return",
"(",
"VERSION",
",",
"core",
".",
"littlecms_version",
",",
"sys",
".",
"version",
".",
"split",
"(",
")",
"[",
"0",
"]",
",",
"Image",
".",
"__version__",
")"
] | [
993,
0
] | [
998,
87
] | python | en | ['en', 'error', 'th'] | False |
ImageCmsProfile.__init__ | (self, profile) |
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
|
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object | def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
"""
if isinstance(profile, str):
if sys.platform == "win32":
profile_bytes... | [
"def",
"__init__",
"(",
"self",
",",
"profile",
")",
":",
"if",
"isinstance",
"(",
"profile",
",",
"str",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"\"win32\"",
":",
"profile_bytes_path",
"=",
"profile",
".",
"encode",
"(",
")",
"try",
":",
"profil... | [
152,
4
] | [
175,
55
] | python | en | ['en', 'error', 'th'] | False |
ImageCmsProfile.tobytes | (self) |
Returns the profile in a format suitable for embedding in
saved images.
:returns: a bytes object containing the ICC profile.
|
Returns the profile in a format suitable for embedding in
saved images. | def tobytes(self):
"""
Returns the profile in a format suitable for embedding in
saved images.
:returns: a bytes object containing the ICC profile.
"""
return core.profile_tobytes(self.profile) | [
"def",
"tobytes",
"(",
"self",
")",
":",
"return",
"core",
".",
"profile_tobytes",
"(",
"self",
".",
"profile",
")"
] | [
187,
4
] | [
195,
49
] | python | en | ['en', 'error', 'th'] | False |
PhyreDataset.__init__ | (self,
tier,
task_ids,
task_indices,
is_solved,
actions,
simulator_cfg,
mode='train',
balance_classes=True,
hard_negatives=0.0,
init_clip_ratio_to_sim... |
Args:
task_indices: The integer indices into the simulator tasks (not the
actual task IDs used by the simulator).
hard_negatives (float): The ratio of times to find a hard negative
instead of a normal negative. Hard negatives are close to the
... |
Args:
task_indices: The integer indices into the simulator tasks (not the
actual task IDs used by the simulator).
hard_negatives (float): The ratio of times to find a hard negative
instead of a normal negative. Hard negatives are close to the
... | def __init__(self,
tier,
task_ids,
task_indices,
is_solved,
actions,
simulator_cfg,
mode='train',
balance_classes=True,
hard_negatives=0.0,
init_clip_... | [
"def",
"__init__",
"(",
"self",
",",
"tier",
",",
"task_ids",
",",
"task_indices",
",",
"is_solved",
",",
"actions",
",",
"simulator_cfg",
",",
"mode",
"=",
"'train'",
",",
"balance_classes",
"=",
"True",
",",
"hard_negatives",
"=",
"0.0",
",",
"init_clip_ra... | [
240,
4
] | [
294,
42
] | python | en | ['en', 'error', 'th'] | False |
PhyreDataset._train_indices_sampler | (self) | Returns a pair of IDs, balanced if asked for. | Returns a pair of IDs, balanced if asked for. | def _train_indices_sampler(self):
"""Returns a pair of IDs, balanced if asked for."""
# Pair so that if asked for balanced, it will return a postiive and
# negative, hence satisfying the constraint
assert self.init_frames_to_sim == 0, 'Not handled here'
indices = np.arange(len(se... | [
"def",
"_train_indices_sampler",
"(",
"self",
")",
":",
"# Pair so that if asked for balanced, it will return a postiive and",
"# negative, hence satisfying the constraint",
"assert",
"self",
".",
"init_frames_to_sim",
"==",
"0",
",",
"'Not handled here'",
"indices",
"=",
"np",
... | [
340,
4
] | [
370,
59
] | python | en | ['en', 'en', 'en'] | True |
PhyreDataset._test_indices_sampler | (self) | Just run in order of actions, need to eval all. | Just run in order of actions, need to eval all. | def _test_indices_sampler(self):
"""Just run in order of actions, need to eval all."""
indices = np.arange(len(self.task_indices))
assert self.shuffle_indices is False, 'No good reason shuffle for test'
worker_info = torch.utils.data.get_worker_info()
if worker_info is not None:
... | [
"def",
"_test_indices_sampler",
"(",
"self",
")",
":",
"indices",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"self",
".",
"task_indices",
")",
")",
"assert",
"self",
".",
"shuffle_indices",
"is",
"False",
",",
"'No good reason shuffle for test'",
"worker_info",
... | [
390,
4
] | [
404,
23
] | python | en | ['en', 'en', 'en'] | True |
mapping | (data_source, geom_name='geom', layer_key=0, multi_geom=False) |
Given a DataSource, generate a dictionary that may be used
for invoking the LayerMapping utility.
Keyword Arguments:
`geom_name` => The name of the geometry field to use for the model.
`layer_key` => The key for specifying which layer in the DataSource to use;
defaults to 0 (the first la... |
Given a DataSource, generate a dictionary that may be used
for invoking the LayerMapping utility. | def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
"""
Given a DataSource, generate a dictionary that may be used
for invoking the LayerMapping utility.
Keyword Arguments:
`geom_name` => The name of the geometry field to use for the model.
`layer_key` => The key for s... | [
"def",
"mapping",
"(",
"data_source",
",",
"geom_name",
"=",
"'geom'",
",",
"layer_key",
"=",
"0",
",",
"multi_geom",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"data_source",
",",
"str",
")",
":",
"# Instantiating the DataSource from the string.",
"data_s... | [
12,
0
] | [
47,
19
] | python | en | ['en', 'error', 'th'] | False |
ogrinspect | (*args, **kwargs) |
Given a data source (either a string or a DataSource object) and a string
model name this function will generate a GeoDjango model.
Usage:
>>> from django.contrib.gis.utils import ogrinspect
>>> ogrinspect('/path/to/shapefile.shp','NewModel')
...will print model definition to stout
or p... |
Given a data source (either a string or a DataSource object) and a string
model name this function will generate a GeoDjango model. | def ogrinspect(*args, **kwargs):
"""
Given a data source (either a string or a DataSource object) and a string
model name this function will generate a GeoDjango model.
Usage:
>>> from django.contrib.gis.utils import ogrinspect
>>> ogrinspect('/path/to/shapefile.shp','NewModel')
...will p... | [
"def",
"ogrinspect",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"_ogrinspect",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")"
] | [
50,
0
] | [
118,
50
] | python | en | ['en', 'error', 'th'] | False |
_ogrinspect | (data_source, model_name, geom_name='geom', layer_key=0, srid=None,
multi_geom=False, name_field=None, imports=True,
decimal=False, blank=False, null=False) |
Helper routine for `ogrinspect` that generates GeoDjango models corresponding
to the given data source. See the `ogrinspect` docstring for more details.
|
Helper routine for `ogrinspect` that generates GeoDjango models corresponding
to the given data source. See the `ogrinspect` docstring for more details.
| def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=None,
multi_geom=False, name_field=None, imports=True,
decimal=False, blank=False, null=False):
"""
Helper routine for `ogrinspect` that generates GeoDjango models corresponding
to the given data sou... | [
"def",
"_ogrinspect",
"(",
"data_source",
",",
"model_name",
",",
"geom_name",
"=",
"'geom'",
",",
"layer_key",
"=",
"0",
",",
"srid",
"=",
"None",
",",
"multi_geom",
"=",
"False",
",",
"name_field",
"=",
"None",
",",
"imports",
"=",
"True",
",",
"decima... | [
121,
0
] | [
236,
66
] | python | en | ['en', 'error', 'th'] | False |
new_date | (d) | Generate a safe date from a datetime.date object. | Generate a safe date from a datetime.date object. | def new_date(d):
"Generate a safe date from a datetime.date object."
return date(d.year, d.month, d.day) | [
"def",
"new_date",
"(",
"d",
")",
":",
"return",
"date",
"(",
"d",
".",
"year",
",",
"d",
".",
"month",
",",
"d",
".",
"day",
")"
] | [
40,
0
] | [
42,
39
] | python | en | ['en', 'en', 'en'] | True |
new_datetime | (d) |
Generate a safe datetime from a datetime.date or datetime.datetime object.
|
Generate a safe datetime from a datetime.date or datetime.datetime object.
| def new_datetime(d):
"""
Generate a safe datetime from a datetime.date or datetime.datetime object.
"""
kw = [d.year, d.month, d.day]
if isinstance(d, real_datetime):
kw.extend([d.hour, d.minute, d.second, d.microsecond, d.tzinfo])
return datetime(*kw) | [
"def",
"new_datetime",
"(",
"d",
")",
":",
"kw",
"=",
"[",
"d",
".",
"year",
",",
"d",
".",
"month",
",",
"d",
".",
"day",
"]",
"if",
"isinstance",
"(",
"d",
",",
"real_datetime",
")",
":",
"kw",
".",
"extend",
"(",
"[",
"d",
".",
"hour",
","... | [
45,
0
] | [
52,
24
] | python | en | ['en', 'error', 'th'] | False |
voice | () | Respond to incoming phone calls with a menu of options | Respond to incoming phone calls with a menu of options | def voice():
"""Respond to incoming phone calls with a menu of options"""
# Start our TwiML response
resp = VoiceResponse()
# Start our <Gather> verb
gather = Gather(num_digits=1, action='/gather')
gather.say('For sales, press 1. For support, press 2.')
resp.append(gather)
# If the use... | [
"def",
"voice",
"(",
")",
":",
"# Start our TwiML response",
"resp",
"=",
"VoiceResponse",
"(",
")",
"# Start our <Gather> verb",
"gather",
"=",
"Gather",
"(",
"num_digits",
"=",
"1",
",",
"action",
"=",
"'/gather'",
")",
"gather",
".",
"say",
"(",
"'For sales... | [
7,
0
] | [
20,
20
] | python | en | ['en', 'en', 'en'] | True |
gather | () | Processes results from the <Gather> prompt in /voice | Processes results from the <Gather> prompt in /voice | def gather():
"""Processes results from the <Gather> prompt in /voice"""
# Start our TwiML response
resp = VoiceResponse()
# If Twilio's request to our app included already gathered digits,
# process them
if 'Digits' in request.values:
# Get which digit the caller chose
choice =... | [
"def",
"gather",
"(",
")",
":",
"# Start our TwiML response",
"resp",
"=",
"VoiceResponse",
"(",
")",
"# If Twilio's request to our app included already gathered digits,",
"# process them",
"if",
"'Digits'",
"in",
"request",
".",
"values",
":",
"# Get which digit the caller c... | [
24,
0
] | [
49,
20
] | python | en | ['en', 'en', 'en'] | True |
DatabaseOperations.fetch_returned_insert_rows | (self, cursor) |
Given a cursor object that has just performed an INSERT...RETURNING
statement into a table, return the tuple of returned data.
|
Given a cursor object that has just performed an INSERT...RETURNING
statement into a table, return the tuple of returned data.
| def fetch_returned_insert_rows(self, cursor):
"""
Given a cursor object that has just performed an INSERT...RETURNING
statement into a table, return the tuple of returned data.
"""
return cursor.fetchall() | [
"def",
"fetch_returned_insert_rows",
"(",
"self",
",",
"cursor",
")",
":",
"return",
"cursor",
".",
"fetchall",
"(",
")"
] | [
81,
4
] | [
86,
32
] | python | en | ['en', 'error', 'th'] | False |
DatabaseOperations.max_name_length | (self) |
Return the maximum length of an identifier.
The maximum length of an identifier is 63 by default, but can be
changed by recompiling PostgreSQL after editing the NAMEDATALEN
macro in src/include/pg_config_manual.h.
This implementation returns 63, but can be overridden by a cust... |
Return the maximum length of an identifier. | def max_name_length(self):
"""
Return the maximum length of an identifier.
The maximum length of an identifier is 63 by default, but can be
changed by recompiling PostgreSQL after editing the NAMEDATALEN
macro in src/include/pg_config_manual.h.
This implementation retur... | [
"def",
"max_name_length",
"(",
"self",
")",
":",
"return",
"63"
] | [
191,
4
] | [
202,
17
] | python | en | ['en', 'error', 'th'] | False |
dameraulevenshtein | (seq1, seq2) | Calculate the Damerau-Levenshtein distance between sequences.
This distance is the number of additions, deletions, substitutions,
and transpositions needed to transform the first sequence into the
second. Although generally used with strings, any sequences of
comparable objects will work.
Transpos... | Calculate the Damerau-Levenshtein distance between sequences. | def dameraulevenshtein(seq1, seq2):
"""Calculate the Damerau-Levenshtein distance between sequences.
This distance is the number of additions, deletions, substitutions,
and transpositions needed to transform the first sequence into the
second. Although generally used with strings, any sequences of
... | [
"def",
"dameraulevenshtein",
"(",
"seq1",
",",
"seq2",
")",
":",
"# codesnippet:D0DE4716-B6E6-4161-9219-2903BF8F547F",
"# Conceptually, this is based on a len(seq1) + 1 * len(seq2) + 1 matrix.",
"# However, only the current and two previous rows are needed at once,",
"# so we only store those.... | [
19,
0
] | [
62,
33
] | python | en | ['en', 'en', 'en'] | True |
evaluation_metrics | (predicted, actual, bow=True) |
Input:
predicted, actual = lists of the predicted and actual tokens
bow: if true use bag of words assumption
Returns:
precision, recall, F1, Levenshtein distance
|
Input:
predicted, actual = lists of the predicted and actual tokens
bow: if true use bag of words assumption
Returns:
precision, recall, F1, Levenshtein distance
| def evaluation_metrics(predicted, actual, bow=True):
"""
Input:
predicted, actual = lists of the predicted and actual tokens
bow: if true use bag of words assumption
Returns:
precision, recall, F1, Levenshtein distance
"""
if bow:
p = set(predicted)
a = set(ac... | [
"def",
"evaluation_metrics",
"(",
"predicted",
",",
"actual",
",",
"bow",
"=",
"True",
")",
":",
"if",
"bow",
":",
"p",
"=",
"set",
"(",
"predicted",
")",
"a",
"=",
"set",
"(",
"actual",
")",
"true_positive",
"=",
"0",
"for",
"token",
"in",
"p",
":... | [
65,
0
] | [
113,
34
] | python | en | ['en', 'error', 'th'] | False |
get_and_union_features | (features) |
Get and combine features in a :class:`FeatureUnion`.
Args:
features (str or List[str], ``Features`` or List[``Features``], or List[Tuple[str, ``Features``]]):
One or more features to be used to transform blocks into a matrix of
numeric values. If more than one, a :class:`Featur... |
Get and combine features in a :class:`FeatureUnion`. | def get_and_union_features(features):
"""
Get and combine features in a :class:`FeatureUnion`.
Args:
features (str or List[str], ``Features`` or List[``Features``], or List[Tuple[str, ``Features``]]):
One or more features to be used to transform blocks into a matrix of
numer... | [
"def",
"get_and_union_features",
"(",
"features",
")",
":",
"if",
"not",
"features",
":",
"raise",
"ValueError",
"(",
"'invalid `features`: may not be null'",
")",
"if",
"isinstance",
"(",
"features",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"if",
"isins... | [
116,
0
] | [
147,
23
] | python | en | ['en', 'error', 'th'] | False |
load_pickled_model | (filename, dirname=None) |
Load a pickled ``Extractor`` model from disk.
Args:
filename (str): Name of pickled model file under ``dirname``.
dirname (str): Name of directory on disk containing the pickled model.
If None, dragnet's default pickled model directory is used:
/path/to/dragnet/pickled_... |
Load a pickled ``Extractor`` model from disk. | def load_pickled_model(filename, dirname=None):
"""
Load a pickled ``Extractor`` model from disk.
Args:
filename (str): Name of pickled model file under ``dirname``.
dirname (str): Name of directory on disk containing the pickled model.
If None, dragnet's default pickled model d... | [
"def",
"load_pickled_model",
"(",
"filename",
",",
"dirname",
"=",
"None",
")",
":",
"if",
"dirname",
"is",
"None",
":",
"pkg_filename",
"=",
"pkgutil",
".",
"get_loader",
"(",
"'dragnet'",
")",
".",
"get_filename",
"(",
"'dragnet'",
")",
"pkg_dirname",
"=",... | [
149,
0
] | [
167,
32
] | python | en | ['en', 'error', 'th'] | False |
get_supported_platform | () | Return this platform's maximum compatible version.
distutils.util.get_platform() normally reports the minimum version
of Mac OS X that would be required to *use* extensions produced by
distutils. But what we want when checking compatibility is to know the
version of Mac OS X that we are *running*. To... | Return this platform's maximum compatible version. | def get_supported_platform():
"""Return this platform's maximum compatible version.
distutils.util.get_platform() normally reports the minimum version
of Mac OS X that would be required to *use* extensions produced by
distutils. But what we want when checking compatibility is to know the
version o... | [
"def",
"get_supported_platform",
"(",
")",
":",
"plat",
"=",
"get_build_platform",
"(",
")",
"m",
"=",
"macosVersionString",
".",
"match",
"(",
"plat",
")",
"if",
"m",
"is",
"not",
"None",
"and",
"sys",
".",
"platform",
"==",
"\"darwin\"",
":",
"try",
":... | [
166,
0
] | [
187,
15
] | python | en | ['en', 'la', 'en'] | True |
register_loader_type | (loader_type, provider_factory) | Register `provider_factory` to make providers for `loader_type`
`loader_type` is the type or class of a PEP 302 ``module.__loader__``,
and `provider_factory` is a function that, passed a *module* object,
returns an ``IResourceProvider`` for that module.
| Register `provider_factory` to make providers for `loader_type` | def register_loader_type(loader_type, provider_factory):
"""Register `provider_factory` to make providers for `loader_type`
`loader_type` is the type or class of a PEP 302 ``module.__loader__``,
and `provider_factory` is a function that, passed a *module* object,
returns an ``IResourceProvider`` for th... | [
"def",
"register_loader_type",
"(",
"loader_type",
",",
"provider_factory",
")",
":",
"_provider_factories",
"[",
"loader_type",
"]",
"=",
"provider_factory"
] | [
330,
0
] | [
337,
55
] | python | en | ['en', 'no', 'en'] | True |
get_provider | (moduleOrReq) | Return an IResourceProvider for the named module or requirement | Return an IResourceProvider for the named module or requirement | def get_provider(moduleOrReq):
"""Return an IResourceProvider for the named module or requirement"""
if isinstance(moduleOrReq, Requirement):
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
try:
module = sys.modules[moduleOrReq]
except KeyError:
__import__(mo... | [
"def",
"get_provider",
"(",
"moduleOrReq",
")",
":",
"if",
"isinstance",
"(",
"moduleOrReq",
",",
"Requirement",
")",
":",
"return",
"working_set",
".",
"find",
"(",
"moduleOrReq",
")",
"or",
"require",
"(",
"str",
"(",
"moduleOrReq",
")",
")",
"[",
"0",
... | [
340,
0
] | [
350,
61
] | python | en | ['en', 'en', 'en'] | True |
get_build_platform | () | Return this platform's string for platform-specific distributions
XXX Currently this is the same as ``distutils.util.get_platform()``, but it
needs some hacks for Linux and Mac OS X.
| Return this platform's string for platform-specific distributions | def get_build_platform():
"""Return this platform's string for platform-specific distributions
XXX Currently this is the same as ``distutils.util.get_platform()``, but it
needs some hacks for Linux and Mac OS X.
"""
try:
# Python 2.7 or >=3.2
from sysconfig import get_platform
e... | [
"def",
"get_build_platform",
"(",
")",
":",
"try",
":",
"# Python 2.7 or >=3.2",
"from",
"sysconfig",
"import",
"get_platform",
"except",
"ImportError",
":",
"from",
"distutils",
".",
"util",
"import",
"get_platform",
"plat",
"=",
"get_platform",
"(",
")",
"if",
... | [
373,
0
] | [
398,
15
] | python | en | ['en', 'da', 'en'] | True |
compatible_platforms | (provided, required) | Can code for the `provided` platform run on the `required` platform?
Returns true if either platform is ``None``, or the platforms are equal.
XXX Needs compatibility checks for Linux and other unixy OSes.
| Can code for the `provided` platform run on the `required` platform? | def compatible_platforms(provided, required):
"""Can code for the `provided` platform run on the `required` platform?
Returns true if either platform is ``None``, or the platforms are equal.
XXX Needs compatibility checks for Linux and other unixy OSes.
"""
if provided is None or required is None ... | [
"def",
"compatible_platforms",
"(",
"provided",
",",
"required",
")",
":",
"if",
"provided",
"is",
"None",
"or",
"required",
"is",
"None",
"or",
"provided",
"==",
"required",
":",
"# easy case",
"return",
"True",
"# Mac OS X special cases",
"reqMac",
"=",
"macos... | [
407,
0
] | [
450,
16
] | python | en | ['en', 'en', 'en'] | True |
run_script | (dist_spec, script_name) | Locate distribution `dist_spec` and run its `script_name` script | Locate distribution `dist_spec` and run its `script_name` script | def run_script(dist_spec, script_name):
"""Locate distribution `dist_spec` and run its `script_name` script"""
ns = sys._getframe(1).f_globals
name = ns['__name__']
ns.clear()
ns['__name__'] = name
require(dist_spec)[0].run_script(script_name, ns) | [
"def",
"run_script",
"(",
"dist_spec",
",",
"script_name",
")",
":",
"ns",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
".",
"f_globals",
"name",
"=",
"ns",
"[",
"'__name__'",
"]",
"ns",
".",
"clear",
"(",
")",
"ns",
"[",
"'__name__'",
"]",
"=",
"n... | [
453,
0
] | [
459,
53
] | python | en | ['en', 'co', 'en'] | True |
get_distribution | (dist) | Return a current distribution object for a Requirement or string | Return a current distribution object for a Requirement or string | def get_distribution(dist):
"""Return a current distribution object for a Requirement or string"""
if isinstance(dist, six.string_types):
dist = Requirement.parse(dist)
if isinstance(dist, Requirement):
dist = get_provider(dist)
if not isinstance(dist, Distribution):
raise TypeEr... | [
"def",
"get_distribution",
"(",
"dist",
")",
":",
"if",
"isinstance",
"(",
"dist",
",",
"six",
".",
"string_types",
")",
":",
"dist",
"=",
"Requirement",
".",
"parse",
"(",
"dist",
")",
"if",
"isinstance",
"(",
"dist",
",",
"Requirement",
")",
":",
"di... | [
466,
0
] | [
474,
15
] | python | en | ['en', 'en', 'en'] | True |
load_entry_point | (dist, group, name) | Return `name` entry point of `group` for `dist` or raise ImportError | Return `name` entry point of `group` for `dist` or raise ImportError | def load_entry_point(dist, group, name):
"""Return `name` entry point of `group` for `dist` or raise ImportError"""
return get_distribution(dist).load_entry_point(group, name) | [
"def",
"load_entry_point",
"(",
"dist",
",",
"group",
",",
"name",
")",
":",
"return",
"get_distribution",
"(",
"dist",
")",
".",
"load_entry_point",
"(",
"group",
",",
"name",
")"
] | [
477,
0
] | [
479,
63
] | python | en | ['en', 'en', 'en'] | True |
get_entry_map | (dist, group=None) | Return the entry point map for `group`, or the full entry map | Return the entry point map for `group`, or the full entry map | def get_entry_map(dist, group=None):
"""Return the entry point map for `group`, or the full entry map"""
return get_distribution(dist).get_entry_map(group) | [
"def",
"get_entry_map",
"(",
"dist",
",",
"group",
"=",
"None",
")",
":",
"return",
"get_distribution",
"(",
"dist",
")",
".",
"get_entry_map",
"(",
"group",
")"
] | [
482,
0
] | [
484,
54
] | python | en | ['en', 'en', 'en'] | True |
get_entry_info | (dist, group, name) | Return the EntryPoint object for `group`+`name`, or ``None`` | Return the EntryPoint object for `group`+`name`, or ``None`` | def get_entry_info(dist, group, name):
"""Return the EntryPoint object for `group`+`name`, or ``None``"""
return get_distribution(dist).get_entry_info(group, name) | [
"def",
"get_entry_info",
"(",
"dist",
",",
"group",
",",
"name",
")",
":",
"return",
"get_distribution",
"(",
"dist",
")",
".",
"get_entry_info",
"(",
"group",
",",
"name",
")"
] | [
487,
0
] | [
489,
61
] | python | en | ['en', 'en', 'en'] | True |
get_default_cache | () |
Return the ``PYTHON_EGG_CACHE`` environment variable
or a platform-relevant user cache dir for an app
named "Python-Eggs".
|
Return the ``PYTHON_EGG_CACHE`` environment variable
or a platform-relevant user cache dir for an app
named "Python-Eggs".
| def get_default_cache():
"""
Return the ``PYTHON_EGG_CACHE`` environment variable
or a platform-relevant user cache dir for an app
named "Python-Eggs".
"""
return (
os.environ.get('PYTHON_EGG_CACHE')
or appdirs.user_cache_dir(appname='Python-Eggs')
) | [
"def",
"get_default_cache",
"(",
")",
":",
"return",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'PYTHON_EGG_CACHE'",
")",
"or",
"appdirs",
".",
"user_cache_dir",
"(",
"appname",
"=",
"'Python-Eggs'",
")",
")"
] | [
1296,
0
] | [
1305,
5
] | python | en | ['en', 'error', 'th'] | False |
safe_name | (name) | Convert an arbitrary string to a standard distribution name
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
| Convert an arbitrary string to a standard distribution name | def safe_name(name):
"""Convert an arbitrary string to a standard distribution name
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
"""
return re.sub('[^A-Za-z0-9.]+', '-', name) | [
"def",
"safe_name",
"(",
"name",
")",
":",
"return",
"re",
".",
"sub",
"(",
"'[^A-Za-z0-9.]+'",
",",
"'-'",
",",
"name",
")"
] | [
1308,
0
] | [
1313,
46
] | python | en | ['en', 'en', 'en'] | True |
safe_version | (version) |
Convert an arbitrary string to a standard version string
|
Convert an arbitrary string to a standard version string
| def safe_version(version):
"""
Convert an arbitrary string to a standard version string
"""
try:
# normalize the version
return str(packaging.version.Version(version))
except packaging.version.InvalidVersion:
version = version.replace(' ', '.')
return re.sub('[^A-Za-z... | [
"def",
"safe_version",
"(",
"version",
")",
":",
"try",
":",
"# normalize the version",
"return",
"str",
"(",
"packaging",
".",
"version",
".",
"Version",
"(",
"version",
")",
")",
"except",
"packaging",
".",
"version",
".",
"InvalidVersion",
":",
"version",
... | [
1316,
0
] | [
1325,
53
] | python | en | ['en', 'error', 'th'] | False |
safe_extra | (extra) | Convert an arbitrary string to a standard 'extra' name
Any runs of non-alphanumeric characters are replaced with a single '_',
and the result is always lowercased.
| Convert an arbitrary string to a standard 'extra' name | def safe_extra(extra):
"""Convert an arbitrary string to a standard 'extra' name
Any runs of non-alphanumeric characters are replaced with a single '_',
and the result is always lowercased.
"""
return re.sub('[^A-Za-z0-9.-]+', '_', extra).lower() | [
"def",
"safe_extra",
"(",
"extra",
")",
":",
"return",
"re",
".",
"sub",
"(",
"'[^A-Za-z0-9.-]+'",
",",
"'_'",
",",
"extra",
")",
".",
"lower",
"(",
")"
] | [
1328,
0
] | [
1334,
56
] | python | en | ['en', 'en', 'en'] | True |
to_filename | (name) | Convert a project or version name to its filename-escaped form
Any '-' characters are currently replaced with '_'.
| Convert a project or version name to its filename-escaped form | def to_filename(name):
"""Convert a project or version name to its filename-escaped form
Any '-' characters are currently replaced with '_'.
"""
return name.replace('-', '_') | [
"def",
"to_filename",
"(",
"name",
")",
":",
"return",
"name",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")"
] | [
1337,
0
] | [
1342,
33
] | python | en | ['en', 'en', 'en'] | True |
invalid_marker | (text) |
Validate text as a PEP 508 environment marker; return an exception
if invalid or False otherwise.
|
Validate text as a PEP 508 environment marker; return an exception
if invalid or False otherwise.
| def invalid_marker(text):
"""
Validate text as a PEP 508 environment marker; return an exception
if invalid or False otherwise.
"""
try:
evaluate_marker(text)
except SyntaxError as e:
e.filename = None
e.lineno = None
return e
return False | [
"def",
"invalid_marker",
"(",
"text",
")",
":",
"try",
":",
"evaluate_marker",
"(",
"text",
")",
"except",
"SyntaxError",
"as",
"e",
":",
"e",
".",
"filename",
"=",
"None",
"e",
".",
"lineno",
"=",
"None",
"return",
"e",
"return",
"False"
] | [
1345,
0
] | [
1356,
16
] | python | en | ['en', 'error', 'th'] | False |
evaluate_marker | (text, extra=None) |
Evaluate a PEP 508 environment marker.
Return a boolean indicating the marker result in this environment.
Raise SyntaxError if marker is invalid.
This implementation uses the 'pyparsing' module.
|
Evaluate a PEP 508 environment marker.
Return a boolean indicating the marker result in this environment.
Raise SyntaxError if marker is invalid. | def evaluate_marker(text, extra=None):
"""
Evaluate a PEP 508 environment marker.
Return a boolean indicating the marker result in this environment.
Raise SyntaxError if marker is invalid.
This implementation uses the 'pyparsing' module.
"""
try:
marker = packaging.markers.Marker(te... | [
"def",
"evaluate_marker",
"(",
"text",
",",
"extra",
"=",
"None",
")",
":",
"try",
":",
"marker",
"=",
"packaging",
".",
"markers",
".",
"Marker",
"(",
"text",
")",
"return",
"marker",
".",
"evaluate",
"(",
")",
"except",
"packaging",
".",
"markers",
"... | [
1359,
0
] | [
1371,
28
] | python | en | ['en', 'error', 'th'] | False |
register_finder | (importer_type, distribution_finder) | Register `distribution_finder` to find distributions in sys.path items
`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `distribution_finder` is a callable that, passed a path
item and the importer instance, yields ``Distribution`` instances found on
that path i... | Register `distribution_finder` to find distributions in sys.path items | def register_finder(importer_type, distribution_finder):
"""Register `distribution_finder` to find distributions in sys.path items
`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `distribution_finder` is a callable that, passed a path
item and the importer inst... | [
"def",
"register_finder",
"(",
"importer_type",
",",
"distribution_finder",
")",
":",
"_distribution_finders",
"[",
"importer_type",
"]",
"=",
"distribution_finder"
] | [
1855,
0
] | [
1862,
62
] | python | en | ['en', 'en', 'en'] | True |
find_distributions | (path_item, only=False) | Yield distributions accessible via `path_item` | Yield distributions accessible via `path_item` | def find_distributions(path_item, only=False):
"""Yield distributions accessible via `path_item`"""
importer = get_importer(path_item)
finder = _find_adapter(_distribution_finders, importer)
return finder(importer, path_item, only) | [
"def",
"find_distributions",
"(",
"path_item",
",",
"only",
"=",
"False",
")",
":",
"importer",
"=",
"get_importer",
"(",
"path_item",
")",
"finder",
"=",
"_find_adapter",
"(",
"_distribution_finders",
",",
"importer",
")",
"return",
"finder",
"(",
"importer",
... | [
1865,
0
] | [
1869,
44
] | python | en | ['en', 'en', 'en'] | True |
find_eggs_in_zip | (importer, path_item, only=False) |
Find eggs in zip files; possibly multiple nested eggs.
|
Find eggs in zip files; possibly multiple nested eggs.
| def find_eggs_in_zip(importer, path_item, only=False):
"""
Find eggs in zip files; possibly multiple nested eggs.
"""
if importer.archive.endswith('.whl'):
# wheels are not supported with this finder
# they don't have PKG-INFO metadata, and won't ever contain eggs
return
meta... | [
"def",
"find_eggs_in_zip",
"(",
"importer",
",",
"path_item",
",",
"only",
"=",
"False",
")",
":",
"if",
"importer",
".",
"archive",
".",
"endswith",
"(",
"'.whl'",
")",
":",
"# wheels are not supported with this finder",
"# they don't have PKG-INFO metadata, and won't ... | [
1872,
0
] | [
1896,
73
] | python | en | ['en', 'error', 'th'] | False |
_by_version_descending | (names) |
Given a list of filenames, return them in descending order
by version number.
>>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg'
>>> _by_version_descending(names)
['Python-2.7.10.egg', 'Python-2.7.2.egg', 'foo', 'bar']
>>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.egg'... |
Given a list of filenames, return them in descending order
by version number. | def _by_version_descending(names):
"""
Given a list of filenames, return them in descending order
by version number.
>>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg'
>>> _by_version_descending(names)
['Python-2.7.10.egg', 'Python-2.7.2.egg', 'foo', 'bar']
>>> names = 'Setup... | [
"def",
"_by_version_descending",
"(",
"names",
")",
":",
"def",
"_by_version",
"(",
"name",
")",
":",
"\"\"\"\n Parse each component of the filename\n \"\"\"",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"name",
")",
"parts",
"=... | [
1909,
0
] | [
1932,
55
] | python | en | ['en', 'error', 'th'] | False |
find_on_path | (importer, path_item, only=False) | Yield distributions accessible on a sys.path directory | Yield distributions accessible on a sys.path directory | def find_on_path(importer, path_item, only=False):
"""Yield distributions accessible on a sys.path directory"""
path_item = _normalize_cached(path_item)
if _is_unpacked_egg(path_item):
yield Distribution.from_filename(
path_item, metadata=PathMetadata(
path_item, os.path... | [
"def",
"find_on_path",
"(",
"importer",
",",
"path_item",
",",
"only",
"=",
"False",
")",
":",
"path_item",
"=",
"_normalize_cached",
"(",
"path_item",
")",
"if",
"_is_unpacked_egg",
"(",
"path_item",
")",
":",
"yield",
"Distribution",
".",
"from_filename",
"(... | [
1935,
0
] | [
1964,
22
] | python | en | ['en', 'en', 'en'] | True |
dist_factory | (path_item, entry, only) |
Return a dist_factory for a path_item and entry
|
Return a dist_factory for a path_item and entry
| def dist_factory(path_item, entry, only):
"""
Return a dist_factory for a path_item and entry
"""
lower = entry.lower()
is_meta = any(map(lower.endswith, ('.egg-info', '.dist-info')))
return (
distributions_from_metadata
if is_meta else
find_distributions
if not o... | [
"def",
"dist_factory",
"(",
"path_item",
",",
"entry",
",",
"only",
")",
":",
"lower",
"=",
"entry",
".",
"lower",
"(",
")",
"is_meta",
"=",
"any",
"(",
"map",
"(",
"lower",
".",
"endswith",
",",
"(",
"'.egg-info'",
",",
"'.dist-info'",
")",
")",
")"... | [
1967,
0
] | [
1981,
5
] | python | en | ['en', 'error', 'th'] | False |
safe_listdir | (path) |
Attempt to list contents of path, but suppress some exceptions.
|
Attempt to list contents of path, but suppress some exceptions.
| def safe_listdir(path):
"""
Attempt to list contents of path, but suppress some exceptions.
"""
try:
return os.listdir(path)
except (PermissionError, NotADirectoryError):
pass
except OSError as e:
# Ignore the directory if does not exist, not a directory or
# perm... | [
"def",
"safe_listdir",
"(",
"path",
")",
":",
"try",
":",
"return",
"os",
".",
"listdir",
"(",
"path",
")",
"except",
"(",
"PermissionError",
",",
"NotADirectoryError",
")",
":",
"pass",
"except",
"OSError",
"as",
"e",
":",
"# Ignore the directory if does not ... | [
2001,
0
] | [
2019,
13
] | python | en | ['en', 'error', 'th'] | False |
non_empty_lines | (path) |
Yield non-empty lines from file at path
|
Yield non-empty lines from file at path
| def non_empty_lines(path):
"""
Yield non-empty lines from file at path
"""
with open(path) as f:
for line in f:
line = line.strip()
if line:
yield line | [
"def",
"non_empty_lines",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
":",
"yield",
"line"
] | [
2037,
0
] | [
2045,
26
] | python | en | ['en', 'error', 'th'] | False |
resolve_egg_link | (path) |
Given a path to an .egg-link, resolve distributions
present in the referenced path.
|
Given a path to an .egg-link, resolve distributions
present in the referenced path.
| def resolve_egg_link(path):
"""
Given a path to an .egg-link, resolve distributions
present in the referenced path.
"""
referenced_paths = non_empty_lines(path)
resolved_paths = (
os.path.join(os.path.dirname(path), ref)
for ref in referenced_paths
)
dist_groups = map(fin... | [
"def",
"resolve_egg_link",
"(",
"path",
")",
":",
"referenced_paths",
"=",
"non_empty_lines",
"(",
"path",
")",
"resolved_paths",
"=",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
",",
"ref",
")",
"for"... | [
2048,
0
] | [
2059,
32
] | python | en | ['en', 'error', 'th'] | False |
register_namespace_handler | (importer_type, namespace_handler) | Register `namespace_handler` to declare namespace packages
`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `namespace_handler` is a callable like this::
def namespace_handler(importer, path_entry, moduleName, module):
# return a path_entry to use f... | Register `namespace_handler` to declare namespace packages | def register_namespace_handler(importer_type, namespace_handler):
"""Register `namespace_handler` to declare namespace packages
`importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
handler), and `namespace_handler` is a callable like this::
def namespace_handler(importer, pa... | [
"def",
"register_namespace_handler",
"(",
"importer_type",
",",
"namespace_handler",
")",
":",
"_namespace_handlers",
"[",
"importer_type",
"]",
"=",
"namespace_handler"
] | [
2071,
0
] | [
2086,
58
] | python | en | ['it', 'en', 'en'] | True |
_handle_ns | (packageName, path_item) | Ensure that named package includes a subpath of path_item (if needed) | Ensure that named package includes a subpath of path_item (if needed) | def _handle_ns(packageName, path_item):
"""Ensure that named package includes a subpath of path_item (if needed)"""
importer = get_importer(path_item)
if importer is None:
return None
loader = importer.find_module(packageName)
if loader is None:
return None
module = sys.modules.... | [
"def",
"_handle_ns",
"(",
"packageName",
",",
"path_item",
")",
":",
"importer",
"=",
"get_importer",
"(",
"path_item",
")",
"if",
"importer",
"is",
"None",
":",
"return",
"None",
"loader",
"=",
"importer",
".",
"find_module",
"(",
"packageName",
")",
"if",
... | [
2089,
0
] | [
2112,
18
] | python | en | ['en', 'en', 'en'] | True |
_rebuild_mod_path | (orig_path, package_name, module) |
Rebuild module.__path__ ensuring that all entries are ordered
corresponding to their sys.path order
|
Rebuild module.__path__ ensuring that all entries are ordered
corresponding to their sys.path order
| def _rebuild_mod_path(orig_path, package_name, module):
"""
Rebuild module.__path__ ensuring that all entries are ordered
corresponding to their sys.path order
"""
sys_path = [_normalize_cached(p) for p in sys.path]
def safe_sys_path_index(entry):
"""
Workaround for #520 and #51... | [
"def",
"_rebuild_mod_path",
"(",
"orig_path",
",",
"package_name",
",",
"module",
")",
":",
"sys_path",
"=",
"[",
"_normalize_cached",
"(",
"p",
")",
"for",
"p",
"in",
"sys",
".",
"path",
"]",
"def",
"safe_sys_path_index",
"(",
"entry",
")",
":",
"\"\"\"\n... | [
2115,
0
] | [
2145,
66
] | python | en | ['en', 'error', 'th'] | False |
declare_namespace | (packageName) | Declare that package 'packageName' is a namespace package | Declare that package 'packageName' is a namespace package | def declare_namespace(packageName):
"""Declare that package 'packageName' is a namespace package"""
_imp.acquire_lock()
try:
if packageName in _namespace_packages:
return
path, parent = sys.path, None
if '.' in packageName:
parent = '.'.join(packageName.spli... | [
"def",
"declare_namespace",
"(",
"packageName",
")",
":",
"_imp",
".",
"acquire_lock",
"(",
")",
"try",
":",
"if",
"packageName",
"in",
"_namespace_packages",
":",
"return",
"path",
",",
"parent",
"=",
"sys",
".",
"path",
",",
"None",
"if",
"'.'",
"in",
... | [
2148,
0
] | [
2178,
27
] | python | en | ['en', 'en', 'en'] | True |
fixup_namespace_packages | (path_item, parent=None) | Ensure that previously-declared namespace packages include path_item | Ensure that previously-declared namespace packages include path_item | def fixup_namespace_packages(path_item, parent=None):
"""Ensure that previously-declared namespace packages include path_item"""
_imp.acquire_lock()
try:
for package in _namespace_packages.get(parent, ()):
subpath = _handle_ns(package, path_item)
if subpath:
f... | [
"def",
"fixup_namespace_packages",
"(",
"path_item",
",",
"parent",
"=",
"None",
")",
":",
"_imp",
".",
"acquire_lock",
"(",
")",
"try",
":",
"for",
"package",
"in",
"_namespace_packages",
".",
"get",
"(",
"parent",
",",
"(",
")",
")",
":",
"subpath",
"=... | [
2181,
0
] | [
2190,
27
] | python | en | ['en', 'en', 'en'] | True |
file_ns_handler | (importer, path_item, packageName, module) | Compute an ns-package subpath for a filesystem or zipfile importer | Compute an ns-package subpath for a filesystem or zipfile importer | def file_ns_handler(importer, path_item, packageName, module):
"""Compute an ns-package subpath for a filesystem or zipfile importer"""
subpath = os.path.join(path_item, packageName.split('.')[-1])
normalized = _normalize_cached(subpath)
for item in module.__path__:
if _normalize_cached(item) =... | [
"def",
"file_ns_handler",
"(",
"importer",
",",
"path_item",
",",
"packageName",
",",
"module",
")",
":",
"subpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path_item",
",",
"packageName",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
")",
"n... | [
2193,
0
] | [
2203,
22
] | python | en | ['en', 'en', 'en'] | True |
normalize_path | (filename) | Normalize a file/dir name for comparison purposes | Normalize a file/dir name for comparison purposes | def normalize_path(filename):
"""Normalize a file/dir name for comparison purposes"""
return os.path.normcase(os.path.realpath(filename)) | [
"def",
"normalize_path",
"(",
"filename",
")",
":",
"return",
"os",
".",
"path",
".",
"normcase",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"filename",
")",
")"
] | [
2220,
0
] | [
2222,
55
] | python | en | ['en', 'it', 'en'] | True |
_is_egg_path | (path) |
Determine if given path appears to be an egg.
|
Determine if given path appears to be an egg.
| def _is_egg_path(path):
"""
Determine if given path appears to be an egg.
"""
return path.lower().endswith('.egg') | [
"def",
"_is_egg_path",
"(",
"path",
")",
":",
"return",
"path",
".",
"lower",
"(",
")",
".",
"endswith",
"(",
"'.egg'",
")"
] | [
2233,
0
] | [
2237,
40
] | python | en | ['en', 'error', 'th'] | False |
_is_unpacked_egg | (path) |
Determine if given path appears to be an unpacked egg.
|
Determine if given path appears to be an unpacked egg.
| def _is_unpacked_egg(path):
"""
Determine if given path appears to be an unpacked egg.
"""
return (
_is_egg_path(path) and
os.path.isfile(os.path.join(path, 'EGG-INFO', 'PKG-INFO'))
) | [
"def",
"_is_unpacked_egg",
"(",
"path",
")",
":",
"return",
"(",
"_is_egg_path",
"(",
"path",
")",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"'EGG-INFO'",
",",
"'PKG-INFO'",
")",
")",
")"
] | [
2240,
0
] | [
2247,
5
] | python | en | ['en', 'error', 'th'] | False |
yield_lines | (strs) | Yield non-empty/non-comment lines of a string or sequence | Yield non-empty/non-comment lines of a string or sequence | def yield_lines(strs):
"""Yield non-empty/non-comment lines of a string or sequence"""
if isinstance(strs, six.string_types):
for s in strs.splitlines():
s = s.strip()
# skip blank lines/comments
if s and not s.startswith('#'):
yield s
else:
... | [
"def",
"yield_lines",
"(",
"strs",
")",
":",
"if",
"isinstance",
"(",
"strs",
",",
"six",
".",
"string_types",
")",
":",
"for",
"s",
"in",
"strs",
".",
"splitlines",
"(",
")",
":",
"s",
"=",
"s",
".",
"strip",
"(",
")",
"# skip blank lines/comments",
... | [
2258,
0
] | [
2269,
23
] | python | en | ['en', 'en', 'en'] | True |
_version_from_file | (lines) |
Given an iterable of lines from a Metadata file, return
the value of the Version field, if present, or None otherwise.
|
Given an iterable of lines from a Metadata file, return
the value of the Version field, if present, or None otherwise.
| def _version_from_file(lines):
"""
Given an iterable of lines from a Metadata file, return
the value of the Version field, if present, or None otherwise.
"""
def is_version_line(line):
return line.lower().startswith('version:')
version_lines = filter(is_version_line, lines)
line = ne... | [
"def",
"_version_from_file",
"(",
"lines",
")",
":",
"def",
"is_version_line",
"(",
"line",
")",
":",
"return",
"line",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'version:'",
")",
"version_lines",
"=",
"filter",
"(",
"is_version_line",
",",
"lines",
... | [
2428,
0
] | [
2438,
46
] | 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.