Skip to content

Commit

Permalink
Remove python3-xdg dependency
Browse files Browse the repository at this point in the history
Use GLib functions get_user_config_dir and get_user_data_dir instead
of pyxdg functions. One less dependency, yay.
  • Loading branch information
GeraldJansen committed Oct 4, 2023
1 parent ce09bfa commit 921bb75
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ Debian-based (tested in Ubuntu 19.04)

.. code:: bash
sudo apt install gettext intltool python3-gi-cairo python3-distutils python3-xdg
sudo apt install gettext intltool python3-gi-cairo python3-distutils
Other
^^^^^

Current (late 2019) dependencies for
`Hamster <https://github.com/projecthamster/hamster/blob/master/README.md>`__
should work, keeping in mind that the dbus and gconf or gsettings/dconf dependencies are not
should work, keeping in mind that the dbus and gconf or gsettings/dconf dependencies are not
needed.

Trying the development version
Expand Down
5 changes: 2 additions & 3 deletions src/hamster_lite/lib/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import os
import json
import datetime as dt
from xdg.BaseDirectory import xdg_data_home, xdg_config_home

from gi.repository import GLib as glib

class Singleton(object):
def __new__(cls, *args, **kwargs):
Expand All @@ -45,7 +44,7 @@ class ConfStore(Singleton):

def __init__(self):
self.config = self.DEFAULTS
config_dir = os.path.join(xdg_config_home, 'hamster-lite')
config_dir = os.path.join(glib.get_user_config_dir(), 'hamster-lite')
if not os.path.exists(config_dir):
os.makedirs(config_dir)
self.config_file = os.path.join(config_dir, 'hamster-lite.json')
Expand Down
4 changes: 2 additions & 2 deletions src/hamster_lite/lib/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import datetime as dt
from gi.repository import GObject as gobject
from gi.repository import Gtk as gtk
from xdg.BaseDirectory import xdg_data_home, xdg_config_home
from gi.repository import GLib as glib
import hamster_lite
import hamster_lite.storage as db

Expand Down Expand Up @@ -105,7 +105,7 @@ def __init__(self):

self.data_dir = os.path.realpath(self.data_dir)
self.home_data_dir = os.path.realpath(
os.path.join(xdg_data_home, "hamster-lite"))
os.path.join(glib.get_user_data_dir(), "hamster-lite"))
self.storage = db.Storage()


Expand Down
9 changes: 2 additions & 7 deletions src/hamster_lite/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,8 @@ def __init__(self, unsorted="", database_dir=None):

def __init_db_file(self, database_dir):
if not database_dir:
try:
from xdg.BaseDirectory import xdg_data_home
except ImportError:
logger.warning(
"Could not import xdg - assuming ~/.local/share")
xdg_data_home = os.path.join(os.path.expanduser('~'),
'.local', 'share')
from gi.repository import GLib
xdg_data_home = GLib.get_user_data_dir()
database_dir = os.path.join(xdg_data_home, 'hamster-lite')

if not os.path.exists(database_dir):
Expand Down

0 comments on commit 921bb75

Please sign in to comment.