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
UserPresenceTests.test_new_user_input
(self, unused_mock: mock.Mock)
Mostly a test for UserActivityInterval
Mostly a test for UserActivityInterval
def test_new_user_input(self, unused_mock: mock.Mock) -> None: """Mostly a test for UserActivityInterval""" user_profile = self.example_user("hamlet") self.login("hamlet") self.assertEqual(UserActivityInterval.objects.filter(user_profile=user_profile).count(), 0) time_zero = time...
[ "def", "test_new_user_input", "(", "self", ",", "unused_mock", ":", "mock", ".", "Mock", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "assertEqu...
[ 203, 4 ]
[ 291, 49 ]
python
en
['en', 'en', 'en']
True
UserPresenceTests.test_no_mit
(self)
Zephyr mirror realms such as MIT never get a list of users
Zephyr mirror realms such as MIT never get a list of users
def test_no_mit(self) -> None: """Zephyr mirror realms such as MIT never get a list of users""" user = self.mit_user("espuser") self.login_user(user) result = self.client_post("/json/users/me/presence", {"status": "idle"}, subdomain="zephyr") self.assert_json_success(result) ...
[ "def", "test_no_mit", "(", "self", ")", "->", "None", ":", "user", "=", "self", ".", "mit_user", "(", "\"espuser\"", ")", "self", ".", "login_user", "(", "user", ")", "result", "=", "self", ".", "client_post", "(", "\"/json/users/me/presence\"", ",", "{", ...
[ 312, 4 ]
[ 318, 56 ]
python
en
['en', 'en', 'en']
True
UserPresenceTests.test_mirror_presence
(self)
Zephyr mirror realms find out the status of their mirror bot
Zephyr mirror realms find out the status of their mirror bot
def test_mirror_presence(self) -> None: """Zephyr mirror realms find out the status of their mirror bot""" user_profile = self.mit_user("espuser") self.login_user(user_profile) def post_presence() -> Dict[str, Any]: result = self.client_post( "/json/users/me/...
[ "def", "test_mirror_presence", "(", "self", ")", "->", "None", ":", "user_profile", "=", "self", ".", "mit_user", "(", "\"espuser\"", ")", "self", ".", "login_user", "(", "user_profile", ")", "def", "post_presence", "(", ")", "->", "Dict", "[", "str", ",",...
[ 320, 4 ]
[ 338, 60 ]
python
en
['en', 'en', 'en']
True
MigrationRecorder.ensure_schema
(self)
Ensures the table exists and has the correct schema.
Ensures the table exists and has the correct schema.
def ensure_schema(self): """ Ensures the table exists and has the correct schema. """ # If the table's there, that's fine - we've never changed its schema # in the codebase. if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.curs...
[ "def", "ensure_schema", "(", "self", ")", ":", "# If the table's there, that's fine - we've never changed its schema", "# in the codebase.", "if", "self", ".", "Migration", ".", "_meta", ".", "db_table", "in", "self", ".", "connection", ".", "introspection", ".", "table...
[ 45, 4 ]
[ 58, 99 ]
python
en
['en', 'error', 'th']
False
MigrationRecorder.applied_migrations
(self)
Returns a set of (app, name) of applied migrations.
Returns a set of (app, name) of applied migrations.
def applied_migrations(self): """ Returns a set of (app, name) of applied migrations. """ self.ensure_schema() return set(tuple(x) for x in self.migration_qs.values_list("app", "name"))
[ "def", "applied_migrations", "(", "self", ")", ":", "self", ".", "ensure_schema", "(", ")", "return", "set", "(", "tuple", "(", "x", ")", "for", "x", "in", "self", ".", "migration_qs", ".", "values_list", "(", "\"app\"", ",", "\"name\"", ")", ")" ]
[ 60, 4 ]
[ 65, 82 ]
python
en
['en', 'error', 'th']
False
MigrationRecorder.record_applied
(self, app, name)
Records that a migration was applied.
Records that a migration was applied.
def record_applied(self, app, name): """ Records that a migration was applied. """ self.ensure_schema() self.migration_qs.create(app=app, name=name)
[ "def", "record_applied", "(", "self", ",", "app", ",", "name", ")", ":", "self", ".", "ensure_schema", "(", ")", "self", ".", "migration_qs", ".", "create", "(", "app", "=", "app", ",", "name", "=", "name", ")" ]
[ 67, 4 ]
[ 72, 52 ]
python
en
['en', 'error', 'th']
False
MigrationRecorder.record_unapplied
(self, app, name)
Records that a migration was unapplied.
Records that a migration was unapplied.
def record_unapplied(self, app, name): """ Records that a migration was unapplied. """ self.ensure_schema() self.migration_qs.filter(app=app, name=name).delete()
[ "def", "record_unapplied", "(", "self", ",", "app", ",", "name", ")", ":", "self", ".", "ensure_schema", "(", ")", "self", ".", "migration_qs", ".", "filter", "(", "app", "=", "app", ",", "name", "=", "name", ")", ".", "delete", "(", ")" ]
[ 74, 4 ]
[ 79, 61 ]
python
en
['en', 'error', 'th']
False
MigrationRecorder.flush
(self)
Deletes all migration records. Useful if you're testing migrations.
Deletes all migration records. Useful if you're testing migrations.
def flush(self): """ Deletes all migration records. Useful if you're testing migrations. """ self.migration_qs.all().delete()
[ "def", "flush", "(", "self", ")", ":", "self", ".", "migration_qs", ".", "all", "(", ")", ".", "delete", "(", ")" ]
[ 81, 4 ]
[ 85, 40 ]
python
en
['en', 'error', 'th']
False
pip_import
(module, pypi_name=None)
Return None if we can't import or install it.
Return None if we can't import or install it.
def pip_import(module, pypi_name=None): """ Return None if we can't import or install it. """ try: return __import__(module) except ImportError: pass subprocess.call([sys.executable, "-m", "pip", "install", pypi_name or module]) return __import__(module)
[ "def", "pip_import", "(", "module", ",", "pypi_name", "=", "None", ")", ":", "try", ":", "return", "__import__", "(", "module", ")", "except", "ImportError", ":", "pass", "subprocess", ".", "call", "(", "[", "sys", ".", "executable", ",", "\"-m\"", ",", ...
[ 6, 0 ]
[ 16, 29 ]
python
en
['en', 'error', 'th']
False
TestSeleniumStuff.test_empty_scenario
(self)
Raise runtime error when no scenario provided :return:
Raise runtime error when no scenario provided :return:
def test_empty_scenario(self): """ Raise runtime error when no scenario provided :return: """ self.configure({EXEC: {"executor": "selenium"}}) self.assertRaises(TaurusConfigError, self.obj.prepare)
[ "def", "test_empty_scenario", "(", "self", ")", ":", "self", ".", "configure", "(", "{", "EXEC", ":", "{", "\"executor\"", ":", "\"selenium\"", "}", "}", ")", "self", ".", "assertRaises", "(", "TaurusConfigError", ",", "self", ".", "obj", ".", "prepare", ...
[ 197, 4 ]
[ 203, 62 ]
python
en
['en', 'error', 'th']
False
TestSeleniumStuff.test_dont_copy_local_script_to_artifacts
(self)
ensures that .java file is not copied into artifacts-dir
ensures that .java file is not copied into artifacts-dir
def test_dont_copy_local_script_to_artifacts(self): "ensures that .java file is not copied into artifacts-dir" filename = "BlazeDemo.java" script_path = RESOURCES_DIR + "" + filename self.obj.execution.merge({ "scenario": { "script": script_path, }...
[ "def", "test_dont_copy_local_script_to_artifacts", "(", "self", ")", ":", "filename", "=", "\"BlazeDemo.java\"", "script_path", "=", "RESOURCES_DIR", "+", "\"\"", "+", "filename", "self", ".", "obj", ".", "execution", ".", "merge", "(", "{", "\"scenario\"", ":", ...
[ 266, 4 ]
[ 279, 58 ]
python
en
['en', 'en', 'en']
True
TestSeleniumStuff.test_take_script_from_artifacts
(self)
ensures that executor looks for script in artifacts-dir (for cloud/remote cases)
ensures that executor looks for script in artifacts-dir (for cloud/remote cases)
def test_take_script_from_artifacts(self): """ensures that executor looks for script in artifacts-dir (for cloud/remote cases)""" self.obj.engine.file_search_paths = [self.obj.engine.artifacts_dir] script_name = "BlazeDemo.java" test_script = RESOURCES_DIR + "" + script_name art...
[ "def", "test_take_script_from_artifacts", "(", "self", ")", ":", "self", ".", "obj", ".", "engine", ".", "file_search_paths", "=", "[", "self", ".", "obj", ".", "engine", ".", "artifacts_dir", "]", "script_name", "=", "\"BlazeDemo.java\"", "test_script", "=", ...
[ 281, 4 ]
[ 295, 26 ]
python
en
['en', 'en', 'en']
True
_script_names
(dist, script_name, is_gui)
Create the fully qualified name of the files created by {console,gui}_scripts for the given ``dist``. Returns the list of file names
Create the fully qualified name of the files created by {console,gui}_scripts for the given ``dist``. Returns the list of file names
def _script_names(dist, script_name, is_gui): # type: (Distribution, str, bool) -> List[str] """Create the fully qualified name of the files created by {console,gui}_scripts for the given ``dist``. Returns the list of file names """ if dist_in_usersite(dist): bin_dir = bin_user else:...
[ "def", "_script_names", "(", "dist", ",", "script_name", ",", "is_gui", ")", ":", "# type: (Distribution, str, bool) -> List[str]", "if", "dist_in_usersite", "(", "dist", ")", ":", "bin_dir", "=", "bin_user", "else", ":", "bin_dir", "=", "bin_py", "exe_name", "=",...
[ 47, 0 ]
[ 66, 26 ]
python
en
['en', 'en', 'en']
True
uninstallation_paths
(dist)
Yield all the uninstallation paths for dist based on RECORD-without-.py[co] Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc and .pyo in the same directory. UninstallPathSet.add() takes care of the __pycache__ .py[co].
Yield all the uninstallation paths for dist based on RECORD-without-.py[co]
def uninstallation_paths(dist): # type: (Distribution) -> Iterator[str] """ Yield all the uninstallation paths for dist based on RECORD-without-.py[co] Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc and .pyo in the same directory. UninstallPathSet.add() takes...
[ "def", "uninstallation_paths", "(", "dist", ")", ":", "# type: (Distribution) -> Iterator[str]", "r", "=", "csv", ".", "reader", "(", "FakeFile", "(", "dist", ".", "get_metadata_lines", "(", "'RECORD'", ")", ")", ")", "for", "row", "in", "r", ":", "path", "=...
[ 83, 0 ]
[ 103, 22 ]
python
en
['en', 'error', 'th']
False
compact
(paths)
Compact a path set to contain the minimal number of paths necessary to contain all paths in the set. If /a/path/ and /a/path/to/a/file.txt are both in the set, leave only the shorter path.
Compact a path set to contain the minimal number of paths necessary to contain all paths in the set. If /a/path/ and /a/path/to/a/file.txt are both in the set, leave only the shorter path.
def compact(paths): # type: (Iterable[str]) -> Set[str] """Compact a path set to contain the minimal number of paths necessary to contain all paths in the set. If /a/path/ and /a/path/to/a/file.txt are both in the set, leave only the shorter path.""" sep = os.path.sep short_paths = set() #...
[ "def", "compact", "(", "paths", ")", ":", "# type: (Iterable[str]) -> Set[str]", "sep", "=", "os", ".", "path", ".", "sep", "short_paths", "=", "set", "(", ")", "# type: Set[str]", "for", "path", "in", "sorted", "(", "paths", ",", "key", "=", "len", ")", ...
[ 106, 0 ]
[ 123, 22 ]
python
en
['en', 'en', 'en']
True
compress_for_rename
(paths)
Returns a set containing the paths that need to be renamed. This set may include directories when the original sequence of paths included every file on disk.
Returns a set containing the paths that need to be renamed.
def compress_for_rename(paths): # type: (Iterable[str]) -> Set[str] """Returns a set containing the paths that need to be renamed. This set may include directories when the original sequence of paths included every file on disk. """ case_map = dict((os.path.normcase(p), p) for p in paths) r...
[ "def", "compress_for_rename", "(", "paths", ")", ":", "# type: (Iterable[str]) -> Set[str]", "case_map", "=", "dict", "(", "(", "os", ".", "path", ".", "normcase", "(", "p", ")", ",", "p", ")", "for", "p", "in", "paths", ")", "remaining", "=", "set", "("...
[ 126, 0 ]
[ 163, 64 ]
python
en
['en', 'en', 'en']
True
compress_for_output_listing
(paths)
Returns a tuple of 2 sets of which paths to display to user The first set contains paths that would be deleted. Files of a package are not added and the top-level directory of the package has a '*' added at the end - to signify that all it's contents are removed. The second set contains files that wou...
Returns a tuple of 2 sets of which paths to display to user
def compress_for_output_listing(paths): # type: (Iterable[str]) -> Tuple[Set[str], Set[str]] """Returns a tuple of 2 sets of which paths to display to user The first set contains paths that would be deleted. Files of a package are not added and the top-level directory of the package has a '*' added ...
[ "def", "compress_for_output_listing", "(", "paths", ")", ":", "# type: (Iterable[str]) -> Tuple[Set[str], Set[str]]", "will_remove", "=", "set", "(", "paths", ")", "will_skip", "=", "set", "(", ")", "# Determine folders and files", "folders", "=", "set", "(", ")", "fi...
[ 166, 0 ]
[ 214, 33 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet._get_directory_stash
(self, path)
Stashes a directory. Directories are stashed adjacent to their original location if possible, or else moved/copied into the user's temp dir.
Stashes a directory.
def _get_directory_stash(self, path): # type: (str) -> str """Stashes a directory. Directories are stashed adjacent to their original location if possible, or else moved/copied into the user's temp dir.""" try: save_dir = AdjacentTempDirectory(path) # type: TempDir...
[ "def", "_get_directory_stash", "(", "self", ",", "path", ")", ":", "# type: (str) -> str", "try", ":", "save_dir", "=", "AdjacentTempDirectory", "(", "path", ")", "# type: TempDirectory", "except", "OSError", ":", "save_dir", "=", "TempDirectory", "(", "kind", "="...
[ 229, 4 ]
[ 242, 28 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet._get_file_stash
(self, path)
Stashes a file. If no root has been provided, one will be created for the directory in the user's temp directory.
Stashes a file.
def _get_file_stash(self, path): # type: (str) -> str """Stashes a file. If no root has been provided, one will be created for the directory in the user's temp directory.""" path = os.path.normcase(path) head, old_head = os.path.dirname(path), None save_dir = Non...
[ "def", "_get_file_stash", "(", "self", ",", "path", ")", ":", "# type: (str) -> str", "path", "=", "os", ".", "path", ".", "normcase", "(", "path", ")", "head", ",", "old_head", "=", "os", ".", "path", ".", "dirname", "(", "path", ")", ",", "None", "...
[ 244, 4 ]
[ 270, 28 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet.stash
(self, path)
Stashes the directory or file and returns its new location. Handle symlinks as files to avoid modifying the symlink targets.
Stashes the directory or file and returns its new location. Handle symlinks as files to avoid modifying the symlink targets.
def stash(self, path): # type: (str) -> str """Stashes the directory or file and returns its new location. Handle symlinks as files to avoid modifying the symlink targets. """ path_is_dir = os.path.isdir(path) and not os.path.islink(path) if path_is_dir: new_p...
[ "def", "stash", "(", "self", ",", "path", ")", ":", "# type: (str) -> str", "path_is_dir", "=", "os", ".", "path", ".", "isdir", "(", "path", ")", "and", "not", "os", ".", "path", ".", "islink", "(", "path", ")", "if", "path_is_dir", ":", "new_path", ...
[ 272, 4 ]
[ 292, 23 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet.commit
(self)
Commits the uninstall by removing stashed files.
Commits the uninstall by removing stashed files.
def commit(self): # type: () -> None """Commits the uninstall by removing stashed files.""" for _, save_dir in self._save_dirs.items(): save_dir.cleanup() self._moves = [] self._save_dirs = {}
[ "def", "commit", "(", "self", ")", ":", "# type: () -> None", "for", "_", ",", "save_dir", "in", "self", ".", "_save_dirs", ".", "items", "(", ")", ":", "save_dir", ".", "cleanup", "(", ")", "self", ".", "_moves", "=", "[", "]", "self", ".", "_save_d...
[ 294, 4 ]
[ 300, 28 ]
python
en
['en', 'en', 'en']
True
StashedUninstallPathSet.rollback
(self)
Undoes the uninstall by moving stashed files back.
Undoes the uninstall by moving stashed files back.
def rollback(self): # type: () -> None """Undoes the uninstall by moving stashed files back.""" for p in self._moves: logger.info("Moving to %s\n from %s", *p) for new_path, path in self._moves: try: logger.debug('Replacing %s from %s', new_path, ...
[ "def", "rollback", "(", "self", ")", ":", "# type: () -> None", "for", "p", "in", "self", ".", "_moves", ":", "logger", ".", "info", "(", "\"Moving to %s\\n from %s\"", ",", "*", "p", ")", "for", "new_path", ",", "path", "in", "self", ".", "_moves", ":",...
[ 302, 4 ]
[ 320, 21 ]
python
en
['en', 'en', 'en']
True
UninstallPathSet._permitted
(self, path)
Return True if the given path is one we are permitted to remove/modify, False otherwise.
Return True if the given path is one we are permitted to remove/modify, False otherwise.
def _permitted(self, path): # type: (str) -> bool """ Return True if the given path is one we are permitted to remove/modify, False otherwise. """ return is_local(path)
[ "def", "_permitted", "(", "self", ",", "path", ")", ":", "# type: (str) -> bool", "return", "is_local", "(", "path", ")" ]
[ 339, 4 ]
[ 346, 29 ]
python
en
['en', 'error', 'th']
False
UninstallPathSet.remove
(self, auto_confirm=False, verbose=False)
Remove paths in ``self.paths`` with confirmation (unless ``auto_confirm`` is True).
Remove paths in ``self.paths`` with confirmation (unless ``auto_confirm`` is True).
def remove(self, auto_confirm=False, verbose=False): # type: (bool, bool) -> None """Remove paths in ``self.paths`` with confirmation (unless ``auto_confirm`` is True).""" if not self.paths: logger.info( "Can't uninstall '%s'. No files were found to uninstall...
[ "def", "remove", "(", "self", ",", "auto_confirm", "=", "False", ",", "verbose", "=", "False", ")", ":", "# type: (bool, bool) -> None", "if", "not", "self", ".", "paths", ":", "logger", ".", "info", "(", "\"Can't uninstall '%s'. No files were found to uninstall.\""...
[ 378, 4 ]
[ 408, 77 ]
python
en
['en', 'en', 'en']
True
UninstallPathSet._allowed_to_proceed
(self, verbose)
Display which files would be deleted and prompt for confirmation
Display which files would be deleted and prompt for confirmation
def _allowed_to_proceed(self, verbose): # type: (bool) -> bool """Display which files would be deleted and prompt for confirmation """ def _display(msg, paths): # type: (str, Iterable[str]) -> None if not paths: return logger.info(msg...
[ "def", "_allowed_to_proceed", "(", "self", ",", "verbose", ")", ":", "# type: (bool) -> bool", "def", "_display", "(", "msg", ",", "paths", ")", ":", "# type: (str, Iterable[str]) -> None", "if", "not", "paths", ":", "return", "logger", ".", "info", "(", "msg", ...
[ 410, 4 ]
[ 439, 56 ]
python
en
['en', 'en', 'en']
True
UninstallPathSet.rollback
(self)
Rollback the changes previously made by remove().
Rollback the changes previously made by remove().
def rollback(self): # type: () -> None """Rollback the changes previously made by remove().""" if not self._moved_paths.can_rollback: logger.error( "Can't roll back %s; was not uninstalled", self.dist.project_name, ) return ...
[ "def", "rollback", "(", "self", ")", ":", "# type: () -> None", "if", "not", "self", ".", "_moved_paths", ".", "can_rollback", ":", "logger", ".", "error", "(", "\"Can't roll back %s; was not uninstalled\"", ",", "self", ".", "dist", ".", "project_name", ",", ")...
[ 441, 4 ]
[ 453, 26 ]
python
en
['en', 'en', 'en']
True
UninstallPathSet.commit
(self)
Remove temporary save dir: rollback will no longer be possible.
Remove temporary save dir: rollback will no longer be possible.
def commit(self): # type: () -> None """Remove temporary save dir: rollback will no longer be possible.""" self._moved_paths.commit()
[ "def", "commit", "(", "self", ")", ":", "# type: () -> None", "self", ".", "_moved_paths", ".", "commit", "(", ")" ]
[ 455, 4 ]
[ 458, 34 ]
python
en
['en', 'en', 'en']
True
mnemonic_to_seed
(mnemonic: str, passphrase: str)
Uses BIP39 standard to derive a seed from entropy bytes.
Uses BIP39 standard to derive a seed from entropy bytes.
def mnemonic_to_seed(mnemonic: str, passphrase: str) -> bytes: """ Uses BIP39 standard to derive a seed from entropy bytes. """ salt_str: str = "mnemonic" + passphrase salt = unicodedata.normalize("NFKD", salt_str).encode("utf-8") mnemonic_normalized = unicodedata.normalize("NFKD", mnemonic).enc...
[ "def", "mnemonic_to_seed", "(", "mnemonic", ":", "str", ",", "passphrase", ":", "str", ")", "->", "bytes", ":", "salt_str", ":", "str", "=", "\"mnemonic\"", "+", "passphrase", "salt", "=", "unicodedata", ".", "normalize", "(", "\"NFKD\"", ",", "salt_str", ...
[ 95, 0 ]
[ 105, 15 ]
python
en
['en', 'error', 'th']
False
Keychain._get_service
(self)
The keychain stores keys under a different name for tests.
The keychain stores keys under a different name for tests.
def _get_service(self) -> str: """ The keychain stores keys under a different name for tests. """ if self.testing: return f"kale-{self.user}-test" else: return f"kale-{self.user}"
[ "def", "_get_service", "(", "self", ")", "->", "str", ":", "if", "self", ".", "testing", ":", "return", "f\"kale-{self.user}-test\"", "else", ":", "return", "f\"kale-{self.user}\"" ]
[ 126, 4 ]
[ 133, 38 ]
python
en
['en', 'error', 'th']
False
Keychain._get_pk_and_entropy
(self, user: str)
Returns the keychain contents for a specific 'user' (key index). The contents include an G1Element and the entropy required to generate the private key. Note that generating the actual private key also requires the passphrase.
Returns the keychain contents for a specific 'user' (key index). The contents include an G1Element and the entropy required to generate the private key. Note that generating the actual private key also requires the passphrase.
def _get_pk_and_entropy(self, user: str) -> Optional[Tuple[G1Element, bytes]]: """ Returns the keychain contents for a specific 'user' (key index). The contents include an G1Element and the entropy required to generate the private key. Note that generating the actual private key also req...
[ "def", "_get_pk_and_entropy", "(", "self", ",", "user", ":", "str", ")", "->", "Optional", "[", "Tuple", "[", "G1Element", ",", "bytes", "]", "]", ":", "read_str", "=", "keyring", ".", "get_password", "(", "self", ".", "_get_service", "(", ")", ",", "u...
[ 135, 4 ]
[ 148, 9 ]
python
en
['en', 'error', 'th']
False
Keychain._get_private_key_user
(self, index: int)
Returns the keychain user string for a key index.
Returns the keychain user string for a key index.
def _get_private_key_user(self, index: int) -> str: """ Returns the keychain user string for a key index. """ if self.testing: return f"wallet-{self.user}-test-{index}" else: return f"wallet-{self.user}-{index}"
[ "def", "_get_private_key_user", "(", "self", ",", "index", ":", "int", ")", "->", "str", ":", "if", "self", ".", "testing", ":", "return", "f\"wallet-{self.user}-test-{index}\"", "else", ":", "return", "f\"wallet-{self.user}-{index}\"" ]
[ 150, 4 ]
[ 157, 48 ]
python
en
['en', 'error', 'th']
False
Keychain._get_free_private_key_index
(self)
Get the index of the first free spot in the keychain.
Get the index of the first free spot in the keychain.
def _get_free_private_key_index(self) -> int: """ Get the index of the first free spot in the keychain. """ index = 0 while True: pk = self._get_private_key_user(index) pkent = self._get_pk_and_entropy(pk) if pkent is None: retu...
[ "def", "_get_free_private_key_index", "(", "self", ")", "->", "int", ":", "index", "=", "0", "while", "True", ":", "pk", "=", "self", ".", "_get_private_key_user", "(", "index", ")", "pkent", "=", "self", ".", "_get_pk_and_entropy", "(", "pk", ")", "if", ...
[ 159, 4 ]
[ 169, 22 ]
python
en
['en', 'error', 'th']
False
Keychain.add_private_key
(self, mnemonic: str, passphrase: str)
Adds a private key to the keychain, with the given entropy and passphrase. The keychain itself will store the public key, and the entropy bytes, but not the passphrase.
Adds a private key to the keychain, with the given entropy and passphrase. The keychain itself will store the public key, and the entropy bytes, but not the passphrase.
def add_private_key(self, mnemonic: str, passphrase: str) -> PrivateKey: """ Adds a private key to the keychain, with the given entropy and passphrase. The keychain itself will store the public key, and the entropy bytes, but not the passphrase. """ seed = mnemonic_to_see...
[ "def", "add_private_key", "(", "self", ",", "mnemonic", ":", "str", ",", "passphrase", ":", "str", ")", "->", "PrivateKey", ":", "seed", "=", "mnemonic_to_seed", "(", "mnemonic", ",", "passphrase", ")", "entropy", "=", "bytes_from_mnemonic", "(", "mnemonic", ...
[ 171, 4 ]
[ 192, 18 ]
python
en
['en', 'error', 'th']
False
Keychain.get_first_private_key
(self, passphrases: List[str] = [""])
Returns the first key in the keychain that has one of the passed in passphrases.
Returns the first key in the keychain that has one of the passed in passphrases.
def get_first_private_key(self, passphrases: List[str] = [""]) -> Optional[Tuple[PrivateKey, bytes]]: """ Returns the first key in the keychain that has one of the passed in passphrases. """ index = 0 pkent = self._get_pk_and_entropy(self._get_private_key_user(index)) whi...
[ "def", "get_first_private_key", "(", "self", ",", "passphrases", ":", "List", "[", "str", "]", "=", "[", "\"\"", "]", ")", "->", "Optional", "[", "Tuple", "[", "PrivateKey", ",", "bytes", "]", "]", ":", "index", "=", "0", "pkent", "=", "self", ".", ...
[ 194, 4 ]
[ 211, 19 ]
python
en
['en', 'error', 'th']
False
Keychain.get_private_key_by_fingerprint
( self, fingerprint: int, passphrases: List[str] = [""] )
Return first private key which have the given public key fingerprint.
Return first private key which have the given public key fingerprint.
def get_private_key_by_fingerprint( self, fingerprint: int, passphrases: List[str] = [""] ) -> Optional[Tuple[PrivateKey, bytes]]: """ Return first private key which have the given public key fingerprint. """ index = 0 pkent = self._get_pk_and_entropy(self._get_privat...
[ "def", "get_private_key_by_fingerprint", "(", "self", ",", "fingerprint", ":", "int", ",", "passphrases", ":", "List", "[", "str", "]", "=", "[", "\"\"", "]", ")", "->", "Optional", "[", "Tuple", "[", "PrivateKey", ",", "bytes", "]", "]", ":", "index", ...
[ 213, 4 ]
[ 232, 19 ]
python
en
['en', 'error', 'th']
False
Keychain.get_all_private_keys
(self, passphrases: List[str] = [""])
Returns all private keys which can be retrieved, with the given passphrases. A tuple of key, and entropy bytes (i.e. mnemonic) is returned for each key.
Returns all private keys which can be retrieved, with the given passphrases. A tuple of key, and entropy bytes (i.e. mnemonic) is returned for each key.
def get_all_private_keys(self, passphrases: List[str] = [""]) -> List[Tuple[PrivateKey, bytes]]: """ Returns all private keys which can be retrieved, with the given passphrases. A tuple of key, and entropy bytes (i.e. mnemonic) is returned for each key. """ all_keys: List[Tuple[P...
[ "def", "get_all_private_keys", "(", "self", ",", "passphrases", ":", "List", "[", "str", "]", "=", "[", "\"\"", "]", ")", "->", "List", "[", "Tuple", "[", "PrivateKey", ",", "bytes", "]", "]", ":", "all_keys", ":", "List", "[", "Tuple", "[", "Private...
[ 234, 4 ]
[ 254, 23 ]
python
en
['en', 'error', 'th']
False
Keychain.get_all_public_keys
(self)
Returns all public keys.
Returns all public keys.
def get_all_public_keys(self) -> List[G1Element]: """ Returns all public keys. """ all_keys: List[Tuple[G1Element, bytes]] = [] index = 0 pkent = self._get_pk_and_entropy(self._get_private_key_user(index)) while index <= MAX_KEYS: if pkent is not None...
[ "def", "get_all_public_keys", "(", "self", ")", "->", "List", "[", "G1Element", "]", ":", "all_keys", ":", "List", "[", "Tuple", "[", "G1Element", ",", "bytes", "]", "]", "=", "[", "]", "index", "=", "0", "pkent", "=", "self", ".", "_get_pk_and_entropy...
[ 256, 4 ]
[ 270, 23 ]
python
en
['en', 'error', 'th']
False
Keychain.get_first_public_key
(self)
Returns the first public key.
Returns the first public key.
def get_first_public_key(self) -> Optional[G1Element]: """ Returns the first public key. """ index = 0 pkent = self._get_pk_and_entropy(self._get_private_key_user(index)) while index <= MAX_KEYS: if pkent is not None: pk, ent = pkent ...
[ "def", "get_first_public_key", "(", "self", ")", "->", "Optional", "[", "G1Element", "]", ":", "index", "=", "0", "pkent", "=", "self", ".", "_get_pk_and_entropy", "(", "self", ".", "_get_private_key_user", "(", "index", ")", ")", "while", "index", "<=", "...
[ 272, 4 ]
[ 284, 19 ]
python
en
['en', 'error', 'th']
False
Keychain.delete_key_by_fingerprint
(self, fingerprint: int)
Deletes all keys which have the given public key fingerprint.
Deletes all keys which have the given public key fingerprint.
def delete_key_by_fingerprint(self, fingerprint: int): """ Deletes all keys which have the given public key fingerprint. """ index = 0 pkent = self._get_pk_and_entropy(self._get_private_key_user(index)) while index <= MAX_KEYS: if pkent is not None: ...
[ "def", "delete_key_by_fingerprint", "(", "self", ",", "fingerprint", ":", "int", ")", ":", "index", "=", "0", "pkent", "=", "self", ".", "_get_pk_and_entropy", "(", "self", ".", "_get_private_key_user", "(", "index", ")", ")", "while", "index", "<=", "MAX_KE...
[ 286, 4 ]
[ 299, 79 ]
python
en
['en', 'error', 'th']
False
Keychain.delete_all_keys
(self)
Deletes all keys from the keychain.
Deletes all keys from the keychain.
def delete_all_keys(self): """ Deletes all keys from the keychain. """ index = 0 delete_exception = False pkent = None while True: try: pkent = self._get_pk_and_entropy(self._get_private_key_user(index)) keyring.delete_...
[ "def", "delete_all_keys", "(", "self", ")", ":", "index", "=", "0", "delete_exception", "=", "False", "pkent", "=", "None", "while", "True", ":", "try", ":", "pkent", "=", "self", ".", "_get_pk_and_entropy", "(", "self", ".", "_get_private_key_user", "(", ...
[ 301, 4 ]
[ 338, 22 ]
python
en
['en', 'error', 'th']
False
unpack
(path, dest='.')
Unpack a wheel. Wheel content will be unpacked to {dest}/{name}-{ver}, where {name} is the package name and {ver} its version. :param path: The path to the wheel. :param dest: Destination directory (default to current directory).
Unpack a wheel.
def unpack(path, dest='.'): """Unpack a wheel. Wheel content will be unpacked to {dest}/{name}-{ver}, where {name} is the package name and {ver} its version. :param path: The path to the wheel. :param dest: Destination directory (default to current directory). """ with WheelFile(path) as w...
[ "def", "unpack", "(", "path", ",", "dest", "=", "'.'", ")", ":", "with", "WheelFile", "(", "path", ")", "as", "wf", ":", "namever", "=", "wf", ".", "parsed_filename", ".", "group", "(", "'namever'", ")", "destination", "=", "os", ".", "path", ".", ...
[ 8, 0 ]
[ 24, 15 ]
python
en
['en', 'gd', 'en']
True
install_lib.get_exclusions
(self)
Return a collections.Sized collections.Container of paths to be excluded for single_version_externally_managed installations.
Return a collections.Sized collections.Container of paths to be excluded for single_version_externally_managed installations.
def get_exclusions(self): """ Return a collections.Sized collections.Container of paths to be excluded for single_version_externally_managed installations. """ all_packages = ( pkg for ns_pkg in self._get_SVEM_NSPs() for pkg in self._all_packag...
[ "def", "get_exclusions", "(", "self", ")", ":", "all_packages", "=", "(", "pkg", "for", "ns_pkg", "in", "self", ".", "_get_SVEM_NSPs", "(", ")", "for", "pkg", "in", "self", ".", "_all_packages", "(", "ns_pkg", ")", ")", "excl_specs", "=", "product", "(",...
[ 16, 4 ]
[ 28, 63 ]
python
en
['en', 'error', 'th']
False
install_lib._exclude_pkg_path
(self, pkg, exclusion_path)
Given a package name and exclusion path within that package, compute the full exclusion path.
Given a package name and exclusion path within that package, compute the full exclusion path.
def _exclude_pkg_path(self, pkg, exclusion_path): """ Given a package name and exclusion path within that package, compute the full exclusion path. """ parts = pkg.split('.') + [exclusion_path] return os.path.join(self.install_dir, *parts)
[ "def", "_exclude_pkg_path", "(", "self", ",", "pkg", ",", "exclusion_path", ")", ":", "parts", "=", "pkg", ".", "split", "(", "'.'", ")", "+", "[", "exclusion_path", "]", "return", "os", ".", "path", ".", "join", "(", "self", ".", "install_dir", ",", ...
[ 30, 4 ]
[ 36, 53 ]
python
en
['en', 'error', 'th']
False
install_lib._all_packages
(pkg_name)
>>> list(install_lib._all_packages('foo.bar.baz')) ['foo.bar.baz', 'foo.bar', 'foo']
>>> list(install_lib._all_packages('foo.bar.baz')) ['foo.bar.baz', 'foo.bar', 'foo']
def _all_packages(pkg_name): """ >>> list(install_lib._all_packages('foo.bar.baz')) ['foo.bar.baz', 'foo.bar', 'foo'] """ while pkg_name: yield pkg_name pkg_name, sep, child = pkg_name.rpartition('.')
[ "def", "_all_packages", "(", "pkg_name", ")", ":", "while", "pkg_name", ":", "yield", "pkg_name", "pkg_name", ",", "sep", ",", "child", "=", "pkg_name", ".", "rpartition", "(", "'.'", ")" ]
[ 39, 4 ]
[ 46, 59 ]
python
en
['en', 'error', 'th']
False
install_lib._get_SVEM_NSPs
(self)
Get namespace packages (list) but only for single_version_externally_managed installations and empty otherwise.
Get namespace packages (list) but only for single_version_externally_managed installations and empty otherwise.
def _get_SVEM_NSPs(self): """ Get namespace packages (list) but only for single_version_externally_managed installations and empty otherwise. """ # TODO: is it necessary to short-circuit here? i.e. what's the cost # if get_finalized_command is called even when namespace_p...
[ "def", "_get_SVEM_NSPs", "(", "self", ")", ":", "# TODO: is it necessary to short-circuit here? i.e. what's the cost", "# if get_finalized_command is called even when namespace_packages is", "# False?", "if", "not", "self", ".", "distribution", ".", "namespace_packages", ":", "retu...
[ 48, 4 ]
[ 62, 67 ]
python
en
['en', 'error', 'th']
False
install_lib._gen_exclusion_paths
()
Generate file paths to be excluded for namespace packages (bytecode cache files).
Generate file paths to be excluded for namespace packages (bytecode cache files).
def _gen_exclusion_paths(): """ Generate file paths to be excluded for namespace packages (bytecode cache files). """ # always exclude the package module itself yield '__init__.py' yield '__init__.pyc' yield '__init__.pyo' if not hasattr(sys, 'im...
[ "def", "_gen_exclusion_paths", "(", ")", ":", "# always exclude the package module itself", "yield", "'__init__.py'", "yield", "'__init__.pyc'", "yield", "'__init__.pyo'", "if", "not", "hasattr", "(", "sys", ",", "'implementation'", ")", ":", "return", "base", "=", "o...
[ 65, 4 ]
[ 84, 33 ]
python
en
['en', 'error', 'th']
False
BaseStructBlock.get_default
(self)
Any default value passed in the constructor or self.meta is going to be a dict rather than a StructValue; for consistency, we need to convert it to a StructValue for StructBlock to work with
Any default value passed in the constructor or self.meta is going to be a dict rather than a StructValue; for consistency, we need to convert it to a StructValue for StructBlock to work with
def get_default(self): """ Any default value passed in the constructor or self.meta is going to be a dict rather than a StructValue; for consistency, we need to convert it to a StructValue for StructBlock to work with """ return self._to_struct_value([ ( ...
[ "def", "get_default", "(", "self", ")", ":", "return", "self", ".", "_to_struct_value", "(", "[", "(", "name", ",", "self", ".", "meta", ".", "default", "[", "name", "]", "if", "name", "in", "self", ".", "meta", ".", "default", "else", "block", ".", ...
[ 91, 4 ]
[ 103, 10 ]
python
en
['en', 'error', 'th']
False
BaseStructBlock.to_python
(self, value)
Recursively call to_python on children and return as a StructValue
Recursively call to_python on children and return as a StructValue
def to_python(self, value): """ Recursively call to_python on children and return as a StructValue """ return self._to_struct_value([ ( name, (child_block.to_python(value[name]) if name in value else child_block.get_default()) # NB the result o...
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "return", "self", ".", "_to_struct_value", "(", "[", "(", "name", ",", "(", "child_block", ".", "to_python", "(", "value", "[", "name", "]", ")", "if", "name", "in", "value", "else", "child_block...
[ 131, 4 ]
[ 141, 10 ]
python
en
['en', 'en', 'en']
True
BaseStructBlock._to_struct_value
(self, block_items)
Return a Structvalue representation of the sub-blocks in this block
Return a Structvalue representation of the sub-blocks in this block
def _to_struct_value(self, block_items): """ Return a Structvalue representation of the sub-blocks in this block """ return self.meta.value_class(self, block_items)
[ "def", "_to_struct_value", "(", "self", ",", "block_items", ")", ":", "return", "self", ".", "meta", ".", "value_class", "(", "self", ",", "block_items", ")" ]
[ 185, 4 ]
[ 187, 55 ]
python
en
['en', 'la', 'en']
True
BaseStructBlock.get_prep_value
(self, value)
Recursively call get_prep_value on children and return as a plain dict
Recursively call get_prep_value on children and return as a plain dict
def get_prep_value(self, value): """ Recursively call get_prep_value on children and return as a plain dict """ return dict([ (name, self.child_blocks[name].get_prep_value(val)) for name, val in value.items() ])
[ "def", "get_prep_value", "(", "self", ",", "value", ")", ":", "return", "dict", "(", "[", "(", "name", ",", "self", ".", "child_blocks", "[", "name", "]", ".", "get_prep_value", "(", "val", ")", ")", "for", "name", ",", "val", "in", "value", ".", "...
[ 189, 4 ]
[ 194, 10 ]
python
en
['en', 'en', 'en']
True
BaseStructBlock.get_api_representation
(self, value, context=None)
Recursively call get_api_representation on children and return as a plain dict
Recursively call get_api_representation on children and return as a plain dict
def get_api_representation(self, value, context=None): """ Recursively call get_api_representation on children and return as a plain dict """ return dict([ (name, self.child_blocks[name].get_api_representation(val, context=context)) for name, val in value.items() ])
[ "def", "get_api_representation", "(", "self", ",", "value", ",", "context", "=", "None", ")", ":", "return", "dict", "(", "[", "(", "name", ",", "self", ".", "child_blocks", "[", "name", "]", ".", "get_api_representation", "(", "val", ",", "context", "="...
[ 202, 4 ]
[ 207, 10 ]
python
en
['en', 'pt', 'en']
True
BaseStructBlock.deconstruct
(self)
Always deconstruct StructBlock instances as if they were plain StructBlocks with all of the field definitions passed to the constructor - even if in reality this is a subclass of StructBlock with the fields defined declaratively, or some combination of the two. This ensures that the fi...
Always deconstruct StructBlock instances as if they were plain StructBlocks with all of the field definitions passed to the constructor - even if in reality this is a subclass of StructBlock with the fields defined declaratively, or some combination of the two.
def deconstruct(self): """ Always deconstruct StructBlock instances as if they were plain StructBlocks with all of the field definitions passed to the constructor - even if in reality this is a subclass of StructBlock with the fields defined declaratively, or some combination of the two....
[ "def", "deconstruct", "(", "self", ")", ":", "path", "=", "'wagtail.core.blocks.StructBlock'", "args", "=", "[", "list", "(", "self", ".", "child_blocks", ".", "items", "(", ")", ")", "]", "kwargs", "=", "self", ".", "_constructor_kwargs", "return", "(", "...
[ 217, 4 ]
[ 229, 35 ]
python
en
['en', 'error', 'th']
False
sample_center_points
(Y, method='all', k=100, keep_edges=False, parallelize=False, random_state=None)
function to define kernel centers with various downsampling alternatives Args: Y: numpy array from which kernel centers shall be selected - shape (n_samples,) or (n_samples, n_dim) method: kernel center selection method - choices: [all, random, distance, k_means, agglomerative] k: number of cent...
function to define kernel centers with various downsampling alternatives
def sample_center_points(Y, method='all', k=100, keep_edges=False, parallelize=False, random_state=None): """ function to define kernel centers with various downsampling alternatives Args: Y: numpy array from which kernel centers shall be selected - shape (n_samples,) or (n_samples, n_dim) method: ...
[ "def", "sample_center_points", "(", "Y", ",", "method", "=", "'all'", ",", "k", "=", "100", ",", "keep_edges", "=", "False", ",", "parallelize", "=", "False", ",", "random_state", "=", "None", ")", ":", "assert", "k", "<=", "Y", ".", "shape", "[", "0...
[ 6, 0 ]
[ 94, 30 ]
python
en
['en', 'en', 'en']
True
deep_update
(source, overrides)
Update a nested dictionary or similar mapping. Modify ``source`` in place.
Update a nested dictionary or similar mapping.
def deep_update(source, overrides): """Update a nested dictionary or similar mapping. Modify ``source`` in place. """ for key, value in overrides.items(): if isinstance(value, collections.Mapping) and value: returned = deep_update(source.get(key, {}), value) source[key] ...
[ "def", "deep_update", "(", "source", ",", "overrides", ")", ":", "for", "key", ",", "value", "in", "overrides", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "collections", ".", "Mapping", ")", "and", "value", ":", "returned", "="...
[ 3, 0 ]
[ 14, 17 ]
python
en
['en', 'en', 'en']
True
TsungConfig.__gen_load
(self, load)
Generate Tsung load profile. Tsung load progression is scenario-based. Virtual users are erlang processes which are spawned according to load profile. Each user executes assigned session (requests + think-time + logic) and then dies. :param scenario: :param load: :retur...
Generate Tsung load profile.
def __gen_load(self, load): """ Generate Tsung load profile. Tsung load progression is scenario-based. Virtual users are erlang processes which are spawned according to load profile. Each user executes assigned session (requests + think-time + logic) and then dies. :param scenar...
[ "def", "__gen_load", "(", "self", ",", "load", ")", ":", "concurrency", "=", "load", ".", "concurrency", "if", "load", ".", "concurrency", "is", "not", "None", "else", "1", "load_elem", "=", "etree", ".", "Element", "(", "\"load\"", ")", "if", "load", ...
[ 333, 4 ]
[ 366, 24 ]
python
en
['en', 'error', 'th']
False
Tsung.get_tool_prefix
(tool_abspath)
Get tsung installation prefix (like /usr/ or /usr/local) :return: str
Get tsung installation prefix (like /usr/ or /usr/local) :return: str
def get_tool_prefix(tool_abspath): """ Get tsung installation prefix (like /usr/ or /usr/local) :return: str """ if tool_abspath is None: return None parts = tool_abspath.split(os.sep) if len(parts) < 2: return None # cut 'bin/ts...
[ "def", "get_tool_prefix", "(", "tool_abspath", ")", ":", "if", "tool_abspath", "is", "None", ":", "return", "None", "parts", "=", "tool_abspath", ".", "split", "(", "os", ".", "sep", ")", "if", "len", "(", "parts", ")", "<", "2", ":", "return", "None",...
[ 451, 4 ]
[ 466, 21 ]
python
en
['en', 'error', 'th']
False
Tsung.get_dtd_path
(self)
Get path of DTD validation file for Tsung.
Get path of DTD validation file for Tsung.
def get_dtd_path(self): "Get path of DTD validation file for Tsung." tsung_abspath = self.get_tool_abspath() prefix = self.get_tool_prefix(tsung_abspath) if not prefix: return self.DEFAULT_DTD_PATH else: return os.path.join(prefix, "share", "tsung", "tsung...
[ "def", "get_dtd_path", "(", "self", ")", ":", "tsung_abspath", "=", "self", ".", "get_tool_abspath", "(", ")", "prefix", "=", "self", ".", "get_tool_prefix", "(", "tsung_abspath", ")", "if", "not", "prefix", ":", "return", "self", ".", "DEFAULT_DTD_PATH", "e...
[ 468, 4 ]
[ 475, 74 ]
python
en
['en', 'en', 'en']
True
deprecated
(reason, replacement, gone_in, issue=None)
Helper to deprecate existing functionality. reason: Textual reason shown to the user about why this functionality has been deprecated. replacement: Textual suggestion shown to the user about what alternative functionality they can use. gone_in: The version of pip doe...
Helper to deprecate existing functionality.
def deprecated(reason, replacement, gone_in, issue=None): # type: (str, Optional[str], Optional[str], Optional[int]) -> None """Helper to deprecate existing functionality. reason: Textual reason shown to the user about why this functionality has been deprecated. replacement: Tex...
[ "def", "deprecated", "(", "reason", ",", "replacement", ",", "gone_in", ",", "issue", "=", "None", ")", ":", "# type: (str, Optional[str], Optional[str], Optional[int]) -> None", "# Construct a nice message.", "# This is eagerly formatted as we want it to get logged as if someone",...
[ 61, 0 ]
[ 103, 72 ]
python
en
['it', 'en', 'en']
True
balanced_reduce
(operator, seq, initializer=NOT_SET)
Has the same result as Python's reduce function, but performs the calculations in a different order. This is important when the operator is constructing data structures such as search query clases. This method will make the resulting data structures flatter, so operations that need to traverse them do...
Has the same result as Python's reduce function, but performs the calculations in a different order.
def balanced_reduce(operator, seq, initializer=NOT_SET): """ Has the same result as Python's reduce function, but performs the calculations in a different order. This is important when the operator is constructing data structures such as search query clases. This method will make the resulting data str...
[ "def", "balanced_reduce", "(", "operator", ",", "seq", ",", "initializer", "=", "NOT_SET", ")", ":", "# Casting all iterables to list makes the implementation simpler", "if", "not", "isinstance", "(", "seq", ",", "list", ")", ":", "seq", "=", "list", "(", "seq", ...
[ 11, 0 ]
[ 53, 46 ]
python
en
['en', 'error', 'th']
False
parse_query_string
(query_string, operator=None, zero_terms=MATCH_NONE)
This takes a query string typed in by a user and extracts the following: - Quoted terms (for phrase search) - Filters For example, the following query: `hello "this is a phrase" live:true` would be parsed into: filters: {'live': 'true'} tokens: And([PlainText('hello'), Phrase('this ...
This takes a query string typed in by a user and extracts the following:
def parse_query_string(query_string, operator=None, zero_terms=MATCH_NONE): """ This takes a query string typed in by a user and extracts the following: - Quoted terms (for phrase search) - Filters For example, the following query: `hello "this is a phrase" live:true` would be parsed into...
[ "def", "parse_query_string", "(", "query_string", ",", "operator", "=", "None", ",", "zero_terms", "=", "MATCH_NONE", ")", ":", "filters", ",", "query_string", "=", "separate_filters_from_query", "(", "query_string", ")", "is_phrase", "=", "False", "tokens", "=", ...
[ 94, 0 ]
[ 131, 32 ]
python
en
['en', 'error', 'th']
False
AdamP.step
(self, closure: OptLossClosure = None)
r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss.
r"""Performs a single optimization step.
def step(self, closure: OptLossClosure = None) -> OptFloat: r"""Performs a single optimization step. Arguments: closure: A closure that reevaluates the model and returns the loss. """ loss = None if closure is not None: loss = closure() for group...
[ "def", "step", "(", "self", ",", "closure", ":", "OptLossClosure", "=", "None", ")", "->", "OptFloat", ":", "loss", "=", "None", "if", "closure", "is", "not", "None", ":", "loss", "=", "closure", "(", ")", "for", "group", "in", "self", ".", "param_gr...
[ 127, 4 ]
[ 195, 19 ]
python
en
['en', 'en', 'en']
True
GUIScreen.get_cols_rows
(self)
Dummy cols and rows :return:
Dummy cols and rows
def get_cols_rows(self): """ Dummy cols and rows :return: """ return self.size
[ "def", "get_cols_rows", "(", "self", ")", ":", "return", "self", ".", "size" ]
[ 46, 4 ]
[ 52, 24 ]
python
en
['en', 'error', 'th']
False
GUIScreen.change_font
(self, event)
Change font event handler :param event: :return:
Change font event handler :param event: :return:
def change_font(self, event): """ Change font event handler :param event: :return: """ min_size = 1 cur_size = self.font['size'] inc = 1 if cur_size > 0 else -1 if event.num == 4 or event.delta > 0: self.font.configure(size=cur_size + i...
[ "def", "change_font", "(", "self", ",", "event", ")", ":", "min_size", "=", "1", "cur_size", "=", "self", ".", "font", "[", "'size'", "]", "inc", "=", "1", "if", "cur_size", ">", "0", "else", "-", "1", "if", "event", ".", "num", "==", "4", "or", ...
[ 81, 4 ]
[ 96, 34 ]
python
en
['en', 'error', 'th']
False
GUIScreen.resize
(self, event)
Resize screen :param event: :return:
Resize screen :param event: :return:
def resize(self, event): """ Resize screen :param event: :return: """ (cwdth, chght) = (self.font.measure(' '), self.font.metrics("linespace")) width = int(math.floor((self.text.winfo_width() - float(cwdth) / 2) / float(cwdth))) height = int(math.floor(se...
[ "def", "resize", "(", "self", ",", "event", ")", ":", "(", "cwdth", ",", "chght", ")", "=", "(", "self", ".", "font", ".", "measure", "(", "' '", ")", ",", "self", ".", "font", ".", "metrics", "(", "\"linespace\"", ")", ")", "width", "=", "int", ...
[ 98, 4 ]
[ 109, 58 ]
python
en
['en', 'error', 'th']
False
GUIScreen.draw_screen
(self, size, canvas)
:param size: :type canvas: urwid.Canvas
def draw_screen(self, size, canvas): """ :param size: :type canvas: urwid.Canvas """ if not self.root: if not self.window_closed: self.window_closed = True raise ManualShutdown("GUI window was closed") return # ena...
[ "def", "draw_screen", "(", "self", ",", "size", ",", "canvas", ")", ":", "if", "not", "self", ".", "root", ":", "if", "not", "self", ".", "window_closed", ":", "self", ".", "window_closed", "=", "True", "raise", "ManualShutdown", "(", "\"GUI window was clo...
[ 115, 4 ]
[ 147, 26 ]
python
en
['en', 'error', 'th']
False
main
()
Check for collisions, then create.
Check for collisions, then create.
def main(): """Check for collisions, then create.""" # Check. errors = False for path in BOILERPLATE: if os.path.exists(path): print('Warning: {0} already exists.'.format(path), file=sys.stderr) errors = True if errors: print('**Exiting without creating files...
[ "def", "main", "(", ")", ":", "# Check.", "errors", "=", "False", "for", "path", "in", "BOILERPLATE", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "print", "(", "'Warning: {0} already exists.'", ".", "format", "(", "path", ")", "...
[ 25, 0 ]
[ 43, 9 ]
python
en
['en', 'en', 'en']
True
render_curl_example
( function: str, api_url: str, exclude: Optional[List[str]] = None, include: Optional[List[str]] = None, )
A simple wrapper around generate_curl_example.
A simple wrapper around generate_curl_example.
def render_curl_example( function: str, api_url: str, exclude: Optional[List[str]] = None, include: Optional[List[str]] = None, ) -> List[str]: """A simple wrapper around generate_curl_example.""" parts = function.split(":") endpoint = parts[0] method = parts[1] kwargs: Dict[str, Any...
[ "def", "render_curl_example", "(", "function", ":", "str", ",", "api_url", ":", "str", ",", "exclude", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ",", "include", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ...
[ 346, 0 ]
[ 364, 60 ]
python
en
['de', 'en', 'en']
True
Browser.process
(self)
Return process of this browser. If browser instance is created by :func:`pyppeteer.launcher.connect`, return ``None``.
Return process of this browser.
def process(self) -> Optional[Popen]: """Return process of this browser. If browser instance is created by :func:`pyppeteer.launcher.connect`, return ``None``. """ return self._process
[ "def", "process", "(", "self", ")", "->", "Optional", "[", "Popen", "]", ":", "return", "self", ".", "_process" ]
[ 81, 4 ]
[ 87, 28 ]
python
en
['en', 'en', 'en']
True
Browser.createIncogniteBrowserContext
(self)
[Deprecated] Miss spelled method. Use :meth:`createIncognitoBrowserContext` method instead.
[Deprecated] Miss spelled method.
async def createIncogniteBrowserContext(self) -> 'BrowserContext': """[Deprecated] Miss spelled method. Use :meth:`createIncognitoBrowserContext` method instead. """ logger.warning( 'createIncogniteBrowserContext is deprecated. ' 'Use createIncognitoBrowserContex...
[ "async", "def", "createIncogniteBrowserContext", "(", "self", ")", "->", "'BrowserContext'", ":", "logger", ".", "warning", "(", "'createIncogniteBrowserContext is deprecated. '", "'Use createIncognitoBrowserContext instead.'", ")", "return", "await", "self", ".", "createInco...
[ 89, 4 ]
[ 98, 57 ]
python
en
['en', 'af', 'en']
True
Browser.createIncognitoBrowserContext
(self)
Create a new incognito browser context. This won't share cookies/cache with other browser contexts. .. code:: browser = await launch() # Create a new incognito browser context. context = await browser.createIncognitoBrowserContext() # Create a new page ...
Create a new incognito browser context.
async def createIncognitoBrowserContext(self) -> 'BrowserContext': """Create a new incognito browser context. This won't share cookies/cache with other browser contexts. .. code:: browser = await launch() # Create a new incognito browser context. context = ...
[ "async", "def", "createIncognitoBrowserContext", "(", "self", ")", "->", "'BrowserContext'", ":", "obj", "=", "await", "self", ".", "_connection", ".", "send", "(", "'Target.createBrowserContext'", ")", "browserContextId", "=", "obj", "[", "'browserContextId'", "]",...
[ 100, 4 ]
[ 120, 22 ]
python
en
['en', 'en', 'en']
True
Browser.browserContexts
(self)
Return a list of all open browser contexts. In a newly created browser, this will return a single instance of ``[BrowserContext]``
Return a list of all open browser contexts.
def browserContexts(self) -> List['BrowserContext']: """Return a list of all open browser contexts. In a newly created browser, this will return a single instance of ``[BrowserContext]`` """ return [self._defaultContext] + [context for context in self._contexts.values()]
[ "def", "browserContexts", "(", "self", ")", "->", "List", "[", "'BrowserContext'", "]", ":", "return", "[", "self", ".", "_defaultContext", "]", "+", "[", "context", "for", "context", "in", "self", ".", "_contexts", ".", "values", "(", ")", "]" ]
[ 123, 4 ]
[ 129, 88 ]
python
en
['en', 'en', 'en']
True
Browser.create
(connection: Connection, contextIds: List[str], ignoreHTTPSErrors: bool, defaultViewport: Optional[Dict], process: Optional[Popen] = None, closeCallback: Callable[[], Awaitable[None]] = None, **kwargs: Any)
Create browser object.
Create browser object.
async def create(connection: Connection, contextIds: List[str], ignoreHTTPSErrors: bool, defaultViewport: Optional[Dict], process: Optional[Popen] = None, closeCallback: Callable[[], Awaitable[None]] = None, **kwargs: Any) -> 'Browser':...
[ "async", "def", "create", "(", "connection", ":", "Connection", ",", "contextIds", ":", "List", "[", "str", "]", ",", "ignoreHTTPSErrors", ":", "bool", ",", "defaultViewport", ":", "Optional", "[", "Dict", "]", ",", "process", ":", "Optional", "[", "Popen"...
[ 138, 4 ]
[ 147, 22 ]
python
en
['en', 'en', 'en']
True
Browser.wsEndpoint
(self)
Return websocket end point url.
Return websocket end point url.
def wsEndpoint(self) -> str: """Return websocket end point url.""" return self._connection.url
[ "def", "wsEndpoint", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_connection", ".", "url" ]
[ 195, 4 ]
[ 197, 35 ]
python
da
['nl', 'da', 'en']
False
Browser.newPage
(self)
Make new page on this browser and return its object.
Make new page on this browser and return its object.
async def newPage(self) -> Page: """Make new page on this browser and return its object.""" return await self._defaultContext.newPage()
[ "async", "def", "newPage", "(", "self", ")", "->", "Page", ":", "return", "await", "self", ".", "_defaultContext", ".", "newPage", "(", ")" ]
[ 199, 4 ]
[ 201, 51 ]
python
en
['en', 'en', 'en']
True
Browser.targets
(self)
Get a list of all active targets inside the browser. In case of multiple browser contexts, the method will return a list with all the targets in all browser contexts.
Get a list of all active targets inside the browser.
def targets(self) -> List[Target]: """Get a list of all active targets inside the browser. In case of multiple browser contexts, the method will return a list with all the targets in all browser contexts. """ return [target for target in self._targets.values() if...
[ "def", "targets", "(", "self", ")", "->", "List", "[", "Target", "]", ":", "return", "[", "target", "for", "target", "in", "self", ".", "_targets", ".", "values", "(", ")", "if", "target", ".", "_isInitialized", "]" ]
[ 220, 4 ]
[ 227, 41 ]
python
en
['en', 'en', 'en']
True
Browser.pages
(self)
Get all pages of this browser. Non visible pages, such as ``"background_page"``, will not be listed here. You can find then using :meth:`pyppeteer.target.Target.page`. In case of multiple browser contexts, this method will return a list with all the pages in all browser contexts. ...
Get all pages of this browser.
async def pages(self) -> List[Page]: """Get all pages of this browser. Non visible pages, such as ``"background_page"``, will not be listed here. You can find then using :meth:`pyppeteer.target.Target.page`. In case of multiple browser contexts, this method will return a list w...
[ "async", "def", "pages", "(", "self", ")", "->", "List", "[", "Page", "]", ":", "# Using asyncio.gather is better for performance", "pages", ":", "List", "[", "Page", "]", "=", "list", "(", ")", "for", "context", "in", "self", ".", "browserContexts", ":", ...
[ 229, 4 ]
[ 242, 20 ]
python
en
['en', 'en', 'en']
True
Browser.version
(self)
Get version of the browser.
Get version of the browser.
async def version(self) -> str: """Get version of the browser.""" version = await self._getVersion() return version['product']
[ "async", "def", "version", "(", "self", ")", "->", "str", ":", "version", "=", "await", "self", ".", "_getVersion", "(", ")", "return", "version", "[", "'product'", "]" ]
[ 244, 4 ]
[ 247, 33 ]
python
en
['en', 'en', 'en']
True
Browser.userAgent
(self)
Return browser's original user agent. .. note:: Pages can override browser user agent with :meth:`pyppeteer.page.Page.setUserAgent`.
Return browser's original user agent.
async def userAgent(self) -> str: """Return browser's original user agent. .. note:: Pages can override browser user agent with :meth:`pyppeteer.page.Page.setUserAgent`. """ version = await self._getVersion() return version.get('userAgent', '')
[ "async", "def", "userAgent", "(", "self", ")", "->", "str", ":", "version", "=", "await", "self", ".", "_getVersion", "(", ")", "return", "version", ".", "get", "(", "'userAgent'", ",", "''", ")" ]
[ 249, 4 ]
[ 257, 43 ]
python
en
['en', 'da', 'en']
True
Browser.close
(self)
Close connections and terminate browser process.
Close connections and terminate browser process.
async def close(self) -> None: """Close connections and terminate browser process.""" await self._closeCallback()
[ "async", "def", "close", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_closeCallback", "(", ")" ]
[ 259, 4 ]
[ 261, 35 ]
python
en
['en', 'en', 'en']
True
Browser.disconnect
(self)
Disconnect browser.
Disconnect browser.
async def disconnect(self) -> None: """Disconnect browser.""" await self._connection.dispose()
[ "async", "def", "disconnect", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_connection", ".", "dispose", "(", ")" ]
[ 263, 4 ]
[ 265, 40 ]
python
en
['en', 'en', 'en']
False
BrowserContext.targets
(self)
Return a list of all active targets inside the browser context.
Return a list of all active targets inside the browser context.
def targets(self) -> List[Target]: """Return a list of all active targets inside the browser context.""" targets = [] for target in self._browser.targets(): if target.browserContext == self: targets.append(target) return targets
[ "def", "targets", "(", "self", ")", "->", "List", "[", "Target", "]", ":", "targets", "=", "[", "]", "for", "target", "in", "self", ".", "_browser", ".", "targets", "(", ")", ":", "if", "target", ".", "browserContext", "==", "self", ":", "targets", ...
[ 308, 4 ]
[ 314, 22 ]
python
en
['en', 'en', 'en']
True
BrowserContext.pages
(self)
Return list of all open pages. Non-visible pages, such as ``"background_page"``, will not be listed here. You can find them using :meth:`pyppeteer.target.Target.page`.
Return list of all open pages.
async def pages(self) -> List[Page]: """Return list of all open pages. Non-visible pages, such as ``"background_page"``, will not be listed here. You can find them using :meth:`pyppeteer.target.Target.page`. """ # Using asyncio.gather is better for performance pages = []...
[ "async", "def", "pages", "(", "self", ")", "->", "List", "[", "Page", "]", ":", "# Using asyncio.gather is better for performance", "pages", "=", "[", "]", "for", "target", "in", "self", ".", "targets", "(", ")", ":", "if", "target", ".", "type", "==", "...
[ 316, 4 ]
[ 329, 20 ]
python
en
['en', 'en', 'en']
True
BrowserContext.isIncognite
(self)
[Deprecated] Miss spelled method. Use :meth:`isIncognito` method instead.
[Deprecated] Miss spelled method.
def isIncognite(self) -> bool: """[Deprecated] Miss spelled method. Use :meth:`isIncognito` method instead. """ logger.warning( 'isIncognite is deprecated. ' 'Use isIncognito instead.' ) return self.isIncognito()
[ "def", "isIncognite", "(", "self", ")", "->", "bool", ":", "logger", ".", "warning", "(", "'isIncognite is deprecated. '", "'Use isIncognito instead.'", ")", "return", "self", ".", "isIncognito", "(", ")" ]
[ 331, 4 ]
[ 340, 33 ]
python
en
['en', 'af', 'en']
True
BrowserContext.isIncognito
(self)
Return whether BrowserContext is incognito. The default browser context is the only non-incognito browser context. .. note:: The default browser context cannot be closed.
Return whether BrowserContext is incognito.
def isIncognito(self) -> bool: """Return whether BrowserContext is incognito. The default browser context is the only non-incognito browser context. .. note:: The default browser context cannot be closed. """ return bool(self._id)
[ "def", "isIncognito", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "_id", ")" ]
[ 342, 4 ]
[ 350, 29 ]
python
en
['en', 'en', 'en']
True
BrowserContext.newPage
(self)
Create a new page in the browser context.
Create a new page in the browser context.
async def newPage(self) -> Page: """Create a new page in the browser context.""" return await self._browser._createPageInContext(self._id)
[ "async", "def", "newPage", "(", "self", ")", "->", "Page", ":", "return", "await", "self", ".", "_browser", ".", "_createPageInContext", "(", "self", ".", "_id", ")" ]
[ 352, 4 ]
[ 354, 65 ]
python
en
['en', 'en', 'en']
True
BrowserContext.browser
(self)
Return the browser this browser context belongs to.
Return the browser this browser context belongs to.
def browser(self) -> Browser: """Return the browser this browser context belongs to.""" return self._browser
[ "def", "browser", "(", "self", ")", "->", "Browser", ":", "return", "self", ".", "_browser" ]
[ 357, 4 ]
[ 359, 28 ]
python
en
['en', 'en', 'en']
True
BrowserContext.close
(self)
Close the browser context. All the targets that belongs to the browser context will be closed. .. note:: Only incognito browser context can be closed.
Close the browser context.
async def close(self) -> None: """Close the browser context. All the targets that belongs to the browser context will be closed. .. note:: Only incognito browser context can be closed. """ if self._id is None: raise BrowserError('Non-incognito profile ca...
[ "async", "def", "close", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_id", "is", "None", ":", "raise", "BrowserError", "(", "'Non-incognito profile cannot be closed'", ")", "await", "self", ".", "_browser", ".", "_disposeContext", "(", "self", "...
[ 361, 4 ]
[ 371, 53 ]
python
en
['en', 'en', 'en']
True
get_srid_info
(srid, connection)
Returns the units, unit name, and spheroid WKT associated with the given SRID from the `spatial_ref_sys` (or equivalent) spatial database table for the given database connection. These results are cached.
Returns the units, unit name, and spheroid WKT associated with the given SRID from the `spatial_ref_sys` (or equivalent) spatial database table for the given database connection. These results are cached.
def get_srid_info(srid, connection): """ Returns the units, unit name, and spheroid WKT associated with the given SRID from the `spatial_ref_sys` (or equivalent) spatial database table for the given database connection. These results are cached. """ from django.contrib.gis.gdal import SpatialRe...
[ "def", "get_srid_info", "(", "srid", ",", "connection", ")", ":", "from", "django", ".", "contrib", ".", "gis", ".", "gdal", "import", "SpatialReference", "global", "_srid_cache", "try", ":", "# The SpatialRefSys model for the spatial backend.", "SpatialRefSys", "=", ...
[ 21, 0 ]
[ 48, 35 ]
python
en
['en', 'error', 'th']
False
GeoSelectFormatMixin.select_format
(self, compiler, sql, params)
Returns the selection format string, depending on the requirements of the spatial backend. For example, Oracle and MySQL require custom selection formats in order to retrieve geometries in OGC WKT. For all other fields a simple '%s' format string is returned.
Returns the selection format string, depending on the requirements of the spatial backend. For example, Oracle and MySQL require custom selection formats in order to retrieve geometries in OGC WKT. For all other fields a simple '%s' format string is returned.
def select_format(self, compiler, sql, params): """ Returns the selection format string, depending on the requirements of the spatial backend. For example, Oracle and MySQL require custom selection formats in order to retrieve geometries in OGC WKT. For all other fields a simple...
[ "def", "select_format", "(", "self", ",", "compiler", ",", "sql", ",", "params", ")", ":", "connection", "=", "compiler", ".", "connection", "srid", "=", "compiler", ".", "query", ".", "get_context", "(", "'transformed_srid'", ")", "if", "srid", ":", "sel_...
[ 52, 4 ]
[ 71, 36 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.__init__
(self, verbose_name=None, srid=4326, spatial_index=True, **kwargs)
The initialization function for base spatial fields. Takes the following as keyword arguments: srid: The spatial reference system identifier, an OGC standard. Defaults to 4326 (WGS84). spatial_index: Indicates whether to create a spatial index. Defaults to ...
The initialization function for base spatial fields. Takes the following as keyword arguments:
def __init__(self, verbose_name=None, srid=4326, spatial_index=True, **kwargs): """ The initialization function for base spatial fields. Takes the following as keyword arguments: srid: The spatial reference system identifier, an OGC standard. Defaults to 4326 (WGS84). ...
[ "def", "__init__", "(", "self", ",", "verbose_name", "=", "None", ",", "srid", "=", "4326", ",", "spatial_index", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# Setting the index flag with the value of the `spatial_index` keyword.", "self", ".", "spatial_index",...
[ 87, 4 ]
[ 113, 56 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.geodetic
(self, connection)
Returns true if this field's SRID corresponds with a coordinate system that uses non-projected units (e.g., latitude/longitude).
Returns true if this field's SRID corresponds with a coordinate system that uses non-projected units (e.g., latitude/longitude).
def geodetic(self, connection): """ Returns true if this field's SRID corresponds with a coordinate system that uses non-projected units (e.g., latitude/longitude). """ units_name = self.units_name(connection) return units_name.lower() in self.geodetic_units if units_name...
[ "def", "geodetic", "(", "self", ",", "connection", ")", ":", "units_name", "=", "self", ".", "units_name", "(", "connection", ")", "return", "units_name", ".", "lower", "(", ")", "in", "self", ".", "geodetic_units", "if", "units_name", "else", "self", ".",...
[ 148, 4 ]
[ 154, 93 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.get_placeholder
(self, value, compiler, connection)
Returns the placeholder for the spatial column for the given value.
Returns the placeholder for the spatial column for the given value.
def get_placeholder(self, value, compiler, connection): """ Returns the placeholder for the spatial column for the given value. """ return connection.ops.get_geom_placeholder(self, value, compiler)
[ "def", "get_placeholder", "(", "self", ",", "value", ",", "compiler", ",", "connection", ")", ":", "return", "connection", ".", "ops", ".", "get_geom_placeholder", "(", "self", ",", "value", ",", "compiler", ")" ]
[ 156, 4 ]
[ 161, 73 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.get_srid
(self, obj)
Return the default SRID for the given geometry or raster, taking into account the SRID set for the field. For example, if the input geometry or raster doesn't have an SRID, then the SRID of the field will be returned.
Return the default SRID for the given geometry or raster, taking into account the SRID set for the field. For example, if the input geometry or raster doesn't have an SRID, then the SRID of the field will be returned.
def get_srid(self, obj): """ Return the default SRID for the given geometry or raster, taking into account the SRID set for the field. For example, if the input geometry or raster doesn't have an SRID, then the SRID of the field will be returned. """ srid = obj.sr...
[ "def", "get_srid", "(", "self", ",", "obj", ")", ":", "srid", "=", "obj", ".", "srid", "# SRID of given geometry.", "if", "srid", "is", "None", "or", "self", ".", "srid", "==", "-", "1", "or", "(", "srid", "==", "-", "1", "and", "self", ".", "srid"...
[ 163, 4 ]
[ 174, 23 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.get_db_prep_save
(self, value, connection)
Prepare the value for saving in the database.
Prepare the value for saving in the database.
def get_db_prep_save(self, value, connection): """ Prepare the value for saving in the database. """ if isinstance(value, Geometry) or value: return connection.ops.Adapter(self.get_prep_value(value)) else: return None
[ "def", "get_db_prep_save", "(", "self", ",", "value", ",", "connection", ")", ":", "if", "isinstance", "(", "value", ",", "Geometry", ")", "or", "value", ":", "return", "connection", ".", "ops", ".", "Adapter", "(", "self", ".", "get_prep_value", "(", "v...
[ 176, 4 ]
[ 183, 23 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.get_raster_prep_value
(self, value, is_candidate)
Return a GDALRaster if conversion is successful, otherwise return None.
Return a GDALRaster if conversion is successful, otherwise return None.
def get_raster_prep_value(self, value, is_candidate): """ Return a GDALRaster if conversion is successful, otherwise return None. """ if isinstance(value, gdal.GDALRaster): return value elif is_candidate: try: return gdal.GDALRaster(value) ...
[ "def", "get_raster_prep_value", "(", "self", ",", "value", ",", "is_candidate", ")", ":", "if", "isinstance", "(", "value", ",", "gdal", ".", "GDALRaster", ")", ":", "return", "value", "elif", "is_candidate", ":", "try", ":", "return", "gdal", ".", "GDALRa...
[ 185, 4 ]
[ 200, 98 ]
python
en
['en', 'error', 'th']
False
BaseSpatialField.get_prep_value
(self, value)
Spatial lookup values are either a parameter that is (or may be converted to) a geometry or raster, or a sequence of lookup values that begins with a geometry or raster. This routine sets up the geometry or raster value properly and preserves any other lookup parameters. ...
Spatial lookup values are either a parameter that is (or may be converted to) a geometry or raster, or a sequence of lookup values that begins with a geometry or raster. This routine sets up the geometry or raster value properly and preserves any other lookup parameters. ...
def get_prep_value(self, value): """ Spatial lookup values are either a parameter that is (or may be converted to) a geometry or raster, or a sequence of lookup values that begins with a geometry or raster. This routine sets up the geometry or raster value properly and preserves ...
[ "def", "get_prep_value", "(", "self", ",", "value", ")", ":", "value", "=", "super", "(", "BaseSpatialField", ",", "self", ")", ".", "get_prep_value", "(", "value", ")", "# For IsValid lookups, boolean values are allowed.", "if", "isinstance", "(", "value", ",", ...
[ 202, 4 ]
[ 250, 22 ]
python
en
['en', 'error', 'th']
False
GeometryField.__init__
(self, verbose_name=None, dim=2, geography=False, **kwargs)
The initialization function for geometry fields. In addition to the parameters from BaseSpatialField, it takes the following as keyword arguments: dim: The number of dimensions for this geometry. Defaults to 2. extent: Customize the extent, in a 4-tuple of W...
The initialization function for geometry fields. In addition to the parameters from BaseSpatialField, it takes the following as keyword arguments:
def __init__(self, verbose_name=None, dim=2, geography=False, **kwargs): """ The initialization function for geometry fields. In addition to the parameters from BaseSpatialField, it takes the following as keyword arguments: dim: The number of dimensions for this geometr...
[ "def", "__init__", "(", "self", ",", "verbose_name", "=", "None", ",", "dim", "=", "2", ",", "geography", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Setting the dimension of the geometry field.", "self", ".", "dim", "=", "dim", "# Is this a geography ...
[ 266, 4 ]
[ 295, 80 ]
python
en
['en', 'error', 'th']
False
GeometryField.get_distance
(self, value, lookup_type, connection)
Returns a distance number in units of the field. For example, if `D(km=1)` was passed in and the units of the field were in meters, then 1000 would be returned.
Returns a distance number in units of the field. For example, if `D(km=1)` was passed in and the units of the field were in meters, then 1000 would be returned.
def get_distance(self, value, lookup_type, connection): """ Returns a distance number in units of the field. For example, if `D(km=1)` was passed in and the units of the field were in meters, then 1000 would be returned. """ return connection.ops.get_distance(self, value...
[ "def", "get_distance", "(", "self", ",", "value", ",", "lookup_type", ",", "connection", ")", ":", "return", "connection", ".", "ops", ".", "get_distance", "(", "self", ",", "value", ",", "lookup_type", ")" ]
[ 307, 4 ]
[ 313, 68 ]
python
en
['en', 'error', 'th']
False
GeometryField._get_db_prep_lookup
(self, lookup_type, value, connection)
Prepare for the database lookup, and return any spatial parameters necessary for the query. This includes wrapping any geometry parameters with a backend-specific adapter and formatting any distance parameters into the correct units for the coordinate system of the field. ...
Prepare for the database lookup, and return any spatial parameters necessary for the query. This includes wrapping any geometry parameters with a backend-specific adapter and formatting any distance parameters into the correct units for the coordinate system of the field.
def _get_db_prep_lookup(self, lookup_type, value, connection): """ Prepare for the database lookup, and return any spatial parameters necessary for the query. This includes wrapping any geometry parameters with a backend-specific adapter and formatting any distance parameters in...
[ "def", "_get_db_prep_lookup", "(", "self", ",", "lookup_type", ",", "value", ",", "connection", ")", ":", "# Populating the parameters list, and wrapping the Geometry", "# with the Adapter of the spatial backend.", "if", "isinstance", "(", "value", ",", "(", "tuple", ",", ...
[ 348, 4 ]
[ 367, 21 ]
python
en
['en', 'error', 'th']
False
get_size
(obj, seen=None)
Recursively finds size of objects
Recursively finds size of objects
def get_size(obj, seen=None): """Recursively finds size of objects""" size = sys.getsizeof(obj) if seen is None: seen = set() obj_id = id(obj) if obj_id in seen: return 0 # Important mark as seen *before* entering recursion to gracefully handle # self-referential objects ...
[ "def", "get_size", "(", "obj", ",", "seen", "=", "None", ")", ":", "size", "=", "sys", ".", "getsizeof", "(", "obj", ")", "if", "seen", "is", "None", ":", "seen", "=", "set", "(", ")", "obj_id", "=", "id", "(", "obj", ")", "if", "obj_id", "in",...
[ 538, 0 ]
[ 556, 15 ]
python
en
['en', 'en', 'en']
True