Skip to content

Commit

Permalink
Revert "Use XDG directories instead of HOME to store plugins data and…
Browse files Browse the repository at this point in the history
… recent files cache (#352)"

This reverts commit b236007.
  • Loading branch information
JarrettSJohnson committed May 31, 2024
1 parent 02caed4 commit bb72e14
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 45 deletions.
17 changes: 2 additions & 15 deletions modules/pymol/_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'''

Expand Down Expand Up @@ -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)
Expand Down
16 changes: 1 addition & 15 deletions modules/pymol/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 3 additions & 15 deletions modules/pymol/plugins/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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):
'''
Expand Down

0 comments on commit bb72e14

Please sign in to comment.