diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-07-04 11:56:42 +0200 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-07-04 12:07:31 +0200 |
commit | f0ad4b348b9cb559a9b45882187514a063bd627f (patch) | |
tree | e462cee76df37cff37e1452d5edfb4db83e3abbe /poezio/theming.py | |
parent | 7b8871b6513623a61a38f7bc0b71da3a79f2e523 (diff) | |
download | poezio-f0ad4b348b9cb559a9b45882187514a063bd627f.tar.gz poezio-f0ad4b348b9cb559a9b45882187514a063bd627f.tar.bz2 poezio-f0ad4b348b9cb559a9b45882187514a063bd627f.tar.xz poezio-f0ad4b348b9cb559a9b45882187514a063bd627f.zip |
Use pathlib.Path and poezio.xdg to load themes.
Diffstat (limited to 'poezio/theming.py')
-rwxr-xr-x | poezio/theming.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/poezio/theming.py b/poezio/theming.py index 5cdd89ae..0cf0f27d 100755 --- a/poezio/theming.py +++ b/poezio/theming.py @@ -74,8 +74,9 @@ except ImportError: import curses import functools import os +from pathlib import Path from os import path -from poezio import colors +from poezio import colors, xdg from importlib import machinery finder = machinery.PathFinder() @@ -493,18 +494,12 @@ def update_themes_dir(option=None, value=None): load_path.append(default_dir) # import from the user-defined prefs - themes_dir = path.expanduser( - value or config.get('themes_dir') or path.join( - os.environ.get('XDG_DATA_HOME') - or path.join(os.environ.get('HOME'), '.local', 'share'), 'poezio', - 'themes')) + themes_dir = config.get('themes_dir') + themes_dir = Path(themes_dir).expanduser() if themes_dir else xdg.DATA_HOME / 'themes' try: - os.makedirs(themes_dir) - except OSError as e: - if e.errno != 17: - log.error('Unable to create the themes dir (%s)', themes_dir) - else: - load_path.append(themes_dir) + themes_dir.mkdir(parents=True, exist_ok=True) + except OSError: + log.exception('Unable to create the themes dir (%s):', themes_dir) else: load_path.append(themes_dir) |