From bb72e1449a6a8b9c1c6f6981ca14073e46f2a343 Mon Sep 17 00:00:00 2001 From: Jarrett Johnson Date: Fri, 31 May 2024 12:59:41 -0400 Subject: [PATCH] Revert "Use XDG directories instead of HOME to store plugins data and recent files cache (#352)" This reverts commit b23600727599fa05beba2b6296e53ae2dc63f1cb. --- modules/pymol/_gui.py | 17 ++--------------- modules/pymol/plugins/__init__.py | 16 +--------------- modules/pymol/plugins/installation.py | 18 +++--------------- 3 files changed, 6 insertions(+), 45 deletions(-) diff --git a/modules/pymol/_gui.py b/modules/pymol/_gui.py index c12f0450b..8ff99a77c 100644 --- a/modules/pymol/_gui.py +++ b/modules/pymol/_gui.py @@ -6,13 +6,6 @@ import os import webbrowser -try: - from platformdirs import user_cache_dir -except ImportError: - def user_cache_dir(appname, *args, **kwargs): - return f"~/.cache/{appname}" - - class PyMOLDesktopGUI(object): '''Superclass for PyMOL Desktop Applications''' @@ -991,14 +984,8 @@ def _recent_filenames_lazy_init(self): return False return True - def _get_db_filepath(): - db_filename = "recent.db" - dir1, dir2 = "~/.pymol", user_cache_dir("pymol") - f1 = os.path.expanduser(os.path.join(dir1, db_filename)) - f2 = os.path.expanduser(os.path.join(dir2, db_filename)) - return (dir1, f1) if os.path.exists(f1) else (dir2, f2) - - d, f = _get_db_filepath() + d = os.path.expanduser('~/.pymol') + f = os.path.join(d, 'recent.db') try: os.makedirs(d) diff --git a/modules/pymol/plugins/__init__.py b/modules/pymol/plugins/__init__.py index 2f8aa5b9e..91772d764 100644 --- a/modules/pymol/plugins/__init__.py +++ b/modules/pymol/plugins/__init__.py @@ -13,23 +13,9 @@ from pymol import colorprinting from .legacysupport import * -try: - from platformdirs import user_data_dir -except ImportError: - def user_data_dir(appname, *args, **kwargs): - return f"~/.local/share/{appname}" - # variables -def _get_pymolplugins_rc_path(): - f1 = os.path.expanduser("~/.pymolpluginsrc.py") - if os.path.exists(f1): - return f1 - - data_dir = os.path.expanduser(user_data_dir("pymol")) - os.makedirs(data_dir, exist_ok=True) - return os.path.join(data_dir, 'pymolpluginsrc.py') -PYMOLPLUGINSRC = _get_pymolplugins_rc_path() +PYMOLPLUGINSRC = os.path.expanduser('~/.pymolpluginsrc.py') preferences = { 'verbose': False, diff --git a/modules/pymol/plugins/installation.py b/modules/pymol/plugins/installation.py index a2278e571..2fb8f6f03 100644 --- a/modules/pymol/plugins/installation.py +++ b/modules/pymol/plugins/installation.py @@ -8,12 +8,6 @@ import os -try: - from platformdirs import user_data_dir -except ImportError: - def user_data_dir(appname, *args, **kwargs): - return f"~/.local/share/{appname}" - # supported file types for installation. Do not support pyc and pyo binaries, # we want text files that can be parsed for metadata. zip_extensions = ['zip', 'tar.gz'] @@ -27,18 +21,12 @@ class BadInstallationFile(Exception): def get_default_user_plugin_path(): r''' - User plugin directory defaults to $XDG_DATA_HOME/startup on Linux and to + User plugin directory defaults to ~/.pymol/startup on Linux and to %APPDATA%\pymol\startup on windows. ''' - dirname = "startup" if 'APPDATA' in os.environ: - return os.path.join(os.environ['APPDATA'], 'pymol', dirname) - - dir1, dir2 = "~/.pymol", user_data_dir("pymol") - d1 = os.path.expanduser(os.path.join(dir1, dirname)) - d2 = os.path.expanduser(os.path.join(dir2, dirname)) - return d1 if os.path.exists(d1) else d2 - + return os.path.join(os.environ['APPDATA'], 'pymol', 'startup') + return os.path.expanduser('~/.pymol/startup') def is_writable(dirname): '''