From 45ed75a6e0a29ed9f6f01aeed730da075d54e72c Mon Sep 17 00:00:00 2001 From: Caleb Perkins Date: Tue, 26 Dec 2017 22:09:37 -0800 Subject: [PATCH] Use XDG_DATA_HOME for history and refresh token. --- CONTRIBUTING.rst | 4 ++-- rtv/config.py | 11 ++++++----- tests/conftest.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 05d85f2..7e06784 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -92,11 +92,11 @@ This both speeds up the tests and helps to maintain consistency across runs. 4. By default, the cassettes will act as read-only. If you have written a new test and would like to record a cassette, you must provide your own refresh token. The easiest thing to do is to use the token generated by RTV when you log in. - This is usually stored as *~/.config/rtv/refresh-token*. + This is usually stored as *~/.local/share/rtv/refresh-token*. .. code-block:: bash - $ python -m pytest ~/code/rtv/tests/ --record-mode once --refresh-token ~/.config/rtv/refresh-token + $ python -m pytest ~/code/rtv/tests/ --record-mode once --refresh-token ~/.local/share/rtv/refresh-token ================================ test session starts ================================ platform linux -- Python 3.4.0, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 rootdir: ~/code/rtv/, inifile: diff --git a/rtv/config.py b/rtv/config.py index f7eb0af..bbecbd1 100644 --- a/rtv/config.py +++ b/rtv/config.py @@ -20,12 +20,13 @@ TEMPLATES = os.path.join(PACKAGE, 'templates') DEFAULT_CONFIG = os.path.join(TEMPLATES, 'rtv.cfg') DEFAULT_MAILCAP = os.path.join(TEMPLATES, 'mailcap') DEFAULT_THEMES = os.path.join(PACKAGE, 'themes') -XDG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config')) -CONFIG = os.path.join(XDG_HOME, 'rtv', 'rtv.cfg') +XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config')) +XDG_DATA_HOME = os.getenv('XDG_DATA_HOME', os.path.join(HOME, '.local', 'share')) +CONFIG = os.path.join(XDG_CONFIG_HOME, 'rtv', 'rtv.cfg') MAILCAP = os.path.join(HOME, '.mailcap') -TOKEN = os.path.join(XDG_HOME, 'rtv', 'refresh-token') -HISTORY = os.path.join(XDG_HOME, 'rtv', 'history.log') -THEMES = os.path.join(XDG_HOME, 'rtv', 'themes') +TOKEN = os.path.join(XDG_DATA_HOME, 'rtv', 'refresh-token') +HISTORY = os.path.join(XDG_DATA_HOME, 'rtv', 'history.log') +THEMES = os.path.join(XDG_CONFIG_HOME, 'rtv', 'themes') def build_parser(): diff --git a/tests/conftest.py b/tests/conftest.py index 2146b98..69e371d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -40,7 +40,7 @@ for name in ['vcr.matchers', 'vcr.stubs']: def pytest_addoption(parser): parser.addoption('--record-mode', dest='record_mode', default='none') parser.addoption('--refresh-token', dest='refresh_token', - default='~/.config/rtv/refresh-token') + default='~/.local/share/rtv/refresh-token') class MockStdscr(mock.MagicMock):