qgis_deployment_toolbelt.shortcuts.shortcuts module#

Cross-platform shortcuts manager. Derived from pycrosskit, by Jiri Otoupal. See also: https://github.com/newville/pyshortcuts/ Author: Julien Moura (https://github.com/guts)

class qgis_deployment_toolbelt.shortcuts.shortcuts.ApplicationShortcut(name: str, exec_path: str | Path, exec_arguments: Iterable[str] = None, description: str = None, icon_path: str | Path = None, work_dir: str | Path = None)#

Bases: object

check_exec_arguments(exec_arguments: Iterable[str] | None) tuple[str] | None#

Check if exec_arguments are valid.

Parameters:

exec_arguments (Union[Iterable[str], None]) – input executable arguments to check

Return Union[Tuple[str], None]:

tuple of arguments

check_icon_path(icon_path: str | Path | None) Path | None#

Check icon path and return full path if it exists.

Parameters:

icon_path (Union[str, Path]) – input icon path to check

Return Union[Path, None]:

icon path as Path if str or Path, else None

check_work_dir(work_dir: str | Path | None) Path | None#

Check work dir and return full path if it exists.

Parameters:

work_dir (Union[str, Path]) – input work dir to check

Return Union[Path, None]:

work dir as Path if str or Path, else None

create(desktop: bool = False, start_menu: bool = False) tuple[str, str]#

Creates Shortcut

Parameters:
  • desktop (bool) – True to generate a Desktop shortcut, defaults to False

  • start_menu (bool) – True to generate a ‘Start Menu’ shortcut, defaults to False

Return Tuple[str, str]:

desktop and startmenu path

property desktop_path: Path#

Return the user Desktop folder.

Partly inspired from https://stackoverflow.com/a/13742626/2556577.

Returns:

path to the current user Desktop folder.

Return type:

Path

freedesktop_create() tuple[Path | None, Path | None]#

Creates shortcut on distributions using FreeDesktop.

Returns:

desktop and startmenu path

Return type:

Tuple[Union[Path, None], Union[Path, None]]

property homedir_path: Path#

Return home directory.

For Windows, note that we return CSIDL_PROFILE, not CSIDL_APPDATA, CSIDL_LOCAL_APPDATA or CSIDL_COMMON_APPDATA. See: https://www.nirsoft.net/articles/find_special_folder_location.html TODO: evaluate use of platformdirs

Return Path:

path to the user home

property startmenu_path: Path#

Return user Start Menu Programs folder.

For Windows, note that we return CSIDL_PROGRAMS not CSIDL_COMMON_PROGRAMS.

Return Path:

path to the Start Menu Programs folder

win32_create() tuple[Path | None, Path | None]#

Creates shortcut on Windows.

Returns:

desktop and startmenu path

Return type:

Tuple[Union[Path, None], Union[Path, None]]