"""Кроссплатформенное открытие файлов, папок и ссылок.""" from __future__ import annotations import os import subprocess import sys def open_path(path: str) -> bool: path = os.path.abspath(os.path.expanduser(str(path))) try: if os.name == "nt": os.startfile(path) # type: ignore[attr-defined] elif sys.platform == "darwin": subprocess.Popen(["open", path]) else: subprocess.Popen(["xdg-open", path]) return True except Exception: return False def open_url(url: str) -> bool: try: if os.name == "nt": os.startfile(url) # type: ignore[attr-defined] elif sys.platform == "darwin": subprocess.Popen(["open", url]) else: subprocess.Popen(["xdg-open", url]) return True except Exception: return False