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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Output._create_logs_directory | (self, time_started) | Create subdirectory in logs in output directory.
New subdirectory is created in Logs with the formatted start time of the HTML output creation.
Args:
time_started (datetime.datetime): start time of HTML Output creation
| Create subdirectory in logs in output directory. | def _create_logs_directory(self, time_started):
"""Create subdirectory in logs in output directory.
New subdirectory is created in Logs with the formatted start time of the HTML output creation.
Args:
time_started (datetime.datetime): start time of HTML Output creation
"""
... | [
"def",
"_create_logs_directory",
"(",
"self",
",",
"time_started",
")",
":",
"directory",
"=",
"time_started",
".",
"strftime",
"(",
"self",
".",
"_logs_time_format",
")",
"logs_directory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"logs_path",
... | [
519,
4
] | [
530,
29
] | python | en | ['en', 'en', 'en'] | True |
Output._copy_static | (self) | Copy static files to static folder in the output directory. | Copy static files to static folder in the output directory. | def _copy_static(self):
"""Copy static files to static folder in the output directory."""
for f in self._static_files_names: # predefined static files to copy
f_copy = pkgutil.get_data(self.package_name, os.path.join(self._static_directory_name, f)).decode("utf-8")
with open(os.... | [
"def",
"_copy_static",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"_static_files_names",
":",
"# predefined static files to copy",
"f_copy",
"=",
"pkgutil",
".",
"get_data",
"(",
"self",
".",
"package_name",
",",
"os",
".",
"path",
".",
"join",
"(... | [
532,
4
] | [
537,
32
] | python | en | ['en', 'en', 'en'] | True |
Output._path_to_file | (self, filename) | Create output directory file path to provided filename.
Returns:
str: output directory file path
| Create output directory file path to provided filename. | def _path_to_file(self, filename):
"""Create output directory file path to provided filename.
Returns:
str: output directory file path
"""
return os.path.join(self.output_directory, filename) | [
"def",
"_path_to_file",
"(",
"self",
",",
"filename",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_directory",
",",
"filename",
")"
] | [
539,
4
] | [
545,
60
] | python | en | ['en', 'en', 'en'] | True |
Output._models_view_creator | (self, problem_type) | Create appropriate ModelsView based on a problem type.
Following ModelsViews can be created:
- classification: ModelsViewClassification
- regression: ModelsViewRegression
- multiclass: ModelsViewMulticlass
Args:
problem_type (str): problem type
... | Create appropriate ModelsView based on a problem type. | def _models_view_creator(self, problem_type):
"""Create appropriate ModelsView based on a problem type.
Following ModelsViews can be created:
- classification: ModelsViewClassification
- regression: ModelsViewRegression
- multiclass: ModelsViewMulticlass
Arg... | [
"def",
"_models_view_creator",
"(",
"self",
",",
"problem_type",
")",
":",
"kwargs",
"=",
"{",
"\"template\"",
":",
"self",
".",
"env",
".",
"get_template",
"(",
"self",
".",
"_view_models_html",
")",
",",
"\"css_path\"",
":",
"(",
"self",
".",
"_static_dire... | [
547,
4
] | [
584,
27
] | python | en | ['en', 'en', 'en'] | True |
Output._models_plot_output | (self, problem_type) | Create appropriate Plots and/or Data based on a problem type.
Plot objects are instantiated and appropriately called based on a provided problem_type. Following ModelPlots
can be created:
- classification: ModelsPlotClassification
- regression: ModelsPlotRegression
-... | Create appropriate Plots and/or Data based on a problem type. | def _models_plot_output(self, problem_type):
"""Create appropriate Plots and/or Data based on a problem type.
Plot objects are instantiated and appropriately called based on a provided problem_type. Following ModelPlots
can be created:
- classification: ModelsPlotClassification
... | [
"def",
"_models_plot_output",
"(",
"self",
",",
"problem_type",
")",
":",
"# Creating Plots based on type of ML problem",
"plot_design",
"=",
"self",
".",
"plot_design",
"if",
"problem_type",
"==",
"self",
".",
"model_finder",
".",
"_classification",
":",
"mp",
"=",
... | [
586,
4
] | [
639,
47
] | python | en | ['en', 'en', 'en'] | True |
test_getstartingblock_multiline | () |
This test was originally found in test_source.py, but it depends on the weird
formatting of the ``x = A`` construct seen here and our autopep8 tool can only exclude entire
files (it does not support excluding lines/blocks using the traditional #noqa comment yet,
see hhatto/autopep8#307). It was conside... |
This test was originally found in test_source.py, but it depends on the weird
formatting of the ``x = A`` construct seen here and our autopep8 tool can only exclude entire
files (it does not support excluding lines/blocks using the traditional #noqa comment yet,
see hhatto/autopep8#307). It was conside... | def test_getstartingblock_multiline():
"""
This test was originally found in test_source.py, but it depends on the weird
formatting of the ``x = A`` construct seen here and our autopep8 tool can only exclude entire
files (it does not support excluding lines/blocks using the traditional #noqa comment yet... | [
"def",
"test_getstartingblock_multiline",
"(",
")",
":",
"class",
"A",
"(",
"object",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
")",
":",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
"self",
".",
"source",
"=",
"_pytest",
"... | [
6,
0
] | [
25,
27
] | python | en | ['en', 'error', 'th'] | False |
build_page_params_for_home_page_load | (
request: HttpRequest,
user_profile: Optional[UserProfile],
realm: Realm,
insecure_desktop_app: bool,
has_mobile_devices: bool,
narrow: List[List[str]],
narrow_stream: Optional[Stream],
narrow_topic: Optional[str],
first_in_realm: bool,
prompt_for_invites: bool,
needs_tutori... |
This function computes page_params for when we load the home page.
The page_params data structure gets sent to the client.
|
This function computes page_params for when we load the home page. | def build_page_params_for_home_page_load(
request: HttpRequest,
user_profile: Optional[UserProfile],
realm: Realm,
insecure_desktop_app: bool,
has_mobile_devices: bool,
narrow: List[List[str]],
narrow_stream: Optional[Stream],
narrow_topic: Optional[str],
first_in_realm: bool,
pr... | [
"def",
"build_page_params_for_home_page_load",
"(",
"request",
":",
"HttpRequest",
",",
"user_profile",
":",
"Optional",
"[",
"UserProfile",
"]",
",",
"realm",
":",
"Realm",
",",
"insecure_desktop_app",
":",
"bool",
",",
"has_mobile_devices",
":",
"bool",
",",
"na... | [
154,
0
] | [
278,
48
] | python | en | ['en', 'error', 'th'] | False |
clear_preregistrationuser_invited_as_admin | (
apps: StateApps, schema_editor: DatabaseSchemaEditor
) | This migration fixes any PreregistrationUser objects that might
have been already corrupted to have the administrator role by the
buggy original version of migration
0198_preregistrationuser_invited_as.
Since invitations that create new users as administrators are
rare, it is cleaner to just remove... | This migration fixes any PreregistrationUser objects that might
have been already corrupted to have the administrator role by the
buggy original version of migration
0198_preregistrationuser_invited_as. | def clear_preregistrationuser_invited_as_admin(
apps: StateApps, schema_editor: DatabaseSchemaEditor
) -> None:
"""This migration fixes any PreregistrationUser objects that might
have been already corrupted to have the administrator role by the
buggy original version of migration
0198_preregistratio... | [
"def",
"clear_preregistrationuser_invited_as_admin",
"(",
"apps",
":",
"StateApps",
",",
"schema_editor",
":",
"DatabaseSchemaEditor",
")",
"->",
"None",
":",
"INVITED_AS_MEMBER",
"=",
"1",
"INVITED_AS_REALM_ADMIN",
"=",
"2",
"PreregistrationUser",
"=",
"apps",
".",
"... | [
9,
0
] | [
30,
5
] | python | en | ['en', 'en', 'en'] | True |
create_env | (full_env_name, cfg=None, env_config=None) |
Factory function that creates environment instances.
Matches full_env_name with env family prefixes registered in the REGISTRY and calls make_env_func()
for the first match.
:param full_env_name: complete name of the environment, starting with the prefix of registered environment family,
e.g. atar... |
Factory function that creates environment instances.
Matches full_env_name with env family prefixes registered in the REGISTRY and calls make_env_func()
for the first match. | def create_env(full_env_name, cfg=None, env_config=None):
"""
Factory function that creates environment instances.
Matches full_env_name with env family prefixes registered in the REGISTRY and calls make_env_func()
for the first match.
:param full_env_name: complete name of the environment, startin... | [
"def",
"create_env",
"(",
"full_env_name",
",",
"cfg",
"=",
"None",
",",
"env_config",
"=",
"None",
")",
":",
"env_registry",
"=",
"global_env_registry",
"(",
")",
"env_registry_entry",
"=",
"env_registry",
".",
"resolve_env_name",
"(",
"full_env_name",
")",
"en... | [
3,
0
] | [
22,
14
] | python | en | ['en', 'error', 'th'] | False |
_copy_file_contents | (src, dst, buffer_size=16*1024) | Copy the file 'src' to 'dst'; both must be filenames. Any error
opening either file, reading from 'src', or writing to 'dst', raises
DistutilsFileError. Data is read/written in chunks of 'buffer_size'
bytes (default 16k). No attempt is made to handle anything apart from
regular files.
| Copy the file 'src' to 'dst'; both must be filenames. Any error
opening either file, reading from 'src', or writing to 'dst', raises
DistutilsFileError. Data is read/written in chunks of 'buffer_size'
bytes (default 16k). No attempt is made to handle anything apart from
regular files.
| def _copy_file_contents(src, dst, buffer_size=16*1024):
"""Copy the file 'src' to 'dst'; both must be filenames. Any error
opening either file, reading from 'src', or writing to 'dst', raises
DistutilsFileError. Data is read/written in chunks of 'buffer_size'
bytes (default 16k). No attempt is made t... | [
"def",
"_copy_file_contents",
"(",
"src",
",",
"dst",
",",
"buffer_size",
"=",
"16",
"*",
"1024",
")",
":",
"# Stolen from shutil module in the standard library, but with",
"# custom error-handling added.",
"fsrc",
"=",
"None",
"fdst",
"=",
"None",
"try",
":",
"try",
... | [
15,
0
] | [
64,
24
] | python | en | ['en', 'en', 'en'] | True |
copy_file | (src, dst, preserve_mode=1, preserve_times=1, update=0,
link=None, verbose=1, dry_run=0) | Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is
copied there with the same name; otherwise, it must be a filename. (If
the file exists, it will be ruthlessly clobbered.) If 'preserve_mode'
is true (the default), the file's mode (type and permission bits, or
whatever is analogous on... | Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is
copied there with the same name; otherwise, it must be a filename. (If
the file exists, it will be ruthlessly clobbered.) If 'preserve_mode'
is true (the default), the file's mode (type and permission bits, or
whatever is analogous on... | def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
link=None, verbose=1, dry_run=0):
"""Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is
copied there with the same name; otherwise, it must be a filename. (If
the file exists, it will be ruthlessly clobbered... | [
"def",
"copy_file",
"(",
"src",
",",
"dst",
",",
"preserve_mode",
"=",
"1",
",",
"preserve_times",
"=",
"1",
",",
"update",
"=",
"0",
",",
"link",
"=",
"None",
",",
"verbose",
"=",
"1",
",",
"dry_run",
"=",
"0",
")",
":",
"# XXX if the destination file... | [
66,
0
] | [
161,
19
] | python | en | ['en', 'en', 'en'] | True |
move_file | (src, dst,
verbose=1,
dry_run=0) | Move a file 'src' to 'dst'. If 'dst' is a directory, the file will
be moved into it with the same name; otherwise, 'src' is just renamed
to 'dst'. Return the new full name of the file.
Handles cross-device moves on Unix using 'copy_file()'. What about
other systems???
| Move a file 'src' to 'dst'. If 'dst' is a directory, the file will
be moved into it with the same name; otherwise, 'src' is just renamed
to 'dst'. Return the new full name of the file. | def move_file (src, dst,
verbose=1,
dry_run=0):
"""Move a file 'src' to 'dst'. If 'dst' is a directory, the file will
be moved into it with the same name; otherwise, 'src' is just renamed
to 'dst'. Return the new full name of the file.
Handles cross-device moves on Unix... | [
"def",
"move_file",
"(",
"src",
",",
"dst",
",",
"verbose",
"=",
"1",
",",
"dry_run",
"=",
"0",
")",
":",
"from",
"os",
".",
"path",
"import",
"exists",
",",
"isfile",
",",
"isdir",
",",
"basename",
",",
"dirname",
"import",
"errno",
"if",
"verbose",... | [
165,
0
] | [
225,
14
] | python | en | ['en', 'en', 'en'] | True |
write_file | (filename, contents) | Create a file with the specified name and write 'contents' (a
sequence of strings without line terminators) to it.
| Create a file with the specified name and write 'contents' (a
sequence of strings without line terminators) to it.
| def write_file (filename, contents):
"""Create a file with the specified name and write 'contents' (a
sequence of strings without line terminators) to it.
"""
f = open(filename, "w")
try:
for line in contents:
f.write(line + "\n")
finally:
f.close() | [
"def",
"write_file",
"(",
"filename",
",",
"contents",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"try",
":",
"for",
"line",
"in",
"contents",
":",
"f",
".",
"write",
"(",
"line",
"+",
"\"\\n\"",
")",
"finally",
":",
"f",
".",
... | [
228,
0
] | [
237,
17
] | python | en | ['en', 'en', 'en'] | True |
_subst_vars | (path, local_vars) | In the string `path`, replace tokens like {some.thing} with the
corresponding value from the map `local_vars`.
If there is no corresponding value, leave the token unchanged.
| In the string `path`, replace tokens like {some.thing} with the
corresponding value from the map `local_vars`. | def _subst_vars(path, local_vars):
"""In the string `path`, replace tokens like {some.thing} with the
corresponding value from the map `local_vars`.
If there is no corresponding value, leave the token unchanged.
"""
def _replacer(matchobj):
name = matchobj.group(1)
if name in local_... | [
"def",
"_subst_vars",
"(",
"path",
",",
"local_vars",
")",
":",
"def",
"_replacer",
"(",
"matchobj",
")",
":",
"name",
"=",
"matchobj",
".",
"group",
"(",
"1",
")",
"if",
"name",
"in",
"local_vars",
":",
"return",
"local_vars",
"[",
"name",
"]",
"elif"... | [
130,
0
] | [
143,
41
] | python | en | ['en', 'en', 'en'] | True |
_parse_makefile | (filename, vars=None) | Parse a Makefile-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
| Parse a Makefile-style file. | def _parse_makefile(filename, vars=None):
"""Parse a Makefile-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
"""
# Regexes needed for parsing Makefile (and similar syntaxes... | [
"def",
"_parse_makefile",
"(",
"filename",
",",
"vars",
"=",
"None",
")",
":",
"# Regexes needed for parsing Makefile (and similar syntaxes,",
"# like old-style Setup files).",
"_variable_rx",
"=",
"re",
".",
"compile",
"(",
"r\"([a-zA-Z][a-zA-Z0-9_]+)\\s*=\\s*(.*)\"",
")",
"... | [
212,
0
] | [
327,
15
] | python | en | ['en', 'en', 'en'] | True |
get_makefile_filename | () | Return the path of the Makefile. | Return the path of the Makefile. | def get_makefile_filename():
"""Return the path of the Makefile."""
if _PYTHON_BUILD:
return os.path.join(_PROJECT_BASE, "Makefile")
if hasattr(sys, 'abiflags'):
config_dir_name = 'config-%s%s' % (_PY_VERSION_SHORT, sys.abiflags)
else:
config_dir_name = 'config'
return os.pat... | [
"def",
"get_makefile_filename",
"(",
")",
":",
"if",
"_PYTHON_BUILD",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"_PROJECT_BASE",
",",
"\"Makefile\"",
")",
"if",
"hasattr",
"(",
"sys",
",",
"'abiflags'",
")",
":",
"config_dir_name",
"=",
"'config-%s... | [
330,
0
] | [
338,
72
] | python | en | ['en', 'en', 'en'] | True |
_init_posix | (vars) | Initialize the module as appropriate for POSIX systems. | Initialize the module as appropriate for POSIX systems. | def _init_posix(vars):
"""Initialize the module as appropriate for POSIX systems."""
# load the installed Makefile:
makefile = get_makefile_filename()
try:
_parse_makefile(makefile, vars)
except IOError as e:
msg = "invalid Python installation: unable to open %s" % makefile
i... | [
"def",
"_init_posix",
"(",
"vars",
")",
":",
"# load the installed Makefile:",
"makefile",
"=",
"get_makefile_filename",
"(",
")",
"try",
":",
"_parse_makefile",
"(",
"makefile",
",",
"vars",
")",
"except",
"IOError",
"as",
"e",
":",
"msg",
"=",
"\"invalid Pytho... | [
341,
0
] | [
366,
44
] | python | en | ['en', 'en', 'en'] | True |
_init_non_posix | (vars) | Initialize the module as appropriate for NT | Initialize the module as appropriate for NT | def _init_non_posix(vars):
"""Initialize the module as appropriate for NT"""
# set basic install directories
vars['LIBDEST'] = get_path('stdlib')
vars['BINLIBDEST'] = get_path('platstdlib')
vars['INCLUDEPY'] = get_path('include')
vars['SO'] = '.pyd'
vars['EXE'] = '.exe'
vars['VERSION'] =... | [
"def",
"_init_non_posix",
"(",
"vars",
")",
":",
"# set basic install directories",
"vars",
"[",
"'LIBDEST'",
"]",
"=",
"get_path",
"(",
"'stdlib'",
")",
"vars",
"[",
"'BINLIBDEST'",
"]",
"=",
"get_path",
"(",
"'platstdlib'",
")",
"vars",
"[",
"'INCLUDEPY'",
"... | [
369,
0
] | [
378,
68
] | python | en | ['en', 'en', 'en'] | True |
parse_config_h | (fp, vars=None) | Parse a config.h-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
| Parse a config.h-style file. | def parse_config_h(fp, vars=None):
"""Parse a config.h-style file.
A dictionary containing name/value pairs is returned. If an
optional dictionary is passed in as the second argument, it is
used instead of a new dictionary.
"""
if vars is None:
vars = {}
define_rx = re.compile("#de... | [
"def",
"parse_config_h",
"(",
"fp",
",",
"vars",
"=",
"None",
")",
":",
"if",
"vars",
"is",
"None",
":",
"vars",
"=",
"{",
"}",
"define_rx",
"=",
"re",
".",
"compile",
"(",
"\"#define ([A-Z][A-Za-z0-9_]+) (.*)\\n\"",
")",
"undef_rx",
"=",
"re",
".",
"com... | [
385,
0
] | [
413,
15
] | python | en | ['es', 'en', 'en'] | True |
get_config_h_filename | () | Return the path of pyconfig.h. | Return the path of pyconfig.h. | def get_config_h_filename():
"""Return the path of pyconfig.h."""
if _PYTHON_BUILD:
if os.name == "nt":
inc_dir = os.path.join(_PROJECT_BASE, "PC")
else:
inc_dir = _PROJECT_BASE
else:
inc_dir = get_path('platinclude')
return os.path.join(inc_dir, 'pyconfig... | [
"def",
"get_config_h_filename",
"(",
")",
":",
"if",
"_PYTHON_BUILD",
":",
"if",
"os",
".",
"name",
"==",
"\"nt\"",
":",
"inc_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_PROJECT_BASE",
",",
"\"PC\"",
")",
"else",
":",
"inc_dir",
"=",
"_PROJECT_BASE... | [
416,
0
] | [
425,
46
] | python | en | ['en', 'en', 'en'] | True |
get_scheme_names | () | Return a tuple containing the schemes names. | Return a tuple containing the schemes names. | def get_scheme_names():
"""Return a tuple containing the schemes names."""
return tuple(sorted(_SCHEMES.sections())) | [
"def",
"get_scheme_names",
"(",
")",
":",
"return",
"tuple",
"(",
"sorted",
"(",
"_SCHEMES",
".",
"sections",
"(",
")",
")",
")"
] | [
428,
0
] | [
430,
45
] | python | en | ['en', 'en', 'en'] | True |
get_path_names | () | Return a tuple containing the paths names. | Return a tuple containing the paths names. | def get_path_names():
"""Return a tuple containing the paths names."""
# xxx see if we want a static list
return _SCHEMES.options('posix_prefix') | [
"def",
"get_path_names",
"(",
")",
":",
"# xxx see if we want a static list",
"return",
"_SCHEMES",
".",
"options",
"(",
"'posix_prefix'",
")"
] | [
433,
0
] | [
436,
43
] | python | en | ['en', 'en', 'en'] | True |
get_paths | (scheme=_get_default_scheme(), vars=None, expand=True) | Return a mapping containing an install scheme.
``scheme`` is the install scheme name. If not provided, it will
return the default scheme for the current platform.
| Return a mapping containing an install scheme. | def get_paths(scheme=_get_default_scheme(), vars=None, expand=True):
"""Return a mapping containing an install scheme.
``scheme`` is the install scheme name. If not provided, it will
return the default scheme for the current platform.
"""
_ensure_cfg_read()
if expand:
return _expand_var... | [
"def",
"get_paths",
"(",
"scheme",
"=",
"_get_default_scheme",
"(",
")",
",",
"vars",
"=",
"None",
",",
"expand",
"=",
"True",
")",
":",
"_ensure_cfg_read",
"(",
")",
"if",
"expand",
":",
"return",
"_expand_vars",
"(",
"scheme",
",",
"vars",
")",
"else",... | [
439,
0
] | [
449,
43
] | python | en | ['en', 'en', 'en'] | True |
get_path | (name, scheme=_get_default_scheme(), vars=None, expand=True) | Return a path corresponding to the scheme.
``scheme`` is the install scheme name.
| Return a path corresponding to the scheme. | def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True):
"""Return a path corresponding to the scheme.
``scheme`` is the install scheme name.
"""
return get_paths(scheme, vars, expand)[name] | [
"def",
"get_path",
"(",
"name",
",",
"scheme",
"=",
"_get_default_scheme",
"(",
")",
",",
"vars",
"=",
"None",
",",
"expand",
"=",
"True",
")",
":",
"return",
"get_paths",
"(",
"scheme",
",",
"vars",
",",
"expand",
")",
"[",
"name",
"]"
] | [
452,
0
] | [
457,
48
] | python | en | ['en', 'el-Latn', 'en'] | True |
get_config_vars | (*args) | With no arguments, return a dictionary of all configuration
variables relevant for the current platform.
On Unix, this means every variable defined in Python's installed Makefile;
On Windows and Mac OS it's a much smaller set.
With arguments, return a list of values that result from looking up
eac... | With no arguments, return a dictionary of all configuration
variables relevant for the current platform. | def get_config_vars(*args):
"""With no arguments, return a dictionary of all configuration
variables relevant for the current platform.
On Unix, this means every variable defined in Python's installed Makefile;
On Windows and Mac OS it's a much smaller set.
With arguments, return a list of values ... | [
"def",
"get_config_vars",
"(",
"*",
"args",
")",
":",
"global",
"_CONFIG_VARS",
"if",
"_CONFIG_VARS",
"is",
"None",
":",
"_CONFIG_VARS",
"=",
"{",
"}",
"# Normalized versions of prefix and exec_prefix are handy to have;",
"# in fact, these are the standard versions used most pl... | [
460,
0
] | [
588,
27
] | python | en | ['en', 'en', 'en'] | True |
get_config_var | (name) | Return the value of a single variable using the dictionary returned by
'get_config_vars()'.
Equivalent to get_config_vars().get(name)
| Return the value of a single variable using the dictionary returned by
'get_config_vars()'. | def get_config_var(name):
"""Return the value of a single variable using the dictionary returned by
'get_config_vars()'.
Equivalent to get_config_vars().get(name)
"""
return get_config_vars().get(name) | [
"def",
"get_config_var",
"(",
"name",
")",
":",
"return",
"get_config_vars",
"(",
")",
".",
"get",
"(",
"name",
")"
] | [
591,
0
] | [
597,
38
] | python | en | ['en', 'en', 'en'] | True |
get_platform | () | Return a string that identifies the current platform.
This is used mainly to distinguish platform-specific build directories and
platform-specific built distributions. Typically includes the OS name
and version and the architecture (as supplied by 'os.uname()'),
although the exact information included... | Return a string that identifies the current platform. | def get_platform():
"""Return a string that identifies the current platform.
This is used mainly to distinguish platform-specific build directories and
platform-specific built distributions. Typically includes the OS name
and version and the architecture (as supplied by 'os.uname()'),
although the... | [
"def",
"get_platform",
"(",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"# sniff sys.version for architecture.",
"prefix",
"=",
"\" bit (\"",
"i",
"=",
"sys",
".",
"version",
".",
"find",
"(",
"prefix",
")",
"if",
"i",
"==",
"-",
"1",
":",
"r... | [
600,
0
] | [
759,
50
] | python | en | ['en', 'en', 'en'] | True |
_main | () | Display all information sysconfig detains. | Display all information sysconfig detains. | def _main():
"""Display all information sysconfig detains."""
print('Platform: "%s"' % get_platform())
print('Python version: "%s"' % get_python_version())
print('Current installation scheme: "%s"' % _get_default_scheme())
print()
_print_dict('Paths', get_paths())
print()
_print_dict('Va... | [
"def",
"_main",
"(",
")",
":",
"print",
"(",
"'Platform: \"%s\"'",
"%",
"get_platform",
"(",
")",
")",
"print",
"(",
"'Python version: \"%s\"'",
"%",
"get_python_version",
"(",
")",
")",
"print",
"(",
"'Current installation scheme: \"%s\"'",
"%",
"_get_default_schem... | [
773,
0
] | [
781,
47
] | python | en | ['en', 'en', 'en'] | True |
show_formats | () | Print all possible values for the 'formats' option (used by
the "--help-formats" command-line option).
| Print all possible values for the 'formats' option (used by
the "--help-formats" command-line option).
| def show_formats():
"""Print all possible values for the 'formats' option (used by
the "--help-formats" command-line option).
"""
from distutils.fancy_getopt import FancyGetopt
from distutils.archive_util import ARCHIVE_FORMATS
formats = []
for format in ARCHIVE_FORMATS.keys():
forma... | [
"def",
"show_formats",
"(",
")",
":",
"from",
"distutils",
".",
"fancy_getopt",
"import",
"FancyGetopt",
"from",
"distutils",
".",
"archive_util",
"import",
"ARCHIVE_FORMATS",
"formats",
"=",
"[",
"]",
"for",
"format",
"in",
"ARCHIVE_FORMATS",
".",
"keys",
"(",
... | [
20,
0
] | [
32,
57
] | python | en | ['en', 'en', 'en'] | True |
sdist.checking_metadata | (self) | Callable used for the check sub-command.
Placed here so user_options can view it | Callable used for the check sub-command. | def checking_metadata(self):
"""Callable used for the check sub-command.
Placed here so user_options can view it"""
return self.metadata_check | [
"def",
"checking_metadata",
"(",
"self",
")",
":",
"return",
"self",
".",
"metadata_check"
] | [
39,
4
] | [
43,
34
] | python | en | ['en', 'en', 'en'] | True |
sdist.check_metadata | (self) | Deprecated API. | Deprecated API. | def check_metadata(self):
"""Deprecated API."""
warn("distutils.command.sdist.check_metadata is deprecated, \
use the check command instead", PendingDeprecationWarning)
check = self.distribution.get_command_obj('check')
check.ensure_finalized()
check.run() | [
"def",
"check_metadata",
"(",
"self",
")",
":",
"warn",
"(",
"\"distutils.command.sdist.check_metadata is deprecated, \\\n use the check command instead\"",
",",
"PendingDeprecationWarning",
")",
"check",
"=",
"self",
".",
"distribution",
".",
"get_command_obj",
"(... | [
161,
4
] | [
167,
19
] | python | en | ['en', 'pt', 'en'] | False |
sdist.get_file_list | (self) | Figure out the list of files to include in the source
distribution, and put it in 'self.filelist'. This might involve
reading the manifest template (and writing the manifest), or just
reading the manifest, or just using the default file set -- it all
depends on the user's options.
... | Figure out the list of files to include in the source
distribution, and put it in 'self.filelist'. This might involve
reading the manifest template (and writing the manifest), or just
reading the manifest, or just using the default file set -- it all
depends on the user's options.
... | def get_file_list(self):
"""Figure out the list of files to include in the source
distribution, and put it in 'self.filelist'. This might involve
reading the manifest template (and writing the manifest), or just
reading the manifest, or just using the default file set -- it all
... | [
"def",
"get_file_list",
"(",
"self",
")",
":",
"# new behavior when using a template:",
"# the file list is recalculated every time because",
"# even if MANIFEST.in or setup.py are not changed",
"# the user might have added some files in the tree that",
"# need to be included.",
"#",
"# Thi... | [
169,
4
] | [
207,
29
] | python | en | ['en', 'en', 'en'] | True |
sdist.add_defaults | (self) | Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_files.
- all files defined as... | Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_files.
- all files defined as... | def add_defaults(self):
"""Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_file... | [
"def",
"add_defaults",
"(",
"self",
")",
":",
"self",
".",
"_add_defaults_standards",
"(",
")",
"self",
".",
"_add_defaults_optional",
"(",
")",
"self",
".",
"_add_defaults_python",
"(",
")",
"self",
".",
"_add_defaults_data_files",
"(",
")",
"self",
".",
"_ad... | [
209,
4
] | [
229,
36
] | python | en | ['en', 'en', 'en'] | True |
sdist._cs_path_exists | (fspath) |
Case-sensitive path existence check
>>> sdist._cs_path_exists(__file__)
True
>>> sdist._cs_path_exists(__file__.upper())
False
|
Case-sensitive path existence check | def _cs_path_exists(fspath):
"""
Case-sensitive path existence check
>>> sdist._cs_path_exists(__file__)
True
>>> sdist._cs_path_exists(__file__.upper())
False
"""
if not os.path.exists(fspath):
return False
# make absolute so we alway... | [
"def",
"_cs_path_exists",
"(",
"fspath",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fspath",
")",
":",
"return",
"False",
"# make absolute so we always have a directory",
"abspath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"fspath",
"... | [
232,
4
] | [
246,
48
] | python | en | ['en', 'error', 'th'] | False |
sdist.read_template | (self) | Read and parse manifest template file named by self.template.
(usually "MANIFEST.in") The parsing and processing is done by
'self.filelist', which updates itself accordingly.
| Read and parse manifest template file named by self.template. | def read_template(self):
"""Read and parse manifest template file named by self.template.
(usually "MANIFEST.in") The parsing and processing is done by
'self.filelist', which updates itself accordingly.
"""
log.info("reading manifest template '%s'", self.template)
templa... | [
"def",
"read_template",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"reading manifest template '%s'\"",
",",
"self",
".",
"template",
")",
"template",
"=",
"TextFile",
"(",
"self",
".",
"template",
",",
"strip_comments",
"=",
"1",
",",
"skip_blanks",
"... | [
323,
4
] | [
350,
28
] | python | en | ['en', 'en', 'en'] | True |
sdist.prune_file_list | (self) | Prune off branches that might slip into the file list as created
by 'read_template()', but really don't belong there:
* the build tree (typically "build")
* the release tree itself (only an issue if we ran "sdist"
previously with --keep-temp, or it aborted)
* any RCS, C... | Prune off branches that might slip into the file list as created
by 'read_template()', but really don't belong there:
* the build tree (typically "build")
* the release tree itself (only an issue if we ran "sdist"
previously with --keep-temp, or it aborted)
* any RCS, C... | def prune_file_list(self):
"""Prune off branches that might slip into the file list as created
by 'read_template()', but really don't belong there:
* the build tree (typically "build")
* the release tree itself (only an issue if we ran "sdist"
previously with --keep-temp,... | [
"def",
"prune_file_list",
"(",
"self",
")",
":",
"build",
"=",
"self",
".",
"get_finalized_command",
"(",
"'build'",
")",
"base_dir",
"=",
"self",
".",
"distribution",
".",
"get_fullname",
"(",
")",
"self",
".",
"filelist",
".",
"exclude_pattern",
"(",
"None... | [
352,
4
] | [
374,
59
] | python | en | ['en', 'en', 'en'] | True |
sdist.write_manifest | (self) | Write the file list in 'self.filelist' (presumably as filled in
by 'add_defaults()' and 'read_template()') to the manifest file
named by 'self.manifest'.
| Write the file list in 'self.filelist' (presumably as filled in
by 'add_defaults()' and 'read_template()') to the manifest file
named by 'self.manifest'.
| def write_manifest(self):
"""Write the file list in 'self.filelist' (presumably as filled in
by 'add_defaults()' and 'read_template()') to the manifest file
named by 'self.manifest'.
"""
if self._manifest_is_not_generated():
log.info("not writing to manually maintaine... | [
"def",
"write_manifest",
"(",
"self",
")",
":",
"if",
"self",
".",
"_manifest_is_not_generated",
"(",
")",
":",
"log",
".",
"info",
"(",
"\"not writing to manually maintained \"",
"\"manifest file '%s'\"",
"%",
"self",
".",
"manifest",
")",
"return",
"content",
"=... | [
376,
4
] | [
389,
66
] | python | en | ['en', 'en', 'en'] | True |
sdist.read_manifest | (self) | Read the manifest file (named by 'self.manifest') and use it to
fill in 'self.filelist', the list of files to include in the source
distribution.
| Read the manifest file (named by 'self.manifest') and use it to
fill in 'self.filelist', the list of files to include in the source
distribution.
| def read_manifest(self):
"""Read the manifest file (named by 'self.manifest') and use it to
fill in 'self.filelist', the list of files to include in the source
distribution.
"""
log.info("reading manifest file '%s'", self.manifest)
with open(self.manifest) as manifest:
... | [
"def",
"read_manifest",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"reading manifest file '%s'\"",
",",
"self",
".",
"manifest",
")",
"with",
"open",
"(",
"self",
".",
"manifest",
")",
"as",
"manifest",
":",
"for",
"line",
"in",
"manifest",
":",
"... | [
403,
4
] | [
415,
42
] | python | en | ['en', 'en', 'en'] | True |
sdist.make_release_tree | (self, base_dir, files) | Create the directory tree that will become the source
distribution archive. All directories implied by the filenames in
'files' are created under 'base_dir', and then we hard link or copy
(if hard linking is unavailable) those files into place.
Essentially, this duplicates the developer... | Create the directory tree that will become the source
distribution archive. All directories implied by the filenames in
'files' are created under 'base_dir', and then we hard link or copy
(if hard linking is unavailable) those files into place.
Essentially, this duplicates the developer... | def make_release_tree(self, base_dir, files):
"""Create the directory tree that will become the source
distribution archive. All directories implied by the filenames in
'files' are created under 'base_dir', and then we hard link or copy
(if hard linking is unavailable) those files into ... | [
"def",
"make_release_tree",
"(",
"self",
",",
"base_dir",
",",
"files",
")",
":",
"# Create all the directories under 'base_dir' necessary to",
"# put 'files' there; the 'mkpath()' is just so we don't die",
"# if the manifest happens to be empty.",
"self",
".",
"mkpath",
"(",
"base... | [
417,
4
] | [
457,
59
] | python | en | ['en', 'en', 'en'] | True |
sdist.make_distribution | (self) | Create the source distribution(s). First, we create the release
tree with 'make_release_tree()'; then, we create all required
archive files (according to 'self.formats') from the release tree.
Finally, we clean up by blowing away the release tree (unless
'self.keep_temp' is true). The ... | Create the source distribution(s). First, we create the release
tree with 'make_release_tree()'; then, we create all required
archive files (according to 'self.formats') from the release tree.
Finally, we clean up by blowing away the release tree (unless
'self.keep_temp' is true). The ... | def make_distribution(self):
"""Create the source distribution(s). First, we create the release
tree with 'make_release_tree()'; then, we create all required
archive files (according to 'self.formats') from the release tree.
Finally, we clean up by blowing away the release tree (unless
... | [
"def",
"make_distribution",
"(",
"self",
")",
":",
"# Don't warn about missing meta-data here -- should be (and is!)",
"# done elsewhere.",
"base_dir",
"=",
"self",
".",
"distribution",
".",
"get_fullname",
"(",
")",
"base_name",
"=",
"os",
".",
"path",
".",
"join",
"... | [
459,
4
] | [
487,
64
] | python | en | ['en', 'en', 'en'] | True |
sdist.get_archive_files | (self) | Return the list of archive files created when the command
was run, or None if the command hasn't run yet.
| Return the list of archive files created when the command
was run, or None if the command hasn't run yet.
| def get_archive_files(self):
"""Return the list of archive files created when the command
was run, or None if the command hasn't run yet.
"""
return self.archive_files | [
"def",
"get_archive_files",
"(",
"self",
")",
":",
"return",
"self",
".",
"archive_files"
] | [
489,
4
] | [
493,
33
] | python | en | ['en', 'en', 'en'] | True |
mark_all_messages_as_read | () |
We want to keep these two flags intact after we
create messages:
has_alert_word
is_private
But we will mark all messages as read to save a step for users.
|
We want to keep these two flags intact after we
create messages: | def mark_all_messages_as_read() -> None:
"""
We want to keep these two flags intact after we
create messages:
has_alert_word
is_private
But we will mark all messages as read to save a step for users.
"""
# Mark all messages as read
UserMessage.objects.all().update(
... | [
"def",
"mark_all_messages_as_read",
"(",
")",
"->",
"None",
":",
"# Mark all messages as read",
"UserMessage",
".",
"objects",
".",
"all",
"(",
")",
".",
"update",
"(",
"flags",
"=",
"F",
"(",
"\"flags\"",
")",
".",
"bitor",
"(",
"UserMessage",
".",
"flags",... | [
890,
0
] | [
903,
5
] | python | en | ['en', 'error', 'th'] | False |
test_marked_class_run_twice | (testdir, request) | Test fails file is run twice that contains marked class.
See issue#683.
| Test fails file is run twice that contains marked class.
See issue#683.
| def test_marked_class_run_twice(testdir, request):
"""Test fails file is run twice that contains marked class.
See issue#683.
"""
py_file = testdir.makepyfile("""
import pytest
@pytest.mark.parametrize('abc', [1, 2, 3])
class Test1(object):
def test_1(self, abc):
assert a... | [
"def",
"test_marked_class_run_twice",
"(",
"testdir",
",",
"request",
")",
":",
"py_file",
"=",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n import pytest\n @pytest.mark.parametrize('abc', [1, 2, 3])\n class Test1(object):\n def test_1(self, abc):\n assert abc ... | [
125,
0
] | [
138,
31
] | python | en | ['en', 'en', 'en'] | True |
test_parametrized_collected_from_command_line | (testdir) | Parametrized test not collected if test named specified
in command line issue#649.
| Parametrized test not collected if test named specified
in command line issue#649.
| def test_parametrized_collected_from_command_line(testdir):
"""Parametrized test not collected if test named specified
in command line issue#649.
"""
py_file = testdir.makepyfile("""
import pytest
@pytest.mark.parametrize("arg", [None, 1.3, "2-3"])
def test_func(arg):
... | [
"def",
"test_parametrized_collected_from_command_line",
"(",
"testdir",
")",
":",
"py_file",
"=",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n import pytest\n @pytest.mark.parametrize(\"arg\", [None, 1.3, \"2-3\"])\n def test_func(arg):\n pass\n \"\"\"",
... | [
364,
0
] | [
376,
31
] | python | en | ['en', 'en', 'en'] | True |
test_parametrized_collect_with_wrong_args | (testdir) | Test collect parametrized func with wrong number of args. | Test collect parametrized func with wrong number of args. | def test_parametrized_collect_with_wrong_args(testdir):
"""Test collect parametrized func with wrong number of args."""
py_file = testdir.makepyfile("""
import pytest
@pytest.mark.parametrize('foo, bar', [(1, 2, 3)])
def test_func(foo, bar):
pass
""")
result = testd... | [
"def",
"test_parametrized_collect_with_wrong_args",
"(",
"testdir",
")",
":",
"py_file",
"=",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n import pytest\n\n @pytest.mark.parametrize('foo, bar', [(1, 2, 3)])\n def test_func(foo, bar):\n pass\n \"\"\"",
")"... | [
379,
0
] | [
393,
6
] | python | en | ['en', 'en', 'en'] | True |
test_parametrized_with_kwargs | (testdir) | Test collect parametrized func with wrong number of args. | Test collect parametrized func with wrong number of args. | def test_parametrized_with_kwargs(testdir):
"""Test collect parametrized func with wrong number of args."""
py_file = testdir.makepyfile("""
import pytest
@pytest.fixture(params=[1,2])
def a(request):
return request.param
@pytest.mark.parametrize(argnames='b', argva... | [
"def",
"test_parametrized_with_kwargs",
"(",
"testdir",
")",
":",
"py_file",
"=",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n import pytest\n\n @pytest.fixture(params=[1,2])\n def a(request):\n return request.param\n\n @pytest.mark.parametrize(argnames... | [
396,
0
] | [
411,
27
] | python | en | ['en', 'en', 'en'] | True |
TestFunctional.assert_markers | (self, items, **expected) | assert that given items have expected marker names applied to them.
expected should be a dict of (item name -> seq of expected marker names)
.. note:: this could be moved to ``testdir`` if proven to be useful
to other modules.
| assert that given items have expected marker names applied to them.
expected should be a dict of (item name -> seq of expected marker names) | def assert_markers(self, items, **expected):
"""assert that given items have expected marker names applied to them.
expected should be a dict of (item name -> seq of expected marker names)
.. note:: this could be moved to ``testdir`` if proven to be useful
to other modules.
"""
... | [
"def",
"assert_markers",
"(",
"self",
",",
"items",
",",
"*",
"*",
"expected",
")",
":",
"from",
"_pytest",
".",
"mark",
"import",
"MarkInfo",
"items",
"=",
"dict",
"(",
"(",
"x",
".",
"name",
",",
"x",
")",
"for",
"x",
"in",
"items",
")",
"for",
... | [
702,
4
] | [
715,
56
] | python | en | ['en', 'en', 'en'] | True |
TestKeywordSelection.test_no_magic_values | (self, testdir) | Make sure the tests do not match on magic values,
no double underscored values, like '__dict__',
and no instance values, like '()'.
| Make sure the tests do not match on magic values,
no double underscored values, like '__dict__',
and no instance values, like '()'.
| def test_no_magic_values(self, testdir):
"""Make sure the tests do not match on magic values,
no double underscored values, like '__dict__',
and no instance values, like '()'.
"""
p = testdir.makepyfile("""
def test_one(): assert 1
""")
def assert_tes... | [
"def",
"test_no_magic_values",
"(",
"self",
",",
"testdir",
")",
":",
"p",
"=",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n def test_one(): assert 1\n \"\"\"",
")",
"def",
"assert_test_is_not_selected",
"(",
"keyword",
")",
":",
"reprec",
"=",
"test... | [
830,
4
] | [
848,
41
] | python | en | ['en', 'en', 'en'] | True |
seed_everything | (seed=12) |
seed randoms for all libraries
|
seed randoms for all libraries
| def seed_everything(seed=12):
'''
seed randoms for all libraries
'''
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic ... | [
"def",
"seed_everything",
"(",
"seed",
"=",
"12",
")",
":",
"random",
".",
"seed",
"(",
"seed",
")",
"np",
".",
"random",
".",
"seed",
"(",
"seed",
")",
"torch",
".",
"manual_seed",
"(",
"seed",
")",
"torch",
".",
"cuda",
".",
"manual_seed_all",
"(",... | [
44,
0
] | [
54,
45
] | python | en | ['en', 'error', 'th'] | False |
create_new_paste | (contents) |
Creates a new paste using bpaste.net service.
:contents: paste contents as utf-8 encoded bytes
:returns: url to the pasted contents
|
Creates a new paste using bpaste.net service. | def create_new_paste(contents):
"""
Creates a new paste using bpaste.net service.
:contents: paste contents as utf-8 encoded bytes
:returns: url to the pasted contents
"""
import re
if sys.version_info < (3, 0):
from urllib import urlopen, urlencode
else:
from urllib.req... | [
"def",
"create_new_paste",
"(",
"contents",
")",
":",
"import",
"re",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"0",
")",
":",
"from",
"urllib",
"import",
"urlopen",
",",
"urlencode",
"else",
":",
"from",
"urllib",
".",
"request",
"import",
... | [
54,
0
] | [
79,
42
] | python | en | ['en', 'error', 'th'] | False |
VizdoomEnv.step | (self, actions) |
Action is either a single value (discrete, one-hot), or a tuple with an action for each of the
discrete action subspaces.
|
Action is either a single value (discrete, one-hot), or a tuple with an action for each of the
discrete action subspaces.
| def step(self, actions):
"""
Action is either a single value (discrete, one-hot), or a tuple with an action for each of the
discrete action subspaces.
"""
action = actions.item()
obs, rew, done, info = self.env.step(action)
# print('Obs shape as returned by the en... | [
"def",
"step",
"(",
"self",
",",
"actions",
")",
":",
"action",
"=",
"actions",
".",
"item",
"(",
")",
"obs",
",",
"rew",
",",
"done",
",",
"info",
"=",
"self",
".",
"env",
".",
"step",
"(",
"action",
")",
"# print('Obs shape as returned by the env:', ob... | [
89,
4
] | [
98,
49
] | python | en | ['en', 'error', 'th'] | False |
DoomLstmModel.forward | (self, image, prev_action, prev_reward, init_rnn_state) | Feedforward layers process as [T*B,H], recurrent ones as [T,B,H].
Return same leading dims as input, can be [T,B], [B], or [].
(Same forward used for sampling and training.) | Feedforward layers process as [T*B,H], recurrent ones as [T,B,H].
Return same leading dims as input, can be [T,B], [B], or [].
(Same forward used for sampling and training.) | def forward(self, image, prev_action, prev_reward, init_rnn_state):
"""Feedforward layers process as [T*B,H], recurrent ones as [T,B,H].
Return same leading dims as input, can be [T,B], [B], or [].
(Same forward used for sampling and training.)"""
img = image.type(torch.float) # Expect... | [
"def",
"forward",
"(",
"self",
",",
"image",
",",
"prev_action",
",",
"prev_reward",
",",
"init_rnn_state",
")",
":",
"img",
"=",
"image",
".",
"type",
"(",
"torch",
".",
"float",
")",
"# Expect doom_torch.uint8 inputs",
"img",
"=",
"img",
".",
"mul_",
"("... | [
137,
4
] | [
165,
36
] | python | en | ['en', 'en', 'en'] | True |
reset_with_info | (env) | Sometimes we want to get info with the very first frame. | Sometimes we want to get info with the very first frame. | def reset_with_info(env):
"""Sometimes we want to get info with the very first frame."""
obs = env.reset()
info = {}
if hasattr(env.unwrapped, 'get_info_all'):
info = env.unwrapped.get_info_all() # info for the new episode
return obs, info | [
"def",
"reset_with_info",
"(",
"env",
")",
":",
"obs",
"=",
"env",
".",
"reset",
"(",
")",
"info",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"env",
".",
"unwrapped",
",",
"'get_info_all'",
")",
":",
"info",
"=",
"env",
".",
"unwrapped",
".",
"get_info_all... | [
20,
0
] | [
26,
20
] | python | en | ['en', 'en', 'en'] | True |
has_image_observations | (observation_space) | It's a heuristic. | It's a heuristic. | def has_image_observations(observation_space):
"""It's a heuristic."""
return len(observation_space.shape) >= 2 | [
"def",
"has_image_observations",
"(",
"observation_space",
")",
":",
"return",
"len",
"(",
"observation_space",
".",
"shape",
")",
">=",
"2"
] | [
52,
0
] | [
54,
44
] | python | en | ['en', 'en', 'en'] | True |
Timeout._validate_timeout | (cls, value, name) | Check that a timeout attribute is valid.
:param value: The timeout value to validate
:param name: The name of the timeout attribute to validate. This is
used to specify in error messages.
:return: The validated and casted version of the given value.
:raises ValueError: If i... | Check that a timeout attribute is valid. | def _validate_timeout(cls, value, name):
""" Check that a timeout attribute is valid.
:param value: The timeout value to validate
:param name: The name of the timeout attribute to validate. This is
used to specify in error messages.
:return: The validated and casted version ... | [
"def",
"_validate_timeout",
"(",
"cls",
",",
"value",
",",
"name",
")",
":",
"if",
"value",
"is",
"_Default",
":",
"return",
"cls",
".",
"DEFAULT_TIMEOUT",
"if",
"value",
"is",
"None",
"or",
"value",
"is",
"cls",
".",
"DEFAULT_TIMEOUT",
":",
"return",
"v... | [
112,
4
] | [
155,
20
] | python | en | ['en', 'en', 'en'] | True |
Timeout.from_float | (cls, timeout) | Create a new Timeout from a legacy timeout value.
The timeout value used by httplib.py sets the same timeout on the
connect(), and recv() socket requests. This creates a :class:`Timeout`
object that sets the individual timeouts to the ``timeout`` value
passed to this function.
... | Create a new Timeout from a legacy timeout value. | def from_float(cls, timeout):
""" Create a new Timeout from a legacy timeout value.
The timeout value used by httplib.py sets the same timeout on the
connect(), and recv() socket requests. This creates a :class:`Timeout`
object that sets the individual timeouts to the ``timeout`` value
... | [
"def",
"from_float",
"(",
"cls",
",",
"timeout",
")",
":",
"return",
"Timeout",
"(",
"read",
"=",
"timeout",
",",
"connect",
"=",
"timeout",
")"
] | [
158,
4
] | [
171,
53
] | python | en | ['en', 'en', 'en'] | True |
Timeout.clone | (self) | Create a copy of the timeout object
Timeout properties are stored per-pool but each request needs a fresh
Timeout object to ensure each one has its own start/stop configured.
:return: a copy of the timeout object
:rtype: :class:`Timeout`
| Create a copy of the timeout object | def clone(self):
""" Create a copy of the timeout object
Timeout properties are stored per-pool but each request needs a fresh
Timeout object to ensure each one has its own start/stop configured.
:return: a copy of the timeout object
:rtype: :class:`Timeout`
"""
... | [
"def",
"clone",
"(",
"self",
")",
":",
"# We can't use copy.deepcopy because that will also create a new object",
"# for _GLOBAL_DEFAULT_TIMEOUT, which socket.py uses as a sentinel to",
"# detect the user default.",
"return",
"Timeout",
"(",
"connect",
"=",
"self",
".",
"_connect",
... | [
173,
4
] | [
185,
80
] | python | en | ['en', 'en', 'en'] | True |
Timeout.start_connect | (self) | Start the timeout clock, used during a connect() attempt
:raises urllib3.exceptions.TimeoutStateError: if you attempt
to start a timer that has been started already.
| Start the timeout clock, used during a connect() attempt | def start_connect(self):
""" Start the timeout clock, used during a connect() attempt
:raises urllib3.exceptions.TimeoutStateError: if you attempt
to start a timer that has been started already.
"""
if self._start_connect is not None:
raise TimeoutStateError("Tim... | [
"def",
"start_connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"_start_connect",
"is",
"not",
"None",
":",
"raise",
"TimeoutStateError",
"(",
"\"Timeout timer has already been started.\"",
")",
"self",
".",
"_start_connect",
"=",
"current_time",
"(",
")",
"retu... | [
187,
4
] | [
196,
34
] | python | en | ['en', 'en', 'en'] | True |
Timeout.get_connect_duration | (self) | Gets the time elapsed since the call to :meth:`start_connect`.
:return: Elapsed time in seconds.
:rtype: float
:raises urllib3.exceptions.TimeoutStateError: if you attempt
to get duration for a timer that hasn't been started.
| Gets the time elapsed since the call to :meth:`start_connect`. | def get_connect_duration(self):
""" Gets the time elapsed since the call to :meth:`start_connect`.
:return: Elapsed time in seconds.
:rtype: float
:raises urllib3.exceptions.TimeoutStateError: if you attempt
to get duration for a timer that hasn't been started.
"""
... | [
"def",
"get_connect_duration",
"(",
"self",
")",
":",
"if",
"self",
".",
"_start_connect",
"is",
"None",
":",
"raise",
"TimeoutStateError",
"(",
"\"Can't get connect duration for timer that has not started.\"",
")",
"return",
"current_time",
"(",
")",
"-",
"self",
"."... | [
198,
4
] | [
210,
51
] | python | en | ['en', 'en', 'en'] | True |
Timeout.connect_timeout | (self) | Get the value to use when setting a connection timeout.
This will be a positive float or integer, the value None
(never timeout), or the default system timeout.
:return: Connect timeout.
:rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
| Get the value to use when setting a connection timeout. | def connect_timeout(self):
""" Get the value to use when setting a connection timeout.
This will be a positive float or integer, the value None
(never timeout), or the default system timeout.
:return: Connect timeout.
:rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
... | [
"def",
"connect_timeout",
"(",
"self",
")",
":",
"if",
"self",
".",
"total",
"is",
"None",
":",
"return",
"self",
".",
"_connect",
"if",
"self",
".",
"_connect",
"is",
"None",
"or",
"self",
".",
"_connect",
"is",
"self",
".",
"DEFAULT_TIMEOUT",
":",
"r... | [
213,
4
] | [
228,
45
] | python | en | ['en', 'en', 'en'] | True |
Timeout.read_timeout | (self) | Get the value for the read timeout.
This assumes some time has elapsed in the connection timeout and
computes the read timeout appropriately.
If self.total is set, the read timeout is dependent on the amount of
time taken by the connect timeout. If the connection time has not been
... | Get the value for the read timeout. | def read_timeout(self):
""" Get the value for the read timeout.
This assumes some time has elapsed in the connection timeout and
computes the read timeout appropriately.
If self.total is set, the read timeout is dependent on the amount of
time taken by the connect timeout. If t... | [
"def",
"read_timeout",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"total",
"is",
"not",
"None",
"and",
"self",
".",
"total",
"is",
"not",
"self",
".",
"DEFAULT_TIMEOUT",
"and",
"self",
".",
"_read",
"is",
"not",
"None",
"and",
"self",
".",
"_read... | [
231,
4
] | [
260,
29
] | python | en | ['en', 'en', 'en'] | True |
choose_boundary | () |
Our embarrassingly-simple replacement for mimetools.choose_boundary.
|
Our embarrassingly-simple replacement for mimetools.choose_boundary.
| def choose_boundary():
"""
Our embarrassingly-simple replacement for mimetools.choose_boundary.
"""
boundary = binascii.hexlify(os.urandom(16))
if not six.PY2:
boundary = boundary.decode("ascii")
return boundary | [
"def",
"choose_boundary",
"(",
")",
":",
"boundary",
"=",
"binascii",
".",
"hexlify",
"(",
"os",
".",
"urandom",
"(",
"16",
")",
")",
"if",
"not",
"six",
".",
"PY2",
":",
"boundary",
"=",
"boundary",
".",
"decode",
"(",
"\"ascii\"",
")",
"return",
"b... | [
14,
0
] | [
21,
19
] | python | en | ['en', 'error', 'th'] | False |
iter_field_objects | (fields) |
Iterate over fields.
Supports list of (k, v) tuples and dicts, and lists of
:class:`~urllib3.fields.RequestField`.
|
Iterate over fields. | def iter_field_objects(fields):
"""
Iterate over fields.
Supports list of (k, v) tuples and dicts, and lists of
:class:`~urllib3.fields.RequestField`.
"""
if isinstance(fields, dict):
i = six.iteritems(fields)
else:
i = iter(fields)
for field in i:
if isinstanc... | [
"def",
"iter_field_objects",
"(",
"fields",
")",
":",
"if",
"isinstance",
"(",
"fields",
",",
"dict",
")",
":",
"i",
"=",
"six",
".",
"iteritems",
"(",
"fields",
")",
"else",
":",
"i",
"=",
"iter",
"(",
"fields",
")",
"for",
"field",
"in",
"i",
":"... | [
24,
0
] | [
41,
50
] | python | en | ['en', 'error', 'th'] | False |
iter_fields | (fields) |
.. deprecated:: 1.6
Iterate over fields.
The addition of :class:`~urllib3.fields.RequestField` makes this function
obsolete. Instead, use :func:`iter_field_objects`, which returns
:class:`~urllib3.fields.RequestField` objects.
Supports list of (k, v) tuples and dicts.
|
.. deprecated:: 1.6 | def iter_fields(fields):
"""
.. deprecated:: 1.6
Iterate over fields.
The addition of :class:`~urllib3.fields.RequestField` makes this function
obsolete. Instead, use :func:`iter_field_objects`, which returns
:class:`~urllib3.fields.RequestField` objects.
Supports list of (k, v) tuples an... | [
"def",
"iter_fields",
"(",
"fields",
")",
":",
"if",
"isinstance",
"(",
"fields",
",",
"dict",
")",
":",
"return",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"fields",
")",
")",
"return",
"(",
"(",
"... | [
44,
0
] | [
59,
38
] | python | en | ['en', 'error', 'th'] | False |
encode_multipart_formdata | (fields, boundary=None) |
Encode a dictionary of ``fields`` using the multipart/form-data MIME format.
:param fields:
Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).
:param boundary:
If not specified, then a random boundary will be generated using
:func:`urllib3.filepost.choos... |
Encode a dictionary of ``fields`` using the multipart/form-data MIME format. | def encode_multipart_formdata(fields, boundary=None):
"""
Encode a dictionary of ``fields`` using the multipart/form-data MIME format.
:param fields:
Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).
:param boundary:
If not specified, then a random boundary ... | [
"def",
"encode_multipart_formdata",
"(",
"fields",
",",
"boundary",
"=",
"None",
")",
":",
"body",
"=",
"BytesIO",
"(",
")",
"if",
"boundary",
"is",
"None",
":",
"boundary",
"=",
"choose_boundary",
"(",
")",
"for",
"field",
"in",
"iter_field_objects",
"(",
... | [
62,
0
] | [
97,
40
] | python | en | ['en', 'error', 'th'] | False |
Paper.jeeves_restrict_paperlabel | (paper, ctxt) |
Policy for seeing author of papers.
|
Policy for seeing author of papers.
| def jeeves_restrict_paperlabel(paper, ctxt):
'''
Policy for seeing author of papers.
'''
if phase == 'final':
return True
else:
if paper == None:
return False
if PaperPCConflict.objects.get(paper=paper, pc=ctxt) != None:
... | [
"def",
"jeeves_restrict_paperlabel",
"(",
"paper",
",",
"ctxt",
")",
":",
"if",
"phase",
"==",
"'final'",
":",
"return",
"True",
"else",
":",
"if",
"paper",
"==",
"None",
":",
"return",
"False",
"if",
"PaperPCConflict",
".",
"objects",
".",
"get",
"(",
"... | [
69,
4
] | [
85,
84
] | python | en | ['en', 'error', 'th'] | False |
VendorImporter.search_path | (self) |
Search first the vendor package then as a natural package.
|
Search first the vendor package then as a natural package.
| def search_path(self):
"""
Search first the vendor package then as a natural package.
"""
yield self.vendor_pkg + '.'
yield '' | [
"def",
"search_path",
"(",
"self",
")",
":",
"yield",
"self",
".",
"vendor_pkg",
"+",
"'.'",
"yield",
"''"
] | [
15,
4
] | [
20,
16
] | python | en | ['en', 'error', 'th'] | False |
VendorImporter.find_module | (self, fullname, path=None) |
Return self when fullname starts with root_name and the
target module is one vendored through this importer.
|
Return self when fullname starts with root_name and the
target module is one vendored through this importer.
| def find_module(self, fullname, path=None):
"""
Return self when fullname starts with root_name and the
target module is one vendored through this importer.
"""
root, base, target = fullname.partition(self.root_name + '.')
if root:
return
if not any(ma... | [
"def",
"find_module",
"(",
"self",
",",
"fullname",
",",
"path",
"=",
"None",
")",
":",
"root",
",",
"base",
",",
"target",
"=",
"fullname",
".",
"partition",
"(",
"self",
".",
"root_name",
"+",
"'.'",
")",
"if",
"root",
":",
"return",
"if",
"not",
... | [
22,
4
] | [
32,
19
] | python | en | ['en', 'error', 'th'] | False |
VendorImporter.load_module | (self, fullname) |
Iterate over the search path to locate and load fullname.
|
Iterate over the search path to locate and load fullname.
| def load_module(self, fullname):
"""
Iterate over the search path to locate and load fullname.
"""
root, base, target = fullname.partition(self.root_name + '.')
for prefix in self.search_path:
try:
extant = prefix + target
__import__(ex... | [
"def",
"load_module",
"(",
"self",
",",
"fullname",
")",
":",
"root",
",",
"base",
",",
"target",
"=",
"fullname",
".",
"partition",
"(",
"self",
".",
"root_name",
"+",
"'.'",
")",
"for",
"prefix",
"in",
"self",
".",
"search_path",
":",
"try",
":",
"... | [
34,
4
] | [
54,
13
] | python | en | ['en', 'error', 'th'] | False |
VendorImporter.install | (self) |
Install this importer into sys.meta_path if not already present.
|
Install this importer into sys.meta_path if not already present.
| def install(self):
"""
Install this importer into sys.meta_path if not already present.
"""
if self not in sys.meta_path:
sys.meta_path.append(self) | [
"def",
"install",
"(",
"self",
")",
":",
"if",
"self",
"not",
"in",
"sys",
".",
"meta_path",
":",
"sys",
".",
"meta_path",
".",
"append",
"(",
"self",
")"
] | [
56,
4
] | [
61,
38
] | python | en | ['en', 'error', 'th'] | False |
KeystoneBackend.get_user | (self, user_id) | Returns the current user from the session data.
If authenticated, this return the user object based on the user ID
and session data.
.. note::
This required monkey-patching the ``contrib.auth`` middleware
to make the ``request`` object available to the auth backend class.
... | Returns the current user from the session data. | def get_user(self, user_id):
"""Returns the current user from the session data.
If authenticated, this return the user object based on the user ID
and session data.
.. note::
This required monkey-patching the ``contrib.auth`` middleware
to make the ``request`` obje... | [
"def",
"get_user",
"(",
"self",
",",
"user_id",
")",
":",
"if",
"(",
"hasattr",
"(",
"self",
",",
"'request'",
")",
"and",
"user_id",
"==",
"self",
".",
"request",
".",
"session",
"[",
"\"user_id\"",
"]",
")",
":",
"token",
"=",
"self",
".",
"request... | [
50,
4
] | [
71,
23
] | python | en | ['en', 'en', 'en'] | True |
KeystoneBackend.authenticate | (self, request, auth_url=None, auth_ref=None, **kwargs) | Authenticates a user via the Keystone Identity API. | Authenticates a user via the Keystone Identity API. | def authenticate(self, request, auth_url=None, auth_ref=None, **kwargs):
"""Authenticates a user via the Keystone Identity API."""
LOG.debug('Beginning user authentication')
if not auth_url:
auth_url = settings.OPENSTACK_KEYSTONE_URL
auth_url, url_fixed = utils.fix_auth_url... | [
"def",
"authenticate",
"(",
"self",
",",
"request",
",",
"auth_url",
"=",
"None",
",",
"auth_ref",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"'Beginning user authentication'",
")",
"if",
"not",
"auth_url",
":",
"auth_url",
... | [
97,
4
] | [
228,
19
] | python | en | ['en', 'sk', 'en'] | True |
KeystoneBackend.get_group_permissions | (self, user, obj=None) | Returns an empty set since Keystone doesn't support "groups". | Returns an empty set since Keystone doesn't support "groups". | def get_group_permissions(self, user, obj=None):
"""Returns an empty set since Keystone doesn't support "groups"."""
# Keystone V3 added "groups". The Auth token response includes the
# roles from the user's Group assignment. It should be fine just
# returning an empty set here.
... | [
"def",
"get_group_permissions",
"(",
"self",
",",
"user",
",",
"obj",
"=",
"None",
")",
":",
"# Keystone V3 added \"groups\". The Auth token response includes the",
"# roles from the user's Group assignment. It should be fine just",
"# returning an empty set here.",
"return",
"set",
... | [
230,
4
] | [
235,
20
] | python | en | ['en', 'en', 'en'] | True |
KeystoneBackend.get_all_permissions | (self, user, obj=None) | Returns a set of permission strings that the user has.
This permission available to the user is derived from the user's
Keystone "roles".
The permissions are returned as ``"openstack.{{ role.name }}"``.
| Returns a set of permission strings that the user has. | def get_all_permissions(self, user, obj=None):
"""Returns a set of permission strings that the user has.
This permission available to the user is derived from the user's
Keystone "roles".
The permissions are returned as ``"openstack.{{ role.name }}"``.
"""
if user.is_an... | [
"def",
"get_all_permissions",
"(",
"self",
",",
"user",
",",
"obj",
"=",
"None",
")",
":",
"if",
"user",
".",
"is_anonymous",
"or",
"obj",
"is",
"not",
"None",
":",
"return",
"set",
"(",
")",
"# TODO(gabrielhurley): Integrate policy-driven RBAC",
"# ... | [
237,
4
] | [
264,
41
] | python | en | ['en', 'en', 'en'] | True |
KeystoneBackend.has_perm | (self, user, perm, obj=None) | Returns True if the given user has the specified permission. | Returns True if the given user has the specified permission. | def has_perm(self, user, perm, obj=None):
"""Returns True if the given user has the specified permission."""
if not user.is_active:
return False
return perm in self.get_all_permissions(user, obj) | [
"def",
"has_perm",
"(",
"self",
",",
"user",
",",
"perm",
",",
"obj",
"=",
"None",
")",
":",
"if",
"not",
"user",
".",
"is_active",
":",
"return",
"False",
"return",
"perm",
"in",
"self",
".",
"get_all_permissions",
"(",
"user",
",",
"obj",
")"
] | [
266,
4
] | [
270,
58
] | python | en | ['en', 'en', 'en'] | True |
KeystoneBackend.has_module_perms | (self, user, app_label) | Returns True if user has any permissions in the given app_label.
Currently this matches for the app_label ``"openstack"``.
| Returns True if user has any permissions in the given app_label. | def has_module_perms(self, user, app_label):
"""Returns True if user has any permissions in the given app_label.
Currently this matches for the app_label ``"openstack"``.
"""
if not user.is_active:
return False
for perm in self.get_all_permissions(user):
... | [
"def",
"has_module_perms",
"(",
"self",
",",
"user",
",",
"app_label",
")",
":",
"if",
"not",
"user",
".",
"is_active",
":",
"return",
"False",
"for",
"perm",
"in",
"self",
".",
"get_all_permissions",
"(",
"user",
")",
":",
"if",
"perm",
"[",
":",
"per... | [
272,
4
] | [
282,
20
] | python | en | ['en', 'en', 'en'] | True |
process_message_notification | (request, messages_path) | Process all the msg file found in the message directory | Process all the msg file found in the message directory | def process_message_notification(request, messages_path):
"""Process all the msg file found in the message directory"""
if not messages_path:
return
global _MESSAGES_CACHE
global _MESSAGES_MTIME
# NOTE (lhcheng): Cache the processed messages to avoid parsing
# the files every time. Che... | [
"def",
"process_message_notification",
"(",
"request",
",",
"messages_path",
")",
":",
"if",
"not",
"messages_path",
":",
"return",
"global",
"_MESSAGES_CACHE",
"global",
"_MESSAGES_MTIME",
"# NOTE (lhcheng): Cache the processed messages to avoid parsing",
"# the files every time... | [
131,
0
] | [
148,
33
] | python | en | ['en', 'en', 'en'] | True |
JSONMessage.load | (self) | Read and parse the message file. | Read and parse the message file. | def load(self):
"""Read and parse the message file."""
try:
self._read()
self._parse()
except Exception as exc:
self.failed = True
params = {'path': self._path, 'exception': exc}
if self.fail_silently:
LOG.warning("Erro... | [
"def",
"load",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_read",
"(",
")",
"self",
".",
"_parse",
"(",
")",
"except",
"Exception",
"as",
"exc",
":",
"self",
".",
"failed",
"=",
"True",
"params",
"=",
"{",
"'path'",
":",
"self",
".",
"_path... | [
84,
4
] | [
99,
48
] | python | en | ['en', 'en', 'en'] | True |
openapi_test_function | (endpoint: str) | This decorator is used to register an OpenAPI test function with
its endpoint. Example usage:
@openapi_test_function("/messages/render:post")
def ...
| This decorator is used to register an OpenAPI test function with
its endpoint. Example usage: | def openapi_test_function(endpoint: str) -> Callable[[FuncT], FuncT]:
"""This decorator is used to register an OpenAPI test function with
its endpoint. Example usage:
@openapi_test_function("/messages/render:post")
def ...
"""
def wrapper(test_func: FuncT) -> FuncT:
@wraps(test_func)
... | [
"def",
"openapi_test_function",
"(",
"endpoint",
":",
"str",
")",
"->",
"Callable",
"[",
"[",
"FuncT",
"]",
",",
"FuncT",
"]",
":",
"def",
"wrapper",
"(",
"test_func",
":",
"FuncT",
")",
"->",
"FuncT",
":",
"@",
"wraps",
"(",
"test_func",
")",
"def",
... | [
35,
0
] | [
54,
18
] | python | en | ['en', 'en', 'en'] | True |
log_unsafe_zipfile_error | (repo_url, commit_ish) |
It is very unlikely that we will get an unsafe zipfile, as we get it
from GitHub, but must be considered.
|
It is very unlikely that we will get an unsafe zipfile, as we get it
from GitHub, but must be considered.
| def log_unsafe_zipfile_error(repo_url, commit_ish):
"""
It is very unlikely that we will get an unsafe zipfile, as we get it
from GitHub, but must be considered.
"""
url = f"{repo_url}#{commit_ish}"
logger.error(f"Malformed or malicious zip file from {url}.") | [
"def",
"log_unsafe_zipfile_error",
"(",
"repo_url",
",",
"commit_ish",
")",
":",
"url",
"=",
"f\"{repo_url}#{commit_ish}\"",
"logger",
".",
"error",
"(",
"f\"Malformed or malicious zip file from {url}.\"",
")"
] | [
86,
0
] | [
92,
64
] | python | en | ['en', 'error', 'th'] | False |
get_project_config | (**kwargs) |
Expects to be in a local_github_checkout.
|
Expects to be in a local_github_checkout.
| def get_project_config(**kwargs):
"""
Expects to be in a local_github_checkout.
"""
universal_config = MetechoUniversalConfig()
return ProjectConfig(universal_config, **kwargs) | [
"def",
"get_project_config",
"(",
"*",
"*",
"kwargs",
")",
":",
"universal_config",
"=",
"MetechoUniversalConfig",
"(",
")",
"return",
"ProjectConfig",
"(",
"universal_config",
",",
"*",
"*",
"kwargs",
")"
] | [
137,
0
] | [
142,
52
] | python | en | ['en', 'error', 'th'] | False |
get_cumulus_prefix | (**kwargs) |
Expects to be in a local_github_checkout.
|
Expects to be in a local_github_checkout.
| def get_cumulus_prefix(**kwargs):
"""
Expects to be in a local_github_checkout.
"""
project_config = get_project_config(**kwargs)
return project_config.project__git__prefix_feature | [
"def",
"get_cumulus_prefix",
"(",
"*",
"*",
"kwargs",
")",
":",
"project_config",
"=",
"get_project_config",
"(",
"*",
"*",
"kwargs",
")",
"return",
"project_config",
".",
"project__git__prefix_feature"
] | [
145,
0
] | [
150,
54
] | python | en | ['en', 'error', 'th'] | False |
get_source_format | (**kwargs) |
Expects to be in a local_github_checkout.
|
Expects to be in a local_github_checkout.
| def get_source_format(**kwargs):
"""
Expects to be in a local_github_checkout.
"""
project_config = get_project_config(**kwargs)
return project_config.project__source_format | [
"def",
"get_source_format",
"(",
"*",
"*",
"kwargs",
")",
":",
"project_config",
"=",
"get_project_config",
"(",
"*",
"*",
"kwargs",
")",
"return",
"project_config",
".",
"project__source_format"
] | [
153,
0
] | [
158,
48
] | python | en | ['en', 'error', 'th'] | False |
normalize_commit | (commit, **kwargs) |
This takes commits either in the JSON format provided by a GitHub
webhook, or the object format provided by github3.py, and returns a
normalized Python dict.
|
This takes commits either in the JSON format provided by a GitHub
webhook, or the object format provided by github3.py, and returns a
normalized Python dict.
| def normalize_commit(commit, **kwargs):
"""
This takes commits either in the JSON format provided by a GitHub
webhook, or the object format provided by github3.py, and returns a
normalized Python dict.
"""
if isinstance(commit, dict):
# If GitHub webhook payload:
sender = kwargs.... | [
"def",
"normalize_commit",
"(",
"commit",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"commit",
",",
"dict",
")",
":",
"# If GitHub webhook payload:",
"sender",
"=",
"kwargs",
".",
"get",
"(",
"\"sender\"",
",",
"{",
"}",
")",
"avatar_url",... | [
189,
0
] | [
226,
9
] | python | en | ['en', 'error', 'th'] | False |
validate_cumulusci_yml_unchanged | (repo) | Confirm cumulusci.yml is unchanged between default_branch and the cwd. | Confirm cumulusci.yml is unchanged between default_branch and the cwd. | def validate_cumulusci_yml_unchanged(repo):
"""Confirm cumulusci.yml is unchanged between default_branch and the cwd."""
try:
cci_config_default_branch = repo.file_contents(
"cumulusci.yml", ref=repo.default_branch
).decoded.decode("utf-8")
except NotFoundError:
cci_confi... | [
"def",
"validate_cumulusci_yml_unchanged",
"(",
"repo",
")",
":",
"try",
":",
"cci_config_default_branch",
"=",
"repo",
".",
"file_contents",
"(",
"\"cumulusci.yml\"",
",",
"ref",
"=",
"repo",
".",
"default_branch",
")",
".",
"decoded",
".",
"decode",
"(",
"\"ut... | [
229,
0
] | [
242,
69
] | python | en | ['en', 'en', 'en'] | True |
EncoderBase.model_to_device | (self, device) | Default implementation, can be overridden in derived classes. | Default implementation, can be overridden in derived classes. | def model_to_device(self, device):
"""Default implementation, can be overridden in derived classes."""
self.to(device) | [
"def",
"model_to_device",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"to",
"(",
"device",
")"
] | [
113,
4
] | [
115,
23
] | python | en | ['en', 'en', 'en'] | True |
EncoderBase.device_and_type_for_input_tensor | (self, _) | Default implementation, can be overridden in derived classes. | Default implementation, can be overridden in derived classes. | def device_and_type_for_input_tensor(self, _):
"""Default implementation, can be overridden in derived classes."""
return self.model_device(), torch.float32 | [
"def",
"device_and_type_for_input_tensor",
"(",
"self",
",",
"_",
")",
":",
"return",
"self",
".",
"model_device",
"(",
")",
",",
"torch",
".",
"float32"
] | [
117,
4
] | [
119,
49
] | python | en | ['en', 'en', 'en'] | True |
ActionParameterizationDefault.forward | (self, actor_core_output) | Just forward the FC layer and generate the distribution object. | Just forward the FC layer and generate the distribution object. | def forward(self, actor_core_output):
"""Just forward the FC layer and generate the distribution object."""
action_distribution_params = self.distribution_linear(actor_core_output)
action_distribution = get_action_distribution(self.action_space, raw_logits=action_distribution_params)
ret... | [
"def",
"forward",
"(",
"self",
",",
"actor_core_output",
")",
":",
"action_distribution_params",
"=",
"self",
".",
"distribution_linear",
"(",
"actor_core_output",
")",
"action_distribution",
"=",
"get_action_distribution",
"(",
"self",
".",
"action_space",
",",
"raw_... | [
427,
4
] | [
431,
62
] | python | en | ['en', 'en', 'en'] | True |
KeypairsFilterAction.filter | (self, table, keypairs, filter_string) | Naive case-insensitive search. | Naive case-insensitive search. | def filter(self, table, keypairs, filter_string):
"""Naive case-insensitive search."""
query = filter_string.lower()
return [keypair for keypair in keypairs
if query in keypair.name.lower()] | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"keypairs",
",",
"filter_string",
")",
":",
"query",
"=",
"filter_string",
".",
"lower",
"(",
")",
"return",
"[",
"keypair",
"for",
"keypair",
"in",
"keypairs",
"if",
"query",
"in",
"keypair",
".",
"name",... | [
112,
4
] | [
116,
49
] | python | en | ['en', 'it', 'en'] | True |
splitclusters | (s) | Generate the grapheme clusters for the string s. (Not the full
Unicode text segmentation algorithm, but probably good enough for
Devanagari.)
| Generate the grapheme clusters for the string s. (Not the full
Unicode text segmentation algorithm, but probably good enough for
Devanagari.) | def splitclusters(s):
"""Generate the grapheme clusters for the string s. (Not the full
Unicode text segmentation algorithm, but probably good enough for
Devanagari.)
"""
# http://pyright.blogspot.com/2009/12/pythons-unicodedata-module.html
# The combining code is typically zero. The virama gets its o... | [
"def",
"splitclusters",
"(",
"s",
")",
":",
"# http://pyright.blogspot.com/2009/12/pythons-unicodedata-module.html",
"# The combining code is typically zero. The virama gets its own special code of nine.",
"# i.e. unicodedata.category=Mn unicodedata.combining=9",
"# (Could be used to extend for o... | [
28,
0
] | [
52,
21
] | python | en | ['en', 'en', 'en'] | True |
no_install_setup_requires | () | Temporarily disable installing setup_requires
Under PEP 517, the backend reports build dependencies to the frontend,
and the frontend is responsible for ensuring they're installed.
So setuptools (acting as a backend) should not try to install them.
| Temporarily disable installing setup_requires | def no_install_setup_requires():
"""Temporarily disable installing setup_requires
Under PEP 517, the backend reports build dependencies to the frontend,
and the frontend is responsible for ensuring they're installed.
So setuptools (acting as a backend) should not try to install them.
"""
orig =... | [
"def",
"no_install_setup_requires",
"(",
")",
":",
"orig",
"=",
"setuptools",
".",
"_install_setup_requires",
"setuptools",
".",
"_install_setup_requires",
"=",
"lambda",
"attrs",
":",
"None",
"try",
":",
"yield",
"finally",
":",
"setuptools",
".",
"_install_setup_r... | [
78,
0
] | [
90,
49
] | python | en | ['en', 'en', 'en'] | True |
Distribution.patch | (cls) |
Replace
distutils.dist.Distribution with this class
for the duration of this context.
|
Replace
distutils.dist.Distribution with this class
for the duration of this context.
| def patch(cls):
"""
Replace
distutils.dist.Distribution with this class
for the duration of this context.
"""
orig = distutils.core.Distribution
distutils.core.Distribution = cls
try:
yield
finally:
distutils.core.Distributi... | [
"def",
"patch",
"(",
"cls",
")",
":",
"orig",
"=",
"distutils",
".",
"core",
".",
"Distribution",
"distutils",
".",
"core",
".",
"Distribution",
"=",
"cls",
"try",
":",
"yield",
"finally",
":",
"distutils",
".",
"core",
".",
"Distribution",
"=",
"orig"
] | [
63,
4
] | [
74,
46
] | python | en | ['en', 'error', 'th'] | False |
to_torch_dtype | (numpy_dtype) | from_numpy automatically infers type, so we leverage that. | from_numpy automatically infers type, so we leverage that. | def to_torch_dtype(numpy_dtype):
"""from_numpy automatically infers type, so we leverage that."""
x = np.zeros([1], dtype=numpy_dtype)
t = torch.from_numpy(x)
return t.dtype | [
"def",
"to_torch_dtype",
"(",
"numpy_dtype",
")",
":",
"x",
"=",
"np",
".",
"zeros",
"(",
"[",
"1",
"]",
",",
"dtype",
"=",
"numpy_dtype",
")",
"t",
"=",
"torch",
".",
"from_numpy",
"(",
"x",
")",
"return",
"t",
".",
"dtype"
] | [
12,
0
] | [
16,
18
] | python | en | ['en', 'en', 'en'] | True |
ensure_memory_shared | (*tensors) | To prevent programming errors, ensure all tensors are in shared memory. | To prevent programming errors, ensure all tensors are in shared memory. | def ensure_memory_shared(*tensors):
"""To prevent programming errors, ensure all tensors are in shared memory."""
for tensor_dict in tensors:
for _, _, t in iterate_recursively(tensor_dict):
assert t.is_shared() | [
"def",
"ensure_memory_shared",
"(",
"*",
"tensors",
")",
":",
"for",
"tensor_dict",
"in",
"tensors",
":",
"for",
"_",
",",
"_",
",",
"t",
"in",
"iterate_recursively",
"(",
"tensor_dict",
")",
":",
"assert",
"t",
".",
"is_shared",
"(",
")"
] | [
35,
0
] | [
39,
32
] | python | en | ['en', 'en', 'en'] | True |
YamlItem.repr_failure | (self, excinfo) | called when self.runtest() raises an exception. | called when self.runtest() raises an exception. | def repr_failure(self, excinfo):
""" called when self.runtest() raises an exception. """
if isinstance(excinfo.value, YamlException):
return "\n".join([
"usecase execution failed",
" spec failed: %r: %r" % excinfo.value.args[1:3],
" no furt... | [
"def",
"repr_failure",
"(",
"self",
",",
"excinfo",
")",
":",
"if",
"isinstance",
"(",
"excinfo",
".",
"value",
",",
"YamlException",
")",
":",
"return",
"\"\\n\"",
".",
"join",
"(",
"[",
"\"usecase execution failed\"",
",",
"\" spec failed: %r: %r\"",
"%",
... | [
26,
4
] | [
33,
14
] | python | en | ['en', 'en', 'en'] | True |
GroupsFilterAction.filter | (self, table, groups, filter_string) | Naive case-insensitive search. | Naive case-insensitive search. | def filter(self, table, groups, filter_string):
"""Naive case-insensitive search."""
query = filter_string.lower()
return [group for group in groups
if query in group.name.lower()] | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"groups",
",",
"filter_string",
")",
":",
"query",
"=",
"filter_string",
".",
"lower",
"(",
")",
"return",
"[",
"group",
"for",
"group",
"in",
"groups",
"if",
"query",
"in",
"group",
".",
"name",
".",
... | [
121,
4
] | [
125,
47
] | python | en | ['en', 'it', 'en'] | True |
api_opbeat_webhook | (
request: HttpRequest,
user_profile: UserProfile,
payload: Dict[str, Any] = REQ(argument_type="body"),
) |
This uses the subject name from opbeat to make the subject,
and the summary from Opbeat as the message body, with
details about the object mentioned.
|
This uses the subject name from opbeat to make the subject,
and the summary from Opbeat as the message body, with
details about the object mentioned.
| def api_opbeat_webhook(
request: HttpRequest,
user_profile: UserProfile,
payload: Dict[str, Any] = REQ(argument_type="body"),
) -> HttpResponse:
"""
This uses the subject name from opbeat to make the subject,
and the summary from Opbeat as the message body, with
details about the object ment... | [
"def",
"api_opbeat_webhook",
"(",
"request",
":",
"HttpRequest",
",",
"user_profile",
":",
"UserProfile",
",",
"payload",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"REQ",
"(",
"argument_type",
"=",
"\"body\"",
")",
",",
")",
"->",
"HttpResponse",
":",... | [
100,
0
] | [
116,
25
] | python | en | ['en', 'error', 'th'] | False |
get_muting_users | (muted_user: UserProfile) |
This is kind of the inverse of `get_user_mutes` above.
While `get_user_mutes` is mainly used for event system work,
this is used in the message send codepath, to get a list
of IDs of users who have muted a particular user.
The result will also include deactivated users.
|
This is kind of the inverse of `get_user_mutes` above.
While `get_user_mutes` is mainly used for event system work,
this is used in the message send codepath, to get a list
of IDs of users who have muted a particular user.
The result will also include deactivated users.
| def get_muting_users(muted_user: UserProfile) -> Set[int]:
"""
This is kind of the inverse of `get_user_mutes` above.
While `get_user_mutes` is mainly used for event system work,
this is used in the message send codepath, to get a list
of IDs of users who have muted a particular user.
The result... | [
"def",
"get_muting_users",
"(",
"muted_user",
":",
"UserProfile",
")",
"->",
"Set",
"[",
"int",
"]",
":",
"rows",
"=",
"MutedUser",
".",
"objects",
".",
"filter",
"(",
"muted_user",
"=",
"muted_user",
",",
")",
".",
"values",
"(",
"\"user_profile_id\"",
")... | [
40,
0
] | [
51,
51
] | python | en | ['en', 'error', 'th'] | False |
LearnerWorker._get_minibatches | (self, batch_size, experience_size) | Generating minibatches for training. | Generating minibatches for training. | def _get_minibatches(self, batch_size, experience_size):
"""Generating minibatches for training."""
assert self.cfg.rollout % self.cfg.recurrence == 0
assert experience_size % batch_size == 0, f'experience size: {experience_size}, batch size: {batch_size}'
if self.cfg.num_batches_per_it... | [
"def",
"_get_minibatches",
"(",
"self",
",",
"batch_size",
",",
"experience_size",
")",
":",
"assert",
"self",
".",
"cfg",
".",
"rollout",
"%",
"self",
".",
"cfg",
".",
"recurrence",
"==",
"0",
"assert",
"experience_size",
"%",
"batch_size",
"==",
"0",
","... | [
264,
4
] | [
284,
26
] | python | en | ['en', 'en', 'en'] | True |
LearnerWorker._after_optimizer_step | (self) | A hook to be called after each optimizer step. | A hook to be called after each optimizer step. | def _after_optimizer_step(self):
"""A hook to be called after each optimizer step."""
self.train_step += 1
self._maybe_save() | [
"def",
"_after_optimizer_step",
"(",
"self",
")",
":",
"self",
".",
"train_step",
"+=",
"1",
"self",
".",
"_maybe_save",
"(",
")"
] | [
311,
4
] | [
314,
26
] | 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.