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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
MsvsSettings.GetCflagsCC | (self, config) | Returns the flags that need to be added to .cc compilations. | Returns the flags that need to be added to .cc compilations. | def GetCflagsCC(self, config):
"""Returns the flags that need to be added to .cc compilations."""
config = self._TargetConfig(config)
return ["/TP"] + self._GetPchFlags(config, ".cc") | [
"def",
"GetCflagsCC",
"(",
"self",
",",
"config",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"return",
"[",
"\"/TP\"",
"]",
"+",
"self",
".",
"_GetPchFlags",
"(",
"config",
",",
"\".cc\"",
")"
] | [
570,
4
] | [
573,
57
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings._GetAdditionalLibraryDirectories | (self, root, config, gyp_to_build_path) | Get and normalize the list of paths in AdditionalLibraryDirectories
setting. | Get and normalize the list of paths in AdditionalLibraryDirectories
setting. | def _GetAdditionalLibraryDirectories(self, root, config, gyp_to_build_path):
"""Get and normalize the list of paths in AdditionalLibraryDirectories
setting."""
config = self._TargetConfig(config)
libpaths = self._Setting(
(root, "AdditionalLibraryDirectories"), config, default=[]... | [
"def",
"_GetAdditionalLibraryDirectories",
"(",
"self",
",",
"root",
",",
"config",
",",
"gyp_to_build_path",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"libpaths",
"=",
"self",
".",
"_Setting",
"(",
"(",
"root",
",",
"\"Addit... | [
575,
4
] | [
586,
57
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.GetLibFlags | (self, config, gyp_to_build_path) | Returns the flags that need to be added to lib commands. | Returns the flags that need to be added to lib commands. | def GetLibFlags(self, config, gyp_to_build_path):
"""Returns the flags that need to be added to lib commands."""
config = self._TargetConfig(config)
libflags = []
lib = self._GetWrapper(
self, self.msvs_settings[config], "VCLibrarianTool", append=libflags
)
li... | [
"def",
"GetLibFlags",
"(",
"self",
",",
"config",
",",
"gyp_to_build_path",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"libflags",
"=",
"[",
"]",
"lib",
"=",
"self",
".",
"_GetWrapper",
"(",
"self",
",",
"self",
".",
"ms... | [
588,
4
] | [
607,
23
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.GetDefFile | (self, gyp_to_build_path) | Returns the .def file from sources, if any. Otherwise returns None. | Returns the .def file from sources, if any. Otherwise returns None. | def GetDefFile(self, gyp_to_build_path):
"""Returns the .def file from sources, if any. Otherwise returns None."""
spec = self.spec
if spec["type"] in ("shared_library", "loadable_module", "executable"):
def_files = [
s for s in spec.get("sources", []) if s.lower().e... | [
"def",
"GetDefFile",
"(",
"self",
",",
"gyp_to_build_path",
")",
":",
"spec",
"=",
"self",
".",
"spec",
"if",
"spec",
"[",
"\"type\"",
"]",
"in",
"(",
"\"shared_library\"",
",",
"\"loadable_module\"",
",",
"\"executable\"",
")",
":",
"def_files",
"=",
"[",
... | [
609,
4
] | [
620,
19
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings._GetDefFileAsLdflags | (self, ldflags, gyp_to_build_path) | .def files get implicitly converted to a ModuleDefinitionFile for the
linker in the VS generator. Emulate that behaviour here. | .def files get implicitly converted to a ModuleDefinitionFile for the
linker in the VS generator. Emulate that behaviour here. | def _GetDefFileAsLdflags(self, ldflags, gyp_to_build_path):
""".def files get implicitly converted to a ModuleDefinitionFile for the
linker in the VS generator. Emulate that behaviour here."""
def_file = self.GetDefFile(gyp_to_build_path)
if def_file:
ldflags.append('/DEF:"%s"' %... | [
"def",
"_GetDefFileAsLdflags",
"(",
"self",
",",
"ldflags",
",",
"gyp_to_build_path",
")",
":",
"def_file",
"=",
"self",
".",
"GetDefFile",
"(",
"gyp_to_build_path",
")",
"if",
"def_file",
":",
"ldflags",
".",
"append",
"(",
"'/DEF:\"%s\"'",
"%",
"def_file",
"... | [
622,
4
] | [
627,
50
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.GetPGDName | (self, config, expand_special) | Gets the explicitly overridden pgd name for a target or returns None
if it's not overridden. | Gets the explicitly overridden pgd name for a target or returns None
if it's not overridden. | def GetPGDName(self, config, expand_special):
"""Gets the explicitly overridden pgd name for a target or returns None
if it's not overridden."""
config = self._TargetConfig(config)
output_file = self._Setting(("VCLinkerTool", "ProfileGuidedDatabase"), config)
if output_file:
... | [
"def",
"GetPGDName",
"(",
"self",
",",
"config",
",",
"expand_special",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"output_file",
"=",
"self",
".",
"_Setting",
"(",
"(",
"\"VCLinkerTool\"",
",",
"\"ProfileGuidedDatabase\"",
")",... | [
629,
4
] | [
638,
26
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.GetLdflags | (
self,
config,
gyp_to_build_path,
expand_special,
manifest_base_name,
output_name,
is_executable,
build_dir,
) | Returns the flags that need to be added to link commands, and the
manifest files. | Returns the flags that need to be added to link commands, and the
manifest files. | def GetLdflags(
self,
config,
gyp_to_build_path,
expand_special,
manifest_base_name,
output_name,
is_executable,
build_dir,
):
"""Returns the flags that need to be added to link commands, and the
manifest files."""
config = self._Ta... | [
"def",
"GetLdflags",
"(",
"self",
",",
"config",
",",
"gyp_to_build_path",
",",
"expand_special",
",",
"manifest_base_name",
",",
"output_name",
",",
"is_executable",
",",
"build_dir",
",",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
... | [
640,
4
] | [
771,
61
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings._GetLdManifestFlags | (
self, config, name, gyp_to_build_path, allow_isolation, build_dir
) | Returns a 3-tuple:
- the set of flags that need to be added to the link to generate
a default manifest
- the intermediate manifest that the linker will generate that should be
used to assert it doesn't add anything to the merged one.
- the list of all the manifest files to be merged by the manif... | Returns a 3-tuple:
- the set of flags that need to be added to the link to generate
a default manifest
- the intermediate manifest that the linker will generate that should be
used to assert it doesn't add anything to the merged one.
- the list of all the manifest files to be merged by the manif... | def _GetLdManifestFlags(
self, config, name, gyp_to_build_path, allow_isolation, build_dir
):
"""Returns a 3-tuple:
- the set of flags that need to be added to the link to generate
a default manifest
- the intermediate manifest that the linker will generate that should be
used to... | [
"def",
"_GetLdManifestFlags",
"(",
"self",
",",
"config",
",",
"name",
",",
"gyp_to_build_path",
",",
"allow_isolation",
",",
"build_dir",
")",
":",
"generate_manifest",
"=",
"self",
".",
"_Setting",
"(",
"(",
"\"VCLinkerTool\"",
",",
"\"GenerateManifest\"",
")",
... | [
773,
4
] | [
865,
49
] | python | en | ['en', 'haw', 'en'] | True |
MsvsSettings._GetAdditionalManifestFiles | (self, config, gyp_to_build_path) | Gets additional manifest files that are added to the default one
generated by the linker. | Gets additional manifest files that are added to the default one
generated by the linker. | def _GetAdditionalManifestFiles(self, config, gyp_to_build_path):
"""Gets additional manifest files that are added to the default one
generated by the linker."""
files = self._Setting(
("VCManifestTool", "AdditionalManifestFiles"), config, default=[]
)
if isinstance(files... | [
"def",
"_GetAdditionalManifestFiles",
"(",
"self",
",",
"config",
",",
"gyp_to_build_path",
")",
":",
"files",
"=",
"self",
".",
"_Setting",
"(",
"(",
"\"VCManifestTool\"",
",",
"\"AdditionalManifestFiles\"",
")",
",",
"config",
",",
"default",
"=",
"[",
"]",
... | [
867,
4
] | [
878,
9
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.IsUseLibraryDependencyInputs | (self, config) | Returns whether the target should be linked via Use Library Dependency
Inputs (using component .objs of a given .lib). | Returns whether the target should be linked via Use Library Dependency
Inputs (using component .objs of a given .lib). | def IsUseLibraryDependencyInputs(self, config):
"""Returns whether the target should be linked via Use Library Dependency
Inputs (using component .objs of a given .lib)."""
config = self._TargetConfig(config)
uldi = self._Setting(("VCLinkerTool", "UseLibraryDependencyInputs"), config)
... | [
"def",
"IsUseLibraryDependencyInputs",
"(",
"self",
",",
"config",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"uldi",
"=",
"self",
".",
"_Setting",
"(",
"(",
"\"VCLinkerTool\"",
",",
"\"UseLibraryDependencyInputs\"",
")",
",",
"... | [
880,
4
] | [
885,
29
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.IsEmbedManifest | (self, config) | Returns whether manifest should be linked into binary. | Returns whether manifest should be linked into binary. | def IsEmbedManifest(self, config):
"""Returns whether manifest should be linked into binary."""
config = self._TargetConfig(config)
embed = self._Setting(
("VCManifestTool", "EmbedManifest"), config, default="true"
)
return embed == "true" | [
"def",
"IsEmbedManifest",
"(",
"self",
",",
"config",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"embed",
"=",
"self",
".",
"_Setting",
"(",
"(",
"\"VCManifestTool\"",
",",
"\"EmbedManifest\"",
")",
",",
"config",
",",
"defa... | [
887,
4
] | [
893,
30
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.IsLinkIncremental | (self, config) | Returns whether the target should be linked incrementally. | Returns whether the target should be linked incrementally. | def IsLinkIncremental(self, config):
"""Returns whether the target should be linked incrementally."""
config = self._TargetConfig(config)
link_inc = self._Setting(("VCLinkerTool", "LinkIncremental"), config)
return link_inc != "1" | [
"def",
"IsLinkIncremental",
"(",
"self",
",",
"config",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"link_inc",
"=",
"self",
".",
"_Setting",
"(",
"(",
"\"VCLinkerTool\"",
",",
"\"LinkIncremental\"",
")",
",",
"config",
")",
... | [
895,
4
] | [
899,
30
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.GetRcflags | (self, config, gyp_to_ninja_path) | Returns the flags that need to be added to invocations of the resource
compiler. | Returns the flags that need to be added to invocations of the resource
compiler. | def GetRcflags(self, config, gyp_to_ninja_path):
"""Returns the flags that need to be added to invocations of the resource
compiler."""
config = self._TargetConfig(config)
rcflags = []
rc = self._GetWrapper(
self, self.msvs_settings[config], "VCResourceCompilerTool", appe... | [
"def",
"GetRcflags",
"(",
"self",
",",
"config",
",",
"gyp_to_ninja_path",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"rcflags",
"=",
"[",
"]",
"rc",
"=",
"self",
".",
"_GetWrapper",
"(",
"self",
",",
"self",
".",
"msvs_... | [
901,
4
] | [
914,
22
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.BuildCygwinBashCommandLine | (self, args, path_to_base) | Build a command line that runs args via cygwin bash. We assume that all
incoming paths are in Windows normpath'd form, so they need to be
converted to posix style for the part of the command line that's passed to
bash. We also have to do some Visual Studio macro emulation here because
various rules use ... | Build a command line that runs args via cygwin bash. We assume that all
incoming paths are in Windows normpath'd form, so they need to be
converted to posix style for the part of the command line that's passed to
bash. We also have to do some Visual Studio macro emulation here because
various rules use ... | def BuildCygwinBashCommandLine(self, args, path_to_base):
"""Build a command line that runs args via cygwin bash. We assume that all
incoming paths are in Windows normpath'd form, so they need to be
converted to posix style for the part of the command line that's passed to
bash. We also have to do s... | [
"def",
"BuildCygwinBashCommandLine",
"(",
"self",
",",
"args",
",",
"path_to_base",
")",
":",
"cygwin_dir",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path_to_base",
",",
"self",
".",
"msvs_cygwin_dirs",
"[",
"0",
... | [
916,
4
] | [
936,
18
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.IsRuleRunUnderCygwin | (self, rule) | Determine if an action should be run under cygwin. If the variable is
unset, or set to 1 we use cygwin. | Determine if an action should be run under cygwin. If the variable is
unset, or set to 1 we use cygwin. | def IsRuleRunUnderCygwin(self, rule):
"""Determine if an action should be run under cygwin. If the variable is
unset, or set to 1 we use cygwin."""
return (
int(rule.get("msvs_cygwin_shell", self.spec.get("msvs_cygwin_shell", 1)))
!= 0
) | [
"def",
"IsRuleRunUnderCygwin",
"(",
"self",
",",
"rule",
")",
":",
"return",
"(",
"int",
"(",
"rule",
".",
"get",
"(",
"\"msvs_cygwin_shell\"",
",",
"self",
".",
"spec",
".",
"get",
"(",
"\"msvs_cygwin_shell\"",
",",
"1",
")",
")",
")",
"!=",
"0",
")"
... | [
938,
4
] | [
944,
9
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings._HasExplicitRuleForExtension | (self, spec, extension) | Determine if there's an explicit rule for a particular extension. | Determine if there's an explicit rule for a particular extension. | def _HasExplicitRuleForExtension(self, spec, extension):
"""Determine if there's an explicit rule for a particular extension."""
for rule in spec.get("rules", []):
if rule["extension"] == extension:
return True
return False | [
"def",
"_HasExplicitRuleForExtension",
"(",
"self",
",",
"spec",
",",
"extension",
")",
":",
"for",
"rule",
"in",
"spec",
".",
"get",
"(",
"\"rules\"",
",",
"[",
"]",
")",
":",
"if",
"rule",
"[",
"\"extension\"",
"]",
"==",
"extension",
":",
"return",
... | [
946,
4
] | [
951,
20
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings._HasExplicitIdlActions | (self, spec) | Determine if an action should not run midl for .idl files. | Determine if an action should not run midl for .idl files. | def _HasExplicitIdlActions(self, spec):
"""Determine if an action should not run midl for .idl files."""
return any(
[action.get("explicit_idl_action", 0) for action in spec.get("actions", [])]
) | [
"def",
"_HasExplicitIdlActions",
"(",
"self",
",",
"spec",
")",
":",
"return",
"any",
"(",
"[",
"action",
".",
"get",
"(",
"\"explicit_idl_action\"",
",",
"0",
")",
"for",
"action",
"in",
"spec",
".",
"get",
"(",
"\"actions\"",
",",
"[",
"]",
")",
"]",... | [
953,
4
] | [
957,
9
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.HasExplicitIdlRulesOrActions | (self, spec) | Determine if there's an explicit rule or action for idl files. When
there isn't we need to generate implicit rules to build MIDL .idl files. | Determine if there's an explicit rule or action for idl files. When
there isn't we need to generate implicit rules to build MIDL .idl files. | def HasExplicitIdlRulesOrActions(self, spec):
"""Determine if there's an explicit rule or action for idl files. When
there isn't we need to generate implicit rules to build MIDL .idl files."""
return self._HasExplicitRuleForExtension(
spec, "idl"
) or self._HasExplicitIdlActions(... | [
"def",
"HasExplicitIdlRulesOrActions",
"(",
"self",
",",
"spec",
")",
":",
"return",
"self",
".",
"_HasExplicitRuleForExtension",
"(",
"spec",
",",
"\"idl\"",
")",
"or",
"self",
".",
"_HasExplicitIdlActions",
"(",
"spec",
")"
] | [
959,
4
] | [
964,
46
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.HasExplicitAsmRules | (self, spec) | Determine if there's an explicit rule for asm files. When there isn't we
need to generate implicit rules to assemble .asm files. | Determine if there's an explicit rule for asm files. When there isn't we
need to generate implicit rules to assemble .asm files. | def HasExplicitAsmRules(self, spec):
"""Determine if there's an explicit rule for asm files. When there isn't we
need to generate implicit rules to assemble .asm files."""
return self._HasExplicitRuleForExtension(spec, "asm") | [
"def",
"HasExplicitAsmRules",
"(",
"self",
",",
"spec",
")",
":",
"return",
"self",
".",
"_HasExplicitRuleForExtension",
"(",
"spec",
",",
"\"asm\"",
")"
] | [
966,
4
] | [
969,
61
] | python | en | ['en', 'en', 'en'] | True |
MsvsSettings.GetIdlBuildData | (self, source, config) | Determine the implicit outputs for an idl file. Returns output
directory, outputs, and variables and flags that are required. | Determine the implicit outputs for an idl file. Returns output
directory, outputs, and variables and flags that are required. | def GetIdlBuildData(self, source, config):
"""Determine the implicit outputs for an idl file. Returns output
directory, outputs, and variables and flags that are required."""
config = self._TargetConfig(config)
midl_get = self._GetWrapper(self, self.msvs_settings[config], "VCMIDLTool")
... | [
"def",
"GetIdlBuildData",
"(",
"self",
",",
"source",
",",
"config",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"midl_get",
"=",
"self",
".",
"_GetWrapper",
"(",
"self",
",",
"self",
".",
"msvs_settings",
"[",
"config",
"]... | [
971,
4
] | [
1001,
47
] | python | en | ['en', 'en', 'en'] | True |
PrecompiledHeader._PchHeader | (self) | Get the header that will appear in an #include line for all source
files. | Get the header that will appear in an #include line for all source
files. | def _PchHeader(self):
"""Get the header that will appear in an #include line for all source
files."""
return self.settings.msvs_precompiled_header[self.config] | [
"def",
"_PchHeader",
"(",
"self",
")",
":",
"return",
"self",
".",
"settings",
".",
"msvs_precompiled_header",
"[",
"self",
".",
"config",
"]"
] | [
1027,
4
] | [
1030,
65
] | python | en | ['en', 'en', 'en'] | True |
PrecompiledHeader.GetObjDependencies | (self, sources, objs, arch) | Given a list of sources files and the corresponding object files,
returns a list of the pch files that should be depended upon. The
additional wrapping in the return value is for interface compatibility
with make.py on Mac, and xcode_emulation.py. | Given a list of sources files and the corresponding object files,
returns a list of the pch files that should be depended upon. The
additional wrapping in the return value is for interface compatibility
with make.py on Mac, and xcode_emulation.py. | def GetObjDependencies(self, sources, objs, arch):
"""Given a list of sources files and the corresponding object files,
returns a list of the pch files that should be depended upon. The
additional wrapping in the return value is for interface compatibility
with make.py on Mac, and xcode_emulation.py... | [
"def",
"GetObjDependencies",
"(",
"self",
",",
"sources",
",",
"objs",
",",
"arch",
")",
":",
"assert",
"arch",
"is",
"None",
"if",
"not",
"self",
".",
"_PchHeader",
"(",
")",
":",
"return",
"[",
"]",
"pch_ext",
"=",
"os",
".",
"path",
".",
"splitext... | [
1032,
4
] | [
1044,
17
] | python | en | ['en', 'en', 'en'] | True |
PrecompiledHeader.GetPchBuildCommands | (self, arch) | Not used on Windows as there are no additional build steps required
(instead, existing steps are modified in GetFlagsModifications below). | Not used on Windows as there are no additional build steps required
(instead, existing steps are modified in GetFlagsModifications below). | def GetPchBuildCommands(self, arch):
"""Not used on Windows as there are no additional build steps required
(instead, existing steps are modified in GetFlagsModifications below)."""
return [] | [
"def",
"GetPchBuildCommands",
"(",
"self",
",",
"arch",
")",
":",
"return",
"[",
"]"
] | [
1046,
4
] | [
1049,
17
] | python | en | ['en', 'en', 'en'] | True |
PrecompiledHeader.GetFlagsModifications | (
self, input, output, implicit, command, cflags_c, cflags_cc, expand_special
) | Get the modified cflags and implicit dependencies that should be used
for the pch compilation step. | Get the modified cflags and implicit dependencies that should be used
for the pch compilation step. | def GetFlagsModifications(
self, input, output, implicit, command, cflags_c, cflags_cc, expand_special
):
"""Get the modified cflags and implicit dependencies that should be used
for the pch compilation step."""
if input == self.pch_source:
pch_output = ["/Yc" + self._PchHead... | [
"def",
"GetFlagsModifications",
"(",
"self",
",",
"input",
",",
"output",
",",
"implicit",
",",
"command",
",",
"cflags_c",
",",
"cflags_cc",
",",
"expand_special",
")",
":",
"if",
"input",
"==",
"self",
".",
"pch_source",
":",
"pch_output",
"=",
"[",
"\"/... | [
1051,
4
] | [
1070,
35
] | python | en | ['en', 'en', 'en'] | True |
get_band | (session, dataset, freq_eff, freq_bw, freq_bw_max=.0) |
Returns the frequency band for the given frequency parameters. Will create a new frequency band entry in the
database if no match is found. You can limit the bandwidth of the band association with the freq_bw_max.
args:
session (sqlalchemy.orm.session.Session): a SQLAlchemy session object
... |
Returns the frequency band for the given frequency parameters. Will create a new frequency band entry in the
database if no match is found. You can limit the bandwidth of the band association with the freq_bw_max. | def get_band(session, dataset, freq_eff, freq_bw, freq_bw_max=.0):
"""
Returns the frequency band for the given frequency parameters. Will create a new frequency band entry in the
database if no match is found. You can limit the bandwidth of the band association with the freq_bw_max.
args:
sess... | [
"def",
"get_band",
"(",
"session",
",",
"dataset",
",",
"freq_eff",
",",
"freq_bw",
",",
"freq_bw_max",
"=",
".0",
")",
":",
"if",
"freq_bw_max",
"==",
".0",
":",
"bw_half",
"=",
"freq_bw",
"/",
"2",
"low",
"=",
"freq_eff",
"-",
"bw_half",
"high",
"=",... | [
9,
0
] | [
48,
15
] | python | en | ['en', 'error', 'th'] | False |
update_skyregion_members | (session, skyregion) |
This function performs a simple distance-check against current members of the
runningcatalog to find sources that should be visible in the given skyregion,
and updates the assocskyrgn table accordingly.
Any previous entries in assocskyrgn relating to this skyregion are
deleted first.
Note 1. ... |
This function performs a simple distance-check against current members of the
runningcatalog to find sources that should be visible in the given skyregion,
and updates the assocskyrgn table accordingly. | def update_skyregion_members(session, skyregion):
"""
This function performs a simple distance-check against current members of the
runningcatalog to find sources that should be visible in the given skyregion,
and updates the assocskyrgn table accordingly.
Any previous entries in assocskyrgn relati... | [
"def",
"update_skyregion_members",
"(",
"session",
",",
"skyregion",
")",
":",
"inter",
"=",
"2.",
"*",
"math",
".",
"sin",
"(",
"math",
".",
"radians",
"(",
"skyregion",
".",
"xtr_radius",
")",
"/",
"2.",
")",
"inter_sq",
"=",
"inter",
"*",
"inter",
"... | [
51,
0
] | [
98,
16
] | python | en | ['en', 'error', 'th'] | False |
get_skyregion | (session, dataset, centre_ra, centre_decl, xtr_radius) |
gets an id for a skyregion, given a pair of central co-ordinates and a radius.
If no matching skyregion is found, a new one is inserted. In this case we also trigger execution of
`updateSkyRgnMembers` for the new skyregion - this performs a simple assocation with current members of the
runningcata... |
gets an id for a skyregion, given a pair of central co-ordinates and a radius. | def get_skyregion(session, dataset, centre_ra, centre_decl, xtr_radius):
"""
gets an id for a skyregion, given a pair of central co-ordinates and a radius.
If no matching skyregion is found, a new one is inserted. In this case we also trigger execution of
`updateSkyRgnMembers` for the new skyregion ... | [
"def",
"get_skyregion",
"(",
"session",
",",
"dataset",
",",
"centre_ra",
",",
"centre_decl",
",",
"xtr_radius",
")",
":",
"skyregion",
"=",
"session",
".",
"query",
"(",
"Skyregion",
")",
".",
"filter",
"(",
"Skyregion",
".",
"dataset",
"==",
"dataset",
"... | [
101,
0
] | [
131,
20
] | python | en | ['en', 'error', 'th'] | False |
insert_image | (session, dataset, freq_eff, freq_bw, taustart_ts, tau_time, beam_smaj_pix, beam_smin_pix,
beam_pa_rad, deltax, deltay, url, centre_ra, centre_decl, xtr_radius, rms_qc, freq_bw_max=0.0,
rms_min=None, rms_max=None, detection_thresh=None, analysis_thresh=None) |
Insert an image for a given dataset.
Args:
session (sqlalchemy.orm.session.Session): A SQLalchemy sessions
dataset (int): ID of parent dataset.
freq_eff: See :ref:`Image table definitions <schema-image>`.
freq_bw: See :ref:`Image table definitions <schema-image>`.
freq_... |
Insert an image for a given dataset. | def insert_image(session, dataset, freq_eff, freq_bw, taustart_ts, tau_time, beam_smaj_pix, beam_smin_pix,
beam_pa_rad, deltax, deltay, url, centre_ra, centre_decl, xtr_radius, rms_qc, freq_bw_max=0.0,
rms_min=None, rms_max=None, detection_thresh=None, analysis_thresh=None):
"""
... | [
"def",
"insert_image",
"(",
"session",
",",
"dataset",
",",
"freq_eff",
",",
"freq_bw",
",",
"taustart_ts",
",",
"tau_time",
",",
"beam_smaj_pix",
",",
"beam_smin_pix",
",",
"beam_pa_rad",
",",
"deltax",
",",
"deltay",
",",
"url",
",",
"centre_ra",
",",
"cen... | [
134,
0
] | [
179,
16
] | python | en | ['en', 'error', 'th'] | False |
do_cache | (parser, token) |
This will cache the contents of a template fragment for a given amount
of time.
Usage::
{% load cache %}
{% cache [expire_time] [fragment_name] %}
.. some expensive processing ..
{% endcache %}
This tag also supports varying by a list of arguments::
{% lo... |
This will cache the contents of a template fragment for a given amount
of time. | def do_cache(parser, token):
"""
This will cache the contents of a template fragment for a given amount
of time.
Usage::
{% load cache %}
{% cache [expire_time] [fragment_name] %}
.. some expensive processing ..
{% endcache %}
This tag also supports varying by ... | [
"def",
"do_cache",
"(",
"parser",
",",
"token",
")",
":",
"nodelist",
"=",
"parser",
".",
"parse",
"(",
"(",
"'endcache'",
",",
")",
")",
"parser",
".",
"delete_first_token",
"(",
")",
"tokens",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len... | [
53,
0
] | [
93,
5
] | python | en | ['en', 'error', 'th'] | False |
show_actual_vendor_versions | (vendor_txt_versions) | Log the actual version and print extra info if there is
a conflict or if the actual version could not be imported.
| Log the actual version and print extra info if there is
a conflict or if the actual version could not be imported.
| def show_actual_vendor_versions(vendor_txt_versions):
# type: (Dict[str, str]) -> None
"""Log the actual version and print extra info if there is
a conflict or if the actual version could not be imported.
"""
for module_name, expected_version in vendor_txt_versions.items():
extra_message = '... | [
"def",
"show_actual_vendor_versions",
"(",
"vendor_txt_versions",
")",
":",
"# type: (Dict[str, str]) -> None",
"for",
"module_name",
",",
"expected_version",
"in",
"vendor_txt_versions",
".",
"items",
"(",
")",
":",
"extra_message",
"=",
"''",
"actual_version",
"=",
"g... | [
103,
0
] | [
118,
75
] | python | en | ['en', 'en', 'en'] | True |
load_job_config | (pipe_config) |
Locates the job_params.cfg in 'job_directory' and loads via ConfigParser.
|
Locates the job_params.cfg in 'job_directory' and loads via ConfigParser.
| def load_job_config(pipe_config):
"""
Locates the job_params.cfg in 'job_directory' and loads via ConfigParser.
"""
job_directory = pipe_config['DEFAULT']['job_directory']
job_config = ConfigParser.SafeConfigParser()
job_config.read(os.path.join(job_directory, 'job_params.cfg'))
return parse... | [
"def",
"load_job_config",
"(",
"pipe_config",
")",
":",
"job_directory",
"=",
"pipe_config",
"[",
"'DEFAULT'",
"]",
"[",
"'job_directory'",
"]",
"job_config",
"=",
"ConfigParser",
".",
"SafeConfigParser",
"(",
")",
"job_config",
".",
"read",
"(",
"os",
".",
"p... | [
22,
0
] | [
29,
36
] | python | en | ['en', 'error', 'th'] | False |
check_job_configs_match | (job_config_1, job_config_2) |
Check if job configs match, except dataset_id which we expect to change.
|
Check if job configs match, except dataset_id which we expect to change.
| def check_job_configs_match(job_config_1, job_config_2):
"""
Check if job configs match, except dataset_id which we expect to change.
"""
jc_from_file = job_config_1.copy()
jc_from_db = job_config_2.copy()
del jc_from_file['persistence']['dataset_id']
del jc_from_db['persistence']['dataset_i... | [
"def",
"check_job_configs_match",
"(",
"job_config_1",
",",
"job_config_2",
")",
":",
"jc_from_file",
"=",
"job_config_1",
".",
"copy",
"(",
")",
"jc_from_db",
"=",
"job_config_2",
".",
"copy",
"(",
")",
"del",
"jc_from_file",
"[",
"'persistence'",
"]",
"[",
"... | [
41,
0
] | [
49,
35
] | python | en | ['en', 'error', 'th'] | False |
setup_logging | (log_dir, debug, use_colorlog,
basename='trap') |
Sets up logging to stdout, + info/debug level logfiles in log_dir.
Args:
log_dir (string): log directory
debug (bool): do we want debug level logging on stdout?
basename (string): basename of the log file
|
Sets up logging to stdout, + info/debug level logfiles in log_dir. | def setup_logging(log_dir, debug, use_colorlog,
basename='trap'):
"""
Sets up logging to stdout, + info/debug level logfiles in log_dir.
Args:
log_dir (string): log directory
debug (bool): do we want debug level logging on stdout?
basename (string): basename of the... | [
"def",
"setup_logging",
"(",
"log_dir",
",",
"debug",
",",
"use_colorlog",
",",
"basename",
"=",
"'trap'",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"log_dir",
")",
":",
"os",
".",
"makedirs",
"(",
"log_dir",
")",
"info_log_file",
"=... | [
52,
0
] | [
121,
80
] | python | en | ['en', 'error', 'th'] | False |
group_per_timestep | (metadatas) |
groups a list of TRAP images per time step.
Per time step the images are order per frequency. We could add other
ordering logic (per stoke) later on.
Args:
metadatas (tuple): list of ImageMetadataForSort
Returns:
tuple: List of tuples. The list is sorted by timestamp.
... |
groups a list of TRAP images per time step. | def group_per_timestep(metadatas):
"""
groups a list of TRAP images per time step.
Per time step the images are order per frequency. We could add other
ordering logic (per stoke) later on.
Args:
metadatas (tuple): list of ImageMetadataForSort
Returns:
tuple: List of tuples. Th... | [
"def",
"group_per_timestep",
"(",
"metadatas",
")",
":",
"grouped_dict",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"metadata",
"in",
"metadatas",
":",
"grouped_dict",
"[",
"metadata",
".",
"timestamp",
"]",
".",
"append",
"(",
"metadata",
")",
"grouped_tupl... | [
146,
0
] | [
176,
78
] | python | en | ['en', 'error', 'th'] | False |
BmpImageFile._bitmap | (self, header=0, offset=0) | Read relevant info about the BMP | Read relevant info about the BMP | def _bitmap(self, header=0, offset=0):
""" Read relevant info about the BMP """
read, seek = self.fp.read, self.fp.seek
if header:
seek(header)
file_info = {}
# read bmp header size @offset 14 (this is part of the header size)
file_info["header_size"] = i32(re... | [
"def",
"_bitmap",
"(",
"self",
",",
"header",
"=",
"0",
",",
"offset",
"=",
"0",
")",
":",
"read",
",",
"seek",
"=",
"self",
".",
"fp",
".",
"read",
",",
"self",
".",
"fp",
".",
"seek",
"if",
"header",
":",
"seek",
"(",
"header",
")",
"file_inf... | [
72,
4
] | [
259,
9
] | python | en | ['en', 'en', 'en'] | True |
BmpImageFile._open | (self) | Open file, check magic number and read header | Open file, check magic number and read header | def _open(self):
""" Open file, check magic number and read header """
# read 14 bytes: magic number, filesize, reserved, header final offset
head_data = self.fp.read(14)
# choke if the file does not have the required magic bytes
if not _accept(head_data):
raise Synta... | [
"def",
"_open",
"(",
"self",
")",
":",
"# read 14 bytes: magic number, filesize, reserved, header final offset",
"head_data",
"=",
"self",
".",
"fp",
".",
"read",
"(",
"14",
")",
"# choke if the file does not have the required magic bytes",
"if",
"not",
"_accept",
"(",
"h... | [
261,
4
] | [
271,
35
] | python | en | ['en', 'en', 'en'] | True |
EmulationManager.__init__ | (self, client: CDPSession) | Make new emulation manager. | Make new emulation manager. | def __init__(self, client: CDPSession) -> None:
"""Make new emulation manager."""
self._client = client
self._emulatingMobile = False
self._hasTouch = False | [
"def",
"__init__",
"(",
"self",
",",
"client",
":",
"CDPSession",
")",
"->",
"None",
":",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_emulatingMobile",
"=",
"False",
"self",
".",
"_hasTouch",
"=",
"False"
] | [
12,
4
] | [
16,
30
] | python | en | ['en', 'da', 'en'] | True |
EmulationManager.emulateViewport | (self, viewport: dict) | Evaluate viewport. | Evaluate viewport. | async def emulateViewport(self, viewport: dict) -> bool:
"""Evaluate viewport."""
options = dict()
mobile = viewport.get('isMobile', False)
options['mobile'] = mobile
if 'width' in viewport:
options['width'] = helper.get_positive_int(viewport, 'width')
if 'hei... | [
"async",
"def",
"emulateViewport",
"(",
"self",
",",
"viewport",
":",
"dict",
")",
"->",
"bool",
":",
"options",
"=",
"dict",
"(",
")",
"mobile",
"=",
"viewport",
".",
"get",
"(",
"'isMobile'",
",",
"False",
")",
"options",
"[",
"'mobile'",
"]",
"=",
... | [
18,
4
] | [
48,
27
] | python | en | ['en', 'id', 'en'] | False |
Format.create_dataset | (self, in_stream) |
Create dataset from given string.
|
Create dataset from given string.
| def create_dataset(self, in_stream):
"""
Create dataset from given string.
"""
raise NotImplementedError() | [
"def",
"create_dataset",
"(",
"self",
",",
"in_stream",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
35,
4
] | [
39,
35
] | python | en | ['en', 'error', 'th'] | False |
Format.export_data | (self, dataset, **kwargs) |
Returns format representation for given dataset.
|
Returns format representation for given dataset.
| def export_data(self, dataset, **kwargs):
"""
Returns format representation for given dataset.
"""
raise NotImplementedError() | [
"def",
"export_data",
"(",
"self",
",",
"dataset",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
41,
4
] | [
45,
35
] | python | en | ['en', 'error', 'th'] | False |
Format.is_binary | (self) |
Returns if this format is binary.
|
Returns if this format is binary.
| def is_binary(self):
"""
Returns if this format is binary.
"""
return True | [
"def",
"is_binary",
"(",
"self",
")",
":",
"return",
"True"
] | [
47,
4
] | [
51,
19
] | python | en | ['en', 'error', 'th'] | False |
Format.get_read_mode | (self) |
Returns mode for opening files.
|
Returns mode for opening files.
| def get_read_mode(self):
"""
Returns mode for opening files.
"""
return 'rb' | [
"def",
"get_read_mode",
"(",
"self",
")",
":",
"return",
"'rb'"
] | [
53,
4
] | [
57,
19
] | python | en | ['en', 'error', 'th'] | False |
Format.get_extension | (self) |
Returns extension for this format files.
|
Returns extension for this format files.
| def get_extension(self):
"""
Returns extension for this format files.
"""
return "" | [
"def",
"get_extension",
"(",
"self",
")",
":",
"return",
"\"\""
] | [
59,
4
] | [
63,
17
] | python | en | ['en', 'error', 'th'] | False |
TablibFormat.get_format | (self) |
Import and returns tablib module.
|
Import and returns tablib module.
| def get_format(self):
"""
Import and returns tablib module.
"""
try:
# Available since tablib 1.0
from tablib.formats import registry
except ImportError:
return import_module(self.TABLIB_MODULE)
else:
key = self.TABLIB_MODUL... | [
"def",
"get_format",
"(",
"self",
")",
":",
"try",
":",
"# Available since tablib 1.0",
"from",
"tablib",
".",
"formats",
"import",
"registry",
"except",
"ImportError",
":",
"return",
"import_module",
"(",
"self",
".",
"TABLIB_MODULE",
")",
"else",
":",
"key",
... | [
85,
4
] | [
96,
43
] | python | en | ['en', 'error', 'th'] | False |
XLS.create_dataset | (self, in_stream) |
Create dataset from first sheet.
|
Create dataset from first sheet.
| def create_dataset(self, in_stream):
"""
Create dataset from first sheet.
"""
import xlrd
xls_book = xlrd.open_workbook(file_contents=in_stream)
dataset = tablib.Dataset()
sheet = xls_book.sheets()[0]
dataset.headers = sheet.row_values(0)
for i in... | [
"def",
"create_dataset",
"(",
"self",
",",
"in_stream",
")",
":",
"import",
"xlrd",
"xls_book",
"=",
"xlrd",
".",
"open_workbook",
"(",
"file_contents",
"=",
"in_stream",
")",
"dataset",
"=",
"tablib",
".",
"Dataset",
"(",
")",
"sheet",
"=",
"xls_book",
".... | [
177,
4
] | [
189,
22
] | python | en | ['en', 'error', 'th'] | False |
XLSX.create_dataset | (self, in_stream) |
Create dataset from first sheet.
|
Create dataset from first sheet.
| def create_dataset(self, in_stream):
"""
Create dataset from first sheet.
"""
from io import BytesIO
import openpyxl
xlsx_book = openpyxl.load_workbook(BytesIO(in_stream), read_only=True)
dataset = tablib.Dataset()
sheet = xlsx_book.active
# obt... | [
"def",
"create_dataset",
"(",
"self",
",",
"in_stream",
")",
":",
"from",
"io",
"import",
"BytesIO",
"import",
"openpyxl",
"xlsx_book",
"=",
"openpyxl",
".",
"load_workbook",
"(",
"BytesIO",
"(",
"in_stream",
")",
",",
"read_only",
"=",
"True",
")",
"dataset... | [
196,
4
] | [
215,
22
] | python | en | ['en', 'error', 'th'] | False |
cursor_iter | (cursor, sentinel, col_count) |
Yields blocks of rows from a cursor and ensures the cursor is closed when
done.
|
Yields blocks of rows from a cursor and ensures the cursor is closed when
done.
| def cursor_iter(cursor, sentinel, col_count):
"""
Yields blocks of rows from a cursor and ensures the cursor is closed when
done.
"""
try:
for rows in iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)),
sentinel):
yield [r[0:col_count] for r in rows... | [
"def",
"cursor_iter",
"(",
"cursor",
",",
"sentinel",
",",
"col_count",
")",
":",
"try",
":",
"for",
"rows",
"in",
"iter",
"(",
"(",
"lambda",
":",
"cursor",
".",
"fetchmany",
"(",
"GET_ITERATOR_CHUNK_SIZE",
")",
")",
",",
"sentinel",
")",
":",
"yield",
... | [
1268,
0
] | [
1278,
22
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.pre_sql_setup | (self) |
Does any necessary class setup immediately prior to producing SQL. This
is for things that can't necessarily be done in __init__ because we
might not have all the pieces in place at that time.
|
Does any necessary class setup immediately prior to producing SQL. This
is for things that can't necessarily be done in __init__ because we
might not have all the pieces in place at that time.
| def pre_sql_setup(self):
"""
Does any necessary class setup immediately prior to producing SQL. This
is for things that can't necessarily be done in __init__ because we
might not have all the pieces in place at that time.
"""
self.setup_query()
order_by = self.get... | [
"def",
"pre_sql_setup",
"(",
"self",
")",
":",
"self",
".",
"setup_query",
"(",
")",
"order_by",
"=",
"self",
".",
"get_order_by",
"(",
")",
"self",
".",
"where",
",",
"self",
".",
"having",
"=",
"self",
".",
"query",
".",
"where",
".",
"split_having",... | [
39,
4
] | [
50,
47
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.get_group_by | (self, select, order_by) |
Returns a list of 2-tuples of form (sql, params).
The logic of what exactly the GROUP BY clause contains is hard
to describe in other words than "if it passes the test suite,
then it is correct".
|
Returns a list of 2-tuples of form (sql, params). | def get_group_by(self, select, order_by):
"""
Returns a list of 2-tuples of form (sql, params).
The logic of what exactly the GROUP BY clause contains is hard
to describe in other words than "if it passes the test suite,
then it is correct".
"""
# Some examples:
... | [
"def",
"get_group_by",
"(",
"self",
",",
"select",
",",
"order_by",
")",
":",
"# Some examples:",
"# SomeModel.objects.annotate(Count('somecol'))",
"# GROUP BY: all fields of the model",
"#",
"# SomeModel.objects.values('name').annotate(Count('somecol'))",
"# GROUP BY: na... | [
52,
4
] | [
130,
21
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.get_select | (self) |
Returns three values:
- a list of 3-tuples of (expression, (sql, params), alias)
- a klass_info structure,
- a dictionary of annotations
The (sql, params) is what the expression will produce, and alias is the
"AS alias" for the column (possibly None).
The klass... |
Returns three values:
- a list of 3-tuples of (expression, (sql, params), alias)
- a klass_info structure,
- a dictionary of annotations | def get_select(self):
"""
Returns three values:
- a list of 3-tuples of (expression, (sql, params), alias)
- a klass_info structure,
- a dictionary of annotations
The (sql, params) is what the expression will produce, and alias is the
"AS alias" for the column (p... | [
"def",
"get_select",
"(",
"self",
")",
":",
"select",
"=",
"[",
"]",
"klass_info",
"=",
"None",
"annotations",
"=",
"{",
"}",
"select_idx",
"=",
"0",
"for",
"alias",
",",
"(",
"sql",
",",
"params",
")",
"in",
"self",
".",
"query",
".",
"extra_select"... | [
164,
4
] | [
231,
43
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.get_order_by | (self) |
Returns a list of 2-tuples of form (expr, (sql, params, is_ref)) for the
ORDER BY clause.
The order_by clause can alter the select clause (for example it
can add aliases to clauses that do not yet have one, or it can
add totally new select clauses).
|
Returns a list of 2-tuples of form (expr, (sql, params, is_ref)) for the
ORDER BY clause. | def get_order_by(self):
"""
Returns a list of 2-tuples of form (expr, (sql, params, is_ref)) for the
ORDER BY clause.
The order_by clause can alter the select clause (for example it
can add aliases to clauses that do not yet have one, or it can
add totally new select cla... | [
"def",
"get_order_by",
"(",
"self",
")",
":",
"if",
"self",
".",
"query",
".",
"extra_order_by",
":",
"ordering",
"=",
"self",
".",
"query",
".",
"extra_order_by",
"elif",
"not",
"self",
".",
"query",
".",
"default_ordering",
":",
"ordering",
"=",
"self",
... | [
233,
4
] | [
338,
21
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.quote_name_unless_alias | (self, name) |
A wrapper around connection.ops.quote_name that doesn't quote aliases
for table names. This avoids problems with some SQL dialects that treat
quoted strings specially (e.g. PostgreSQL).
|
A wrapper around connection.ops.quote_name that doesn't quote aliases
for table names. This avoids problems with some SQL dialects that treat
quoted strings specially (e.g. PostgreSQL).
| def quote_name_unless_alias(self, name):
"""
A wrapper around connection.ops.quote_name that doesn't quote aliases
for table names. This avoids problems with some SQL dialects that treat
quoted strings specially (e.g. PostgreSQL).
"""
if name in self.quote_cache:
... | [
"def",
"quote_name_unless_alias",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"quote_cache",
":",
"return",
"self",
".",
"quote_cache",
"[",
"name",
"]",
"if",
"(",
"(",
"name",
"in",
"self",
".",
"query",
".",
"alias_map",
"an... | [
350,
4
] | [
365,
16
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.as_sql | (self, with_limits=True, with_col_aliases=False) |
Creates the SQL for this query. Returns the SQL string and list of
parameters.
If 'with_limits' is False, any limit/offset information is not included
in the query.
|
Creates the SQL for this query. Returns the SQL string and list of
parameters. | def as_sql(self, with_limits=True, with_col_aliases=False):
"""
Creates the SQL for this query. Returns the SQL string and list of
parameters.
If 'with_limits' is False, any limit/offset information is not included
in the query.
"""
refcounts_before = self.query.... | [
"def",
"as_sql",
"(",
"self",
",",
"with_limits",
"=",
"True",
",",
"with_col_aliases",
"=",
"False",
")",
":",
"refcounts_before",
"=",
"self",
".",
"query",
".",
"alias_refcount",
".",
"copy",
"(",
")",
"try",
":",
"extra_select",
",",
"order_by",
",",
... | [
401,
4
] | [
512,
56
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.get_default_columns | (self, start_alias=None, opts=None, from_parent=None) |
Computes the default columns for selecting every field in the base
model. Will sometimes be called to pull in related models (e.g. via
select_related), in which case "opts" and "start_alias" will be given
to provide a starting point for the traversal.
Returns a list of strings,... |
Computes the default columns for selecting every field in the base
model. Will sometimes be called to pull in related models (e.g. via
select_related), in which case "opts" and "start_alias" will be given
to provide a starting point for the traversal. | def get_default_columns(self, start_alias=None, opts=None, from_parent=None):
"""
Computes the default columns for selecting every field in the base
model. Will sometimes be called to pull in related models (e.g. via
select_related), in which case "opts" and "start_alias" will be given
... | [
"def",
"get_default_columns",
"(",
"self",
",",
"start_alias",
"=",
"None",
",",
"opts",
"=",
"None",
",",
"from_parent",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"if",
"opts",
"is",
"None",
":",
"opts",
"=",
"self",
".",
"query",
".",
"get_me... | [
514,
4
] | [
557,
21
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.get_distinct | (self) |
Returns a quoted list of fields to use in DISTINCT ON part of the query.
Note that this method can alter the tables in the query, and thus it
must be called before get_from_clause().
|
Returns a quoted list of fields to use in DISTINCT ON part of the query. | def get_distinct(self):
"""
Returns a quoted list of fields to use in DISTINCT ON part of the query.
Note that this method can alter the tables in the query, and thus it
must be called before get_from_clause().
"""
qn = self.quote_name_unless_alias
qn2 = self.con... | [
"def",
"get_distinct",
"(",
"self",
")",
":",
"qn",
"=",
"self",
".",
"quote_name_unless_alias",
"qn2",
"=",
"self",
".",
"connection",
".",
"ops",
".",
"quote_name",
"result",
"=",
"[",
"]",
"opts",
"=",
"self",
".",
"query",
".",
"get_meta",
"(",
")"... | [
559,
4
] | [
580,
21
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.find_ordering_name | (self, name, opts, alias=None, default_order='ASC',
already_seen=None) |
Returns the table alias (the name might be ambiguous, the alias will
not be) and column name for ordering by the given 'name' parameter.
The 'name' is of the form 'field1__field2__...__fieldN'.
|
Returns the table alias (the name might be ambiguous, the alias will
not be) and column name for ordering by the given 'name' parameter.
The 'name' is of the form 'field1__field2__...__fieldN'.
| def find_ordering_name(self, name, opts, alias=None, default_order='ASC',
already_seen=None):
"""
Returns the table alias (the name might be ambiguous, the alias will
not be) and column name for ordering by the given 'name' parameter.
The 'name' is of the form ... | [
"def",
"find_ordering_name",
"(",
"self",
",",
"name",
",",
"opts",
",",
"alias",
"=",
"None",
",",
"default_order",
"=",
"'ASC'",
",",
"already_seen",
"=",
"None",
")",
":",
"name",
",",
"order",
"=",
"get_order_dir",
"(",
"name",
",",
"default_order",
... | [
582,
4
] | [
612,
91
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler._setup_joins | (self, pieces, opts, alias) |
A helper method for get_order_by and get_distinct.
Note that get_ordering and get_distinct must produce same target
columns on same input, as the prefixes of get_ordering and get_distinct
must match. Executing SQL where this is not true is an error.
|
A helper method for get_order_by and get_distinct. | def _setup_joins(self, pieces, opts, alias):
"""
A helper method for get_order_by and get_distinct.
Note that get_ordering and get_distinct must produce same target
columns on same input, as the prefixes of get_ordering and get_distinct
must match. Executing SQL where this is no... | [
"def",
"_setup_joins",
"(",
"self",
",",
"pieces",
",",
"opts",
",",
"alias",
")",
":",
"if",
"not",
"alias",
":",
"alias",
"=",
"self",
".",
"query",
".",
"get_initial_alias",
"(",
")",
"field",
",",
"targets",
",",
"opts",
",",
"joins",
",",
"path"... | [
614,
4
] | [
627,
55
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.get_from_clause | (self) |
Returns a list of strings that are joined together to go after the
"FROM" part of the query, as well as a list any extra parameters that
need to be included. Sub-classes, can override this to create a
from-clause via a "select".
This should only be called after any SQL construc... |
Returns a list of strings that are joined together to go after the
"FROM" part of the query, as well as a list any extra parameters that
need to be included. Sub-classes, can override this to create a
from-clause via a "select". | def get_from_clause(self):
"""
Returns a list of strings that are joined together to go after the
"FROM" part of the query, as well as a list any extra parameters that
need to be included. Sub-classes, can override this to create a
from-clause via a "select".
This should... | [
"def",
"get_from_clause",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"params",
"=",
"[",
"]",
"for",
"alias",
"in",
"self",
".",
"query",
".",
"tables",
":",
"if",
"not",
"self",
".",
"query",
".",
"alias_refcount",
"[",
"alias",
"]",
":",
"co... | [
629,
4
] | [
661,
29
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.get_related_selections | (self, select, opts=None, root_alias=None, cur_depth=1,
requested=None, restricted=None) |
Fill in the information needed for a select_related query. The current
depth is measured as the number of connections away from the root model
(for example, cur_depth=1 means we are looking at models with direct
connections to the root model).
|
Fill in the information needed for a select_related query. The current
depth is measured as the number of connections away from the root model
(for example, cur_depth=1 means we are looking at models with direct
connections to the root model).
| def get_related_selections(self, select, opts=None, root_alias=None, cur_depth=1,
requested=None, restricted=None):
"""
Fill in the information needed for a select_related query. The current
depth is measured as the number of connections away from the root model
... | [
"def",
"get_related_selections",
"(",
"self",
",",
"select",
",",
"opts",
"=",
"None",
",",
"root_alias",
"=",
"None",
",",
"cur_depth",
"=",
"1",
",",
"requested",
"=",
"None",
",",
"restricted",
"=",
"None",
")",
":",
"def",
"_get_field_choices",
"(",
... | [
663,
4
] | [
791,
34
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.deferred_to_columns | (self) |
Converts the self.deferred_loading data structure to mapping of table
names to sets of column names which are to be loaded. Returns the
dictionary.
|
Converts the self.deferred_loading data structure to mapping of table
names to sets of column names which are to be loaded. Returns the
dictionary.
| def deferred_to_columns(self):
"""
Converts the self.deferred_loading data structure to mapping of table
names to sets of column names which are to be loaded. Returns the
dictionary.
"""
columns = {}
self.query.deferred_to_data(columns, self.query.get_loaded_field... | [
"def",
"deferred_to_columns",
"(",
"self",
")",
":",
"columns",
"=",
"{",
"}",
"self",
".",
"query",
".",
"deferred_to_data",
"(",
"columns",
",",
"self",
".",
"query",
".",
"get_loaded_field_names_cb",
")",
"return",
"columns"
] | [
793,
4
] | [
801,
22
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.results_iter | (self, results=None) |
Returns an iterator over the results from executing this query.
|
Returns an iterator over the results from executing this query.
| def results_iter(self, results=None):
"""
Returns an iterator over the results from executing this query.
"""
if results is None:
results = self.execute_sql(MULTI)
fields = [s[0] for s in self.select[0:self.col_count]]
converters = self.get_converters(fields)
... | [
"def",
"results_iter",
"(",
"self",
",",
"results",
"=",
"None",
")",
":",
"if",
"results",
"is",
"None",
":",
"results",
"=",
"self",
".",
"execute_sql",
"(",
"MULTI",
")",
"fields",
"=",
"[",
"s",
"[",
"0",
"]",
"for",
"s",
"in",
"self",
".",
"... | [
822,
4
] | [
834,
25
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.has_results | (self) |
Backends (e.g. NoSQL) can override this in order to use optimized
versions of "query has any results."
|
Backends (e.g. NoSQL) can override this in order to use optimized
versions of "query has any results."
| def has_results(self):
"""
Backends (e.g. NoSQL) can override this in order to use optimized
versions of "query has any results."
"""
# This is always executed on a query clone, so we can modify self.query
self.query.add_extra({'a': 1}, None, None, None, None, None)
... | [
"def",
"has_results",
"(",
"self",
")",
":",
"# This is always executed on a query clone, so we can modify self.query",
"self",
".",
"query",
".",
"add_extra",
"(",
"{",
"'a'",
":",
"1",
"}",
",",
"None",
",",
"None",
",",
"None",
",",
"None",
",",
"None",
")"... | [
836,
4
] | [
844,
45
] | python | en | ['en', 'error', 'th'] | False |
SQLCompiler.execute_sql | (self, result_type=MULTI, chunked_fetch=False) |
Run the query against the database and returns the result(s). The
return value is a single data item if result_type is SINGLE, or an
iterator over the results if the result_type is MULTI.
result_type is either MULTI (use fetchmany() to retrieve all rows),
SINGLE (only retrieve ... |
Run the query against the database and returns the result(s). The
return value is a single data item if result_type is SINGLE, or an
iterator over the results if the result_type is MULTI. | def execute_sql(self, result_type=MULTI, chunked_fetch=False):
"""
Run the query against the database and returns the result(s). The
return value is a single data item if result_type is SINGLE, or an
iterator over the results if the result_type is MULTI.
result_type is either MU... | [
"def",
"execute_sql",
"(",
"self",
",",
"result_type",
"=",
"MULTI",
",",
"chunked_fetch",
"=",
"False",
")",
":",
"if",
"not",
"result_type",
":",
"result_type",
"=",
"NO_RESULTS",
"try",
":",
"sql",
",",
"params",
"=",
"self",
".",
"as_sql",
"(",
")",
... | [
846,
4
] | [
917,
21
] | python | en | ['en', 'error', 'th'] | False |
SQLInsertCompiler.field_as_sql | (self, field, val) |
Take a field and a value intended to be saved on that field, and
return placeholder SQL and accompanying params. Checks for raw values,
expressions and fields with get_placeholder() defined in that order.
When field is None, the value is considered raw and is used as the
placeh... |
Take a field and a value intended to be saved on that field, and
return placeholder SQL and accompanying params. Checks for raw values,
expressions and fields with get_placeholder() defined in that order. | def field_as_sql(self, field, val):
"""
Take a field and a value intended to be saved on that field, and
return placeholder SQL and accompanying params. Checks for raw values,
expressions and fields with get_placeholder() defined in that order.
When field is None, the value is c... | [
"def",
"field_as_sql",
"(",
"self",
",",
"field",
",",
"val",
")",
":",
"if",
"field",
"is",
"None",
":",
"# A field value of None means the value is raw.",
"sql",
",",
"params",
"=",
"val",
",",
"[",
"]",
"elif",
"hasattr",
"(",
"val",
",",
"'as_sql'",
")... | [
939,
4
] | [
969,
26
] | python | en | ['en', 'error', 'th'] | False |
SQLInsertCompiler.prepare_value | (self, field, value) |
Prepare a value to be used in a query by resolving it if it is an
expression and otherwise calling the field's get_db_prep_save().
|
Prepare a value to be used in a query by resolving it if it is an
expression and otherwise calling the field's get_db_prep_save().
| def prepare_value(self, field, value):
"""
Prepare a value to be used in a query by resolving it if it is an
expression and otherwise calling the field's get_db_prep_save().
"""
if hasattr(value, 'resolve_expression'):
value = value.resolve_expression(self.query, allo... | [
"def",
"prepare_value",
"(",
"self",
",",
"field",
",",
"value",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'resolve_expression'",
")",
":",
"value",
"=",
"value",
".",
"resolve_expression",
"(",
"self",
".",
"query",
",",
"allow_joins",
"=",
"False",
... | [
971,
4
] | [
990,
20
] | python | en | ['en', 'error', 'th'] | False |
SQLInsertCompiler.pre_save_val | (self, field, obj) |
Get the given field's value off the given obj. pre_save() is used for
things like auto_now on DateTimeField. Skip it if this is a raw query.
|
Get the given field's value off the given obj. pre_save() is used for
things like auto_now on DateTimeField. Skip it if this is a raw query.
| def pre_save_val(self, field, obj):
"""
Get the given field's value off the given obj. pre_save() is used for
things like auto_now on DateTimeField. Skip it if this is a raw query.
"""
if self.query.raw:
return getattr(obj, field.attname)
return field.pre_save... | [
"def",
"pre_save_val",
"(",
"self",
",",
"field",
",",
"obj",
")",
":",
"if",
"self",
".",
"query",
".",
"raw",
":",
"return",
"getattr",
"(",
"obj",
",",
"field",
".",
"attname",
")",
"return",
"field",
".",
"pre_save",
"(",
"obj",
",",
"add",
"="... | [
992,
4
] | [
999,
44
] | python | en | ['en', 'error', 'th'] | False |
SQLInsertCompiler.assemble_as_sql | (self, fields, value_rows) |
Take a sequence of N fields and a sequence of M rows of values,
generate placeholder SQL and parameters for each field and value, and
return a pair containing:
* a sequence of M rows of N SQL placeholder strings, and
* a sequence of M rows of corresponding parameter values.
... |
Take a sequence of N fields and a sequence of M rows of values,
generate placeholder SQL and parameters for each field and value, and
return a pair containing:
* a sequence of M rows of N SQL placeholder strings, and
* a sequence of M rows of corresponding parameter values. | def assemble_as_sql(self, fields, value_rows):
"""
Take a sequence of N fields and a sequence of M rows of values,
generate placeholder SQL and parameters for each field and value, and
return a pair containing:
* a sequence of M rows of N SQL placeholder strings, and
* ... | [
"def",
"assemble_as_sql",
"(",
"self",
",",
"fields",
",",
"value_rows",
")",
":",
"if",
"not",
"value_rows",
":",
"return",
"[",
"]",
",",
"[",
"]",
"# list of (sql, [params]) tuples for each object to be saved",
"# Shape: [n_objs][n_fields][2]",
"rows_of_fields_as_sql",... | [
1001,
4
] | [
1034,
43
] | python | en | ['en', 'error', 'th'] | False |
SQLDeleteCompiler.as_sql | (self) |
Creates the SQL for this query. Returns the SQL string and list of
parameters.
|
Creates the SQL for this query. Returns the SQL string and list of
parameters.
| def as_sql(self):
"""
Creates the SQL for this query. Returns the SQL string and list of
parameters.
"""
assert len([t for t in self.query.tables if self.query.alias_refcount[t] > 0]) == 1, \
"Can only delete from one table at a time."
qn = self.quote_name_unl... | [
"def",
"as_sql",
"(",
"self",
")",
":",
"assert",
"len",
"(",
"[",
"t",
"for",
"t",
"in",
"self",
".",
"query",
".",
"tables",
"if",
"self",
".",
"query",
".",
"alias_refcount",
"[",
"t",
"]",
">",
"0",
"]",
")",
"==",
"1",
",",
"\"Can only delet... | [
1112,
4
] | [
1124,
46
] | python | en | ['en', 'error', 'th'] | False |
SQLUpdateCompiler.as_sql | (self) |
Creates the SQL for this query. Returns the SQL string and list of
parameters.
|
Creates the SQL for this query. Returns the SQL string and list of
parameters.
| def as_sql(self):
"""
Creates the SQL for this query. Returns the SQL string and list of
parameters.
"""
self.pre_sql_setup()
if not self.query.values:
return '', ()
qn = self.quote_name_unless_alias
values, update_params = [], []
for f... | [
"def",
"as_sql",
"(",
"self",
")",
":",
"self",
".",
"pre_sql_setup",
"(",
")",
"if",
"not",
"self",
".",
"query",
".",
"values",
":",
"return",
"''",
",",
"(",
")",
"qn",
"=",
"self",
".",
"quote_name_unless_alias",
"values",
",",
"update_params",
"="... | [
1128,
4
] | [
1181,
62
] | python | en | ['en', 'error', 'th'] | False |
SQLUpdateCompiler.execute_sql | (self, result_type) |
Execute the specified update. Returns the number of rows affected by
the primary update query. The "primary update query" is the first
non-empty query that is executed. Row counts for any subsequent,
related queries are not available.
|
Execute the specified update. Returns the number of rows affected by
the primary update query. The "primary update query" is the first
non-empty query that is executed. Row counts for any subsequent,
related queries are not available.
| def execute_sql(self, result_type):
"""
Execute the specified update. Returns the number of rows affected by
the primary update query. The "primary update query" is the first
non-empty query that is executed. Row counts for any subsequent,
related queries are not available.
... | [
"def",
"execute_sql",
"(",
"self",
",",
"result_type",
")",
":",
"cursor",
"=",
"super",
"(",
"SQLUpdateCompiler",
",",
"self",
")",
".",
"execute_sql",
"(",
"result_type",
")",
"try",
":",
"rows",
"=",
"cursor",
".",
"rowcount",
"if",
"cursor",
"else",
... | [
1183,
4
] | [
1202,
19
] | python | en | ['en', 'error', 'th'] | False |
SQLUpdateCompiler.pre_sql_setup | (self) |
If the update depends on results from other tables, we need to do some
munging of the "where" conditions to match the format required for
(portable) SQL updates. That is done here.
Further, if we are going to be running multiple updates, we pull out
the id values to update at t... |
If the update depends on results from other tables, we need to do some
munging of the "where" conditions to match the format required for
(portable) SQL updates. That is done here. | def pre_sql_setup(self):
"""
If the update depends on results from other tables, we need to do some
munging of the "where" conditions to match the format required for
(portable) SQL updates. That is done here.
Further, if we are going to be running multiple updates, we pull out
... | [
"def",
"pre_sql_setup",
"(",
"self",
")",
":",
"refcounts_before",
"=",
"self",
".",
"query",
".",
"alias_refcount",
".",
"copy",
"(",
")",
"# Ensure base table is in the query",
"self",
".",
"query",
".",
"get_initial_alias",
"(",
")",
"count",
"=",
"self",
"... | [
1204,
4
] | [
1245,
52
] | python | en | ['en', 'error', 'th'] | False |
SQLAggregateCompiler.as_sql | (self) |
Creates the SQL for this query. Returns the SQL string and list of
parameters.
|
Creates the SQL for this query. Returns the SQL string and list of
parameters.
| def as_sql(self):
"""
Creates the SQL for this query. Returns the SQL string and list of
parameters.
"""
sql, params = [], []
for annotation in self.query.annotation_select.values():
ann_sql, ann_params = self.compile(annotation, select_format=FORCE)
... | [
"def",
"as_sql",
"(",
"self",
")",
":",
"sql",
",",
"params",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"annotation",
"in",
"self",
".",
"query",
".",
"annotation_select",
".",
"values",
"(",
")",
":",
"ann_sql",
",",
"ann_params",
"=",
"self",
".",
"co... | [
1249,
4
] | [
1265,
26
] | python | en | ['en', 'error', 'th'] | False |
TestPageCreation.test_create_multipart | (self) |
Test checks if 'enctype="multipart/form-data"' is added and only to forms that require multipart encoding.
|
Test checks if 'enctype="multipart/form-data"' is added and only to forms that require multipart encoding.
| def test_create_multipart(self):
"""
Test checks if 'enctype="multipart/form-data"' is added and only to forms that require multipart encoding.
"""
# check for SimplePage where is no file field
response = self.client.get(reverse('wagtailadmin_pages:add', args=('tests', 'simplepag... | [
"def",
"test_create_multipart",
"(",
"self",
")",
":",
"# check for SimplePage where is no file field",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:add'",
",",
"args",
"=",
"(",
"'tests'",
",",
"'simplepage'",
",",
... | [
131,
4
] | [
144,
70
] | python | en | ['en', 'error', 'th'] | False |
TestPageCreation.test_create_page_without_promote_tab | (self) |
Test that the Promote tab is not rendered for page classes that define it as empty
|
Test that the Promote tab is not rendered for page classes that define it as empty
| def test_create_page_without_promote_tab(self):
"""
Test that the Promote tab is not rendered for page classes that define it as empty
"""
response = self.client.get(
reverse('wagtailadmin_pages:add', args=('tests', 'standardindex', self.root_page.id))
)
self.... | [
"def",
"test_create_page_without_promote_tab",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:add'",
",",
"args",
"=",
"(",
"'tests'",
",",
"'standardindex'",
",",
"self",
".",
"root_page",
... | [
146,
4
] | [
155,
106
] | python | en | ['en', 'error', 'th'] | False |
TestPageCreation.test_create_page_with_custom_tabs | (self) |
Test that custom edit handlers are rendered
|
Test that custom edit handlers are rendered
| def test_create_page_with_custom_tabs(self):
"""
Test that custom edit handlers are rendered
"""
response = self.client.get(
reverse('wagtailadmin_pages:add', args=('tests', 'standardchild', self.root_page.id))
)
self.assertEqual(response.status_code, 200)
... | [
"def",
"test_create_page_with_custom_tabs",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:add'",
",",
"args",
"=",
"(",
"'tests'",
",",
"'standardchild'",
",",
"self",
".",
"root_page",
"."... | [
157,
4
] | [
167,
109
] | python | en | ['en', 'error', 'th'] | False |
TestPageCreation.test_create_page_with_non_model_field | (self) |
Test that additional fields defined on the form rather than the model are accepted and rendered
|
Test that additional fields defined on the form rather than the model are accepted and rendered
| def test_create_page_with_non_model_field(self):
"""
Test that additional fields defined on the form rather than the model are accepted and rendered
"""
response = self.client.get(reverse('wagtailadmin_pages:add', args=('tests', 'formclassadditionalfieldpage', self.root_page.id)))
... | [
"def",
"test_create_page_with_non_model_field",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:add'",
",",
"args",
"=",
"(",
"'tests'",
",",
"'formclassadditionalfieldpage'",
",",
"self",
".",
... | [
169,
4
] | [
176,
70
] | python | en | ['en', 'error', 'th'] | False |
TestPageCreation.test_display_moderation_button_by_default | (self) |
Tests that by default the "Submit for Moderation" button is shown in the action menu.
|
Tests that by default the "Submit for Moderation" button is shown in the action menu.
| def test_display_moderation_button_by_default(self):
"""
Tests that by default the "Submit for Moderation" button is shown in the action menu.
"""
response = self.client.get(reverse('wagtailadmin_pages:add', args=('tests', 'simplepage', self.root_page.id)))
self.assertContains(
... | [
"def",
"test_display_moderation_button_by_default",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:add'",
",",
"args",
"=",
"(",
"'tests'",
",",
"'simplepage'",
",",
"self",
".",
"root_page",
... | [
725,
4
] | [
735,
9
] | python | en | ['en', 'error', 'th'] | False |
TestPageCreation.test_hide_moderation_button | (self) |
Tests that if WAGTAIL_MODERATION_ENABLED is set to False, the "Submit for Moderation" button is not shown.
|
Tests that if WAGTAIL_MODERATION_ENABLED is set to False, the "Submit for Moderation" button is not shown.
| def test_hide_moderation_button(self):
"""
Tests that if WAGTAIL_MODERATION_ENABLED is set to False, the "Submit for Moderation" button is not shown.
"""
response = self.client.get(reverse('wagtailadmin_pages:add', args=('tests', 'simplepage', self.root_page.id)))
self.assertNotC... | [
"def",
"test_hide_moderation_button",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:add'",
",",
"args",
"=",
"(",
"'tests'",
",",
"'simplepage'",
",",
"self",
".",
"root_page",
".",
"id",... | [
738,
4
] | [
743,
162
] | python | en | ['en', 'error', 'th'] | False |
TestPerRequestEditHandler.test_create_page_with_per_request_custom_edit_handlers | (self) |
Test that per-request custom behaviour in edit handlers is honoured
|
Test that per-request custom behaviour in edit handlers is honoured
| def test_create_page_with_per_request_custom_edit_handlers(self):
"""
Test that per-request custom behaviour in edit handlers is honoured
"""
# non-superusers should not see secret_data
self.login(username='siteeditor', password='password')
response = self.client.get(
... | [
"def",
"test_create_page_with_per_request_custom_edit_handlers",
"(",
"self",
")",
":",
"# non-superusers should not see secret_data",
"self",
".",
"login",
"(",
"username",
"=",
"'siteeditor'",
",",
"password",
"=",
"'password'",
")",
"response",
"=",
"self",
".",
"cli... | [
771,
4
] | [
791,
54
] | python | en | ['en', 'error', 'th'] | False |
remove_choose_permission | (apps, _schema_editor) | Reverse the above additions of permissions. | Reverse the above additions of permissions. | def remove_choose_permission(apps, _schema_editor):
"""Reverse the above additions of permissions."""
ContentType = apps.get_model('contenttypes.ContentType')
Permission = apps.get_model('auth.Permission')
document_content_type = ContentType.objects.get(
model='document',
app_label='wagt... | [
"def",
"remove_choose_permission",
"(",
"apps",
",",
"_schema_editor",
")",
":",
"ContentType",
"=",
"apps",
".",
"get_model",
"(",
"'contenttypes.ContentType'",
")",
"Permission",
"=",
"apps",
".",
"get_model",
"(",
"'auth.Permission'",
")",
"document_content_type",
... | [
30,
0
] | [
42,
14
] | python | en | ['en', 'en', 'en'] | True |
main | (args=None) | This is preserved for old console scripts that may still be referencing
it.
For additional details, see https://github.com/pypa/pip/issues/7498.
| This is preserved for old console scripts that may still be referencing
it. | def main(args=None):
# type: (Optional[List[str]]) -> int
"""This is preserved for old console scripts that may still be referencing
it.
For additional details, see https://github.com/pypa/pip/issues/7498.
"""
from pip._internal.utils.entrypoints import _wrapper
return _wrapper(args) | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"# type: (Optional[List[str]]) -> int",
"from",
"pip",
".",
"_internal",
".",
"utils",
".",
"entrypoints",
"import",
"_wrapper",
"return",
"_wrapper",
"(",
"args",
")"
] | [
6,
0
] | [
15,
25
] | python | en | ['en', 'en', 'en'] | True |
remove_unused_versions_dir | (args: argparse.Namespace) | Deletes cache data from obsolete Yarn versions.
Yarn does not provide an interface for removing obsolete data from
~/.cache/yarn for packages that you haven't installed in years; but one
can always remove the cache entirely.
| Deletes cache data from obsolete Yarn versions. | def remove_unused_versions_dir(args: argparse.Namespace) -> None:
"""Deletes cache data from obsolete Yarn versions.
Yarn does not provide an interface for removing obsolete data from
~/.cache/yarn for packages that you haven't installed in years; but one
can always remove the cache entirely.
"""
... | [
"def",
"remove_unused_versions_dir",
"(",
"args",
":",
"argparse",
".",
"Namespace",
")",
"->",
"None",
":",
"current_version_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"YARN_CACHE_PATH",
",",
"CURRENT_VERSION",
")",
"try",
":",
"dirs_to_purge",
"=",
"set... | [
14,
0
] | [
40,
5
] | python | en | ['en', 'en', 'en'] | True |
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_req_group = sp.get_std_req_group(parser)
hlpstr = "Input bamfile"
option_short_name = "b"
option_name = "bamfile"
script_req_group.add_argument('-%s' % option_short_name,
... | [
"def",
"addScriptOptions",
"(",
"parser",
",",
"pos_args",
",",
"kw_args",
")",
":",
"script_req_group",
"=",
"sp",
".",
"get_std_req_group",
"(",
"parser",
")",
"hlpstr",
"=",
"\"Input bamfile\"",
"option_short_name",
"=",
"\"b\"",
"option_name",
"=",
"\"bamfile\... | [
127,
0
] | [
339,
37
] | python | en | ['en', 'it', 'en'] | True |
charcterizeIntrons | (read_iterator, genome, annotation_splices=None, splicepad=0,
min_intron_length=20, pwms=None, pwmscorethreshold=3.0, logger=None, LOG_EVERY_N=10000,
pwm_species="") | Return a dictionary {readID:[(start, stop)...]}
Listing the intronic sites for each read (identified by 'N' in the cigar strings).
read_iterator can be the result of a .fetch(...) call.
Or it can be a generator filtering such reads. Example
samfile.find_introns((read for read in samf... | Return a dictionary {readID:[(start, stop)...]}
Listing the intronic sites for each read (identified by 'N' in the cigar strings).
read_iterator can be the result of a .fetch(...) call.
Or it can be a generator filtering such reads. Example
samfile.find_introns((read for read in samf... | def charcterizeIntrons(read_iterator, genome, annotation_splices=None, splicepad=0,
min_intron_length=20, pwms=None, pwmscorethreshold=3.0, logger=None, LOG_EVERY_N=10000,
pwm_species=""):
"""Return a dictionary {readID:[(start, stop)...]}
Listing the intron... | [
"def",
"charcterizeIntrons",
"(",
"read_iterator",
",",
"genome",
",",
"annotation_splices",
"=",
"None",
",",
"splicepad",
"=",
"0",
",",
"min_intron_length",
"=",
"20",
",",
"pwms",
"=",
"None",
",",
"pwmscorethreshold",
"=",
"3.0",
",",
"logger",
"=",
"No... | [
419,
0
] | [
814,
64
] | python | en | ['en', 'en', 'en'] | True |
getAnnotationIntrons | (annot, genome, chr_synonym_dic={}, logger=None, LOG_EVERY_N=10000) | return a dictionary with all the introns in a given annotation | return a dictionary with all the introns in a given annotation | def getAnnotationIntrons(annot, genome, chr_synonym_dic={}, logger=None, LOG_EVERY_N=10000):
""" return a dictionary with all the introns in a given annotation """
if logger is not None:
logger.info("parsing transcript exon structures....")
annot.clear_all()
annot.set_feature("exo... | [
"def",
"getAnnotationIntrons",
"(",
"annot",
",",
"genome",
",",
"chr_synonym_dic",
"=",
"{",
"}",
",",
"logger",
"=",
"None",
",",
"LOG_EVERY_N",
"=",
"10000",
")",
":",
"if",
"logger",
"is",
"not",
"None",
":",
"logger",
".",
"info",
"(",
"\"parsing tr... | [
816,
0
] | [
893,
26
] | python | en | ['en', 'en', 'en'] | True |
writeBamFiles | (thisbam, splice_read_details, prefix, splits, pwms=None, logger=None) | write bam files separating out the reads into their categories | write bam files separating out the reads into their categories | def writeBamFiles(thisbam, splice_read_details, prefix, splits, pwms=None, logger=None):
""" write bam files separating out the reads into their categories """
annot_opts = ["annotated","novel"]
cann_opts = ["canonical","non_canonical"]
pwm_opts=["unclassified"]
if pwms is not None:
... | [
"def",
"writeBamFiles",
"(",
"thisbam",
",",
"splice_read_details",
",",
"prefix",
",",
"splits",
",",
"pwms",
"=",
"None",
",",
"logger",
"=",
"None",
")",
":",
"annot_opts",
"=",
"[",
"\"annotated\"",
",",
"\"novel\"",
"]",
"cann_opts",
"=",
"[",
"\"cano... | [
895,
0
] | [
977,
32
] | python | en | ['en', 'en', 'en'] | True |
mkAnnotPWMBoxPlots | (splice_details, plotfile, pointsize=4, title="", legend_fontsize=10, legendloc=(0.2,0.7),
logger=None) | plot the results of the analysis as a set of cool box plots... | plot the results of the analysis as a set of cool box plots... | def mkAnnotPWMBoxPlots(splice_details, plotfile, pointsize=4, title="", legend_fontsize=10, legendloc=(0.2,0.7),
logger=None):
""" plot the results of the analysis as a set of cool box plots..."""
if logger is not None:
logger.info("Plotting classified annotated splicing... | [
"def",
"mkAnnotPWMBoxPlots",
"(",
"splice_details",
",",
"plotfile",
",",
"pointsize",
"=",
"4",
",",
"title",
"=",
"\"\"",
",",
"legend_fontsize",
"=",
"10",
",",
"legendloc",
"=",
"(",
"0.2",
",",
"0.7",
")",
",",
"logger",
"=",
"None",
")",
":",
"if... | [
989,
0
] | [
1142,
48
] | python | en | ['en', 'en', 'en'] | True |
mkPWMBoxPlots | (splice_details, plotfile, pointsize=4, title="", logger=None) | plot the results of the analysis as a set of cool box plots... | plot the results of the analysis as a set of cool box plots... | def mkPWMBoxPlots(splice_details, plotfile, pointsize=4, title="", logger=None):
""" plot the results of the analysis as a set of cool box plots..."""
if logger is not None:
logger.info("Plotting classified splicing details boxplots...")
splice_exprs_data = {}
for splice in s... | [
"def",
"mkPWMBoxPlots",
"(",
"splice_details",
",",
"plotfile",
",",
"pointsize",
"=",
"4",
",",
"title",
"=",
"\"\"",
",",
"logger",
"=",
"None",
")",
":",
"if",
"logger",
"is",
"not",
"None",
":",
"logger",
".",
"info",
"(",
"\"Plotting classified splici... | [
1144,
0
] | [
1215,
48
] | python | en | ['en', 'en', 'en'] | True |
mkAnnotBoxPlots | (splice_details, plotfile, pointsize=4, title="", legend_fontsize=8, logger=None) | plot the results of the analysis as a set of cool box plots... | plot the results of the analysis as a set of cool box plots... | def mkAnnotBoxPlots(splice_details, plotfile, pointsize=4, title="", legend_fontsize=8, logger=None):
""" plot the results of the analysis as a set of cool box plots..."""
if logger is not None:
logger.info("Plotting annotated splicing details boxplots...")
splice_exprs_data={"annotat... | [
"def",
"mkAnnotBoxPlots",
"(",
"splice_details",
",",
"plotfile",
",",
"pointsize",
"=",
"4",
",",
"title",
"=",
"\"\"",
",",
"legend_fontsize",
"=",
"8",
",",
"logger",
"=",
"None",
")",
":",
"if",
"logger",
"is",
"not",
"None",
":",
"logger",
".",
"i... | [
1217,
0
] | [
1331,
48
] | python | en | ['en', 'en', 'en'] | True |
mkBoxPlots | (splice_details, plotfile, pointsize=4, title="", logger=None) | plot the results of the analysis as a set of cool box plots... | plot the results of the analysis as a set of cool box plots... | def mkBoxPlots(splice_details, plotfile, pointsize=4, title="", logger=None):
""" plot the results of the analysis as a set of cool box plots..."""
if logger is not None:
logger.info("Plotting basic splicing details boxplots...")
splice_exprs_data = {"canonical":[],
... | [
"def",
"mkBoxPlots",
"(",
"splice_details",
",",
"plotfile",
",",
"pointsize",
"=",
"4",
",",
"title",
"=",
"\"\"",
",",
"logger",
"=",
"None",
")",
":",
"if",
"logger",
"is",
"not",
"None",
":",
"logger",
".",
"info",
"(",
"\"Plotting basic splicing detai... | [
1333,
0
] | [
1409,
48
] | python | en | ['en', 'en', 'en'] | True |
Connection.request | (self, relative_endpoint, method='get', json=None, data=None, query_parameters=None, headers=None) | Core requests.Session wrapper that returns requests.Response objects | Core requests.Session wrapper that returns requests.Response objects | def request(self, relative_endpoint, method='get', json=None, data=None, query_parameters=None, headers=None):
"""Core requests.Session wrapper that returns requests.Response objects"""
session_request_method = getattr(self.session, method, None)
if not session_request_method:
raise ... | [
"def",
"request",
"(",
"self",
",",
"relative_endpoint",
",",
"method",
"=",
"'get'",
",",
"json",
"=",
"None",
",",
"data",
"=",
"None",
",",
"query_parameters",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"session_request_method",
"=",
"getattr",... | [
67,
4
] | [
98,
23
] | python | en | ['en', 'en', 'en'] | True |
validate_options | (options) | Validates options. | Validates options. | def validate_options(options):
"""Validates options."""
kwcase = options.get('keyword_case')
if kwcase not in [None, 'upper', 'lower', 'capitalize']:
raise SQLParseError('Invalid value for keyword_case: '
'{!r}'.format(kwcase))
idcase = options.get('identifier_case')... | [
"def",
"validate_options",
"(",
"options",
")",
":",
"kwcase",
"=",
"options",
".",
"get",
"(",
"'keyword_case'",
")",
"if",
"kwcase",
"not",
"in",
"[",
"None",
",",
"'upper'",
",",
"'lower'",
",",
"'capitalize'",
"]",
":",
"raise",
"SQLParseError",
"(",
... | [
13,
0
] | [
128,
18
] | python | en | ['en', 'et', 'en'] | False |
build_filter_stack | (stack, options) | Setup and return a filter stack.
Args:
stack: :class:`~sqlparse.filters.FilterStack` instance
options: Dictionary with options validated by validate_options.
| Setup and return a filter stack. | def build_filter_stack(stack, options):
"""Setup and return a filter stack.
Args:
stack: :class:`~sqlparse.filters.FilterStack` instance
options: Dictionary with options validated by validate_options.
"""
# Token filter
if options.get('keyword_case'):
stack.preprocess.append(
... | [
"def",
"build_filter_stack",
"(",
"stack",
",",
"options",
")",
":",
"# Token filter",
"if",
"options",
".",
"get",
"(",
"'keyword_case'",
")",
":",
"stack",
".",
"preprocess",
".",
"append",
"(",
"filters",
".",
"KeywordCaseFilter",
"(",
"options",
"[",
"'k... | [
131,
0
] | [
197,
16
] | python | en | ['en', 'da', 'en'] | True |
decorate_urlpatterns | (urlpatterns, decorator) | Decorate all the views in the passed urlpatterns list with the given decorator | Decorate all the views in the passed urlpatterns list with the given decorator | def decorate_urlpatterns(urlpatterns, decorator):
"""Decorate all the views in the passed urlpatterns list with the given decorator"""
for pattern in urlpatterns:
if hasattr(pattern, 'url_patterns'):
# this is an included RegexURLResolver; recursively decorate the views
# contain... | [
"def",
"decorate_urlpatterns",
"(",
"urlpatterns",
",",
"decorator",
")",
":",
"for",
"pattern",
"in",
"urlpatterns",
":",
"if",
"hasattr",
"(",
"pattern",
",",
"'url_patterns'",
")",
":",
"# this is an included RegexURLResolver; recursively decorate the views",
"# contai... | [
3,
0
] | [
14,
22
] | python | en | ['en', 'en', 'en'] | True |
filter_empty_cols | (c) | Remove columns for bases which are not represented in the data | Remove columns for bases which are not represented in the data | def filter_empty_cols(c):
'''Remove columns for bases which are not represented in the data'''
c_t = c.T
c_t = c_t[c_t.any(1)]
return c_t.T | [
"def",
"filter_empty_cols",
"(",
"c",
")",
":",
"c_t",
"=",
"c",
".",
"T",
"c_t",
"=",
"c_t",
"[",
"c_t",
".",
"any",
"(",
"1",
")",
"]",
"return",
"c_t",
".",
"T"
] | [
18,
0
] | [
22,
16
] | python | en | ['en', 'en', 'en'] | True |
test_significant_der_sites | (counts, fdr_threshold, fasta) | Conduct G-test on counts to identify sites with differential error profiles | Conduct G-test on counts to identify sites with differential error profiles | def test_significant_der_sites(counts, fdr_threshold, fasta):
'''Conduct G-test on counts to identify sites with differential error profiles'''
res = []
mismatch_counts = []
kd_has_replicates = len(counts['kd'].columns.levels[0]) > 1
cntrl_has_replicates = len(counts['cntrl'].columns.levels[0]) > ... | [
"def",
"test_significant_der_sites",
"(",
"counts",
",",
"fdr_threshold",
",",
"fasta",
")",
":",
"res",
"=",
"[",
"]",
"mismatch_counts",
"=",
"[",
"]",
"kd_has_replicates",
"=",
"len",
"(",
"counts",
"[",
"'kd'",
"]",
".",
"columns",
".",
"levels",
"[",
... | [
25,
0
] | [
79,
31
] | python | en | ['en', 'en', 'en'] | True |
RoutablePageMixin.reverse_subpage | (self, name, args=None, kwargs=None) |
This method takes a route name/arguments and returns a URL path.
|
This method takes a route name/arguments and returns a URL path.
| def reverse_subpage(self, name, args=None, kwargs=None):
"""
This method takes a route name/arguments and returns a URL path.
"""
args = args or []
kwargs = kwargs or {}
return self.get_resolver().reverse(name, *args, **kwargs) | [
"def",
"reverse_subpage",
"(",
"self",
",",
"name",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"args",
"=",
"args",
"or",
"[",
"]",
"kwargs",
"=",
"kwargs",
"or",
"{",
"}",
"return",
"self",
".",
"get_resolver",
"(",
")",
".",
... | [
76,
4
] | [
83,
65
] | python | en | ['en', 'error', 'th'] | False |
RoutablePageMixin.resolve_subpage | (self, path) |
This method takes a URL path and finds the view to call.
|
This method takes a URL path and finds the view to call.
| def resolve_subpage(self, path):
"""
This method takes a URL path and finds the view to call.
"""
view, args, kwargs = self.get_resolver().resolve(path)
# Bind the method
view = view.__get__(self, type(self))
return view, args, kwargs | [
"def",
"resolve_subpage",
"(",
"self",
",",
"path",
")",
":",
"view",
",",
"args",
",",
"kwargs",
"=",
"self",
".",
"get_resolver",
"(",
")",
".",
"resolve",
"(",
"path",
")",
"# Bind the method",
"view",
"=",
"view",
".",
"__get__",
"(",
"self",
",",
... | [
85,
4
] | [
94,
33
] | python | en | ['en', 'error', 'th'] | False |
RoutablePageMixin.route | (self, request, path_components) |
This hooks the subpage URLs into Wagtail's routing.
|
This hooks the subpage URLs into Wagtail's routing.
| def route(self, request, path_components):
"""
This hooks the subpage URLs into Wagtail's routing.
"""
if self.live:
try:
path = '/'
if path_components:
path += '/'.join(path_components) + '/'
view, args, kw... | [
"def",
"route",
"(",
"self",
",",
"request",
",",
"path_components",
")",
":",
"if",
"self",
".",
"live",
":",
"try",
":",
"path",
"=",
"'/'",
"if",
"path_components",
":",
"path",
"+=",
"'/'",
".",
"join",
"(",
"path_components",
")",
"+",
"'/'",
"v... | [
96,
4
] | [
111,
54
] | python | en | ['en', 'error', 'th'] | False |
RoutablePageMixin.render | (self, request, *args, template=None, context_overrides=None, **kwargs) |
.. versionadded:: 2.11
This method replicates what ``Page.serve()`` usually does when ``RoutablePageMixin``
is not used. By default, ``Page.get_template()`` is called to derive the template
to use for rendering, and ``Page.get_context()`` is always called to gather the
data to ... |
.. versionadded:: 2.11 | def render(self, request, *args, template=None, context_overrides=None, **kwargs):
"""
.. versionadded:: 2.11
This method replicates what ``Page.serve()`` usually does when ``RoutablePageMixin``
is not used. By default, ``Page.get_template()`` is called to derive the template
to... | [
"def",
"render",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"template",
"=",
"None",
",",
"context_overrides",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"template",
"is",
"None",
":",
"template",
"=",
"self",
".",
"get_template",
... | [
122,
4
] | [
163,
59
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.