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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
MacTool._CommandifyName | (self, name_string) | Transforms a tool name like copy-info-plist to CopyInfoPlist | Transforms a tool name like copy-info-plist to CopyInfoPlist | def _CommandifyName(self, name_string):
"""Transforms a tool name like copy-info-plist to CopyInfoPlist"""
return name_string.title().replace("-", "") | [
"def",
"_CommandifyName",
"(",
"self",
",",
"name_string",
")",
":",
"return",
"name_string",
".",
"title",
"(",
")",
".",
"replace",
"(",
"\"-\"",
",",
"\"\"",
")"
] | [
47,
4
] | [
49,
51
] | python | en | ['en', 'pl', 'en'] | True |
MacTool.ExecCopyBundleResource | (self, source, dest, convert_to_binary) | Copies a resource file to the bundle/Resources directory, performing any
necessary compilation on each resource. | Copies a resource file to the bundle/Resources directory, performing any
necessary compilation on each resource. | def ExecCopyBundleResource(self, source, dest, convert_to_binary):
"""Copies a resource file to the bundle/Resources directory, performing any
necessary compilation on each resource."""
convert_to_binary = convert_to_binary == "True"
extension = os.path.splitext(source)[1].lower()
if... | [
"def",
"ExecCopyBundleResource",
"(",
"self",
",",
"source",
",",
"dest",
",",
"convert_to_binary",
")",
":",
"convert_to_binary",
"=",
"convert_to_binary",
"==",
"\"True\"",
"extension",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"source",
")",
"[",
"1",
... | [
51,
4
] | [
76,
39
] | python | en | ['en', 'en', 'en'] | True |
MacTool._CopyXIBFile | (self, source, dest) | Compiles a XIB file with ibtool into a binary plist in the bundle. | Compiles a XIB file with ibtool into a binary plist in the bundle. | def _CopyXIBFile(self, source, dest):
"""Compiles a XIB file with ibtool into a binary plist in the bundle."""
# ibtool sometimes crashes with relative paths. See crbug.com/314728.
base = os.path.dirname(os.path.realpath(__file__))
if os.path.relpath(source):
source = os.pat... | [
"def",
"_CopyXIBFile",
"(",
"self",
",",
"source",
",",
"dest",
")",
":",
"# ibtool sometimes crashes with relative paths. See crbug.com/314728.",
"base",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",... | [
78,
4
] | [
133,
16
] | python | en | ['en', 'en', 'en'] | True |
MacTool._CopyStringsFile | (self, source, dest) | Copies a .strings file using iconv to reconvert the input into UTF-16. | Copies a .strings file using iconv to reconvert the input into UTF-16. | def _CopyStringsFile(self, source, dest):
"""Copies a .strings file using iconv to reconvert the input into UTF-16."""
input_code = self._DetectInputEncoding(source) or "UTF-8"
# Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call
# CFPropertyListCreateFromXMLData() behind th... | [
"def",
"_CopyStringsFile",
"(",
"self",
",",
"source",
",",
"dest",
")",
":",
"input_code",
"=",
"self",
".",
"_DetectInputEncoding",
"(",
"source",
")",
"or",
"\"UTF-8\"",
"# Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call",
"# CFPropertyListCreateFromXMLDat... | [
140,
4
] | [
159,
59
] | python | en | ['en', 'en', 'en'] | True |
MacTool._DetectInputEncoding | (self, file_name) | Reads the first few bytes from file_name and tries to guess the text
encoding. Returns None as a guess if it can't detect it. | Reads the first few bytes from file_name and tries to guess the text
encoding. Returns None as a guess if it can't detect it. | def _DetectInputEncoding(self, file_name):
"""Reads the first few bytes from file_name and tries to guess the text
encoding. Returns None as a guess if it can't detect it."""
with open(file_name, "rb") as fp:
try:
header = fp.read(3)
except Exception:
... | [
"def",
"_DetectInputEncoding",
"(",
"self",
",",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"\"rb\"",
")",
"as",
"fp",
":",
"try",
":",
"header",
"=",
"fp",
".",
"read",
"(",
"3",
")",
"except",
"Exception",
":",
"return",
"None",
... | [
161,
4
] | [
176,
23
] | python | en | ['en', 'en', 'en'] | True |
MacTool.ExecCopyInfoPlist | (self, source, dest, convert_to_binary, *keys) | Copies the |source| Info.plist to the destination directory |dest|. | Copies the |source| Info.plist to the destination directory |dest|. | def ExecCopyInfoPlist(self, source, dest, convert_to_binary, *keys):
"""Copies the |source| Info.plist to the destination directory |dest|."""
# Read the source Info.plist into memory.
with open(source, "r") as fd:
lines = fd.read()
# Insert synthesized key/value pairs (e.g.... | [
"def",
"ExecCopyInfoPlist",
"(",
"self",
",",
"source",
",",
"dest",
",",
"convert_to_binary",
",",
"*",
"keys",
")",
":",
"# Read the source Info.plist into memory.",
"with",
"open",
"(",
"source",
",",
"\"r\"",
")",
"as",
"fd",
":",
"lines",
"=",
"fd",
"."... | [
178,
4
] | [
231,
39
] | python | en | ['en', 'fr', 'en'] | True |
MacTool._WritePkgInfo | (self, info_plist) | This writes the PkgInfo file from the data stored in Info.plist. | This writes the PkgInfo file from the data stored in Info.plist. | def _WritePkgInfo(self, info_plist):
"""This writes the PkgInfo file from the data stored in Info.plist."""
plist = plistlib.readPlist(info_plist)
if not plist:
return
# Only create PkgInfo for executable types.
package_type = plist["CFBundlePackageType"]
if ... | [
"def",
"_WritePkgInfo",
"(",
"self",
",",
"info_plist",
")",
":",
"plist",
"=",
"plistlib",
".",
"readPlist",
"(",
"info_plist",
")",
"if",
"not",
"plist",
":",
"return",
"# Only create PkgInfo for executable types.",
"package_type",
"=",
"plist",
"[",
"\"CFBundle... | [
233,
4
] | [
253,
61
] | python | en | ['en', 'en', 'en'] | True |
MacTool.ExecFlock | (self, lockfile, *cmd_list) | Emulates the most basic behavior of Linux's flock(1). | Emulates the most basic behavior of Linux's flock(1). | def ExecFlock(self, lockfile, *cmd_list):
"""Emulates the most basic behavior of Linux's flock(1)."""
# Rely on exception handling to report errors.
fd = os.open(lockfile, os.O_RDONLY | os.O_NOCTTY | os.O_CREAT, 0o666)
fcntl.flock(fd, fcntl.LOCK_EX)
return subprocess.call(cmd_lis... | [
"def",
"ExecFlock",
"(",
"self",
",",
"lockfile",
",",
"*",
"cmd_list",
")",
":",
"# Rely on exception handling to report errors.",
"fd",
"=",
"os",
".",
"open",
"(",
"lockfile",
",",
"os",
".",
"O_RDONLY",
"|",
"os",
".",
"O_NOCTTY",
"|",
"os",
".",
"O_CR... | [
255,
4
] | [
260,
40
] | python | en | ['en', 'da', 'en'] | True |
MacTool.ExecFilterLibtool | (self, *cmd_list) | Calls libtool and filters out '/path/to/libtool: file: foo.o has no
symbols'. | Calls libtool and filters out '/path/to/libtool: file: foo.o has no
symbols'. | def ExecFilterLibtool(self, *cmd_list):
"""Calls libtool and filters out '/path/to/libtool: file: foo.o has no
symbols'."""
libtool_re = re.compile(
r"^.*libtool: (?:for architecture: \S* )?" r"file: .* has no symbols$"
)
libtool_re5 = re.compile(
r"^.*libtool... | [
"def",
"ExecFilterLibtool",
"(",
"self",
",",
"*",
"cmd_list",
")",
":",
"libtool_re",
"=",
"re",
".",
"compile",
"(",
"r\"^.*libtool: (?:for architecture: \\S* )?\"",
"r\"file: .* has no symbols$\"",
")",
"libtool_re5",
"=",
"re",
".",
"compile",
"(",
"r\"^.*libtool:... | [
262,
4
] | [
293,
36
] | python | en | ['en', 'en', 'en'] | True |
MacTool.ExecPackageFramework | (self, framework, version) | Takes a path to Something.framework and the Current version of that and
sets up all the symlinks. | Takes a path to Something.framework and the Current version of that and
sets up all the symlinks. | def ExecPackageFramework(self, framework, version):
"""Takes a path to Something.framework and the Current version of that and
sets up all the symlinks."""
# Find the name of the binary based on the part before the ".framework".
binary = os.path.basename(framework).split(".")[0]
CUR... | [
"def",
"ExecPackageFramework",
"(",
"self",
",",
"framework",
",",
"version",
")",
":",
"# Find the name of the binary based on the part before the \".framework\".",
"binary",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"framework",
")",
".",
"split",
"(",
"\".\"",
... | [
313,
4
] | [
340,
21
] | python | en | ['en', 'en', 'en'] | True |
MacTool._Relink | (self, dest, link) | Creates a symlink to |dest| named |link|. If |link| already exists,
it is overwritten. | Creates a symlink to |dest| named |link|. If |link| already exists,
it is overwritten. | def _Relink(self, dest, link):
"""Creates a symlink to |dest| named |link|. If |link| already exists,
it is overwritten."""
if os.path.lexists(link):
os.remove(link)
os.symlink(dest, link) | [
"def",
"_Relink",
"(",
"self",
",",
"dest",
",",
"link",
")",
":",
"if",
"os",
".",
"path",
".",
"lexists",
"(",
"link",
")",
":",
"os",
".",
"remove",
"(",
"link",
")",
"os",
".",
"symlink",
"(",
"dest",
",",
"link",
")"
] | [
342,
4
] | [
347,
30
] | python | en | ['en', 'en', 'en'] | True |
MacTool.ExecCompileXcassets | (self, keys, *inputs) | Compiles multiple .xcassets files into a single .car file.
This invokes 'actool' to compile all the inputs .xcassets files. The
|keys| arguments is a json-encoded dictionary of extra arguments to
pass to 'actool' when the asset catalogs contains an application icon
or a launch image.
Note that 'ac... | Compiles multiple .xcassets files into a single .car file. | def ExecCompileXcassets(self, keys, *inputs):
"""Compiles multiple .xcassets files into a single .car file.
This invokes 'actool' to compile all the inputs .xcassets files. The
|keys| arguments is a json-encoded dictionary of extra arguments to
pass to 'actool' when the asset catalogs contains an a... | [
"def",
"ExecCompileXcassets",
"(",
"self",
",",
"keys",
",",
"*",
"inputs",
")",
":",
"command_line",
"=",
"[",
"\"xcrun\"",
",",
"\"actool\"",
",",
"\"--output-format\"",
",",
"\"human-readable-text\"",
",",
"\"--compress-pngs\"",
",",
"\"--notices\"",
",",
"\"--... | [
366,
4
] | [
436,
43
] | python | en | ['en', 'en', 'en'] | True |
MacTool.ExecMergeInfoPlist | (self, output, *inputs) | Merge multiple .plist files into a single .plist file. | Merge multiple .plist files into a single .plist file. | def ExecMergeInfoPlist(self, output, *inputs):
"""Merge multiple .plist files into a single .plist file."""
merged_plist = {}
for path in inputs:
plist = self._LoadPlistMaybeBinary(path)
self._MergePlist(merged_plist, plist)
plistlib.writePlist(merged_plist, outpu... | [
"def",
"ExecMergeInfoPlist",
"(",
"self",
",",
"output",
",",
"*",
"inputs",
")",
":",
"merged_plist",
"=",
"{",
"}",
"for",
"path",
"in",
"inputs",
":",
"plist",
"=",
"self",
".",
"_LoadPlistMaybeBinary",
"(",
"path",
")",
"self",
".",
"_MergePlist",
"(... | [
438,
4
] | [
444,
49
] | python | en | ['en', 'et', 'en'] | True |
MacTool.ExecCodeSignBundle | (self, key, entitlements, provisioning, path, preserve) | Code sign a bundle.
This function tries to code sign an iOS bundle, following the same
algorithm as Xcode:
1. pick the provisioning profile that best match the bundle identifier,
and copy it into the bundle as embedded.mobileprovision,
2. copy Entitlements.plist from user or SDK next to th... | Code sign a bundle. | def ExecCodeSignBundle(self, key, entitlements, provisioning, path, preserve):
"""Code sign a bundle.
This function tries to code sign an iOS bundle, following the same
algorithm as Xcode:
1. pick the provisioning profile that best match the bundle identifier,
and copy it into the bundle... | [
"def",
"ExecCodeSignBundle",
"(",
"self",
",",
"key",
",",
"entitlements",
",",
"provisioning",
",",
"path",
",",
"preserve",
")",
":",
"substitutions",
",",
"overrides",
"=",
"self",
".",
"_InstallProvisioningProfile",
"(",
"provisioning",
",",
"self",
".",
"... | [
446,
4
] | [
469,
35
] | python | en | ['en', 'su', 'en'] | True |
MacTool._InstallProvisioningProfile | (self, profile, bundle_identifier) | Installs embedded.mobileprovision into the bundle.
Args:
profile: string, optional, short name of the .mobileprovision file
to use, if empty or the file is missing, the best file installed
will be used
bundle_identifier: string, value of CFBundleIdentifier from Info.plist
Returns:
... | Installs embedded.mobileprovision into the bundle. | def _InstallProvisioningProfile(self, profile, bundle_identifier):
"""Installs embedded.mobileprovision into the bundle.
Args:
profile: string, optional, short name of the .mobileprovision file
to use, if empty or the file is missing, the best file installed
will be used
bundle_... | [
"def",
"_InstallProvisioningProfile",
"(",
"self",
",",
"profile",
",",
"bundle_identifier",
")",
":",
"source_path",
",",
"provisioning_data",
",",
"team_id",
"=",
"self",
".",
"_FindProvisioningProfile",
"(",
"profile",
",",
"bundle_identifier",
")",
"target_path",
... | [
471,
4
] | [
494,
63
] | python | en | ['en', 'en', 'en'] | True |
MacTool._FindProvisioningProfile | (self, profile, bundle_identifier) | Finds the .mobileprovision file to use for signing the bundle.
Checks all the installed provisioning profiles (or if the user specified
the PROVISIONING_PROFILE variable, only consult it) and select the most
specific that correspond to the bundle identifier.
Args:
profile: string, optional, shor... | Finds the .mobileprovision file to use for signing the bundle. | def _FindProvisioningProfile(self, profile, bundle_identifier):
"""Finds the .mobileprovision file to use for signing the bundle.
Checks all the installed provisioning profiles (or if the user specified
the PROVISIONING_PROFILE variable, only consult it) and select the most
specific that correspond... | [
"def",
"_FindProvisioningProfile",
"(",
"self",
",",
"profile",
",",
"bundle_identifier",
")",
":",
"profiles_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
"[",
"\"HOME\"",
"]",
",",
"\"Library\"",
",",
"\"MobileDevice\"",
",",
"\"Pro... | [
496,
4
] | [
559,
56
] | python | en | ['en', 'en', 'en'] | True |
MacTool._LoadProvisioningProfile | (self, profile_path) | Extracts the plist embedded in a provisioning profile.
Args:
profile_path: string, path to the .mobileprovision file
Returns:
Content of the plist embedded in the provisioning profile as a dictionary.
| Extracts the plist embedded in a provisioning profile. | def _LoadProvisioningProfile(self, profile_path):
"""Extracts the plist embedded in a provisioning profile.
Args:
profile_path: string, path to the .mobileprovision file
Returns:
Content of the plist embedded in the provisioning profile as a dictionary.
"""
with tempfile.NamedT... | [
"def",
"_LoadProvisioningProfile",
"(",
"self",
",",
"profile_path",
")",
":",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
"as",
"temp",
":",
"subprocess",
".",
"check_call",
"(",
"[",
"\"security\"",
",",
"\"cms\"",
",",
"\"-D\"",
",",
"\"-i\"",
... | [
561,
4
] | [
574,
56
] | python | en | ['en', 'en', 'en'] | True |
MacTool._MergePlist | (self, merged_plist, plist) | Merge |plist| into |merged_plist|. | Merge |plist| into |merged_plist|. | def _MergePlist(self, merged_plist, plist):
"""Merge |plist| into |merged_plist|."""
for key, value in plist.items():
if isinstance(value, dict):
merged_value = merged_plist.get(key, {})
if isinstance(merged_value, dict):
self._MergePlist(m... | [
"def",
"_MergePlist",
"(",
"self",
",",
"merged_plist",
",",
"plist",
")",
":",
"for",
"key",
",",
"value",
"in",
"plist",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"merged_value",
"=",
"merged_plist",
".",
... | [
576,
4
] | [
587,
41
] | python | en | ['it', 'et', 'en'] | False |
MacTool._LoadPlistMaybeBinary | (self, plist_path) | Loads into a memory a plist possibly encoded in binary format.
This is a wrapper around plistlib.readPlist that tries to convert the
plist to the XML format if it can't be parsed (assuming that it is in
the binary format).
Args:
plist_path: string, path to a plist file, in XML or binary format
... | Loads into a memory a plist possibly encoded in binary format. | def _LoadPlistMaybeBinary(self, plist_path):
"""Loads into a memory a plist possibly encoded in binary format.
This is a wrapper around plistlib.readPlist that tries to convert the
plist to the XML format if it can't be parsed (assuming that it is in
the binary format).
Args:
plist_path:... | [
"def",
"_LoadPlistMaybeBinary",
"(",
"self",
",",
"plist_path",
")",
":",
"try",
":",
"# First, try to read the file using plistlib that only supports XML,",
"# and if an exception is raised, convert a temporary copy to XML and",
"# load that copy.",
"return",
"plistlib",
".",
"readP... | [
589,
4
] | [
612,
48
] | python | en | ['en', 'en', 'en'] | True |
MacTool._GetSubstitutions | (self, bundle_identifier, app_identifier_prefix) | Constructs a dictionary of variable substitutions for Entitlements.plist.
Args:
bundle_identifier: string, value of CFBundleIdentifier from Info.plist
app_identifier_prefix: string, value for AppIdentifierPrefix
Returns:
Dictionary of substitutions to apply when generating Entitlements.plist... | Constructs a dictionary of variable substitutions for Entitlements.plist. | def _GetSubstitutions(self, bundle_identifier, app_identifier_prefix):
"""Constructs a dictionary of variable substitutions for Entitlements.plist.
Args:
bundle_identifier: string, value of CFBundleIdentifier from Info.plist
app_identifier_prefix: string, value for AppIdentifierPrefix
Retu... | [
"def",
"_GetSubstitutions",
"(",
"self",
",",
"bundle_identifier",
",",
"app_identifier_prefix",
")",
":",
"return",
"{",
"\"CFBundleIdentifier\"",
":",
"bundle_identifier",
",",
"\"AppIdentifierPrefix\"",
":",
"app_identifier_prefix",
",",
"}"
] | [
614,
4
] | [
627,
9
] | python | en | ['en', 'en', 'en'] | True |
MacTool._GetCFBundleIdentifier | (self) | Extracts CFBundleIdentifier value from Info.plist in the bundle.
Returns:
Value of CFBundleIdentifier in the Info.plist located in the bundle.
| Extracts CFBundleIdentifier value from Info.plist in the bundle. | def _GetCFBundleIdentifier(self):
"""Extracts CFBundleIdentifier value from Info.plist in the bundle.
Returns:
Value of CFBundleIdentifier in the Info.plist located in the bundle.
"""
info_plist_path = os.path.join(
os.environ["TARGET_BUILD_DIR"], os.environ["INFOPLIST_PATH"]
... | [
"def",
"_GetCFBundleIdentifier",
"(",
"self",
")",
":",
"info_plist_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
"[",
"\"TARGET_BUILD_DIR\"",
"]",
",",
"os",
".",
"environ",
"[",
"\"INFOPLIST_PATH\"",
"]",
")",
"info_plist_data",
"=... | [
629,
4
] | [
639,
52
] | python | en | ['en', 'en', 'en'] | True |
MacTool._InstallEntitlements | (self, entitlements, substitutions, overrides) | Generates and install the ${BundleName}.xcent entitlements file.
Expands variables "$(variable)" pattern in the source entitlements file,
add extra entitlements defined in the .mobileprovision file and the copy
the generated plist to "${BundlePath}.xcent".
Args:
entitlements: string, optional, p... | Generates and install the ${BundleName}.xcent entitlements file. | def _InstallEntitlements(self, entitlements, substitutions, overrides):
"""Generates and install the ${BundleName}.xcent entitlements file.
Expands variables "$(variable)" pattern in the source entitlements file,
add extra entitlements defined in the .mobileprovision file and the copy
the generated... | [
"def",
"_InstallEntitlements",
"(",
"self",
",",
"entitlements",
",",
"substitutions",
",",
"overrides",
")",
":",
"source_path",
"=",
"entitlements",
"target_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
"[",
"\"BUILT_PRODUCTS_DIR\"",
... | [
641,
4
] | [
671,
26
] | python | en | ['en', 'en', 'en'] | True |
MacTool._ExpandVariables | (self, data, substitutions) | Expands variables "$(variable)" in data.
Args:
data: object, can be either string, list or dictionary
substitutions: dictionary, variable substitutions to perform
Returns:
Copy of data where each references to "$(variable)" has been replaced
by the corresponding value found in substitu... | Expands variables "$(variable)" in data. | def _ExpandVariables(self, data, substitutions):
"""Expands variables "$(variable)" in data.
Args:
data: object, can be either string, list or dictionary
substitutions: dictionary, variable substitutions to perform
Returns:
Copy of data where each references to "$(variable)" has been... | [
"def",
"_ExpandVariables",
"(",
"self",
",",
"data",
",",
"substitutions",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"for",
"key",
",",
"value",
"in",
"substitutions",
".",
"items",
"(",
")",
":",
"data",
"=",
"data",
".",
"rep... | [
673,
4
] | [
693,
19
] | python | en | ['nl', 'en', 'en'] | True |
random_result | (*kwargs) | Random objective. | Random objective. | def random_result(*kwargs):
"""Random objective."""
return round(random.random(),3) * 100 | [
"def",
"random_result",
"(",
"*",
"kwargs",
")",
":",
"return",
"round",
"(",
"random",
".",
"random",
"(",
")",
",",
"3",
")",
"*",
"100"
] | [
22,
0
] | [
25,
41
] | python | en | ['en', 'mg', 'en'] | False |
TaskManager.__init__ | (self) |
Do NOT put database queries or other potentially expensive operations
in the task manager init. The task manager object is created every time a
job is created, transitions state, and every 30 seconds on each tower node.
More often then not, the object is destroyed quickly because the NO... |
Do NOT put database queries or other potentially expensive operations
in the task manager init. The task manager object is created every time a
job is created, transitions state, and every 30 seconds on each tower node.
More often then not, the object is destroyed quickly because the NO... | def __init__(self):
"""
Do NOT put database queries or other potentially expensive operations
in the task manager init. The task manager object is created every time a
job is created, transitions state, and every 30 seconds on each tower node.
More often then not, the object is d... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"graph",
"=",
"dict",
"(",
")",
"# start task limit indicates how many pending jobs can be started on this",
"# .schedule() run. Starting jobs is expensive, and there is code in place to reap",
"# the task manager after 5 minutes. ... | [
47,
4
] | [
65,
63
] | python | en | ['en', 'error', 'th'] | False |
TaskManager.after_lock_init | (self) |
Init AFTER we know this instance of the task manager will run because the lock is acquired.
|
Init AFTER we know this instance of the task manager will run because the lock is acquired.
| def after_lock_init(self):
"""
Init AFTER we know this instance of the task manager will run because the lock is acquired.
"""
instances = Instance.objects.filter(~Q(hostname=None), enabled=True)
self.real_instances = {i.hostname: i for i in instances}
instances_partial ... | [
"def",
"after_lock_init",
"(",
"self",
")",
":",
"instances",
"=",
"Instance",
".",
"objects",
".",
"filter",
"(",
"~",
"Q",
"(",
"hostname",
"=",
"None",
")",
",",
"enabled",
"=",
"True",
")",
"self",
".",
"real_instances",
"=",
"{",
"i",
".",
"host... | [
67,
4
] | [
106,
112
] | python | en | ['en', 'error', 'th'] | False |
TaskManager.should_update_inventory_source | (self, job, latest_inventory_update) |
If there's already a inventory update utilizing this job that's about to run
then we don't need to create one
|
If there's already a inventory update utilizing this job that's about to run
then we don't need to create one
| def should_update_inventory_source(self, job, latest_inventory_update):
now = tz_now()
if latest_inventory_update is None:
return True
'''
If there's already a inventory update utilizing this job that's about to run
then we don't need to create one
'''
... | [
"def",
"should_update_inventory_source",
"(",
"self",
",",
"job",
",",
"latest_inventory_update",
")",
":",
"now",
"=",
"tz_now",
"(",
")",
"if",
"latest_inventory_update",
"is",
"None",
":",
"return",
"True",
"if",
"latest_inventory_update",
".",
"status",
"in",
... | [
382,
4
] | [
399,
20
] | python | en | ['en', 'error', 'th'] | False |
TaskManager.should_update_related_project | (self, job, latest_project_update) |
If there's already a project update utilizing this job that's about to run
then we don't need to create one
|
If there's already a project update utilizing this job that's about to run
then we don't need to create one
| def should_update_related_project(self, job, latest_project_update):
now = tz_now()
if latest_project_update is None:
return True
if latest_project_update.status in ['failed', 'canceled']:
return True
'''
If there's already a project update utilizing th... | [
"def",
"should_update_related_project",
"(",
"self",
",",
"job",
",",
"latest_project_update",
")",
":",
"now",
"=",
"tz_now",
"(",
")",
"if",
"latest_project_update",
"is",
"None",
":",
"return",
"True",
"if",
"latest_project_update",
".",
"status",
"in",
"[",
... | [
407,
4
] | [
440,
20
] | python | en | ['en', 'error', 'th'] | False |
iBaseDriver.ContainmentTree | (self) |
Creates and returns the component tree of the device with Keys of the Components organized in a tree structure
|
Creates and returns the component tree of the device with Keys of the Components organized in a tree structure
| def ContainmentTree(self):
"""
Creates and returns the component tree of the device with Keys of the Components organized in a tree structure
"""
device_json = self.get_json_device()
return self._build_ctree(self.protofactory.ctree, device_json) | [
"def",
"ContainmentTree",
"(",
"self",
")",
":",
"device_json",
"=",
"self",
".",
"get_json_device",
"(",
")",
"return",
"self",
".",
"_build_ctree",
"(",
"self",
".",
"protofactory",
".",
"ctree",
",",
"device_json",
")"
] | [
279,
4
] | [
284,
70
] | python | en | ['en', 'ja', 'th'] | False |
iBaseDriver.get_partial_entityjson | (self, *en) |
Gets the json with components which are passed as argument for this function
:param en: list of Components of the device whose json is required
:type en: list of strings or enums of components
:return: json only the components passed in en
:rtype: JSON
|
Gets the json with components which are passed as argument for this function
:param en: list of Components of the device whose json is required
:type en: list of strings or enums of components
:return: json only the components passed in en
:rtype: JSON
| def get_partial_entityjson(self, *en):
"""
Gets the json with components which are passed as argument for this function
:param en: list of Components of the device whose json is required
:type en: list of strings or enums of components
:return: json only the components p... | [
"def",
"get_partial_entityjson",
"(",
"self",
",",
"*",
"en",
")",
":",
"# Components with Sensors_*\r",
"comps",
"=",
"self",
".",
"ref",
".",
"convert_comp_to_enum",
"(",
"en",
",",
"self",
".",
"comp_union_spec",
",",
"self",
".",
"comp_merge_join_spec",
",",... | [
448,
4
] | [
469,
21
] | python | en | ['en', 'ja', 'th'] | False |
iBaseDriver.get_entityjson | (self) |
Create the json of the device by fetching attributes from the device using the protocol
Internally creates the raw json of the device
:return: True if successful
:rtype: bool
|
Create the json of the device by fetching attributes from the device using the protocol
Internally creates the raw json of the device
:return: True if successful
:rtype: bool
| def get_entityjson(self):
"""
Create the json of the device by fetching attributes from the device using the protocol
Internally creates the raw json of the device
:return: True if successful
:rtype: bool
"""
if self.inited == False and self.connec... | [
"def",
"get_entityjson",
"(",
"self",
")",
":",
"if",
"self",
".",
"inited",
"==",
"False",
"and",
"self",
".",
"connect",
"(",
")",
":",
"if",
"not",
"self",
".",
"my_get_entityjson",
"(",
")",
":",
"return",
"False",
"self",
".",
"_build_device_map",
... | [
480,
4
] | [
496,
26
] | python | en | ['en', 'ja', 'th'] | False |
DenseNet.__init__ | (self, args) |
TODO: Write Comment
|
TODO: Write Comment
| def __init__(self, args):
"""
TODO: Write Comment
"""
self.name = 'DenseNet'
CifarModel.__init__(self, args) | [
"def",
"__init__",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"name",
"=",
"'DenseNet'",
"CifarModel",
".",
"__init__",
"(",
"self",
",",
"args",
")"
] | [
10,
4
] | [
17,
39
] | python | en | ['en', 'error', 'th'] | False |
DenseNet.network | (self, img_input) |
TODO: Write Comment
|
TODO: Write Comment
| def network(self, img_input):
"""
TODO: Write Comment
"""
from tensorflow.keras import initializers, layers, regularizers
growth_rate = 12
depth = 100
compression = 0.5
weight_decay = 0.0001
nblocks = (depth - 4) // 6
nchann... | [
"def",
"network",
"(",
"self",
",",
"img_input",
")",
":",
"from",
"tensorflow",
".",
"keras",
"import",
"initializers",
",",
"layers",
",",
"regularizers",
"growth_rate",
"=",
"12",
"depth",
"=",
"100",
"compression",
"=",
"0.5",
"weight_decay",
"=",
"0.000... | [
19,
4
] | [
117,
16
] | python | en | ['en', 'error', 'th'] | False |
DenseNet.scheduler | (self, epoch) |
TODO: Write Comment
|
TODO: Write Comment
| def scheduler(self, epoch):
"""
TODO: Write Comment
"""
if epoch <= 75:
return 0.1
if epoch <= 150:
return 0.01
return 0.001 | [
"def",
"scheduler",
"(",
"self",
",",
"epoch",
")",
":",
"if",
"epoch",
"<=",
"75",
":",
"return",
"0.1",
"if",
"epoch",
"<=",
"150",
":",
"return",
"0.01",
"return",
"0.001"
] | [
119,
4
] | [
128,
20
] | python | en | ['en', 'error', 'th'] | False |
immediate_on_commit | () |
Context manager executing transaction.on_commit() hooks immediately as
if the connection was in auto-commit mode.
|
Context manager executing transaction.on_commit() hooks immediately as
if the connection was in auto-commit mode.
| def immediate_on_commit():
"""
Context manager executing transaction.on_commit() hooks immediately as
if the connection was in auto-commit mode.
"""
def on_commit(func):
func()
with mock.patch('django.db.connection.on_commit', side_effect=on_commit) as patch:
yield patch | [
"def",
"immediate_on_commit",
"(",
")",
":",
"def",
"on_commit",
"(",
"func",
")",
":",
"func",
"(",
")",
"with",
"mock",
".",
"patch",
"(",
"'django.db.connection.on_commit'",
",",
"side_effect",
"=",
"on_commit",
")",
"as",
"patch",
":",
"yield",
"patch"
] | [
83,
0
] | [
93,
19
] | python | en | ['en', 'error', 'th'] | False |
cache_page | (*args, **kwargs) |
Decorator for views that tries getting the page from the cache and
populates the cache if the page isn't in the cache yet.
The cache is keyed by the URL and some data from the headers.
Additionally there is the key prefix that is used to distinguish different
cache areas in a multi-site setup. You... |
Decorator for views that tries getting the page from the cache and
populates the cache if the page isn't in the cache yet. | def cache_page(*args, **kwargs):
"""
Decorator for views that tries getting the page from the cache and
populates the cache if the page isn't in the cache yet.
The cache is keyed by the URL and some data from the headers.
Additionally there is the key prefix that is used to distinguish different
... | [
"def",
"cache_page",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# We also add some asserts to give better error messages in case people are",
"# using other ways to call cache_page that no longer work.",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"or",
"callable",... | [
9,
0
] | [
35,
5
] | python | en | ['en', 'error', 'th'] | False |
never_cache | (view_func) |
Decorator that adds headers to a response so that it will
never be cached.
|
Decorator that adds headers to a response so that it will
never be cached.
| def never_cache(view_func):
"""
Decorator that adds headers to a response so that it will
never be cached.
"""
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view_func(request, *args, **kwargs):
response = view_func(request, *args, **kwargs)
add_never_cache_h... | [
"def",
"never_cache",
"(",
"view_func",
")",
":",
"@",
"wraps",
"(",
"view_func",
",",
"assigned",
"=",
"available_attrs",
"(",
"view_func",
")",
")",
"def",
"_wrapped_view_func",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"resp... | [
49,
0
] | [
59,
29
] | python | en | ['en', 'error', 'th'] | False |
NavigatorWatcher.__init__ | (self, frameManager: FrameManager, frame: Frame, timeout: int,
options: Dict = None, **kwargs: Any) | Make new navigator watcher. | Make new navigator watcher. | def __init__(self, frameManager: FrameManager, frame: Frame, timeout: int,
options: Dict = None, **kwargs: Any) -> None:
"""Make new navigator watcher."""
options = merge_dict(options, kwargs)
self._validate_options(options)
self._frameManager = frameManager
self... | [
"def",
"__init__",
"(",
"self",
",",
"frameManager",
":",
"FrameManager",
",",
"frame",
":",
"Frame",
",",
"timeout",
":",
"int",
",",
"options",
":",
"Dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
... | [
18,
4
] | [
53,
40
] | python | en | ['en', 'lb', 'en'] | True |
NavigatorWatcher.navigationPromise | (self) | Return navigation promise. | Return navigation promise. | def navigationPromise(self) -> Any:
"""Return navigation promise."""
return self._navigationPromise | [
"def",
"navigationPromise",
"(",
"self",
")",
"->",
"Any",
":",
"return",
"self",
".",
"_navigationPromise"
] | [
103,
4
] | [
105,
38
] | python | da | ['fi', 'da', 'en'] | False |
NavigatorWatcher.cancel | (self) | Cancel navigation. | Cancel navigation. | def cancel(self) -> None:
"""Cancel navigation."""
self._cleanup() | [
"def",
"cancel",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_cleanup",
"(",
")"
] | [
133,
4
] | [
135,
23
] | python | da | ['es', 'da', 'en'] | False |
write_emoticon_data | (
realm_id: int, custom_emoji_data: List[Dict[str, Any]], data_dir: str, output_dir: str
) |
This function does most of the work for processing emoticons, the bulk
of which is copying files. We also write a json file with metadata.
Finally, we return a list of RealmEmoji dicts to our caller.
In our data_dir we have a pretty simple setup:
The exported JSON file will have emoji rows i... |
This function does most of the work for processing emoticons, the bulk
of which is copying files. We also write a json file with metadata.
Finally, we return a list of RealmEmoji dicts to our caller. | def write_emoticon_data(
realm_id: int, custom_emoji_data: List[Dict[str, Any]], data_dir: str, output_dir: str
) -> List[ZerverFieldsT]:
"""
This function does most of the work for processing emoticons, the bulk
of which is copying files. We also write a json file with metadata.
Finally, we return... | [
"def",
"write_emoticon_data",
"(",
"realm_id",
":",
"int",
",",
"custom_emoji_data",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"data_dir",
":",
"str",
",",
"output_dir",
":",
"str",
")",
"->",
"List",
"[",
"ZerverFieldsT",
"]",
"... | [
597,
0
] | [
678,
21
] | python | en | ['en', 'error', 'th'] | False |
PyDialog.__init__ | (self, *args, **kw) | Dialog(database, name, x, y, w, h, attributes, title, first,
default, cancel, bitmap=true) | Dialog(database, name, x, y, w, h, attributes, title, first,
default, cancel, bitmap=true) | def __init__(self, *args, **kw):
"""Dialog(database, name, x, y, w, h, attributes, title, first,
default, cancel, bitmap=true)"""
Dialog.__init__(self, *args)
ruler = self.h - 36
bmwidth = 152*ruler/328
#if kw.get("bitmap", True):
# self.bitmap("Bitmap", 0, 0, ... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"Dialog",
".",
"__init__",
"(",
"self",
",",
"*",
"args",
")",
"ruler",
"=",
"self",
".",
"h",
"-",
"36",
"bmwidth",
"=",
"152",
"*",
"ruler",
"/",
"328",
"#if kw.... | [
26,
4
] | [
34,
52
] | python | en | ['en', 'en', 'pl'] | True |
PyDialog.title | (self, title) | Set the title text of the dialog at the top. | Set the title text of the dialog at the top. | def title(self, title):
"Set the title text of the dialog at the top."
# name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
# text, in VerdanaBold10
self.text("Title", 15, 10, 320, 60, 0x30003,
r"{\VerdanaBold10}%s" % title) | [
"def",
"title",
"(",
"self",
",",
"title",
")",
":",
"# name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,",
"# text, in VerdanaBold10",
"self",
".",
"text",
"(",
"\"Title\"",
",",
"15",
",",
"10",
",",
"320",
",",
"60",
",",
"0x30003",
",",
"r\"{\\Verd... | [
36,
4
] | [
41,
48
] | python | en | ['en', 'en', 'en'] | True |
PyDialog.back | (self, title, next, name = "Back", active = 1) | Add a back button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled.
Return the button, so that events can be associated | Add a back button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled. | def back(self, title, next, name = "Back", active = 1):
"""Add a back button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled.
Return the button, so that events can be associated"""
if active:
flags = 3 # Visible|Enabled
... | [
"def",
"back",
"(",
"self",
",",
"title",
",",
"next",
",",
"name",
"=",
"\"Back\"",
",",
"active",
"=",
"1",
")",
":",
"if",
"active",
":",
"flags",
"=",
"3",
"# Visible|Enabled",
"else",
":",
"flags",
"=",
"1",
"# Visible",
"return",
"self",
".",
... | [
43,
4
] | [
52,
81
] | python | en | ['en', 'en', 'en'] | True |
PyDialog.cancel | (self, title, next, name = "Cancel", active = 1) | Add a cancel button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled.
Return the button, so that events can be associated | Add a cancel button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled. | def cancel(self, title, next, name = "Cancel", active = 1):
"""Add a cancel button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled.
Return the button, so that events can be associated"""
if active:
flags = 3 # Visible|Enabl... | [
"def",
"cancel",
"(",
"self",
",",
"title",
",",
"next",
",",
"name",
"=",
"\"Cancel\"",
",",
"active",
"=",
"1",
")",
":",
"if",
"active",
":",
"flags",
"=",
"3",
"# Visible|Enabled",
"else",
":",
"flags",
"=",
"1",
"# Visible",
"return",
"self",
".... | [
54,
4
] | [
63,
80
] | python | en | ['en', 'en', 'en'] | True |
PyDialog.next | (self, title, next, name = "Next", active = 1) | Add a Next button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled.
Return the button, so that events can be associated | Add a Next button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled. | def next(self, title, next, name = "Next", active = 1):
"""Add a Next button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled.
Return the button, so that events can be associated"""
if active:
flags = 3 # Visible|Enabled
... | [
"def",
"next",
"(",
"self",
",",
"title",
",",
"next",
",",
"name",
"=",
"\"Next\"",
",",
"active",
"=",
"1",
")",
":",
"if",
"active",
":",
"flags",
"=",
"3",
"# Visible|Enabled",
"else",
":",
"flags",
"=",
"1",
"# Visible",
"return",
"self",
".",
... | [
65,
4
] | [
74,
80
] | python | en | ['en', 'en', 'en'] | True |
PyDialog.xbutton | (self, name, title, next, xpos) | Add a button with a given title, the tab-next button,
its name in the Control table, giving its x position; the
y-position is aligned with the other buttons.
Return the button, so that events can be associated | Add a button with a given title, the tab-next button,
its name in the Control table, giving its x position; the
y-position is aligned with the other buttons. | def xbutton(self, name, title, next, xpos):
"""Add a button with a given title, the tab-next button,
its name in the Control table, giving its x position; the
y-position is aligned with the other buttons.
Return the button, so that events can be associated"""
return self.pushbut... | [
"def",
"xbutton",
"(",
"self",
",",
"name",
",",
"title",
",",
"next",
",",
"xpos",
")",
":",
"return",
"self",
".",
"pushbutton",
"(",
"name",
",",
"int",
"(",
"self",
".",
"w",
"*",
"xpos",
"-",
"28",
")",
",",
"self",
".",
"h",
"-",
"27",
... | [
76,
4
] | [
82,
94
] | python | en | ['en', 'en', 'en'] | True |
bdist_msi.add_find_python | (self) | Adds code to the installer to compute the location of Python.
Properties PYTHON.MACHINE.X.Y and PYTHON.USER.X.Y will be set from the
registry for each version of Python.
Properties TARGETDIRX.Y will be set from PYTHON.USER.X.Y if defined,
else from PYTHON.MACHINE.X.Y.
Properti... | Adds code to the installer to compute the location of Python. | def add_find_python(self):
"""Adds code to the installer to compute the location of Python.
Properties PYTHON.MACHINE.X.Y and PYTHON.USER.X.Y will be set from the
registry for each version of Python.
Properties TARGETDIRX.Y will be set from PYTHON.USER.X.Y if defined,
else from... | [
"def",
"add_find_python",
"(",
"self",
")",
":",
"start",
"=",
"402",
"for",
"ver",
"in",
"self",
".",
"versions",
":",
"install_path",
"=",
"r\"SOFTWARE\\Python\\PythonCore\\%s\\InstallPath\"",
"%",
"ver",
"machine_reg",
"=",
"\"python.machine.\"",
"+",
"ver",
"u... | [
330,
4
] | [
382,
30
] | python | en | ['en', 'en', 'en'] | True |
filter_ice_border | (ice_thick) | Sets the ice thickness at the border of the domain to zero. | Sets the ice thickness at the border of the domain to zero. | def filter_ice_border(ice_thick):
"""Sets the ice thickness at the border of the domain to zero."""
ice_thick[0, :] = 0
ice_thick[-1, :] = 0
ice_thick[:, 0] = 0
ice_thick[:, -1] = 0
return ice_thick | [
"def",
"filter_ice_border",
"(",
"ice_thick",
")",
":",
"ice_thick",
"[",
"0",
",",
":",
"]",
"=",
"0",
"ice_thick",
"[",
"-",
"1",
",",
":",
"]",
"=",
"0",
"ice_thick",
"[",
":",
",",
"0",
"]",
"=",
"0",
"ice_thick",
"[",
":",
",",
"-",
"1",
... | [
9,
0
] | [
15,
20
] | python | en | ['en', 'en', 'en'] | True |
Model2D.__init__ | (self, bed_topo, init_ice_thick=None, dx=None, dy=None,
mb_model=None, y0=0., glen_a=None, mb_elev_feedback='annual',
ice_thick_filter=filter_ice_border) | Create a new 2D model from gridded data.
Parameters
----------
bed_topo : 2d array
the topography
init_ice_thick : 2d array (optional)
the initial ice thickness (default is zero everywhere)
dx : float
map resolution (m)
dy : float
... | Create a new 2D model from gridded data. | def __init__(self, bed_topo, init_ice_thick=None, dx=None, dy=None,
mb_model=None, y0=0., glen_a=None, mb_elev_feedback='annual',
ice_thick_filter=filter_ice_border):
"""Create a new 2D model from gridded data.
Parameters
----------
bed_topo : 2d array
... | [
"def",
"__init__",
"(",
"self",
",",
"bed_topo",
",",
"init_ice_thick",
"=",
"None",
",",
"dx",
"=",
"None",
",",
"dy",
"=",
"None",
",",
"mb_model",
"=",
"None",
",",
"y0",
"=",
"0.",
",",
"glen_a",
"=",
"None",
",",
"mb_elev_feedback",
"=",
"'annua... | [
21,
4
] | [
76,
41
] | python | en | ['en', 'en', 'en'] | True |
Model2D.reset_y0 | (self, y0) | Reset the initial model time | Reset the initial model time | def reset_y0(self, y0):
"""Reset the initial model time"""
self.y0 = y0
self.t = 0 | [
"def",
"reset_y0",
"(",
"self",
",",
"y0",
")",
":",
"self",
".",
"y0",
"=",
"y0",
"self",
".",
"t",
"=",
"0"
] | [
99,
4
] | [
102,
18
] | python | en | ['en', 'en', 'en'] | True |
Model2D.reset_ice_thick | (self, ice_thick=None) | Reset the ice thickness | Reset the ice thickness | def reset_ice_thick(self, ice_thick=None):
"""Reset the ice thickness"""
if ice_thick is None:
ice_thick = self.bed_topo * 0.
self.ice_thick = ice_thick.copy() | [
"def",
"reset_ice_thick",
"(",
"self",
",",
"ice_thick",
"=",
"None",
")",
":",
"if",
"ice_thick",
"is",
"None",
":",
"ice_thick",
"=",
"self",
".",
"bed_topo",
"*",
"0.",
"self",
".",
"ice_thick",
"=",
"ice_thick",
".",
"copy",
"(",
")"
] | [
104,
4
] | [
108,
41
] | python | en | ['en', 'en', 'en'] | True |
Model2D.get_mb | (self, year=None) | Get the mass balance at the requested height and time.
Optimized so that no mb model call is necessary at each step.
| Get the mass balance at the requested height and time. | def get_mb(self, year=None):
"""Get the mass balance at the requested height and time.
Optimized so that no mb model call is necessary at each step.
"""
if year is None:
year = self.yr
# Do we have to optimise?
if self.mb_elev_feedback == 'always':
... | [
"def",
"get_mb",
"(",
"self",
",",
"year",
"=",
"None",
")",
":",
"if",
"year",
"is",
"None",
":",
"year",
"=",
"self",
".",
"yr",
"# Do we have to optimise?",
"if",
"self",
".",
"mb_elev_feedback",
"==",
"'always'",
":",
"return",
"self",
".",
"_mb_call... | [
134,
4
] | [
158,
35
] | python | en | ['en', 'en', 'en'] | True |
Model2D.step | (self, dt) | Advance one step. | Advance one step. | def step(self, dt):
"""Advance one step."""
raise NotImplementedError | [
"def",
"step",
"(",
"self",
",",
"dt",
")",
":",
"raise",
"NotImplementedError"
] | [
160,
4
] | [
162,
33
] | python | en | ['en', 'ig', 'en'] | True |
Model2D.run_until | (self, y1, stop_if_border=False) | Run until a selected year. | Run until a selected year. | def run_until(self, y1, stop_if_border=False):
"""Run until a selected year."""
t = (y1 - self.y0) * SEC_IN_YEAR
while self.t < t:
self.step(t - self.t)
if stop_if_border:
if (np.any(self.ice_thick[0, :] > 10) or
np.any(self.ice_th... | [
"def",
"run_until",
"(",
"self",
",",
"y1",
",",
"stop_if_border",
"=",
"False",
")",
":",
"t",
"=",
"(",
"y1",
"-",
"self",
".",
"y0",
")",
"*",
"SEC_IN_YEAR",
"while",
"self",
".",
"t",
"<",
"t",
":",
"self",
".",
"step",
"(",
"t",
"-",
"self... | [
164,
4
] | [
180,
66
] | python | en | ['en', 'en', 'en'] | True |
Model2D.run_until_equilibrium | (self, rate=0.001, ystep=5, max_ite=200) | Run until an equilibrium is reached (can take a while). | Run until an equilibrium is reached (can take a while). | def run_until_equilibrium(self, rate=0.001, ystep=5, max_ite=200):
"""Run until an equilibrium is reached (can take a while)."""
ite = 0
was_close_zero = 0
t_rate = 1
while (t_rate > rate) and (ite <= max_ite) and (was_close_zero < 5):
ite += 1
v_bef = se... | [
"def",
"run_until_equilibrium",
"(",
"self",
",",
"rate",
"=",
"0.001",
",",
"ystep",
"=",
"5",
",",
"max_ite",
"=",
"200",
")",
":",
"ite",
"=",
"0",
"was_close_zero",
"=",
"0",
"t_rate",
"=",
"1",
"while",
"(",
"t_rate",
">",
"rate",
")",
"and",
... | [
182,
4
] | [
199,
59
] | python | en | ['en', 'en', 'en'] | True |
Model2D.run_until_and_store | (self, ye, step=2, run_path=None, grid=None,
print_stdout=False, stop_if_border=False) | Run until a selected year and store the output in a NetCDF file. | Run until a selected year and store the output in a NetCDF file. | def run_until_and_store(self, ye, step=2, run_path=None, grid=None,
print_stdout=False, stop_if_border=False):
"""Run until a selected year and store the output in a NetCDF file."""
yrs = np.arange(np.floor(self.yr), np.floor(ye) + 1, step)
out_thick = np.zeros((len(... | [
"def",
"run_until_and_store",
"(",
"self",
",",
"ye",
",",
"step",
"=",
"2",
",",
"run_path",
"=",
"None",
",",
"grid",
"=",
"None",
",",
"print_stdout",
"=",
"False",
",",
"stop_if_border",
"=",
"False",
")",
":",
"yrs",
"=",
"np",
".",
"arange",
"(... | [
201,
4
] | [
231,
21
] | python | en | ['en', 'en', 'en'] | True |
Upstream2D.__init__ | (self, bed_topo, init_ice_thick=None, dx=None,
mb_model=None, y0=0., glen_a=None, mb_elev_feedback='annual',
cfl=0.124, max_dt=31*SEC_IN_DAY,
ice_thick_filter=filter_ice_border) | Create a new 2D model from gridded data.
Parameters
----------
bed_topo : 2d array
the topography
init_ice_thick : 2d array (optional)
the initial ice thickness (default is zero everywhere)
dx : float
map resolution (m)
dy : float
... | Create a new 2D model from gridded data. | def __init__(self, bed_topo, init_ice_thick=None, dx=None,
mb_model=None, y0=0., glen_a=None, mb_elev_feedback='annual',
cfl=0.124, max_dt=31*SEC_IN_DAY,
ice_thick_filter=filter_ice_border):
"""Create a new 2D model from gridded data.
Parameters
... | [
"def",
"__init__",
"(",
"self",
",",
"bed_topo",
",",
"init_ice_thick",
"=",
"None",
",",
"dx",
"=",
"None",
",",
"mb_model",
"=",
"None",
",",
"y0",
"=",
"0.",
",",
"glen_a",
"=",
"None",
",",
"mb_elev_feedback",
"=",
"'annual'",
",",
"cfl",
"=",
"0... | [
237,
4
] | [
313,
44
] | python | en | ['en', 'en', 'en'] | True |
Upstream2D.step | (self, dt) | Advance one step. | Advance one step. | def step(self, dt):
"""Advance one step."""
div_q, dt_cfl = self.diffusion_upstream_2d()
dt_use = utils.clip_scalar(np.min([dt_cfl, dt]), 0, self.max_dt)
self.ice_thick = utils.clip_min(self.surface_h +
(self.get_mb() + div_q) * dt_use -
... | [
"def",
"step",
"(",
"self",
",",
"dt",
")",
":",
"div_q",
",",
"dt_cfl",
"=",
"self",
".",
"diffusion_upstream_2d",
"(",
")",
"dt_use",
"=",
"utils",
".",
"clip_scalar",
"(",
"np",
".",
"min",
"(",
"[",
"dt_cfl",
",",
"dt",
"]",
")",
",",
"0",
",... | [
418,
4
] | [
432,
17
] | python | en | ['en', 'ig', 'en'] | True |
ElementHandle.asElement | (self) | Return this ElementHandle. | Return this ElementHandle. | def asElement(self) -> 'ElementHandle':
"""Return this ElementHandle."""
return self | [
"def",
"asElement",
"(",
"self",
")",
"->",
"'ElementHandle'",
":",
"return",
"self"
] | [
49,
4
] | [
51,
19
] | python | en | ['en', 'be', 'en'] | True |
ElementHandle.contentFrame | (self) | Return the content frame for the element handle.
Return ``None`` if this handle is not referencing iframe.
| Return the content frame for the element handle. | async def contentFrame(self) -> Optional['Frame']:
"""Return the content frame for the element handle.
Return ``None`` if this handle is not referencing iframe.
"""
nodeInfo = await self._client.send('DOM.describeNode', {
'objectId': self._remoteObject.get('objectId'),
... | [
"async",
"def",
"contentFrame",
"(",
"self",
")",
"->",
"Optional",
"[",
"'Frame'",
"]",
":",
"nodeInfo",
"=",
"await",
"self",
".",
"_client",
".",
"send",
"(",
"'DOM.describeNode'",
",",
"{",
"'objectId'",
":",
"self",
".",
"_remoteObject",
".",
"get",
... | [
53,
4
] | [
64,
60
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.hover | (self) | Move mouse over to center of this element.
If needed, this method scrolls element into view. If this element is
detached from DOM tree, the method raises an ``ElementHandleError``.
| Move mouse over to center of this element. | async def hover(self) -> None:
"""Move mouse over to center of this element.
If needed, this method scrolls element into view. If this element is
detached from DOM tree, the method raises an ``ElementHandleError``.
"""
await self._scrollIntoViewIfNeeded()
obj = await sel... | [
"async",
"def",
"hover",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"_scrollIntoViewIfNeeded",
"(",
")",
"obj",
"=",
"await",
"self",
".",
"_clickablePoint",
"(",
")",
"x",
"=",
"obj",
".",
"get",
"(",
"'x'",
",",
"0",
")",
"y",
"="... | [
149,
4
] | [
159,
41
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.click | (self, options: dict = None, **kwargs: Any) | Click the center of this element.
If needed, this method scrolls element into view. If the element is
detached from DOM, the method raises ``ElementHandleError``.
``options`` can contain the following fields:
* ``button`` (str): ``left``, ``right``, of ``middle``, defaults to
... | Click the center of this element. | async def click(self, options: dict = None, **kwargs: Any) -> None:
"""Click the center of this element.
If needed, this method scrolls element into view. If the element is
detached from DOM, the method raises ``ElementHandleError``.
``options`` can contain the following fields:
... | [
"async",
"def",
"click",
"(",
"self",
",",
"options",
":",
"dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"await",
"self",
".",
"_scrollIntoViewIfNeede... | [
161,
4
] | [
180,
51
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.uploadFile | (self, *filePaths: str) | Upload files. | Upload files. | async def uploadFile(self, *filePaths: str) -> dict:
"""Upload files."""
files = [os.path.abspath(p) for p in filePaths]
objectId = self._remoteObject.get('objectId')
return await self._client.send(
'DOM.setFileInputFiles',
{'objectId': objectId, 'files': files}
... | [
"async",
"def",
"uploadFile",
"(",
"self",
",",
"*",
"filePaths",
":",
"str",
")",
"->",
"dict",
":",
"files",
"=",
"[",
"os",
".",
"path",
".",
"abspath",
"(",
"p",
")",
"for",
"p",
"in",
"filePaths",
"]",
"objectId",
"=",
"self",
".",
"_remoteObj... | [
182,
4
] | [
189,
9
] | python | en | ['en', 'ja', 'en'] | False |
ElementHandle.tap | (self) | Tap the center of this element.
If needed, this method scrolls element into view. If the element is
detached from DOM, the method raises ``ElementHandleError``.
| Tap the center of this element. | async def tap(self) -> None:
"""Tap the center of this element.
If needed, this method scrolls element into view. If the element is
detached from DOM, the method raises ``ElementHandleError``.
"""
await self._scrollIntoViewIfNeeded()
center = await self._clickablePoint()... | [
"async",
"def",
"tap",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"_scrollIntoViewIfNeeded",
"(",
")",
"center",
"=",
"await",
"self",
".",
"_clickablePoint",
"(",
")",
"x",
"=",
"center",
".",
"get",
"(",
"'x'",
",",
"0",
")",
"y",
... | [
191,
4
] | [
201,
46
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.focus | (self) | Focus on this element. | Focus on this element. | async def focus(self) -> None:
"""Focus on this element."""
await self.executionContext.evaluate(
'element => element.focus()', self) | [
"async",
"def",
"focus",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"executionContext",
".",
"evaluate",
"(",
"'element => element.focus()'",
",",
"self",
")"
] | [
203,
4
] | [
206,
47
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.type | (self, text: str, options: Dict = None, **kwargs: Any
) | Focus the element and then type text.
Details see :meth:`pyppeteer.input.Keyboard.type` method.
| Focus the element and then type text. | async def type(self, text: str, options: Dict = None, **kwargs: Any
) -> None:
"""Focus the element and then type text.
Details see :meth:`pyppeteer.input.Keyboard.type` method.
"""
options = merge_dict(options, kwargs)
await self.focus()
await self._p... | [
"async",
"def",
"type",
"(",
"self",
",",
"text",
":",
"str",
",",
"options",
":",
"Dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"await",
"self",
... | [
208,
4
] | [
216,
53
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.press | (self, key: str, options: Dict = None, **kwargs: Any
) | Press ``key`` onto the element.
This method focuses the element, and then uses
:meth:`pyppeteer.input.keyboard.down` and
:meth:`pyppeteer.input.keyboard.up`.
:arg str key: Name of key to press, such as ``ArrowLeft``.
This method accepts the following options:
* ``text... | Press ``key`` onto the element. | async def press(self, key: str, options: Dict = None, **kwargs: Any
) -> None:
"""Press ``key`` onto the element.
This method focuses the element, and then uses
:meth:`pyppeteer.input.keyboard.down` and
:meth:`pyppeteer.input.keyboard.up`.
:arg str key: Name... | [
"async",
"def",
"press",
"(",
"self",
",",
"key",
":",
"str",
",",
"options",
":",
"Dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"await",
"self",
... | [
218,
4
] | [
237,
53
] | python | en | ['en', 'hu', 'en'] | True |
ElementHandle.boundingBox | (self) | Return bounding box of this element.
If the element is not visible, return ``None``.
This method returns dictionary of bounding box, which contains:
* ``x`` (int): The X coordinate of the element in pixels.
* ``y`` (int): The Y coordinate of the element in pixels.
* ``width`` ... | Return bounding box of this element. | async def boundingBox(self) -> Optional[Dict[str, float]]:
"""Return bounding box of this element.
If the element is not visible, return ``None``.
This method returns dictionary of bounding box, which contains:
* ``x`` (int): The X coordinate of the element in pixels.
* ``y`` ... | [
"async",
"def",
"boundingBox",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"float",
"]",
"]",
":",
"result",
"=",
"await",
"self",
".",
"_getBoxModel",
"(",
")",
"if",
"not",
"result",
":",
"return",
"None",
"quad",
"=",
"result... | [
239,
4
] | [
261,
65
] | python | en | ['en', 'sn', 'en'] | True |
ElementHandle.boxModel | (self) | Return boxes of element.
Return ``None`` if element is not visible. Boxes are represented as an
list of points; each Point is a dictionary ``{x, y}``. Box points are
sorted clock-wise.
Returned value is a dictionary with the following fields:
* ``content`` (List[Dict]): Conten... | Return boxes of element. | async def boxModel(self) -> Optional[Dict]:
"""Return boxes of element.
Return ``None`` if element is not visible. Boxes are represented as an
list of points; each Point is a dictionary ``{x, y}``. Box points are
sorted clock-wise.
Returned value is a dictionary with the follow... | [
"async",
"def",
"boxModel",
"(",
"self",
")",
"->",
"Optional",
"[",
"Dict",
"]",
":",
"result",
"=",
"await",
"self",
".",
"_getBoxModel",
"(",
")",
"if",
"not",
"result",
":",
"return",
"None",
"model",
"=",
"result",
".",
"get",
"(",
"'model'",
",... | [
263,
4
] | [
292,
9
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.screenshot | (self, options: Dict = None, **kwargs: Any) | Take a screenshot of this element.
If the element is detached from DOM, this method raises an
``ElementHandleError``.
Available options are same as :meth:`pyppeteer.page.Page.screenshot`.
| Take a screenshot of this element. | async def screenshot(self, options: Dict = None, **kwargs: Any) -> bytes:
"""Take a screenshot of this element.
If the element is detached from DOM, this method raises an
``ElementHandleError``.
Available options are same as :meth:`pyppeteer.page.Page.screenshot`.
"""
o... | [
"async",
"def",
"screenshot",
"(",
"self",
",",
"options",
":",
"Dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"bytes",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"needsViewportReset",
"=",
"False",
"bo... | [
294,
4
] | [
350,
24
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.querySelector | (self, selector: str) | Return first element which matches ``selector`` under this element.
If no element matches the ``selector``, returns ``None``.
| Return first element which matches ``selector`` under this element. | async def querySelector(self, selector: str) -> Optional['ElementHandle']:
"""Return first element which matches ``selector`` under this element.
If no element matches the ``selector``, returns ``None``.
"""
handle = await self.executionContext.evaluateHandle(
'(element, sel... | [
"async",
"def",
"querySelector",
"(",
"self",
",",
"selector",
":",
"str",
")",
"->",
"Optional",
"[",
"'ElementHandle'",
"]",
":",
"handle",
"=",
"await",
"self",
".",
"executionContext",
".",
"evaluateHandle",
"(",
"'(element, selector) => element.querySelector(se... | [
352,
4
] | [
365,
19
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.querySelectorAll | (self, selector: str) | Return all elements which match ``selector`` under this element.
If no element matches the ``selector``, returns empty list (``[]``).
| Return all elements which match ``selector`` under this element. | async def querySelectorAll(self, selector: str) -> List['ElementHandle']:
"""Return all elements which match ``selector`` under this element.
If no element matches the ``selector``, returns empty list (``[]``).
"""
arrayHandle = await self.executionContext.evaluateHandle(
'(... | [
"async",
"def",
"querySelectorAll",
"(",
"self",
",",
"selector",
":",
"str",
")",
"->",
"List",
"[",
"'ElementHandle'",
"]",
":",
"arrayHandle",
"=",
"await",
"self",
".",
"executionContext",
".",
"evaluateHandle",
"(",
"'(element, selector) => element.querySelecto... | [
367,
4
] | [
383,
21
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.querySelectorEval | (self, selector: str, pageFunction: str,
*args: Any) | Run ``Page.querySelectorEval`` within the element.
This method runs ``document.querySelector`` within the element and
passes it as the first argument to ``pageFunction``. If there is no
element matching ``selector``, the method raises
``ElementHandleError``.
If ``pageFunction``... | Run ``Page.querySelectorEval`` within the element. | async def querySelectorEval(self, selector: str, pageFunction: str,
*args: Any) -> Any:
"""Run ``Page.querySelectorEval`` within the element.
This method runs ``document.querySelector`` within the element and
passes it as the first argument to ``pageFunction``. I... | [
"async",
"def",
"querySelectorEval",
"(",
"self",
",",
"selector",
":",
"str",
",",
"pageFunction",
":",
"str",
",",
"*",
"args",
":",
"Any",
")",
"->",
"Any",
":",
"# noqa: E501",
"elementHandle",
"=",
"await",
"self",
".",
"querySelector",
"(",
"selector... | [
385,
4
] | [
415,
21
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.querySelectorAllEval | (self, selector: str, pageFunction: str,
*args: Any) | Run ``Page.querySelectorAllEval`` within the element.
This method runs ``Array.from(document.querySelectorAll)`` within the
element and passes it as the first argument to ``pageFunction``. If
there is no element matching ``selector``, the method raises
``ElementHandleError``.
I... | Run ``Page.querySelectorAllEval`` within the element. | async def querySelectorAllEval(self, selector: str, pageFunction: str,
*args: Any) -> Any:
"""Run ``Page.querySelectorAllEval`` within the element.
This method runs ``Array.from(document.querySelectorAll)`` within the
element and passes it as the first argumen... | [
"async",
"def",
"querySelectorAllEval",
"(",
"self",
",",
"selector",
":",
"str",
",",
"pageFunction",
":",
"str",
",",
"*",
"args",
":",
"Any",
")",
"->",
"Any",
":",
"# noqa: E501",
"arrayHandle",
"=",
"await",
"self",
".",
"executionContext",
".",
"eval... | [
417,
4
] | [
450,
21
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.xpath | (self, expression: str) | Evaluate the XPath expression relative to this elementHandle.
If there are no such elements, return an empty list.
:arg str expression: XPath string to be evaluated.
| Evaluate the XPath expression relative to this elementHandle. | async def xpath(self, expression: str) -> List['ElementHandle']:
"""Evaluate the XPath expression relative to this elementHandle.
If there are no such elements, return an empty list.
:arg str expression: XPath string to be evaluated.
"""
arrayHandle = await self.executionContex... | [
"async",
"def",
"xpath",
"(",
"self",
",",
"expression",
":",
"str",
")",
"->",
"List",
"[",
"'ElementHandle'",
"]",
":",
"arrayHandle",
"=",
"await",
"self",
".",
"executionContext",
".",
"evaluateHandle",
"(",
"'''(element, expression) => {\n const ... | [
461,
4
] | [
487,
21
] | python | en | ['en', 'en', 'en'] | True |
ElementHandle.isIntersectingViewport | (self) | Return ``True`` if the element is visible in the viewport. | Return ``True`` if the element is visible in the viewport. | async def isIntersectingViewport(self) -> bool:
"""Return ``True`` if the element is visible in the viewport."""
return await self.executionContext.evaluate('''async element => {
const visibleRatio = await new Promise(resolve => {
const observer = new IntersectionObserver(ent... | [
"async",
"def",
"isIntersectingViewport",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"await",
"self",
".",
"executionContext",
".",
"evaluate",
"(",
"'''async element => {\n const visibleRatio = await new Promise(resolve => {\n const observer = new Int... | [
492,
4
] | [
503,
19
] | python | en | ['en', 'en', 'en'] | True |
test_no_templated_values | (collection_import) | This test corresponds to replacements done by
awx_collection/tools/roles/template_galaxy/tasks/main.yml
Those replacements should happen at build time, so they should not be
checked into source.
| This test corresponds to replacements done by
awx_collection/tools/roles/template_galaxy/tasks/main.yml
Those replacements should happen at build time, so they should not be
checked into source.
| def test_no_templated_values(collection_import):
"""This test corresponds to replacements done by
awx_collection/tools/roles/template_galaxy/tasks/main.yml
Those replacements should happen at build time, so they should not be
checked into source.
"""
ControllerAPIModule = collection_import('plug... | [
"def",
"test_no_templated_values",
"(",
"collection_import",
")",
":",
"ControllerAPIModule",
"=",
"collection_import",
"(",
"'plugins.module_utils.controller_api'",
")",
".",
"ControllerAPIModule",
"assert",
"ControllerAPIModule",
".",
"_COLLECTION_VERSION",
"==",
"\"0.0.1-dev... | [
176,
0
] | [
189,
5
] | python | en | ['en', 'en', 'en'] | True |
test_conflicting_name_and_id | (run_module, admin_user) | In the event that 2 related items match our search criteria in this way:
one item has an id that matches input
one item has a name that matches input
We should preference the id over the name.
Otherwise, the universality of the controller_api lookup plugin is compromised.
| In the event that 2 related items match our search criteria in this way:
one item has an id that matches input
one item has a name that matches input
We should preference the id over the name.
Otherwise, the universality of the controller_api lookup plugin is compromised.
| def test_conflicting_name_and_id(run_module, admin_user):
"""In the event that 2 related items match our search criteria in this way:
one item has an id that matches input
one item has a name that matches input
We should preference the id over the name.
Otherwise, the universality of the controller_... | [
"def",
"test_conflicting_name_and_id",
"(",
"run_module",
",",
"admin_user",
")",
":",
"org_by_id",
"=",
"Organization",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'foo'",
")",
"slug",
"=",
"str",
"(",
"org_by_id",
".",
"id",
")",
"Organization",
".",... | [
192,
0
] | [
206,
42
] | python | en | ['en', 'en', 'en'] | True |
check | () |
Checks for any inconsistent values in tables.
Returns False if any inconsistency is found, otherwise True.
|
Checks for any inconsistent values in tables. | def check():
"""
Checks for any inconsistent values in tables.
Returns False if any inconsistency is found, otherwise True.
"""
for query in (query_id0, query_image0, query_zone0):
if not isconsistent(query):
return False
return True | [
"def",
"check",
"(",
")",
":",
"for",
"query",
"in",
"(",
"query_id0",
",",
"query_image0",
",",
"query_zone0",
")",
":",
"if",
"not",
"isconsistent",
"(",
"query",
")",
":",
"return",
"False",
"return",
"True"
] | [
31,
0
] | [
40,
15
] | python | en | ['en', 'error', 'th'] | False |
isconsistent | (query) |
Counting rows should return 0, otherwise database is in an
inconsistent state.
If the database is consistent we return True, otherwise False.
|
Counting rows should return 0, otherwise database is in an
inconsistent state. | def isconsistent(query):
"""
Counting rows should return 0, otherwise database is in an
inconsistent state.
If the database is consistent we return True, otherwise False.
"""
try:
cursor = tkp.db.execute(query, commit=True)
result = cursor.fetchone()[0]
if result == 0:
... | [
"def",
"isconsistent",
"(",
"query",
")",
":",
"try",
":",
"cursor",
"=",
"tkp",
".",
"db",
".",
"execute",
"(",
"query",
",",
"commit",
"=",
"True",
")",
"result",
"=",
"cursor",
".",
"fetchone",
"(",
")",
"[",
"0",
"]",
"if",
"result",
"==",
"0... | [
42,
0
] | [
58,
16
] | python | en | ['en', 'error', 'th'] | False |
DeleteQuery.delete_batch | (self, pk_list, using) |
Set up and execute delete queries for all the objects in pk_list.
More than one physical query may be executed if there are a
lot of values in pk_list.
|
Set up and execute delete queries for all the objects in pk_list. | def delete_batch(self, pk_list, using):
"""
Set up and execute delete queries for all the objects in pk_list.
More than one physical query may be executed if there are a
lot of values in pk_list.
"""
# number of objects deleted
num_deleted = 0
field = sel... | [
"def",
"delete_batch",
"(",
"self",
",",
"pk_list",
",",
"using",
")",
":",
"# number of objects deleted",
"num_deleted",
"=",
"0",
"field",
"=",
"self",
".",
"get_meta",
"(",
")",
".",
"pk",
"for",
"offset",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"... | [
30,
4
] | [
45,
26
] | python | en | ['en', 'error', 'th'] | False |
DeleteQuery.delete_qs | (self, query, using) |
Delete the queryset in one SQL query (if possible). For simple queries
this is done by copying the query.query.where to self.query, for
complex queries by using subquery.
|
Delete the queryset in one SQL query (if possible). For simple queries
this is done by copying the query.query.where to self.query, for
complex queries by using subquery.
| def delete_qs(self, query, using):
"""
Delete the queryset in one SQL query (if possible). For simple queries
this is done by copying the query.query.where to self.query, for
complex queries by using subquery.
"""
innerq = query.query
# Make sure the inner query h... | [
"def",
"delete_qs",
"(",
"self",
",",
"query",
",",
"using",
")",
":",
"innerq",
"=",
"query",
".",
"query",
"# Make sure the inner query has at least one table in use.",
"innerq",
".",
"get_initial_alias",
"(",
")",
"# The same for our new query.",
"self",
".",
"get_... | [
47,
4
] | [
80,
47
] | python | en | ['en', 'error', 'th'] | False |
UpdateQuery._setup_query | (self) |
Runs on initialization and after cloning. Any attributes that would
normally be set in __init__ should go in here, instead, so that they
are also set up after a clone() call.
|
Runs on initialization and after cloning. Any attributes that would
normally be set in __init__ should go in here, instead, so that they
are also set up after a clone() call.
| def _setup_query(self):
"""
Runs on initialization and after cloning. Any attributes that would
normally be set in __init__ should go in here, instead, so that they
are also set up after a clone() call.
"""
self.values = []
self.related_ids = None
if not h... | [
"def",
"_setup_query",
"(",
"self",
")",
":",
"self",
".",
"values",
"=",
"[",
"]",
"self",
".",
"related_ids",
"=",
"None",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'related_updates'",
")",
":",
"self",
".",
"related_updates",
"=",
"{",
"}"
] | [
94,
4
] | [
103,
37
] | python | en | ['en', 'error', 'th'] | False |
UpdateQuery.add_update_values | (self, values) |
Convert a dictionary of field name to value mappings into an update
query. This is the entry point for the public update() method on
querysets.
|
Convert a dictionary of field name to value mappings into an update
query. This is the entry point for the public update() method on
querysets.
| def add_update_values(self, values):
"""
Convert a dictionary of field name to value mappings into an update
query. This is the entry point for the public update() method on
querysets.
"""
values_seq = []
for name, val in six.iteritems(values):
field =... | [
"def",
"add_update_values",
"(",
"self",
",",
"values",
")",
":",
"values_seq",
"=",
"[",
"]",
"for",
"name",
",",
"val",
"in",
"six",
".",
"iteritems",
"(",
"values",
")",
":",
"field",
"=",
"self",
".",
"get_meta",
"(",
")",
".",
"get_field",
"(",
... | [
115,
4
] | [
135,
49
] | python | en | ['en', 'error', 'th'] | False |
UpdateQuery.add_update_fields | (self, values_seq) |
Append a sequence of (field, model, value) triples to the internal list
that will be used to generate the UPDATE query. Might be more usefully
called add_update_targets() to hint at the extra information here.
|
Append a sequence of (field, model, value) triples to the internal list
that will be used to generate the UPDATE query. Might be more usefully
called add_update_targets() to hint at the extra information here.
| def add_update_fields(self, values_seq):
"""
Append a sequence of (field, model, value) triples to the internal list
that will be used to generate the UPDATE query. Might be more usefully
called add_update_targets() to hint at the extra information here.
"""
for field, mo... | [
"def",
"add_update_fields",
"(",
"self",
",",
"values_seq",
")",
":",
"for",
"field",
",",
"model",
",",
"val",
"in",
"values_seq",
":",
"if",
"hasattr",
"(",
"val",
",",
"'resolve_expression'",
")",
":",
"# Resolve expressions here so that annotations are no longer... | [
137,
4
] | [
147,
51
] | python | en | ['en', 'error', 'th'] | False |
UpdateQuery.add_related_update | (self, model, field, value) |
Adds (name, value) to an update query for an ancestor model.
Updates are coalesced so that we only run one update query per ancestor.
|
Adds (name, value) to an update query for an ancestor model. | def add_related_update(self, model, field, value):
"""
Adds (name, value) to an update query for an ancestor model.
Updates are coalesced so that we only run one update query per ancestor.
"""
self.related_updates.setdefault(model, []).append((field, None, value)) | [
"def",
"add_related_update",
"(",
"self",
",",
"model",
",",
"field",
",",
"value",
")",
":",
"self",
".",
"related_updates",
".",
"setdefault",
"(",
"model",
",",
"[",
"]",
")",
".",
"append",
"(",
"(",
"field",
",",
"None",
",",
"value",
")",
")"
] | [
149,
4
] | [
155,
79
] | python | en | ['en', 'error', 'th'] | False |
UpdateQuery.get_related_updates | (self) |
Returns a list of query objects: one for each update required to an
ancestor model. Each query will have the same filtering conditions as
the current query but will only update a single table.
|
Returns a list of query objects: one for each update required to an
ancestor model. Each query will have the same filtering conditions as
the current query but will only update a single table.
| def get_related_updates(self):
"""
Returns a list of query objects: one for each update required to an
ancestor model. Each query will have the same filtering conditions as
the current query but will only update a single table.
"""
if not self.related_updates:
... | [
"def",
"get_related_updates",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"related_updates",
":",
"return",
"[",
"]",
"result",
"=",
"[",
"]",
"for",
"model",
",",
"values",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"related_updates",
")",
... | [
157,
4
] | [
172,
21
] | python | en | ['en', 'error', 'th'] | False |
InsertQuery.insert_values | (self, fields, objs, raw=False) |
Set up the insert query from the 'insert_values' dictionary. The
dictionary gives the model field names and their target values.
If 'raw_values' is True, the values in the 'insert_values' dictionary
are inserted directly into the query, rather than passed as SQL
parameters. Thi... |
Set up the insert query from the 'insert_values' dictionary. The
dictionary gives the model field names and their target values. | def insert_values(self, fields, objs, raw=False):
"""
Set up the insert query from the 'insert_values' dictionary. The
dictionary gives the model field names and their target values.
If 'raw_values' is True, the values in the 'insert_values' dictionary
are inserted directly into... | [
"def",
"insert_values",
"(",
"self",
",",
"fields",
",",
"objs",
",",
"raw",
"=",
"False",
")",
":",
"self",
".",
"fields",
"=",
"fields",
"self",
".",
"objs",
"=",
"objs",
"self",
".",
"raw",
"=",
"raw"
] | [
183,
4
] | [
195,
22
] | python | en | ['en', 'error', 'th'] | False |
OGRGeometry.__init__ | (self, geom_input, srs=None) | Initializes Geometry on either WKT or an OGR pointer as input. | Initializes Geometry on either WKT or an OGR pointer as input. | def __init__(self, geom_input, srs=None):
"Initializes Geometry on either WKT or an OGR pointer as input."
str_instance = isinstance(geom_input, six.string_types)
# If HEX, unpack input to a binary buffer.
if str_instance and hex_regex.match(geom_input):
geom_input = six.me... | [
"def",
"__init__",
"(",
"self",
",",
"geom_input",
",",
"srs",
"=",
"None",
")",
":",
"str_instance",
"=",
"isinstance",
"(",
"geom_input",
",",
"six",
".",
"string_types",
")",
"# If HEX, unpack input to a binary buffer.",
"if",
"str_instance",
"and",
"hex_regex"... | [
66,
4
] | [
121,
56
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry.from_bbox | (cls, bbox) | Constructs a Polygon from a bounding box (4-tuple). | Constructs a Polygon from a bounding box (4-tuple). | def from_bbox(cls, bbox):
"Constructs a Polygon from a bounding box (4-tuple)."
x0, y0, x1, y1 = bbox
return OGRGeometry('POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % (
x0, y0, x0, y1, x1, y1, x1, y0, x0, y0)) | [
"def",
"from_bbox",
"(",
"cls",
",",
"bbox",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"bbox",
"return",
"OGRGeometry",
"(",
"'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))'",
"%",
"(",
"x0",
",",
"y0",
",",
"x0",
",",
"y1",
",",
"x1",
",",
... | [
145,
4
] | [
149,
52
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry.__or__ | (self, other) | Returns the union of the two geometries. | Returns the union of the two geometries. | def __or__(self, other):
"Returns the union of the two geometries."
return self.union(other) | [
"def",
"__or__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"union",
"(",
"other",
")"
] | [
157,
4
] | [
159,
32
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry.__and__ | (self, other) | Returns the intersection of this Geometry and the other. | Returns the intersection of this Geometry and the other. | def __and__(self, other):
"Returns the intersection of this Geometry and the other."
return self.intersection(other) | [
"def",
"__and__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"intersection",
"(",
"other",
")"
] | [
162,
4
] | [
164,
39
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry.__sub__ | (self, other) | Return the difference this Geometry and the other. | Return the difference this Geometry and the other. | def __sub__(self, other):
"Return the difference this Geometry and the other."
return self.difference(other) | [
"def",
"__sub__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"difference",
"(",
"other",
")"
] | [
167,
4
] | [
169,
37
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry.__xor__ | (self, other) | Return the symmetric difference of this Geometry and the other. | Return the symmetric difference of this Geometry and the other. | def __xor__(self, other):
"Return the symmetric difference of this Geometry and the other."
return self.sym_difference(other) | [
"def",
"__xor__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"sym_difference",
"(",
"other",
")"
] | [
172,
4
] | [
174,
41
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry.__eq__ | (self, other) | Is this Geometry equal to the other? | Is this Geometry equal to the other? | def __eq__(self, other):
"Is this Geometry equal to the other?"
if isinstance(other, OGRGeometry):
return self.equals(other)
else:
return False | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"OGRGeometry",
")",
":",
"return",
"self",
".",
"equals",
"(",
"other",
")",
"else",
":",
"return",
"False"
] | [
176,
4
] | [
181,
24
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry.__ne__ | (self, other) | Tests for inequality. | Tests for inequality. | def __ne__(self, other):
"Tests for inequality."
return not (self == other) | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"return",
"not",
"(",
"self",
"==",
"other",
")"
] | [
183,
4
] | [
185,
34
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry.__str__ | (self) | WKT is used for the string representation. | WKT is used for the string representation. | def __str__(self):
"WKT is used for the string representation."
return self.wkt | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"self",
".",
"wkt"
] | [
187,
4
] | [
189,
23
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry.dimension | (self) | Returns 0 for points, 1 for lines, and 2 for surfaces. | Returns 0 for points, 1 for lines, and 2 for surfaces. | def dimension(self):
"Returns 0 for points, 1 for lines, and 2 for surfaces."
return capi.get_dims(self.ptr) | [
"def",
"dimension",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_dims",
"(",
"self",
".",
"ptr",
")"
] | [
193,
4
] | [
195,
38
] | python | en | ['en', 'en', 'en'] | True |
OGRGeometry._get_coord_dim | (self) | Returns the coordinate dimension of the Geometry. | Returns the coordinate dimension of the Geometry. | def _get_coord_dim(self):
"Returns the coordinate dimension of the Geometry."
return capi.get_coord_dim(self.ptr) | [
"def",
"_get_coord_dim",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_coord_dim",
"(",
"self",
".",
"ptr",
")"
] | [
197,
4
] | [
199,
43
] | 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.