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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
_CreateMSVSUserFile | (proj_path, version, spec) | Generates a .user file for the user running this Gyp program.
Arguments:
proj_path: The path of the project file being created. The .user file
shares the same path (with an appropriate suffix).
version: The VisualStudioVersion object.
spec: The target dictionary containing the properties ... | Generates a .user file for the user running this Gyp program. | def _CreateMSVSUserFile(proj_path, version, spec):
"""Generates a .user file for the user running this Gyp program.
Arguments:
proj_path: The path of the project file being created. The .user file
shares the same path (with an appropriate suffix).
version: The VisualStudioVersion object.
... | [
"def",
"_CreateMSVSUserFile",
"(",
"proj_path",
",",
"version",
",",
"spec",
")",
":",
"(",
"domain",
",",
"username",
")",
"=",
"_GetDomainAndUserName",
"(",
")",
"vcuser_filename",
"=",
"\".\"",
".",
"join",
"(",
"[",
"proj_path",
",",
"domain",
",",
"us... | [
1109,
0
] | [
1123,
20
] | python | en | ['en', 'en', 'en'] | True |
_GetMSVSConfigurationType | (spec, build_file) | Returns the configuration type for this project.
It's a number defined by Microsoft. May raise an exception.
Args:
spec: The target dictionary containing the properties of the target.
build_file: The path of the gyp file.
Returns:
An integer, the configuration type.
| Returns the configuration type for this project. | def _GetMSVSConfigurationType(spec, build_file):
"""Returns the configuration type for this project.
It's a number defined by Microsoft. May raise an exception.
Args:
spec: The target dictionary containing the properties of the target.
build_file: The path of the gyp file.
Returns:
An int... | [
"def",
"_GetMSVSConfigurationType",
"(",
"spec",
",",
"build_file",
")",
":",
"try",
":",
"config_type",
"=",
"{",
"\"executable\"",
":",
"\"1\"",
",",
"# .exe",
"\"shared_library\"",
":",
"\"2\"",
",",
"# .dll",
"\"loadable_module\"",
":",
"\"2\"",
",",
"# .dll... | [
1126,
0
] | [
1157,
22
] | python | en | ['en', 'en', 'en'] | True |
_AddConfigurationToMSVSProject | (p, spec, config_type, config_name, config) | Adds a configuration to the MSVS project.
Many settings in a vcproj file are specific to a configuration. This
function the main part of the vcproj file that's configuration specific.
Arguments:
p: The target project being generated.
spec: The target dictionary containing the properties of the target.
... | Adds a configuration to the MSVS project. | def _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config):
"""Adds a configuration to the MSVS project.
Many settings in a vcproj file are specific to a configuration. This
function the main part of the vcproj file that's configuration specific.
Arguments:
p: The target project bein... | [
"def",
"_AddConfigurationToMSVSProject",
"(",
"p",
",",
"spec",
",",
"config_type",
",",
"config_name",
",",
"config",
")",
":",
"# Get the information for this configuration",
"include_dirs",
",",
"midl_include_dirs",
",",
"resource_include_dirs",
"=",
"_GetIncludeDirs",
... | [
1160,
0
] | [
1247,
77
] | python | en | ['en', 'en', 'en'] | True |
_GetIncludeDirs | (config) | Returns the list of directories to be used for #include directives.
Arguments:
config: The dictionary that defines the special processing to be done
for this configuration.
Returns:
The list of directory paths.
| Returns the list of directories to be used for #include directives. | def _GetIncludeDirs(config):
"""Returns the list of directories to be used for #include directives.
Arguments:
config: The dictionary that defines the special processing to be done
for this configuration.
Returns:
The list of directory paths.
"""
# TODO(bradnelson): include_dirs shoul... | [
"def",
"_GetIncludeDirs",
"(",
"config",
")",
":",
"# TODO(bradnelson): include_dirs should really be flexible enough not to",
"# require this sort of thing.",
"include_dirs",
"=",
"config",
".",
"get",
"(",
"\"include_dirs\"",
",",
"[",
"]",
")",
"+",
"conf... | [
1250,
0
] | [
1271,
65
] | python | en | ['en', 'en', 'en'] | True |
_GetLibraryDirs | (config) | Returns the list of directories to be used for library search paths.
Arguments:
config: The dictionary that defines the special processing to be done
for this configuration.
Returns:
The list of directory paths.
| Returns the list of directories to be used for library search paths. | def _GetLibraryDirs(config):
"""Returns the list of directories to be used for library search paths.
Arguments:
config: The dictionary that defines the special processing to be done
for this configuration.
Returns:
The list of directory paths.
"""
library_dirs = config.get("library_d... | [
"def",
"_GetLibraryDirs",
"(",
"config",
")",
":",
"library_dirs",
"=",
"config",
".",
"get",
"(",
"\"library_dirs\"",
",",
"[",
"]",
")",
"library_dirs",
"=",
"_FixPaths",
"(",
"library_dirs",
")",
"return",
"library_dirs"
] | [
1274,
0
] | [
1286,
23
] | python | en | ['en', 'en', 'en'] | True |
_GetLibraries | (spec) | Returns the list of libraries for this configuration.
Arguments:
spec: The target dictionary containing the properties of the target.
Returns:
The list of directory paths.
| Returns the list of libraries for this configuration. | def _GetLibraries(spec):
"""Returns the list of libraries for this configuration.
Arguments:
spec: The target dictionary containing the properties of the target.
Returns:
The list of directory paths.
"""
libraries = spec.get("libraries", [])
# Strip out -l, as it is not used on windows (but i... | [
"def",
"_GetLibraries",
"(",
"spec",
")",
":",
"libraries",
"=",
"spec",
".",
"get",
"(",
"\"libraries\"",
",",
"[",
"]",
")",
"# Strip out -l, as it is not used on windows (but is needed so we can pass",
"# in libraries that are assumed to be in the default library path).",
"#... | [
1289,
0
] | [
1312,
32
] | python | en | ['en', 'en', 'en'] | True |
_GetOutputFilePathAndTool | (spec, msbuild) | Returns the path and tool to use for this target.
Figures out the path of the file this spec will create and the name of
the VC tool that will create it.
Arguments:
spec: The target dictionary containing the properties of the target.
Returns:
A triple of (file path, name of the vc tool, name of the ms... | Returns the path and tool to use for this target. | def _GetOutputFilePathAndTool(spec, msbuild):
"""Returns the path and tool to use for this target.
Figures out the path of the file this spec will create and the name of
the VC tool that will create it.
Arguments:
spec: The target dictionary containing the properties of the target.
Returns:
A trip... | [
"def",
"_GetOutputFilePathAndTool",
"(",
"spec",
",",
"msbuild",
")",
":",
"# Select a name for the output file.",
"out_file",
"=",
"\"\"",
"vc_tool",
"=",
"\"\"",
"msbuild_tool",
"=",
"\"\"",
"output_file_map",
"=",
"{",
"\"executable\"",
":",
"(",
"\"VCLinkerTool\""... | [
1315,
0
] | [
1351,
42
] | python | en | ['en', 'en', 'en'] | True |
_GetOutputTargetExt | (spec) | Returns the extension for this target, including the dot
If product_extension is specified, set target_extension to this to avoid
MSB8012, returns None otherwise. Ignores any target_extension settings in
the input files.
Arguments:
spec: The target dictionary containing the properties of the target.
Ret... | Returns the extension for this target, including the dot | def _GetOutputTargetExt(spec):
"""Returns the extension for this target, including the dot
If product_extension is specified, set target_extension to this to avoid
MSB8012, returns None otherwise. Ignores any target_extension settings in
the input files.
Arguments:
spec: The target dictionary containi... | [
"def",
"_GetOutputTargetExt",
"(",
"spec",
")",
":",
"target_extension",
"=",
"spec",
".",
"get",
"(",
"\"product_extension\"",
")",
"if",
"target_extension",
":",
"return",
"\".\"",
"+",
"target_extension",
"return",
"None"
] | [
1354,
0
] | [
1369,
15
] | python | en | ['en', 'en', 'en'] | True |
_GetDefines | (config) | Returns the list of preprocessor definitions for this configuration.
Arguments:
config: The dictionary that defines the special processing to be done
for this configuration.
Returns:
The list of preprocessor definitions.
| Returns the list of preprocessor definitions for this configuration. | def _GetDefines(config):
"""Returns the list of preprocessor definitions for this configuration.
Arguments:
config: The dictionary that defines the special processing to be done
for this configuration.
Returns:
The list of preprocessor definitions.
"""
defines = []
for d in config... | [
"def",
"_GetDefines",
"(",
"config",
")",
":",
"defines",
"=",
"[",
"]",
"for",
"d",
"in",
"config",
".",
"get",
"(",
"\"defines\"",
",",
"[",
"]",
")",
":",
"if",
"type",
"(",
"d",
")",
"==",
"list",
":",
"fd",
"=",
"\"=\"",
".",
"join",
"(",
... | [
1372,
0
] | [
1388,
18
] | python | en | ['en', 'en', 'en'] | True |
_ConvertToolsToExpectedForm | (tools) | Convert tools to a form expected by Visual Studio.
Arguments:
tools: A dictionary of settings; the tool name is the key.
Returns:
A list of Tool objects.
| Convert tools to a form expected by Visual Studio. | def _ConvertToolsToExpectedForm(tools):
"""Convert tools to a form expected by Visual Studio.
Arguments:
tools: A dictionary of settings; the tool name is the key.
Returns:
A list of Tool objects.
"""
tool_list = []
for tool, settings in tools.items():
# Collapse settings with lists.
... | [
"def",
"_ConvertToolsToExpectedForm",
"(",
"tools",
")",
":",
"tool_list",
"=",
"[",
"]",
"for",
"tool",
",",
"settings",
"in",
"tools",
".",
"items",
"(",
")",
":",
"# Collapse settings with lists.",
"settings_fixed",
"=",
"{",
"}",
"for",
"setting",
",",
"... | [
1414,
0
] | [
1438,
20
] | python | en | ['en', 'en', 'en'] | True |
_AddConfigurationToMSVS | (p, spec, tools, config, config_type, config_name) | Add to the project file the configuration specified by config.
Arguments:
p: The target project being generated.
spec: the target project dict.
tools: A dictionary of settings; the tool name is the key.
config: The dictionary that defines the special processing to be done
for this configu... | Add to the project file the configuration specified by config. | def _AddConfigurationToMSVS(p, spec, tools, config, config_type, config_name):
"""Add to the project file the configuration specified by config.
Arguments:
p: The target project being generated.
spec: the target project dict.
tools: A dictionary of settings; the tool name is the key.
config: The ... | [
"def",
"_AddConfigurationToMSVS",
"(",
"p",
",",
"spec",
",",
"tools",
",",
"config",
",",
"config_type",
",",
"config_name",
")",
":",
"attributes",
"=",
"_GetMSVSAttributes",
"(",
"spec",
",",
"config",
",",
"config_type",
")",
"# Add in this configuration.",
... | [
1441,
0
] | [
1456,
88
] | python | en | ['en', 'en', 'en'] | True |
_PrepareListOfSources | (spec, generator_flags, gyp_file) | Prepare list of sources and excluded sources.
Besides the sources specified directly in the spec, adds the gyp file so
that a change to it will cause a re-compile. Also adds appropriate sources
for actions and copies. Assumes later stage will un-exclude files which
have custom build steps attached.
Argument... | Prepare list of sources and excluded sources. | def _PrepareListOfSources(spec, generator_flags, gyp_file):
"""Prepare list of sources and excluded sources.
Besides the sources specified directly in the spec, adds the gyp file so
that a change to it will cause a re-compile. Also adds appropriate sources
for actions and copies. Assumes later stage will un-... | [
"def",
"_PrepareListOfSources",
"(",
"spec",
",",
"generator_flags",
",",
"gyp_file",
")",
":",
"sources",
"=",
"OrderedSet",
"(",
")",
"_AddNormalizedSources",
"(",
"sources",
",",
"spec",
".",
"get",
"(",
"\"sources\"",
",",
"[",
"]",
")",
")",
"excluded_s... | [
1490,
0
] | [
1526,
38
] | python | en | ['en', 'en', 'en'] | True |
_AdjustSourcesAndConvertToFilterHierarchy | (
spec, options, gyp_dir, sources, excluded_sources, list_excluded, version
) | Adjusts the list of sources and excluded sources.
Also converts the sets to lists.
Arguments:
spec: The target dictionary containing the properties of the target.
options: Global generator options.
gyp_dir: The path to the gyp file being processed.
sources: A set of sources to be included for this... | Adjusts the list of sources and excluded sources. | def _AdjustSourcesAndConvertToFilterHierarchy(
spec, options, gyp_dir, sources, excluded_sources, list_excluded, version
):
"""Adjusts the list of sources and excluded sources.
Also converts the sets to lists.
Arguments:
spec: The target dictionary containing the properties of the target.
options:... | [
"def",
"_AdjustSourcesAndConvertToFilterHierarchy",
"(",
"spec",
",",
"options",
",",
"gyp_dir",
",",
"sources",
",",
"excluded_sources",
",",
"list_excluded",
",",
"version",
")",
":",
"# Exclude excluded sources coming into the generator.",
"excluded_sources",
".",
"updat... | [
1529,
0
] | [
1586,
50
] | python | en | ['en', 'en', 'en'] | True |
_CreateProjectObjects | (target_list, target_dicts, options, msvs_version) | Create a MSVSProject object for the targets found in target list.
Arguments:
target_list: the list of targets to generate project objects for.
target_dicts: the dictionary of specifications.
options: global generator options.
msvs_version: the MSVSVersion object.
Returns:
A set of created proje... | Create a MSVSProject object for the targets found in target list. | def _CreateProjectObjects(target_list, target_dicts, options, msvs_version):
"""Create a MSVSProject object for the targets found in target list.
Arguments:
target_list: the list of targets to generate project objects for.
target_dicts: the dictionary of specifications.
options: global generator opti... | [
"def",
"_CreateProjectObjects",
"(",
"target_list",
",",
"target_dicts",
",",
"options",
",",
"msvs_version",
")",
":",
"global",
"fixpath_prefix",
"# Generate each project.",
"projects",
"=",
"{",
"}",
"for",
"qualified_target",
"in",
"target_list",
":",
"spec",
"=... | [
1916,
0
] | [
1964,
19
] | python | en | ['en', 'en', 'en'] | True |
_InitNinjaFlavor | (params, target_list, target_dicts) | Initialize targets for the ninja flavor.
This sets up the necessary variables in the targets to generate msvs projects
that use ninja as an external builder. The variables in the spec are only set
if they have not been set. This allows individual specs to override the
default values initialized here.
Argumen... | Initialize targets for the ninja flavor. | def _InitNinjaFlavor(params, target_list, target_dicts):
"""Initialize targets for the ninja flavor.
This sets up the necessary variables in the targets to generate msvs projects
that use ninja as an external builder. The variables in the spec are only set
if they have not been set. This allows individual sp... | [
"def",
"_InitNinjaFlavor",
"(",
"params",
",",
"target_list",
",",
"target_dicts",
")",
":",
"for",
"qualified_target",
"in",
"target_list",
":",
"spec",
"=",
"target_dicts",
"[",
"qualified_target",
"]",
"if",
"spec",
".",
"get",
"(",
"\"msvs_external_builder\"",... | [
1967,
0
] | [
2015,
13
] | python | en | ['en', 'en', 'en'] | True |
CalculateVariables | (default_variables, params) | Generated variables that require params to be known. | Generated variables that require params to be known. | def CalculateVariables(default_variables, params):
"""Generated variables that require params to be known."""
generator_flags = params.get("generator_flags", {})
# Select project file format version (if unset, default to auto detecting).
msvs_version = MSVSVersion.SelectVisualStudioVersion(
ge... | [
"def",
"CalculateVariables",
"(",
"default_variables",
",",
"params",
")",
":",
"generator_flags",
"=",
"params",
".",
"get",
"(",
"\"generator_flags\"",
",",
"{",
"}",
")",
"# Select project file format version (if unset, default to auto detecting).",
"msvs_version",
"=",
... | [
2018,
0
] | [
2046,
69
] | python | en | ['en', 'en', 'en'] | True |
GenerateOutput | (target_list, target_dicts, data, params) | Generate .sln and .vcproj files.
This is the entry point for this generator.
Arguments:
target_list: List of target pairs: 'base/base.gyp:base'.
target_dicts: Dict of target properties keyed on target pair.
data: Dictionary containing per .gyp data.
| Generate .sln and .vcproj files. | def GenerateOutput(target_list, target_dicts, data, params):
"""Generate .sln and .vcproj files.
This is the entry point for this generator.
Arguments:
target_list: List of target pairs: 'base/base.gyp:base'.
target_dicts: Dict of target properties keyed on target pair.
data: Dictionary containing ... | [
"def",
"GenerateOutput",
"(",
"target_list",
",",
"target_dicts",
",",
"data",
",",
"params",
")",
":",
"global",
"fixpath_prefix",
"options",
"=",
"params",
"[",
"\"options\"",
"]",
"# Get the project file format version back out of where we stashed it in",
"# GeneratorCal... | [
2086,
0
] | [
2175,
63
] | python | it | ['en', 'it', 'it'] | True |
_GenerateMSBuildFiltersFile | (
filters_path,
source_files,
rule_dependencies,
extension_to_rule_name,
platforms,
toolset,
) | Generate the filters file.
This file is used by Visual Studio to organize the presentation of source
files into folders.
Arguments:
filters_path: The path of the file to be created.
source_files: The hierarchical structure of all the sources.
extension_to_rule_name: A dictionary mapping file e... | Generate the filters file. | def _GenerateMSBuildFiltersFile(
filters_path,
source_files,
rule_dependencies,
extension_to_rule_name,
platforms,
toolset,
):
"""Generate the filters file.
This file is used by Visual Studio to organize the presentation of source
files into folders.
Arguments:
filters_path: Th... | [
"def",
"_GenerateMSBuildFiltersFile",
"(",
"filters_path",
",",
"source_files",
",",
"rule_dependencies",
",",
"extension_to_rule_name",
",",
"platforms",
",",
"toolset",
",",
")",
":",
"filter_group",
"=",
"[",
"]",
"source_group",
"=",
"[",
"]",
"_AppendFiltersFor... | [
2178,
0
] | [
2221,
31
] | python | en | ['en', 'en', 'en'] | True |
_AppendFiltersForMSBuild | (
parent_filter_name,
sources,
rule_dependencies,
extension_to_rule_name,
platforms,
toolset,
filter_group,
source_group,
) | Creates the list of filters and sources to be added in the filter file.
Args:
parent_filter_name: The name of the filter under which the sources are
found.
sources: The hierarchy of filters and sources to process.
extension_to_rule_name: A dictionary mapping file extensions to rules.
... | Creates the list of filters and sources to be added in the filter file. | def _AppendFiltersForMSBuild(
parent_filter_name,
sources,
rule_dependencies,
extension_to_rule_name,
platforms,
toolset,
filter_group,
source_group,
):
"""Creates the list of filters and sources to be added in the filter file.
Args:
parent_filter_name: The name of the filte... | [
"def",
"_AppendFiltersForMSBuild",
"(",
"parent_filter_name",
",",
"sources",
",",
"rule_dependencies",
",",
"extension_to_rule_name",
",",
"platforms",
",",
"toolset",
",",
"filter_group",
",",
"source_group",
",",
")",
":",
"for",
"source",
"in",
"sources",
":",
... | [
2224,
0
] | [
2279,
45
] | python | en | ['en', 'en', 'en'] | True |
_MapFileToMsBuildSourceType | (
source, rule_dependencies, extension_to_rule_name, platforms, toolset
) | Returns the group and element type of the source file.
Arguments:
source: The source file name.
extension_to_rule_name: A dictionary mapping file extensions to rules.
Returns:
A pair of (group this file should be part of, the label of element)
| Returns the group and element type of the source file. | def _MapFileToMsBuildSourceType(
source, rule_dependencies, extension_to_rule_name, platforms, toolset
):
"""Returns the group and element type of the source file.
Arguments:
source: The source file name.
extension_to_rule_name: A dictionary mapping file extensions to rules.
Returns:
A p... | [
"def",
"_MapFileToMsBuildSourceType",
"(",
"source",
",",
"rule_dependencies",
",",
"extension_to_rule_name",
",",
"platforms",
",",
"toolset",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"source",
")",
"ext",
"=",
"ext",
".",
... | [
2282,
0
] | [
2322,
27
] | python | en | ['en', 'en', 'en'] | True |
_GenerateMSBuildRulePropsFile | (props_path, msbuild_rules) | Generate the .props file. | Generate the .props file. | def _GenerateMSBuildRulePropsFile(props_path, msbuild_rules):
"""Generate the .props file."""
content = [
"Project",
{"xmlns": "http://schemas.microsoft.com/developer/msbuild/2003"},
]
for rule in msbuild_rules:
content.extend(
[
[
... | [
"def",
"_GenerateMSBuildRulePropsFile",
"(",
"props_path",
",",
"msbuild_rules",
")",
":",
"content",
"=",
"[",
"\"Project\"",
",",
"{",
"\"xmlns\"",
":",
"\"http://schemas.microsoft.com/developer/msbuild/2003\"",
"}",
",",
"]",
"for",
"rule",
"in",
"msbuild_rules",
"... | [
2437,
0
] | [
2476,
76
] | python | en | ['en', 'en', 'en'] | True |
_GenerateMSBuildRuleTargetsFile | (targets_path, msbuild_rules) | Generate the .targets file. | Generate the .targets file. | def _GenerateMSBuildRuleTargetsFile(targets_path, msbuild_rules):
"""Generate the .targets file."""
content = [
"Project",
{"xmlns": "http://schemas.microsoft.com/developer/msbuild/2003"},
]
item_group = [
"ItemGroup",
[
"PropertyPageSchema",
{"Inc... | [
"def",
"_GenerateMSBuildRuleTargetsFile",
"(",
"targets_path",
",",
"msbuild_rules",
")",
":",
"content",
"=",
"[",
"\"Project\"",
",",
"{",
"\"xmlns\"",
":",
"\"http://schemas.microsoft.com/developer/msbuild/2003\"",
"}",
",",
"]",
"item_group",
"=",
"[",
"\"ItemGroup\... | [
2479,
0
] | [
2678,
78
] | python | en | ['en', 'en', 'en'] | True |
TestBlazeMeterClientUnicode.test_unicode_request | (self) |
test UnicodeDecodeError in BlazeMeterClient._request()
|
test UnicodeDecodeError in BlazeMeterClient._request()
| def test_unicode_request(self):
"""
test UnicodeDecodeError in BlazeMeterClient._request()
"""
session = Session(data={'id': 1})
mock = BZMock(session)
mock.mock_post['https://data.blazemeter.com/api/v4/image/1/files?signature=None'] = {"result": 1}
session.upload... | [
"def",
"test_unicode_request",
"(",
"self",
")",
":",
"session",
"=",
"Session",
"(",
"data",
"=",
"{",
"'id'",
":",
"1",
"}",
")",
"mock",
"=",
"BZMock",
"(",
"session",
")",
"mock",
".",
"mock_post",
"[",
"'https://data.blazemeter.com/api/v4/image/1/files?si... | [
445,
4
] | [
452,
66
] | python | en | ['en', 'error', 'th'] | False |
TwoPhaseCommitTests.connect | (self) | Make a database connection. | Make a database connection. | def connect(self):
"""Make a database connection."""
raise NotImplementedError | [
"def",
"connect",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
11,
4
] | [
13,
33
] | python | en | ['en', 'en', 'en'] | True |
prepopulated_fields_js | (context) |
Creates a list of prepopulated_fields that should render Javascript for
the prepopulated fields for both the admin form and inlines.
|
Creates a list of prepopulated_fields that should render Javascript for
the prepopulated fields for both the admin form and inlines.
| def prepopulated_fields_js(context):
"""
Creates a list of prepopulated_fields that should render Javascript for
the prepopulated fields for both the admin form and inlines.
"""
prepopulated_fields = []
if 'adminform' in context:
prepopulated_fields.extend(context['adminform'].prepopulat... | [
"def",
"prepopulated_fields_js",
"(",
"context",
")",
":",
"prepopulated_fields",
"=",
"[",
"]",
"if",
"'adminform'",
"in",
"context",
":",
"prepopulated_fields",
".",
"extend",
"(",
"context",
"[",
"'adminform'",
"]",
".",
"prepopulated_fields",
")",
"if",
"'in... | [
9,
0
] | [
38,
18
] | python | en | ['en', 'error', 'th'] | False |
submit_row | (context) |
Displays the row of buttons for delete and save.
|
Displays the row of buttons for delete and save.
| def submit_row(context):
"""
Displays the row of buttons for delete and save.
"""
change = context['change']
is_popup = context['is_popup']
save_as = context['save_as']
show_save = context.get('show_save', True)
show_save_and_continue = context.get('show_save_and_continue', True)
ctx... | [
"def",
"submit_row",
"(",
"context",
")",
":",
"change",
"=",
"context",
"[",
"'change'",
"]",
"is_popup",
"=",
"context",
"[",
"'is_popup'",
"]",
"save_as",
"=",
"context",
"[",
"'save_as'",
"]",
"show_save",
"=",
"context",
".",
"get",
"(",
"'show_save'"... | [
42,
0
] | [
65,
14
] | python | en | ['en', 'error', 'th'] | False |
cell_count | (inline_admin_form) | Returns the number of cells used in a tabular inline | Returns the number of cells used in a tabular inline | def cell_count(inline_admin_form):
"""Returns the number of cells used in a tabular inline"""
count = 1 # Hidden cell with hidden 'id' field
for fieldset in inline_admin_form:
# Loop through all the fields (one per cell)
for line in fieldset:
for field in line:
c... | [
"def",
"cell_count",
"(",
"inline_admin_form",
")",
":",
"count",
"=",
"1",
"# Hidden cell with hidden 'id' field",
"for",
"fieldset",
"in",
"inline_admin_form",
":",
"# Loop through all the fields (one per cell)",
"for",
"line",
"in",
"fieldset",
":",
"for",
"field",
"... | [
69,
0
] | [
80,
16
] | python | en | ['en', 'en', 'en'] | True |
install_thread_excepthook | () |
Workaround for sys.excepthook thread bug
From
http://spyced.blogspot.com/2007/06/workaround-for-sysexcepthook-bug.html
(https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1230540&group_id=5470).
Call once from __main__ before creating any threads.
If using psyco, call psyco.cannotcomp... |
Workaround for sys.excepthook thread bug
From
http://spyced.blogspot.com/2007/06/workaround-for-sysexcepthook-bug.html
(https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1230540&group_id=5470).
Call once from __main__ before creating any threads.
If using psyco, call psyco.cannotcomp... | def install_thread_excepthook():
"""
Workaround for sys.excepthook thread bug
From
http://spyced.blogspot.com/2007/06/workaround-for-sysexcepthook-bug.html
(https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1230540&group_id=5470).
Call once from __main__ before creating any threads.
... | [
"def",
"install_thread_excepthook",
"(",
")",
":",
"init_old",
"=",
"threading",
".",
"Thread",
".",
"__init__",
"def",
"init",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"init_old",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*"... | [
24,
0
] | [
49,
36
] | python | en | ['en', 'error', 'th'] | False |
parse_tag | (tag) |
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
Returning a set is required due to the possibility that the tag is a
compressed tag set.
|
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances. | def parse_tag(tag):
# type: (str) -> FrozenSet[Tag]
"""
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
Returning a set is required due to the possibility that the tag is a
compressed tag set.
"""
tags = set()
interpreters, abis, platforms = tag.split("-... | [
"def",
"parse_tag",
"(",
"tag",
")",
":",
"# type: (str) -> FrozenSet[Tag]",
"tags",
"=",
"set",
"(",
")",
"interpreters",
",",
"abis",
",",
"platforms",
"=",
"tag",
".",
"split",
"(",
"\"-\"",
")",
"for",
"interpreter",
"in",
"interpreters",
".",
"split",
... | [
139,
0
] | [
153,
26
] | python | en | ['en', 'error', 'th'] | False |
_warn_keyword_parameter | (func_name, kwargs) |
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
|
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
| def _warn_keyword_parameter(func_name, kwargs):
# type: (str, Dict[str, bool]) -> bool
"""
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
"""
if not kwargs:
return False
elif len(kwargs) > 1 or "warn" not in kwargs:
kwargs.pop("warn", None)
... | [
"def",
"_warn_keyword_parameter",
"(",
"func_name",
",",
"kwargs",
")",
":",
"# type: (str, Dict[str, bool]) -> bool",
"if",
"not",
"kwargs",
":",
"return",
"False",
"elif",
"len",
"(",
"kwargs",
")",
">",
"1",
"or",
"\"warn\"",
"not",
"in",
"kwargs",
":",
"kw... | [
156,
0
] | [
169,
25
] | python | en | ['en', 'error', 'th'] | False |
_abi3_applies | (python_version) |
Determine if the Python version supports abi3.
PEP 384 was first implemented in Python 3.2.
|
Determine if the Python version supports abi3. | def _abi3_applies(python_version):
# type: (PythonVersion) -> bool
"""
Determine if the Python version supports abi3.
PEP 384 was first implemented in Python 3.2.
"""
return len(python_version) > 1 and tuple(python_version) >= (3, 2) | [
"def",
"_abi3_applies",
"(",
"python_version",
")",
":",
"# type: (PythonVersion) -> bool",
"return",
"len",
"(",
"python_version",
")",
">",
"1",
"and",
"tuple",
"(",
"python_version",
")",
">=",
"(",
"3",
",",
"2",
")"
] | [
187,
0
] | [
194,
70
] | python | en | ['en', 'error', 'th'] | False |
cpython_tags | (
python_version=None, # type: Optional[PythonVersion]
abis=None, # type: Optional[Iterable[str]]
platforms=None, # type: Optional[Iterable[str]]
**kwargs # type: bool
) |
Yields the tags for a CPython interpreter.
The tags consist of:
- cp<python_version>-<abi>-<platform>
- cp<python_version>-abi3-<platform>
- cp<python_version>-none-<platform>
- cp<less than python_version>-abi3-<platform> # Older Python versions down to 3.2.
If python_version only speci... |
Yields the tags for a CPython interpreter. | def cpython_tags(
python_version=None, # type: Optional[PythonVersion]
abis=None, # type: Optional[Iterable[str]]
platforms=None, # type: Optional[Iterable[str]]
**kwargs # type: bool
):
# type: (...) -> Iterator[Tag]
"""
Yields the tags for a CPython interpreter.
The tags consist o... | [
"def",
"cpython_tags",
"(",
"python_version",
"=",
"None",
",",
"# type: Optional[PythonVersion]",
"abis",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
"platforms",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
"*",
"*",
"kwargs",
"# type: bool",
")",
":"... | [
234,
0
] | [
291,
57
] | python | en | ['en', 'error', 'th'] | False |
generic_tags | (
interpreter=None, # type: Optional[str]
abis=None, # type: Optional[Iterable[str]]
platforms=None, # type: Optional[Iterable[str]]
**kwargs # type: bool
) |
Yields the tags for a generic interpreter.
The tags consist of:
- <interpreter>-<abi>-<platform>
The "none" ABI will be added if it was not explicitly provided.
|
Yields the tags for a generic interpreter. | def generic_tags(
interpreter=None, # type: Optional[str]
abis=None, # type: Optional[Iterable[str]]
platforms=None, # type: Optional[Iterable[str]]
**kwargs # type: bool
):
# type: (...) -> Iterator[Tag]
"""
Yields the tags for a generic interpreter.
The tags consist of:
- <int... | [
"def",
"generic_tags",
"(",
"interpreter",
"=",
"None",
",",
"# type: Optional[str]",
"abis",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
"platforms",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
"*",
"*",
"kwargs",
"# type: bool",
")",
":",
"# type: ... | [
301,
0
] | [
329,
50
] | python | en | ['en', 'error', 'th'] | False |
_py_interpreter_range | (py_version) |
Yields Python versions in descending order.
After the latest version, the major-only version will be yielded, and then
all previous versions of that major version.
|
Yields Python versions in descending order. | def _py_interpreter_range(py_version):
# type: (PythonVersion) -> Iterator[str]
"""
Yields Python versions in descending order.
After the latest version, the major-only version will be yielded, and then
all previous versions of that major version.
"""
if len(py_version) > 1:
yield "... | [
"def",
"_py_interpreter_range",
"(",
"py_version",
")",
":",
"# type: (PythonVersion) -> Iterator[str]",
"if",
"len",
"(",
"py_version",
")",
">",
"1",
":",
"yield",
"\"py{version}\"",
".",
"format",
"(",
"version",
"=",
"_version_nodot",
"(",
"py_version",
"[",
"... | [
332,
0
] | [
345,
86
] | python | en | ['en', 'error', 'th'] | False |
compatible_tags | (
python_version=None, # type: Optional[PythonVersion]
interpreter=None, # type: Optional[str]
platforms=None, # type: Optional[Iterable[str]]
) |
Yields the sequence of tags that are compatible with a specific version of Python.
The tags consist of:
- py*-none-<platform>
- <interpreter>-none-any # ... if `interpreter` is provided.
- py*-none-any
|
Yields the sequence of tags that are compatible with a specific version of Python. | def compatible_tags(
python_version=None, # type: Optional[PythonVersion]
interpreter=None, # type: Optional[str]
platforms=None, # type: Optional[Iterable[str]]
):
# type: (...) -> Iterator[Tag]
"""
Yields the sequence of tags that are compatible with a specific version of Python.
The t... | [
"def",
"compatible_tags",
"(",
"python_version",
"=",
"None",
",",
"# type: Optional[PythonVersion]",
"interpreter",
"=",
"None",
",",
"# type: Optional[str]",
"platforms",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
")",
":",
"# type: (...) -> Iterator[Tag]",
"if"... | [
348,
0
] | [
371,
41
] | python | en | ['en', 'error', 'th'] | False |
mac_platforms | (version=None, arch=None) |
Yields the platform tags for a macOS system.
The `version` parameter is a two-item tuple specifying the macOS version to
generate platform tags for. The `arch` parameter is the CPU architecture to
generate platform tags for. Both parameters default to the appropriate value
for the current system.
... |
Yields the platform tags for a macOS system. | def mac_platforms(version=None, arch=None):
# type: (Optional[MacVersion], Optional[str]) -> Iterator[str]
"""
Yields the platform tags for a macOS system.
The `version` parameter is a two-item tuple specifying the macOS version to
generate platform tags for. The `arch` parameter is the CPU archite... | [
"def",
"mac_platforms",
"(",
"version",
"=",
"None",
",",
"arch",
"=",
"None",
")",
":",
"# type: (Optional[MacVersion], Optional[str]) -> Iterator[str]",
"version_str",
",",
"_",
",",
"cpu_arch",
"=",
"platform",
".",
"mac_ver",
"(",
")",
"# type: ignore",
"if",
... | [
418,
0
] | [
472,
17
] | python | en | ['en', 'error', 'th'] | False |
_glibc_version_string_confstr | () |
Primary implementation of glibc_version_string using os.confstr.
|
Primary implementation of glibc_version_string using os.confstr.
| def _glibc_version_string_confstr():
# type: () -> Optional[str]
"""
Primary implementation of glibc_version_string using os.confstr.
"""
# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely
# to be broken or missing. This strategy is used in the standard library
# platf... | [
"def",
"_glibc_version_string_confstr",
"(",
")",
":",
"# type: () -> Optional[str]",
"# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely",
"# to be broken or missing. This strategy is used in the standard library",
"# platform module.",
"# https://github.com/python/cpython/... | [
512,
0
] | [
531,
18
] | python | en | ['en', 'error', 'th'] | False |
_glibc_version_string_ctypes | () |
Fallback implementation of glibc_version_string using ctypes.
|
Fallback implementation of glibc_version_string using ctypes.
| def _glibc_version_string_ctypes():
# type: () -> Optional[str]
"""
Fallback implementation of glibc_version_string using ctypes.
"""
try:
import ctypes
except ImportError:
return None
# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
# manpage says, "... | [
"def",
"_glibc_version_string_ctypes",
"(",
")",
":",
"# type: () -> Optional[str]",
"try",
":",
"import",
"ctypes",
"except",
"ImportError",
":",
"return",
"None",
"# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen",
"# manpage says, \"If filename is NULL, then th... | [
534,
0
] | [
577,
22
] | python | en | ['en', 'error', 'th'] | False |
_platform_tags | () |
Provides the platform tags for this installation.
|
Provides the platform tags for this installation.
| def _platform_tags():
# type: () -> Iterator[str]
"""
Provides the platform tags for this installation.
"""
if platform.system() == "Darwin":
return mac_platforms()
elif platform.system() == "Linux":
return _linux_platforms()
else:
return _generic_platforms() | [
"def",
"_platform_tags",
"(",
")",
":",
"# type: () -> Iterator[str]",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"\"Darwin\"",
":",
"return",
"mac_platforms",
"(",
")",
"elif",
"platform",
".",
"system",
"(",
")",
"==",
"\"Linux\"",
":",
"return",
"_l... | [
787,
0
] | [
797,
35
] | python | en | ['en', 'error', 'th'] | False |
interpreter_name | () |
Returns the name of the running interpreter.
|
Returns the name of the running interpreter.
| def interpreter_name():
# type: () -> str
"""
Returns the name of the running interpreter.
"""
try:
name = sys.implementation.name # type: ignore
except AttributeError: # pragma: no cover
# Python 2.7 compatibility.
name = platform.python_implementation().lower()
re... | [
"def",
"interpreter_name",
"(",
")",
":",
"# type: () -> str",
"try",
":",
"name",
"=",
"sys",
".",
"implementation",
".",
"name",
"# type: ignore",
"except",
"AttributeError",
":",
"# pragma: no cover",
"# Python 2.7 compatibility.",
"name",
"=",
"platform",
".",
"... | [
800,
0
] | [
810,
52
] | python | en | ['en', 'error', 'th'] | False |
interpreter_version | (**kwargs) |
Returns the version of the running interpreter.
|
Returns the version of the running interpreter.
| def interpreter_version(**kwargs):
# type: (bool) -> str
"""
Returns the version of the running interpreter.
"""
warn = _warn_keyword_parameter("interpreter_version", kwargs)
version = _get_config_var("py_version_nodot", warn=warn)
if version:
version = str(version)
else:
... | [
"def",
"interpreter_version",
"(",
"*",
"*",
"kwargs",
")",
":",
"# type: (bool) -> str",
"warn",
"=",
"_warn_keyword_parameter",
"(",
"\"interpreter_version\"",
",",
"kwargs",
")",
"version",
"=",
"_get_config_var",
"(",
"\"py_version_nodot\"",
",",
"warn",
"=",
"w... | [
813,
0
] | [
824,
18
] | python | en | ['en', 'error', 'th'] | False |
sys_tags | (**kwargs) |
Returns the sequence of tag triples for the running interpreter.
The order of the sequence corresponds to priority order for the
interpreter, from most to least important.
|
Returns the sequence of tag triples for the running interpreter. | def sys_tags(**kwargs):
# type: (bool) -> Iterator[Tag]
"""
Returns the sequence of tag triples for the running interpreter.
The order of the sequence corresponds to priority order for the
interpreter, from most to least important.
"""
warn = _warn_keyword_parameter("sys_tags", kwargs)
... | [
"def",
"sys_tags",
"(",
"*",
"*",
"kwargs",
")",
":",
"# type: (bool) -> Iterator[Tag]",
"warn",
"=",
"_warn_keyword_parameter",
"(",
"\"sys_tags\"",
",",
"kwargs",
")",
"interp_name",
"=",
"interpreter_name",
"(",
")",
"if",
"interp_name",
"==",
"\"cp\"",
":",
... | [
832,
0
] | [
851,
17
] | python | en | ['en', 'error', 'th'] | False |
calculate_deficit | (
constants: ConsensusConstants,
height: uint32,
prev_b: Optional[BlockRecord],
overflow: bool,
num_finished_sub_slots: int,
) |
Returns the deficit of the block to be created at height.
Args:
constants: consensus constants being used for this chain
height: block height of the block that we care about
prev_b: previous block
overflow: whether or not this is an overflow block
num_finished_sub_slots... |
Returns the deficit of the block to be created at height. | def calculate_deficit(
constants: ConsensusConstants,
height: uint32,
prev_b: Optional[BlockRecord],
overflow: bool,
num_finished_sub_slots: int,
) -> uint8:
"""
Returns the deficit of the block to be created at height.
Args:
constants: consensus constants being used for this ch... | [
"def",
"calculate_deficit",
"(",
"constants",
":",
"ConsensusConstants",
",",
"height",
":",
"uint32",
",",
"prev_b",
":",
"Optional",
"[",
"BlockRecord",
"]",
",",
"overflow",
":",
"bool",
",",
"num_finished_sub_slots",
":",
"int",
",",
")",
"->",
"uint8",
... | [
7,
0
] | [
52,
42
] | python | en | ['en', 'error', 'th'] | False |
get_cache_with_key | (
keyfunc: Callable[..., str],
cache_name: Optional[str] = None,
) |
The main goal of this function getting value from the cache like in the "cache_with_key".
A cache value can contain any data including the "None", so
here used exception for case if value isn't found in the cache.
|
The main goal of this function getting value from the cache like in the "cache_with_key".
A cache value can contain any data including the "None", so
here used exception for case if value isn't found in the cache.
| def get_cache_with_key(
keyfunc: Callable[..., str],
cache_name: Optional[str] = None,
) -> Callable[[FuncT], FuncT]:
"""
The main goal of this function getting value from the cache like in the "cache_with_key".
A cache value can contain any data including the "None", so
here used exception for ... | [
"def",
"get_cache_with_key",
"(",
"keyfunc",
":",
"Callable",
"[",
"...",
",",
"str",
"]",
",",
"cache_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"Callable",
"[",
"[",
"FuncT",
"]",
",",
"FuncT",
"]",
":",
"def",
"decorator... | [
131,
0
] | [
158,
20
] | python | en | ['en', 'error', 'th'] | False |
cache_with_key | (
keyfunc: Callable[..., str],
cache_name: Optional[str] = None,
timeout: Optional[int] = None,
with_statsd_key: Optional[str] = None,
) | Decorator which applies Django caching to a function.
Decorator argument is a function which computes a cache key
from the original function's arguments. You are responsible
for avoiding collisions with other uses of this decorator or
other uses of caching. | Decorator which applies Django caching to a function. | def cache_with_key(
keyfunc: Callable[..., str],
cache_name: Optional[str] = None,
timeout: Optional[int] = None,
with_statsd_key: Optional[str] = None,
) -> Callable[[FuncT], FuncT]:
"""Decorator which applies Django caching to a function.
Decorator argument is a function which computes a cach... | [
"def",
"cache_with_key",
"(",
"keyfunc",
":",
"Callable",
"[",
"...",
",",
"str",
"]",
",",
"cache_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"timeout",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"with_statsd_key",
":",
"Option... | [
161,
0
] | [
211,
20
] | python | en | ['en', 'en', 'en'] | True |
safe_cache_get_many | (keys: List[str], cache_name: Optional[str] = None) | Variant of cache_get_many that drops any keys that fail
validation, rather than throwing an exception visible to the
caller. | Variant of cache_get_many that drops any keys that fail
validation, rather than throwing an exception visible to the
caller. | def safe_cache_get_many(keys: List[str], cache_name: Optional[str] = None) -> Dict[str, Any]:
"""Variant of cache_get_many that drops any keys that fail
validation, rather than throwing an exception visible to the
caller."""
try:
# Almost always the keys will all be correct, so we just try
... | [
"def",
"safe_cache_get_many",
"(",
"keys",
":",
"List",
"[",
"str",
"]",
",",
"cache_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"try",
":",
"# Almost always the keys will all be correct, so we j... | [
277,
0
] | [
291,
52
] | python | en | ['en', 'en', 'en'] | True |
safe_cache_set_many | (
items: Dict[str, Any], cache_name: Optional[str] = None, timeout: Optional[int] = None
) | Variant of cache_set_many that drops saving any keys that fail
validation, rather than throwing an exception visible to the
caller. | Variant of cache_set_many that drops saving any keys that fail
validation, rather than throwing an exception visible to the
caller. | def safe_cache_set_many(
items: Dict[str, Any], cache_name: Optional[str] = None, timeout: Optional[int] = None
) -> None:
"""Variant of cache_set_many that drops saving any keys that fail
validation, rather than throwing an exception visible to the
caller."""
try:
# Almost always the keys w... | [
"def",
"safe_cache_set_many",
"(",
"items",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"cache_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"timeout",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
"->",
"None",
":",
"try",
":... | [
308,
0
] | [
326,
62
] | python | en | ['en', 'en', 'en'] | True |
ignore_unhashable_lru_cache | (
maxsize: int = 128, typed: bool = False
) |
This is a wrapper over lru_cache function. It adds following features on
top of lru_cache:
* It will not cache result of functions with unhashable arguments.
* It will clear cache whenever zerver.lib.cache.KEY_PREFIX changes.
|
This is a wrapper over lru_cache function. It adds following features on
top of lru_cache: | def ignore_unhashable_lru_cache(
maxsize: int = 128, typed: bool = False
) -> Callable[[FuncT], FuncT]:
"""
This is a wrapper over lru_cache function. It adds following features on
top of lru_cache:
* It will not cache result of functions with unhashable arguments.
* It will clear cache... | [
"def",
"ignore_unhashable_lru_cache",
"(",
"maxsize",
":",
"int",
"=",
"128",
",",
"typed",
":",
"bool",
"=",
"False",
")",
"->",
"Callable",
"[",
"[",
"FuncT",
"]",
",",
"FuncT",
"]",
":",
"internal_decorator",
"=",
"lru_cache",
"(",
"maxsize",
"=",
"ma... | [
748,
0
] | [
796,
20
] | python | en | ['en', 'error', 'th'] | False |
dict_to_items_tuple | (user_function: Callable[..., Any]) | Wrapper that converts any dict args to dict item tuples. | Wrapper that converts any dict args to dict item tuples. | def dict_to_items_tuple(user_function: Callable[..., Any]) -> Callable[..., Any]:
"""Wrapper that converts any dict args to dict item tuples."""
def dict_to_tuple(arg: Any) -> Any:
if isinstance(arg, dict):
return tuple(sorted(arg.items()))
return arg
def wrapper(*args: Any, **... | [
"def",
"dict_to_items_tuple",
"(",
"user_function",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
")",
"->",
"Callable",
"[",
"...",
",",
"Any",
"]",
":",
"def",
"dict_to_tuple",
"(",
"arg",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
... | [
799,
0
] | [
811,
18
] | python | en | ['en', 'en', 'en'] | True |
items_tuple_to_dict | (user_function: Callable[..., Any]) | Wrapper that converts any dict items tuple args to dicts. | Wrapper that converts any dict items tuple args to dicts. | def items_tuple_to_dict(user_function: Callable[..., Any]) -> Callable[..., Any]:
"""Wrapper that converts any dict items tuple args to dicts."""
def dict_items_to_dict(arg: Any) -> Any:
if isinstance(arg, tuple):
try:
return dict(arg)
except TypeError:
... | [
"def",
"items_tuple_to_dict",
"(",
"user_function",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
")",
"->",
"Callable",
"[",
"...",
",",
"Any",
"]",
":",
"def",
"dict_items_to_dict",
"(",
"arg",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"... | [
814,
0
] | [
830,
18
] | python | en | ['en', 'en', 'en'] | True |
sync_rejectreasons | (session) |
Check if rejectreasons are in sync. If not, insert as needed and commit.
Args:
session (sqlalchemy.orm.session.Session): Database session.
|
Check if rejectreasons are in sync. If not, insert as needed and commit. | def sync_rejectreasons(session):
"""
Check if rejectreasons are in sync. If not, insert as needed and commit.
Args:
session (sqlalchemy.orm.session.Session): Database session.
"""
if session.query(Rejectreason).count() != len(reject_reasons):
dbreason_id_rows = session.query(Rejectr... | [
"def",
"sync_rejectreasons",
"(",
"session",
")",
":",
"if",
"session",
".",
"query",
"(",
"Rejectreason",
")",
".",
"count",
"(",
")",
"!=",
"len",
"(",
"reject_reasons",
")",
":",
"dbreason_id_rows",
"=",
"session",
".",
"query",
"(",
"Rejectreason",
"."... | [
18,
0
] | [
34,
24
] | python | en | ['en', 'error', 'th'] | False |
reject | (imageid, reason, comment, session) |
Add a reject reason to the db for a given image.
Args:
imageid (int): The image ID of the image to reject
reason (tkp.db.model.Rejectreason): Why is the image rejected
comment (str): An optional comment with details about the reason
session (sqlalchemy.orm.session.Session): Dat... |
Add a reject reason to the db for a given image. | def reject(imageid, reason, comment, session):
"""
Add a reject reason to the db for a given image.
Args:
imageid (int): The image ID of the image to reject
reason (tkp.db.model.Rejectreason): Why is the image rejected
comment (str): An optional comment with details about the reason... | [
"def",
"reject",
"(",
"imageid",
",",
"reason",
",",
"comment",
",",
"session",
")",
":",
"r",
"=",
"Rejection",
"(",
"image_id",
"=",
"imageid",
",",
"rejectreason_id",
"=",
"reason",
".",
"id",
",",
"comment",
"=",
"comment",
",",
")",
"session",
"."... | [
37,
0
] | [
51,
18
] | python | en | ['en', 'error', 'th'] | False |
unreject | (imageid, session) |
Remove any rejections of a given imageid
Args:
imageid: The image ID
session (sqlalchemy.orm.session.Session): Database session.
|
Remove any rejections of a given imageid | def unreject(imageid, session):
"""
Remove any rejections of a given imageid
Args:
imageid: The image ID
session (sqlalchemy.orm.session.Session): Database session.
"""
session.query(Rejection).filter(
Rejection.image_id == imageid).delete() | [
"def",
"unreject",
"(",
"imageid",
",",
"session",
")",
":",
"session",
".",
"query",
"(",
"Rejection",
")",
".",
"filter",
"(",
"Rejection",
".",
"image_id",
"==",
"imageid",
")",
".",
"delete",
"(",
")"
] | [
54,
0
] | [
63,
47
] | python | en | ['en', 'error', 'th'] | False |
isrejected | (imageid, session) |
Find out if an image is rejected or not
Args:
imageid: The image ID
session (sqlalchemy.orm.session.Session): Database session.
Returns:
tuple: Empty if not rejected, a list of strings formatted as
'{description}: {comment}' if rejected.
|
Find out if an image is rejected or not
Args:
imageid: The image ID
session (sqlalchemy.orm.session.Session): Database session.
Returns:
tuple: Empty if not rejected, a list of strings formatted as
'{description}: {comment}' if rejected.
| def isrejected(imageid, session):
"""
Find out if an image is rejected or not
Args:
imageid: The image ID
session (sqlalchemy.orm.session.Session): Database session.
Returns:
tuple: Empty if not rejected, a list of strings formatted as
'{description}: {comment}' if re... | [
"def",
"isrejected",
"(",
"imageid",
",",
"session",
")",
":",
"image_rejections",
"=",
"session",
".",
"query",
"(",
"Rejection",
")",
".",
"filter",
"(",
"Rejection",
".",
"image_id",
"==",
"imageid",
")",
".",
"all",
"(",
")",
"return",
"[",
"\"{}: {}... | [
66,
0
] | [
79,
39
] | python | en | ['en', 'error', 'th'] | False |
addScriptOptions | (parser, pos_args, kw_args) | add script-specific script options | add script-specific script options | def addScriptOptions(parser, pos_args, kw_args):
""" add script-specific script options """
script_options_group = parser.add_argument_group('Options')
hlpstr = "Prefix string for output filenames. Can optionally include a " \
"full path. Defaults to the input filename."
... | [
"def",
"addScriptOptions",
"(",
"parser",
",",
"pos_args",
",",
"kw_args",
")",
":",
"script_options_group",
"=",
"parser",
".",
"add_argument_group",
"(",
"'Options'",
")",
"hlpstr",
"=",
"\"Prefix string for output filenames. Can optionally include a \"",
"\"full path. De... | [
98,
0
] | [
119,
37
] | python | en | ['en', 'it', 'en'] | True |
getLongestAlignments | (bamfile, logger=None) | Get the best alignment of each read - where best == longest | Get the best alignment of each read - where best == longest | def getLongestAlignments(bamfile, logger=None):
"""Get the best alignment of each read - where best == longest"""
logger.info("Parsing alignments, keeping longest alignments for " \
"multiple mapping reads...")
best_alns={}
rej_alns={}
for readaln in bamfile.fetch... | [
"def",
"getLongestAlignments",
"(",
"bamfile",
",",
"logger",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"\"Parsing alignments, keeping longest alignments for \"",
"\"multiple mapping reads...\"",
")",
"best_alns",
"=",
"{",
"}",
"rej_alns",
"=",
"{",
"}",
"... | [
121,
0
] | [
139,
31
] | python | en | ['en', 'en', 'en'] | True |
countBaseInstances | (thisstr, updatedic) | for a string count the a, t, g,& c's and update the input dictionary | for a string count the a, t, g,& c's and update the input dictionary | def countBaseInstances(thisstr, updatedic):
""" for a string count the a, t, g,& c's and update the input dictionary """
bases = ["A","T","G","C"]
for base in bases:
updatedic[base]+=thisstr.count(base)
return(updatedic) | [
"def",
"countBaseInstances",
"(",
"thisstr",
",",
"updatedic",
")",
":",
"bases",
"=",
"[",
"\"A\"",
",",
"\"T\"",
",",
"\"G\"",
",",
"\"C\"",
"]",
"for",
"base",
"in",
"bases",
":",
"updatedic",
"[",
"base",
"]",
"+=",
"thisstr",
".",
"count",
"(",
... | [
141,
0
] | [
149,
21
] | python | en | ['en', 'en', 'en'] | True |
parseCStag | (cstag, readseq, logger=None, debug=False) | Parses and extracts the information stored in the 'cs' flag of bamfile alignments.
The information we're looking for with this are identity matches, deletions in reads
relative to the reference, insertions in reads relative to the reference and finally
substitutions of the reference base for other base... | Parses and extracts the information stored in the 'cs' flag of bamfile alignments.
The information we're looking for with this are identity matches, deletions in reads
relative to the reference, insertions in reads relative to the reference and finally
substitutions of the reference base for other base... | def parseCStag(cstag, readseq, logger=None, debug=False):
"""Parses and extracts the information stored in the 'cs' flag of bamfile alignments.
The information we're looking for with this are identity matches, deletions in reads
relative to the reference, insertions in reads relative to the refere... | [
"def",
"parseCStag",
"(",
"cstag",
",",
"readseq",
",",
"logger",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"# define the regex that matches the cs flag components",
"r",
"=",
"re",
".",
"compile",
"(",
"\":[0-9]+|\\*[a-z][a-z]|[=\\+\\-][A-Za-z]+\"",
")",
"... | [
151,
0
] | [
240,
32
] | python | en | ['en', 'en', 'en'] | True |
getGlobalAlignmentStats | (reads, parseCS=True, logger=None) | Get a summary of the alignment stats for the reads | Get a summary of the alignment stats for the reads | def getGlobalAlignmentStats(reads, parseCS=True, logger=None):
"""Get a summary of the alignment stats for the reads"""
logger.info("Building global alignments error stats...")
stats = {"matches":[],
"insertion":[],
"deletion":[],
"skip":[],
... | [
"def",
"getGlobalAlignmentStats",
"(",
"reads",
",",
"parseCS",
"=",
"True",
",",
"logger",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"\"Building global alignments error stats...\"",
")",
"stats",
"=",
"{",
"\"matches\"",
":",
"[",
"]",
",",
"\"insert... | [
242,
0
] | [
316,
17
] | python | en | ['en', 'en', 'en'] | True |
plotErrorDistributions | (aln_stats, nbins=100, saveas=None, logger=None) | Plot sthe distributions of each error type in the data. | Plot sthe distributions of each error type in the data. | def plotErrorDistributions(aln_stats, nbins=100, saveas=None, logger=None):
"""Plot sthe distributions of each error type in the data."""
fig = plt.figure(figsize=(8,18), dpi=150)
plt.subplot(411)
x = plt.hist(aln_stats["nalignedbases"]/aln_stats["nbases"], bins=nbins, alpha=0.5, label="a... | [
"def",
"plotErrorDistributions",
"(",
"aln_stats",
",",
"nbins",
"=",
"100",
",",
"saveas",
"=",
"None",
",",
"logger",
"=",
"None",
")",
":",
"fig",
"=",
"plt",
".",
"figure",
"(",
"figsize",
"=",
"(",
"8",
",",
"18",
")",
",",
"dpi",
"=",
"150",
... | [
318,
0
] | [
356,
15
] | python | en | ['en', 'en', 'en'] | True |
getProportionStats | (aln_stat, logger=None) | convert the alignment stats to proportions so we can compare the occurance of
each error type vs the reference bp proportions | convert the alignment stats to proportions so we can compare the occurance of
each error type vs the reference bp proportions | def getProportionStats(aln_stat, logger=None):
""" convert the alignment stats to proportions so we can compare the occurance of
each error type vs the reference bp proportions """
logger.info("Fractions of each base in the reference sequence underlying each read:")
proportions={"refbases":{},... | [
"def",
"getProportionStats",
"(",
"aln_stat",
",",
"logger",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"\"Fractions of each base in the reference sequence underlying each read:\"",
")",
"proportions",
"=",
"{",
"\"refbases\"",
":",
"{",
"}",
",",
"\"bp_stats\... | [
358,
0
] | [
406,
23
] | python | en | ['en', 'en', 'en'] | True |
plotProportions | (proportions, saveas=None, logger=None) | plot the error proportions fir each of the categories, and the details of the substitutions | plot the error proportions fir each of the categories, and the details of the substitutions | def plotProportions(proportions, saveas=None, logger=None):
"""plot the error proportions fir each of the categories, and the details of the substitutions"""
bases = ["A","T","G","C"]
fig1 = plt.figure(figsize=(10,6), dpi=150)
plotprops = []
ploterrors = []
for base in bases:
... | [
"def",
"plotProportions",
"(",
"proportions",
",",
"saveas",
"=",
"None",
",",
"logger",
"=",
"None",
")",
":",
"bases",
"=",
"[",
"\"A\"",
",",
"\"T\"",
",",
"\"G\"",
",",
"\"C\"",
"]",
"fig1",
"=",
"plt",
".",
"figure",
"(",
"figsize",
"=",
"(",
... | [
408,
0
] | [
472,
21
] | python | en | ['en', 'en', 'en'] | True |
RSpecTester.startup | (self) |
run rspec plugin
|
run rspec plugin
| def startup(self):
"""
run rspec plugin
"""
interpreter = self.settings.get("interpreter", "ruby")
rspec_cmdline = [
interpreter,
self.plugin.tool_path,
"--report-file",
self.report_file,
"--test-suite",
sel... | [
"def",
"startup",
"(",
"self",
")",
":",
"interpreter",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"\"interpreter\"",
",",
"\"ruby\"",
")",
"rspec_cmdline",
"=",
"[",
"interpreter",
",",
"self",
".",
"plugin",
".",
"tool_path",
",",
"\"--report-file\"",
... | [
51,
4
] | [
72,
51
] | python | en | ['en', 'error', 'th'] | False |
DatabaseCreation.test_db_signature | (self) |
Returns a tuple that uniquely identifies a test database.
This takes into account the special cases of ":memory:" and "" for
SQLite since the databases will be distinct despite having the same
TEST NAME. See http://www.sqlite.org/inmemorydb.html
|
Returns a tuple that uniquely identifies a test database. | def test_db_signature(self):
"""
Returns a tuple that uniquely identifies a test database.
This takes into account the special cases of ":memory:" and "" for
SQLite since the databases will be distinct despite having the same
TEST NAME. See http://www.sqlite.org/inmemorydb.html
... | [
"def",
"test_db_signature",
"(",
"self",
")",
":",
"test_database_name",
"=",
"self",
".",
"_get_test_db_name",
"(",
")",
"sig",
"=",
"[",
"self",
".",
"connection",
".",
"settings_dict",
"[",
"'NAME'",
"]",
"]",
"if",
"self",
".",
"is_in_memory_db",
"(",
... | [
100,
4
] | [
112,
25
] | python | en | ['en', 'error', 'th'] | False |
detect_narrowed_window | (
request: HttpRequest, user_profile: Optional[UserProfile]
) | This function implements Zulip's support for a mini Zulip window
that just handles messages from a single narrow | This function implements Zulip's support for a mini Zulip window
that just handles messages from a single narrow | def detect_narrowed_window(
request: HttpRequest, user_profile: Optional[UserProfile]
) -> Tuple[List[List[str]], Optional[Stream], Optional[str]]:
"""This function implements Zulip's support for a mini Zulip window
that just handles messages from a single narrow"""
if user_profile is None:
retu... | [
"def",
"detect_narrowed_window",
"(",
"request",
":",
"HttpRequest",
",",
"user_profile",
":",
"Optional",
"[",
"UserProfile",
"]",
")",
"->",
"Tuple",
"[",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
",",
"Optional",
"[",
"Stream",
"]",
",",
"Optional",
... | [
62,
0
] | [
84,
46
] | python | en | ['en', 'en', 'en'] | True |
update_last_reminder | (user_profile: Optional[UserProfile]) | Reset our don't-spam-users-with-email counter since the
user has since logged in
| Reset our don't-spam-users-with-email counter since the
user has since logged in
| def update_last_reminder(user_profile: Optional[UserProfile]) -> None:
"""Reset our don't-spam-users-with-email counter since the
user has since logged in
"""
if user_profile is None:
return
if user_profile.last_reminder is not None: # nocoverage
# TODO: Look into the history of la... | [
"def",
"update_last_reminder",
"(",
"user_profile",
":",
"Optional",
"[",
"UserProfile",
"]",
")",
"->",
"None",
":",
"if",
"user_profile",
"is",
"None",
":",
"return",
"if",
"user_profile",
".",
"last_reminder",
"is",
"not",
"None",
":",
"# nocoverage",
"# TO... | [
87,
0
] | [
98,
58
] | python | en | ['en', 'en', 'en'] | True |
user_data_dir | (appname=None, appauthor=None, version=None, roaming=False) | r"""Return full path to the user-specific data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific data dir for this application. | def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of ... | [
"def",
"user_data_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"roaming",
"=",
"False",
")",
":",
"if",
"system",
"==",
"\"win32\"",
":",
"if",
"appauthor",
"is",
"None",
":",
"appauthor",
"=",
"ap... | [
48,
0
] | [
100,
15
] | python | en | ['en', 'en', 'en'] | True |
site_data_dir | (appname=None, appauthor=None, version=None, multipath=False) | r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-shared data dir for this application. | def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of ... | [
"def",
"site_data_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"multipath",
"=",
"False",
")",
":",
"if",
"system",
"==",
"\"win32\"",
":",
"if",
"appauthor",
"is",
"None",
":",
"appauthor",
"=",
"... | [
103,
0
] | [
166,
15
] | python | en | ['en', 'en', 'en'] | True |
user_config_dir | (appname=None, appauthor=None, version=None, roaming=False) | r"""Return full path to the user-specific config dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific config dir for this application. | def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific config dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name... | [
"def",
"user_config_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"roaming",
"=",
"False",
")",
":",
"if",
"system",
"in",
"[",
"\"win32\"",
",",
"\"darwin\"",
"]",
":",
"path",
"=",
"user_data_dir",
... | [
169,
0
] | [
206,
15
] | python | en | ['en', 'en', 'en'] | True |
site_config_dir | (appname=None, appauthor=None, version=None, multipath=False) | r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-shared data dir for this application. | def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name o... | [
"def",
"site_config_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"multipath",
"=",
"False",
")",
":",
"if",
"system",
"in",
"[",
"\"win32\"",
",",
"\"darwin\"",
"]",
":",
"path",
"=",
"site_data_dir"... | [
211,
0
] | [
260,
15
] | python | en | ['en', 'en', 'en'] | True |
user_cache_dir | (appname=None, appauthor=None, version=None, opinion=True) | r"""Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific cache dir for this application. | def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
r"""Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of... | [
"def",
"user_cache_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"opinion",
"=",
"True",
")",
":",
"if",
"system",
"==",
"\"win32\"",
":",
"if",
"appauthor",
"is",
"None",
":",
"appauthor",
"=",
"ap... | [
263,
0
] | [
321,
15
] | python | en | ['en', 'en', 'en'] | True |
user_state_dir | (appname=None, appauthor=None, version=None, roaming=False) | r"""Return full path to the user-specific state dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific state dir for this application. | def user_state_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific state dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name o... | [
"def",
"user_state_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"roaming",
"=",
"False",
")",
":",
"if",
"system",
"in",
"[",
"\"win32\"",
",",
"\"darwin\"",
"]",
":",
"path",
"=",
"user_data_dir",
... | [
324,
0
] | [
363,
15
] | python | en | ['en', 'en', 'en'] | True |
user_log_dir | (appname=None, appauthor=None, version=None, opinion=True) | r"""Return full path to the user-specific log dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
... | r"""Return full path to the user-specific log dir for this application. | def user_log_dir(appname=None, appauthor=None, version=None, opinion=True):
r"""Return full path to the user-specific log dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the... | [
"def",
"user_log_dir",
"(",
"appname",
"=",
"None",
",",
"appauthor",
"=",
"None",
",",
"version",
"=",
"None",
",",
"opinion",
"=",
"True",
")",
":",
"if",
"system",
"==",
"\"darwin\"",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
... | [
366,
0
] | [
414,
15
] | python | en | ['en', 'en', 'en'] | True |
_get_win_folder_from_registry | (csidl_name) | This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
| This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
| def _get_win_folder_from_registry(csidl_name):
"""This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
"""
if PY3:
import winreg as _winreg
else:
import _winreg
shell_folder_name = {
"CS... | [
"def",
"_get_win_folder_from_registry",
"(",
"csidl_name",
")",
":",
"if",
"PY3",
":",
"import",
"winreg",
"as",
"_winreg",
"else",
":",
"import",
"_winreg",
"shell_folder_name",
"=",
"{",
"\"CSIDL_APPDATA\"",
":",
"\"AppData\"",
",",
"\"CSIDL_COMMON_APPDATA\"",
":"... | [
465,
0
] | [
486,
14
] | python | en | ['en', 'en', 'en'] | True |
_win_path_to_bytes | (path) | Encode Windows paths to bytes. Only used on Python 2.
Motivation is to be consistent with other operating systems where paths
are also returned as bytes. This avoids problems mixing bytes and Unicode
elsewhere in the codebase. For more details and discussion see
<https://github.com/pypa/pip/issues/3463... | Encode Windows paths to bytes. Only used on Python 2. | def _win_path_to_bytes(path):
"""Encode Windows paths to bytes. Only used on Python 2.
Motivation is to be consistent with other operating systems where paths
are also returned as bytes. This avoids problems mixing bytes and Unicode
elsewhere in the codebase. For more details and discussion see
<ht... | [
"def",
"_win_path_to_bytes",
"(",
"path",
")",
":",
"for",
"encoding",
"in",
"(",
"'ASCII'",
",",
"'MBCS'",
")",
":",
"try",
":",
"return",
"path",
".",
"encode",
"(",
"encoding",
")",
"except",
"(",
"UnicodeEncodeError",
",",
"LookupError",
")",
":",
"p... | [
580,
0
] | [
595,
15
] | python | en | ['en', 'en', 'en'] | True |
TestSearchAreaNoPagePermissions.test_dashboard | (self) |
Check that the menu search area on the dashboard is not searching
pages, as they are not allowed.
|
Check that the menu search area on the dashboard is not searching
pages, as they are not allowed.
| def test_dashboard(self):
"""
Check that the menu search area on the dashboard is not searching
pages, as they are not allowed.
"""
response = self.client.get('/admin/')
# The menu search bar should go to /customsearch/, not /admin/pages/search/
self.assertNotCont... | [
"def",
"test_dashboard",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"'/admin/'",
")",
"# The menu search bar should go to /customsearch/, not /admin/pages/search/",
"self",
".",
"assertNotContains",
"(",
"response",
",",
"reverse",
... | [
86,
4
] | [
94,
64
] | python | en | ['en', 'error', 'th'] | False |
TestSearchAreaNoPagePermissions.test_menu_search | (self) |
The search form should go to the custom search, not the page search.
|
The search form should go to the custom search, not the page search.
| def test_menu_search(self):
"""
The search form should go to the custom search, not the page search.
"""
rendered = self.menu_search()
self.assertNotIn(reverse('wagtailadmin_pages:search'), rendered)
self.assertIn('action="/customsearch/"', rendered) | [
"def",
"test_menu_search",
"(",
"self",
")",
":",
"rendered",
"=",
"self",
".",
"menu_search",
"(",
")",
"self",
".",
"assertNotIn",
"(",
"reverse",
"(",
"'wagtailadmin_pages:search'",
")",
",",
"rendered",
")",
"self",
".",
"assertIn",
"(",
"'action=\"/custom... | [
96,
4
] | [
102,
58
] | python | en | ['en', 'error', 'th'] | False |
TestSearchAreaNoPagePermissions.test_search_other | (self) | The pages search link should be hidden, custom search should be visible. | The pages search link should be hidden, custom search should be visible. | def test_search_other(self):
"""The pages search link should be hidden, custom search should be visible."""
rendered = self.search_other()
self.assertNotIn(reverse('wagtailadmin_pages:search'), rendered)
self.assertIn('/customsearch/', rendered)
self.assertNotIn('Pages', rendere... | [
"def",
"test_search_other",
"(",
"self",
")",
":",
"rendered",
"=",
"self",
".",
"search_other",
"(",
")",
"self",
".",
"assertNotIn",
"(",
"reverse",
"(",
"'wagtailadmin_pages:search'",
")",
",",
"rendered",
")",
"self",
".",
"assertIn",
"(",
"'/customsearch/... | [
104,
4
] | [
111,
44
] | python | en | ['en', 'en', 'en'] | True |
Inventory.print_ini | (self) | Print an ini version of the inventory | Print an ini version of the inventory | def print_ini(self):
"""Print an ini version of the inventory"""
output = list()
inv_dict = self.related.script.get(hostvars=1).json
for group in inv_dict.keys():
if group == '_meta':
continue
# output host groups
output.append('[%s]'... | [
"def",
"print_ini",
"(",
"self",
")",
":",
"output",
"=",
"list",
"(",
")",
"inv_dict",
"=",
"self",
".",
"related",
".",
"script",
".",
"get",
"(",
"hostvars",
"=",
"1",
")",
".",
"json",
"for",
"group",
"in",
"inv_dict",
".",
"keys",
"(",
")",
... | [
22,
4
] | [
52,
32
] | python | en | ['en', 'en', 'en'] | True |
Group.is_root_group | (self) | Returns whether the current group is a top-level root group in the inventory | Returns whether the current group is a top-level root group in the inventory | def is_root_group(self):
"""Returns whether the current group is a top-level root group in the inventory"""
return self.related.inventory.get().related.root_groups.get(id=self.id).count == 1 | [
"def",
"is_root_group",
"(",
"self",
")",
":",
"return",
"self",
".",
"related",
".",
"inventory",
".",
"get",
"(",
")",
".",
"related",
".",
"root_groups",
".",
"get",
"(",
"id",
"=",
"self",
".",
"id",
")",
".",
"count",
"==",
"1"
] | [
146,
4
] | [
148,
90
] | python | en | ['en', 'en', 'en'] | True |
Group.get_parents | (self) | Inspects the API and returns all groups that include the current group as a child. | Inspects the API and returns all groups that include the current group as a child. | def get_parents(self):
"""Inspects the API and returns all groups that include the current group as a child."""
return Groups(self.connection).get(children=self.id).results | [
"def",
"get_parents",
"(",
"self",
")",
":",
"return",
"Groups",
"(",
"self",
".",
"connection",
")",
".",
"get",
"(",
"children",
"=",
"self",
".",
"id",
")",
".",
"results"
] | [
150,
4
] | [
152,
68
] | python | en | ['en', 'en', 'en'] | True |
InventorySource.update | (self) | Update the inventory_source using related->update endpoint | Update the inventory_source using related->update endpoint | def update(self):
"""Update the inventory_source using related->update endpoint"""
# get related->launch
update_pg = self.get_related('update')
# assert can_update == True
assert update_pg.can_update, "The specified inventory_source (id:%s) is not able to update (can_update:%s)"... | [
"def",
"update",
"(",
"self",
")",
":",
"# get related->launch",
"update_pg",
"=",
"self",
".",
"get_related",
"(",
"'update'",
")",
"# assert can_update == True",
"assert",
"update_pg",
".",
"can_update",
",",
"\"The specified inventory_source (id:%s) is not able to update... | [
366,
4
] | [
386,
33
] | python | en | ['en', 'en', 'en'] | True |
InventorySource.is_successful | (self) | An inventory_source is considered successful when source != "" and super().is_successful . | An inventory_source is considered successful when source != "" and super().is_successful . | def is_successful(self):
"""An inventory_source is considered successful when source != "" and super().is_successful ."""
return self.source != "" and super(InventorySource, self).is_successful | [
"def",
"is_successful",
"(",
"self",
")",
":",
"return",
"self",
".",
"source",
"!=",
"\"\"",
"and",
"super",
"(",
"InventorySource",
",",
"self",
")",
".",
"is_successful"
] | [
389,
4
] | [
391,
79
] | python | en | ['en', 'en', 'en'] | True |
launch | (options: dict = None, **kwargs: Any) | Start chrome process and return :class:`~pyppeteer.browser.Browser`.
This function is a shortcut to :meth:`Launcher(options, **kwargs).launch`.
Available options are:
* ``ignoreHTTPSErrors`` (bool): Whether to ignore HTTPS errors. Defaults to
``False``.
* ``headless`` (bool): Whether to run bro... | Start chrome process and return :class:`~pyppeteer.browser.Browser`. | async def launch(options: dict = None, **kwargs: Any) -> Browser:
"""Start chrome process and return :class:`~pyppeteer.browser.Browser`.
This function is a shortcut to :meth:`Launcher(options, **kwargs).launch`.
Available options are:
* ``ignoreHTTPSErrors`` (bool): Whether to ignore HTTPS errors. D... | [
"async",
"def",
"launch",
"(",
"options",
":",
"dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Browser",
":",
"return",
"await",
"Launcher",
"(",
"options",
",",
"*",
"*",
"kwargs",
")",
".",
"launch",
"(",
")"
] | [
250,
0
] | [
329,
53
] | python | en | ['en', 'en', 'en'] | True |
connect | (options: dict = None, **kwargs: Any) | Connect to the existing chrome.
``browserWSEndpoint`` option is necessary to connect to the chrome. The
format is ``ws://${host}:${port}/devtools/browser/<id>``. This value can
get by :attr:`~pyppeteer.browser.Browser.wsEndpoint`.
Available options are:
* ``browserWSEndpoint`` (str): A browser we... | Connect to the existing chrome. | async def connect(options: dict = None, **kwargs: Any) -> Browser:
"""Connect to the existing chrome.
``browserWSEndpoint`` option is necessary to connect to the chrome. The
format is ``ws://${host}:${port}/devtools/browser/<id>``. This value can
get by :attr:`~pyppeteer.browser.Browser.wsEndpoint`.
... | [
"async",
"def",
"connect",
"(",
"options",
":",
"dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Browser",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"logLevel",
"=",
"options",
".",
"get",
"(",
"'logL... | [
332,
0
] | [
384,
55
] | python | en | ['en', 'en', 'en'] | True |
executablePath | () | Get executable path of default chromium. | Get executable path of default chromium. | def executablePath() -> str:
"""Get executable path of default chromium."""
return str(chromium_executable()) | [
"def",
"executablePath",
"(",
")",
"->",
"str",
":",
"return",
"str",
"(",
"chromium_executable",
"(",
")",
")"
] | [
387,
0
] | [
389,
37
] | python | en | ['nl', 'la', 'en'] | False |
defaultArgs | (options: Dict = None, **kwargs: Any) | Get the default flags the chromium will be launched with.
``options`` or keyword arguments are set of configurable options to set on
the browser. Can have the following fields:
* ``headless`` (bool): Whether to run browser in headless mode. Defaults to
``True`` unless the ``devtools`` option is ``Tr... | Get the default flags the chromium will be launched with. | def defaultArgs(options: Dict = None, **kwargs: Any) -> List[str]: # noqa: C901,E501
"""Get the default flags the chromium will be launched with.
``options`` or keyword arguments are set of configurable options to set on
the browser. Can have the following fields:
* ``headless`` (bool): Whether to ru... | [
"def",
"defaultArgs",
"(",
"options",
":",
"Dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"List",
"[",
"str",
"]",
":",
"# noqa: C901,E501",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"devtools",
"=",
"optio... | [
392,
0
] | [
431,
26
] | python | en | ['en', 'en', 'en'] | True |
Launcher.__init__ | (self, options: Dict[str, Any] = None, # noqa: C901
**kwargs: Any) | Make new launcher. | Make new launcher. | def __init__(self, options: Dict[str, Any] = None, # noqa: C901
**kwargs: Any) -> None:
"""Make new launcher."""
options = merge_dict(options, kwargs)
self.port = get_free_port()
self.url = f'http://127.0.0.1:{self.port}'
self._loop = options.get('loop', asynci... | [
"def",
"__init__",
"(",
"self",
",",
"options",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
",",
"# noqa: C901",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"s... | [
68,
4
] | [
126,
65
] | python | en | ['en', 'sn', 'en'] | True |
Launcher.launch | (self) | Start chrome process and return `Browser` object. | Start chrome process and return `Browser` object. | async def launch(self) -> Browser: # noqa: C901
"""Start chrome process and return `Browser` object."""
self.chromeClosed = False
self.connection: Optional[Connection] = None
options = dict()
options['env'] = self.env
if not self.dumpio:
options['stdout'] = ... | [
"async",
"def",
"launch",
"(",
"self",
")",
"->",
"Browser",
":",
"# noqa: C901",
"self",
".",
"chromeClosed",
"=",
"False",
"self",
".",
"connection",
":",
"Optional",
"[",
"Connection",
"]",
"=",
"None",
"options",
"=",
"dict",
"(",
")",
"options",
"["... | [
140,
4
] | [
184,
22
] | python | en | ['en', 'en', 'en'] | True |
Launcher.ensureInitialPage | (self, browser: Browser) | Wait for initial page target to be created. | Wait for initial page target to be created. | async def ensureInitialPage(self, browser: Browser) -> None:
"""Wait for initial page target to be created."""
for target in browser.targets():
if target.type == 'page':
return
initialPagePromise = self._loop.create_future()
def initialPageCallback() -> None... | [
"async",
"def",
"ensureInitialPage",
"(",
"self",
",",
"browser",
":",
"Browser",
")",
"->",
"None",
":",
"for",
"target",
"in",
"browser",
".",
"targets",
"(",
")",
":",
"if",
"target",
".",
"type",
"==",
"'page'",
":",
"return",
"initialPagePromise",
"... | [
186,
4
] | [
203,
39
] | python | en | ['en', 'en', 'en'] | True |
Launcher.waitForChromeToClose | (self) | Terminate chrome. | Terminate chrome. | def waitForChromeToClose(self) -> None:
"""Terminate chrome."""
if self.proc.poll() is None and not self.chromeClosed:
self.chromeClosed = True
try:
self.proc.terminate()
self.proc.wait()
except Exception:
# browser proc... | [
"def",
"waitForChromeToClose",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"proc",
".",
"poll",
"(",
")",
"is",
"None",
"and",
"not",
"self",
".",
"chromeClosed",
":",
"self",
".",
"chromeClosed",
"=",
"True",
"try",
":",
"self",
".",
"pr... | [
223,
4
] | [
232,
20
] | python | en | ['en', 'mi', 'en'] | False |
Launcher.killChrome | (self) | Terminate chromium process. | Terminate chromium process. | async def killChrome(self) -> None:
"""Terminate chromium process."""
logger.info('terminate chrome process...')
if self.connection and self.connection._connected:
try:
await self.connection.send('Browser.close')
await self.connection.dispose()
... | [
"async",
"def",
"killChrome",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"'terminate chrome process...'",
")",
"if",
"self",
".",
"connection",
"and",
"self",
".",
"connection",
".",
"_connected",
":",
"try",
":",
"await",
"self",
"."... | [
234,
4
] | [
247,
45
] | python | en | ['en', 'la', 'it'] | False |
data_to_internal | (data) |
returns internal representation, model objects, dictionaries, etc
as opposed to integer primary keys and JSON strings
|
returns internal representation, model objects, dictionaries, etc
as opposed to integer primary keys and JSON strings
| def data_to_internal(data):
"""
returns internal representation, model objects, dictionaries, etc
as opposed to integer primary keys and JSON strings
"""
internal = data.copy()
if 'extra_vars' in data:
internal['extra_vars'] = json.loads(data['extra_vars'])
if 'credentials' in data:
... | [
"def",
"data_to_internal",
"(",
"data",
")",
":",
"internal",
"=",
"data",
".",
"copy",
"(",
")",
"if",
"'extra_vars'",
"in",
"data",
":",
"internal",
"[",
"'extra_vars'",
"]",
"=",
"json",
".",
"loads",
"(",
"data",
"[",
"'extra_vars'",
"]",
")",
"if"... | [
82,
0
] | [
94,
19
] | python | en | ['en', 'error', 'th'] | False |
test_job_launch_JT_enforces_unique_credentials_kinds | (machine_credential, credentialtype_aws, deploy_jobtemplate) |
JT launching should require that credentials have distinct CredentialTypes
|
JT launching should require that credentials have distinct CredentialTypes
| def test_job_launch_JT_enforces_unique_credentials_kinds(machine_credential, credentialtype_aws, deploy_jobtemplate):
"""
JT launching should require that credentials have distinct CredentialTypes
"""
creds = []
for i in range(2):
aws = Credential.objects.create(name='cred-%d' % i, credentia... | [
"def",
"test_job_launch_JT_enforces_unique_credentials_kinds",
"(",
"machine_credential",
",",
"credentialtype_aws",
",",
"deploy_jobtemplate",
")",
":",
"creds",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"2",
")",
":",
"aws",
"=",
"Credential",
".",
"objects... | [
291,
0
] | [
304,
24
] | python | en | ['en', 'error', 'th'] | False |
TestPagePermission.test_need_delete_permission_to_bulk_delete | (self) |
Having bulk_delete permission is not in itself sufficient to allow deleting pages -
you need actual edit permission on the pages too.
In this test the event editor is given bulk_delete permission, but since their
only other permission is 'add', they cannot delete published pages or pag... |
Having bulk_delete permission is not in itself sufficient to allow deleting pages -
you need actual edit permission on the pages too. | def test_need_delete_permission_to_bulk_delete(self):
"""
Having bulk_delete permission is not in itself sufficient to allow deleting pages -
you need actual edit permission on the pages too.
In this test the event editor is given bulk_delete permission, but since their
only oth... | [
"def",
"test_need_delete_permission_to_bulk_delete",
"(",
"self",
")",
":",
"event_editor",
"=",
"get_user_model",
"(",
")",
".",
"objects",
".",
"get",
"(",
"email",
"=",
"'eventeditor@example.com'",
")",
"events_page",
"=",
"EventIndex",
".",
"objects",
".",
"ge... | [
224,
4
] | [
244,
51
] | python | en | ['en', 'error', 'th'] | False |
set_cru_url | (url) | If you want to use a different server for CRU (for testing, etc). | If you want to use a different server for CRU (for testing, etc). | def set_cru_url(url):
"""If you want to use a different server for CRU (for testing, etc)."""
global CRU_SERVER
CRU_SERVER = url | [
"def",
"set_cru_url",
"(",
"url",
")",
":",
"global",
"CRU_SERVER",
"CRU_SERVER",
"=",
"url"
] | [
33,
0
] | [
36,
20
] | python | en | ['en', 'en', 'en'] | True |
get_cru_cl_file | () | Returns the path to the unpacked CRU CL file. | Returns the path to the unpacked CRU CL file. | def get_cru_cl_file():
"""Returns the path to the unpacked CRU CL file."""
return utils.file_extractor(utils.file_downloader(CRU_CL)) | [
"def",
"get_cru_cl_file",
"(",
")",
":",
"return",
"utils",
".",
"file_extractor",
"(",
"utils",
".",
"file_downloader",
"(",
"CRU_CL",
")",
")"
] | [
40,
0
] | [
42,
62
] | python | en | ['en', 'en', 'en'] | True |
get_cru_file | (var=None) | Returns a path to the desired CRU baseline climate file.
If the file is not present, download it.
Parameters
----------
var : str
'tmp' for temperature
'pre' for precipitation
Returns
-------
str
path to the CRU file
| Returns a path to the desired CRU baseline climate file. | def get_cru_file(var=None):
"""Returns a path to the desired CRU baseline climate file.
If the file is not present, download it.
Parameters
----------
var : str
'tmp' for temperature
'pre' for precipitation
Returns
-------
str
path to the CRU file
"""
... | [
"def",
"get_cru_file",
"(",
"var",
"=",
"None",
")",
":",
"# Be sure input makes sense",
"if",
"var",
"not",
"in",
"[",
"'tmp'",
",",
"'pre'",
"]",
":",
"raise",
"InvalidParamsError",
"(",
"'CRU variable {} does not exist!'",
".",
"format",
"(",
"var",
")",
")... | [
46,
0
] | [
70,
63
] | python | en | ['en', 'en', 'en'] | True |
process_cru_data | (gdir, tmp_file=None, pre_file=None, y0=None, y1=None,
output_filesuffix=None) | Processes and writes the CRU baseline climate data for this glacier.
Interpolates the CRU TS data to the high-resolution CL2 climatologies
(provided with OGGM) and writes everything to a NetCDF file.
Parameters
----------
gdir : :py:class:`oggm.GlacierDirectory`
the glacier directory to pr... | Processes and writes the CRU baseline climate data for this glacier. | def process_cru_data(gdir, tmp_file=None, pre_file=None, y0=None, y1=None,
output_filesuffix=None):
"""Processes and writes the CRU baseline climate data for this glacier.
Interpolates the CRU TS data to the high-resolution CL2 climatologies
(provided with OGGM) and writes everything t... | [
"def",
"process_cru_data",
"(",
"gdir",
",",
"tmp_file",
"=",
"None",
",",
"pre_file",
"=",
"None",
",",
"y0",
"=",
"None",
",",
"y1",
"=",
"None",
",",
"output_filesuffix",
"=",
"None",
")",
":",
"if",
"cfg",
".",
"PARAMS",
"[",
"'baseline_climate'",
... | [
74,
0
] | [
289,
25
] | python | en | ['en', 'en', 'en'] | True |
process_dummy_cru_file | (gdir, sigma_temp=2, sigma_prcp=0.5, seed=None,
y0=None, y1=None, output_filesuffix=None) | Create a simple baseline climate file for this glacier - for testing!
This simply reproduces the climatology with a little randomness in it.
TODO: extend the functionality by allowing a monthly varying sigma
Parameters
----------
gdir : GlacierDirectory
the glacier directory
sigma_tem... | Create a simple baseline climate file for this glacier - for testing! | def process_dummy_cru_file(gdir, sigma_temp=2, sigma_prcp=0.5, seed=None,
y0=None, y1=None, output_filesuffix=None):
"""Create a simple baseline climate file for this glacier - for testing!
This simply reproduces the climatology with a little randomness in it.
TODO: extend the f... | [
"def",
"process_dummy_cru_file",
"(",
"gdir",
",",
"sigma_temp",
"=",
"2",
",",
"sigma_prcp",
"=",
"0.5",
",",
"seed",
"=",
"None",
",",
"y0",
"=",
"None",
",",
"y1",
"=",
"None",
",",
"output_filesuffix",
"=",
"None",
")",
":",
"# read the climatology",
... | [
293,
0
] | [
433,
22
] | 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.