Skip to content

Commit

Permalink
Catch up with hamster-lib 0.13 config helper changes
Browse files Browse the repository at this point in the history
``hamster-lib 0.13.0`` changes the interface of the configuration helpers
in a backwards incompatible way. The now unnecessary helper was also removed.

Closes: projecthamster#182
  • Loading branch information
jtojnar authored and Grandmother committed Jan 12, 2019
1 parent c516552 commit 96b9ce3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions hamster_gtk/hamster_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
from hamster_gtk.helpers import get_parent_window, get_resource_path
from six import text_type

# [FIXME]
# Remove once hamster-lib has been patched
from hamster_gtk.helpers import get_config_instance
from hamster_gtk.misc import HamsterAboutDialog as AboutDialog
from hamster_gtk.overview import OverviewDialog
from hamster_gtk.preferences import PreferencesDialog
Expand Down Expand Up @@ -174,6 +171,9 @@ def __init__(self):
"""Setup instance and make sure default signals are connected to methods."""
super(HamsterGTK, self).__init__()
self.window = None

self._appdirs = config_helpers.HamsterAppDirs('hamster-gtk')

# Which config backend to use.
self.config_store = 'file'
# Yes this is redundent, but more transparent. And we can worry about
Expand All @@ -195,7 +195,7 @@ def save_config(self, config):
dict: Dictionary of config keys and values.
"""
cp_instance = self._config_to_configparser(config)
config_helpers.write_config_file(cp_instance, 'hamster-gtk', 'hamster-gtk.conf')
config_helpers.write_config_file(cp_instance, self._appdirs, 'hamster-gtk.conf')
self.controler.signal_handler.emit('config-changed')

def _startup(self, app):
Expand Down Expand Up @@ -249,7 +249,7 @@ def _get_default_config(self):
Note: Those defaults are independend of the particular config store.
"""
appdirs = config_helpers.HamsterAppDirs('hamster-gtk')
appdirs = self._appdirs
return {
# Backend
'store': 'sqlalchemy',
Expand Down Expand Up @@ -362,7 +362,7 @@ def _write_config_to_file(self, configparser_instance):
Args:
cp_instance (SafeConfigParser): Instance to be written to file.
"""
config_helpers.write_config_file(configparser_instance, 'hamster-gtk', 'hamster-gtk.conf')
config_helpers.write_config_file(configparser_instance, self._appdirs, 'hamster-gtk.conf')

def _get_config_from_file(self):
"""
Expand All @@ -380,7 +380,8 @@ def get_fallback():
config = self._get_default_config()
return self._config_to_configparser(config)

cp_instance = get_config_instance(get_fallback(), 'hamster-gtk', 'hamster-gtk.conf')
cp_instance = config_helpers.load_config_file(self._appdirs, 'hamster-gtk.conf',
get_fallback())
return self._configparser_to_config(cp_instance)


Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
history = history_file.read().replace('.. :changelog:', '')

requirements = [
'hamster-lib',
'orderedset',
'hamster-lib >=0.13.0,<0.14.0',
]

setup(
Expand Down

0 comments on commit 96b9ce3

Please sign in to comment.