Source code for maestral.constants

This module provides constants used throughout the maestral, the GUI and CLI. It should
be kept free of memory heavy imports.

# system imports
import sys
import platform
import pathlib
from enum import Enum
from importlib_metadata import metadata, PackageNotFoundError
from typing import ContextManager

    # For Python 3.9 and later.
    from importlib.resources import as_file, files  # type: ignore

[docs] def resource_path(package: str, resource: str) -> ContextManager[pathlib.Path]: return as_file(files(package) / resource)
except ImportError: # Fallback for Python 3.8 from importlib.resources import path as resource_path FROZEN = getattr(sys, "frozen", False) for package in ( __package__, "maestral", "maestral-cocoa", "maestral-qt", "maestral-gui", ): try:
[docs] FROZEN = "Briefcase-Version" in metadata(package) or FROZEN
except PackageNotFoundError: pass # app
[docs] APP_NAME = "Maestral"
[docs] BUNDLE_ID = "com.samschott.maestral"
[docs] APP_ICON_PATH = resource_path("maestral.resources", "maestral.png").__enter__()
[docs] ENV = {"PYTHONOPTIMIZE": "2", "LC_CTYPE": "UTF-8"}
[docs] DEFAULT_CONFIG_NAME = "maestral"
# sync
[docs] OLD_REV_FILE = ".maestral"
[docs] MIGNORE_FILE = ".mignore"
[docs] FILE_CACHE = ".maestral.cache"
[docs] EXCLUDED_FILE_NAMES = frozenset( [ "desktop.ini", "Thumbs.db", "thumbs.db", ".DS_Store", ".ds_tore", "Icon\r", "icon\r", "", ".dropbox", ".dropbox.attr", ".dropbox.cache", FILE_CACHE, OLD_REV_FILE, ] )
[docs] EXCLUDED_DIR_NAMES = frozenset([".dropbox.cache", FILE_CACHE])
# state messages
[docs] IDLE = "Up to date"
[docs] SYNCING = "Syncing..."
[docs] PAUSED = "Paused"
[docs] CONNECTED = "Connected"
[docs] DISCONNECTED = "Connection lost"
[docs] CONNECTING = "Connecting..."
[docs] SYNC_ERROR = "Sync error"
[docs] ERROR = "Fatal error"
# file status enum
[docs] class FileStatus(Enum): """Enumeration of sync status"""
[docs] Unwatched = "unwatched"
[docs] Uploading = "uploading"
[docs] Downloading = "downloading"
[docs] Error = "error"
[docs] Synced = "up to date"
# platform detection
[docs] IS_MACOS = platform.system() == "Darwin"
[docs] IS_LINUX = platform.system() == "Linux"
# keys
[docs] DROPBOX_APP_KEY = "2jmbq42w7vof78h"
# urls