maestral.utils.appdirs#

This module contains functions to retrieve platform dependent locations to store app data. It supports macOS and Linux.

Module Contents#

maestral.utils.appdirs.get_home_dir()[source]#

Returns user home directory. This will be determined from the first valid result out of (osp.expanduser(“~”), $HOME, $USERPROFILE, $TMP).

Return type:

str

maestral.utils.appdirs.get_conf_path(subfolder=None, filename=None, create=True)[source]#

Returns the default config path for the platform. This will be:

  • macOS: “~/Library/Application Support/<subfolder>/<filename>.”

  • Linux: “XDG_CONFIG_HOME/<subfolder>/<filename>”

  • other: “~/.config/<subfolder>/<filename>”

Parameters:
  • subfolder (Optional[str]) – The subfolder for the app.

  • filename (Optional[str]) – The filename to append for the app.

  • create (bool) – If True, the folder subfolder will be created on-demand.

Return type:

str

maestral.utils.appdirs.get_data_path(subfolder=None, filename=None, create=True)[source]#

Returns the default path to save application data for the platform. This will be:

  • macOS: “~/Library/Application Support/SUBFOLDER/FILENAME”

  • Linux: “$XDG_DATA_DIR/SUBFOLDER/FILENAME”

  • fallback: “$HOME/.local/share/SUBFOLDER/FILENAME”

Note: We do not use “~/Library/Saved Application State” on macOS since this folder is reserved for user interface state and can be cleared by the user / system.

Parameters:
  • subfolder (Optional[str]) – The subfolder for the app.

  • filename (Optional[str]) – The filename to append for the app.

  • create (bool) – If True, the folder subfolder will be created on-demand.

Return type:

str

maestral.utils.appdirs.get_cache_path(subfolder=None, filename=None, create=True)[source]#

Returns the default cache path for the platform. This will be:

  • macOS: “~/Library/Caches/SUBFOLDER/FILENAME”

  • Linux: “$XDG_CACHE_HOME/SUBFOLDER/FILENAME”

  • fallback: “$HOME/.cache/SUBFOLDER/FILENAME”

Parameters:
  • subfolder (Optional[str]) – The subfolder for the app.

  • filename (Optional[str]) – The filename to append for the app.

  • create (bool) – If True, the folder subfolder will be created on-demand.

Return type:

str

maestral.utils.appdirs.get_log_path(subfolder=None, filename=None, create=True)[source]#

Returns the default log path for the platform. This will be:

  • macOS: “~/Library/Logs/SUBFOLDER/FILENAME”

  • Linux: “$XDG_CACHE_HOME/SUBFOLDER/FILENAME”

  • fallback: “$HOME/.cache/SUBFOLDER/FILENAME”

Parameters:
  • subfolder (Optional[str]) – The subfolder for the app.

  • filename (Optional[str]) – The filename to append for the app.

  • create (bool) – If True, the folder subfolder will be created on-demand.

Return type:

str

maestral.utils.appdirs.get_autostart_path(filename=None, create=True)[source]#

Returns the default path for login items for the platform. This will be:

  • macOS: “~/Library/LaunchAgents/FILENAME”

  • Linux: “$XDG_CONFIG_HOME/autostart/FILENAME”

  • fallback: “$HOME/.config/autostart/FILENAME”

Parameters:
  • filename (Optional[str]) – The filename to append for the app.

  • create (bool) – If True, the folder subfolder will be created on-demand.

Return type:

str

maestral.utils.appdirs.get_runtime_path(subfolder=None, filename=None, create=True)[source]#

Returns the default runtime path for the platform. This will be:

  • macOS: “~/Library/Application Support/SUBFOLDER/FILENAME”

  • Linux: “$XDG_RUNTIME_DIR/SUBFOLDER/FILENAME”

  • fallback: “$HOME/.cache/SUBFOLDER/FILENAME”

Parameters:
  • subfolder (Optional[str]) – The subfolder for the app.

  • filename (Optional[str]) – The filename to append for the app.

  • create (bool) – If True, the folder subfolder will be created on-demand.

Return type:

str