summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-03-07 23:20:12 +0100
committerAnton Khirnov <anton@khirnov.net>2023-03-07 23:21:40 +0100
commit174481a048cdb9d4f39e2dd593c10ec8dd8e8d43 (patch)
tree6abbb7be7a59c3456f567d8351049b66eb9b7e98
parent14a14bb4acf122f339b0a8c40268bd81bcecf005 (diff)
settings/utils: move resolve_att to the only place where it's used
-rw-r--r--alot/settings/manager.py28
-rw-r--r--alot/settings/utils.py16
2 files changed, 21 insertions, 23 deletions
diff --git a/alot/settings/manager.py b/alot/settings/manager.py
index 5d2098b0..2945c125 100644
--- a/alot/settings/manager.py
+++ b/alot/settings/manager.py
@@ -13,10 +13,10 @@ import os
import re
from configobj import ConfigObj, Section
+from urwid import AttrSpec
from .errors import ConfigError, NoMatchingAccount
from .utils import read_config
-from .utils import resolve_att
from .theme import Theme
from ..account import SendmailAccount
@@ -29,6 +29,20 @@ DEFAULTSPATH = os.path.join(os.path.dirname(__file__), '..', 'defaults')
DATA_DIRS = get_xdg_env('XDG_DATA_DIRS',
'/usr/local/share:/usr/share').split(':')
+def _resolve_att(a, fallback):
+ """ replace '' and 'default' by fallback values """
+ if a is None:
+ return fallback
+ if a.background in ['default', '']:
+ bg = fallback.background
+ else:
+ bg = a.background
+ if a.foreground in ['default', '']:
+ fg = fallback.foreground
+ else:
+ fg = a.foreground
+ return AttrSpec(fg, bg)
+
def _pretty_datetime(d):
"""
translates :class:`datetime` `d` to a "sup-style" human readable string.
@@ -428,15 +442,15 @@ class SettingsManager:
default_focus = theme.get_attribute(colourmode, 'global', 'tag_focus')
# local defaults for tagstring attributes. depend on next lower widget
- fallback_normal = resolve_att(onebelow_normal, default_normal)
- fallback_focus = resolve_att(onebelow_focus, default_focus)
+ fallback_normal = _resolve_att(onebelow_normal, default_normal)
+ fallback_focus = _resolve_att(onebelow_focus, default_focus)
for sec in cfg['tags'].sections:
if re.match('^{}$'.format(sec), tag):
- normal = resolve_att(colourpick(cfg['tags'][sec]['normal']),
- fallback_normal)
- focus = resolve_att(colourpick(cfg['tags'][sec]['focus']),
- fallback_focus)
+ normal = _resolve_att(colourpick(cfg['tags'][sec]['normal']),
+ fallback_normal)
+ focus = _resolve_att(colourpick(cfg['tags'][sec]['focus']),
+ fallback_focus)
translated = cfg['tags'][sec]['translated']
if translated is None:
diff --git a/alot/settings/utils.py b/alot/settings/utils.py
index e830fafc..316083aa 100644
--- a/alot/settings/utils.py
+++ b/alot/settings/utils.py
@@ -6,7 +6,6 @@ import logging
from configobj import (ConfigObj, ConfigObjError, flatten_errors,
get_extra_values)
-from urwid import AttrSpec
from validate import Validator
from .errors import ConfigError
@@ -81,18 +80,3 @@ def read_config(configpath=None, specpath=None, checks=None,
msg.append(str(val))
logging.info('\n'.join(msg))
return config
-
-
-def resolve_att(a, fallback):
- """ replace '' and 'default' by fallback values """
- if a is None:
- return fallback
- if a.background in ['default', '']:
- bg = fallback.background
- else:
- bg = a.background
- if a.foreground in ['default', '']:
- fg = fallback.foreground
- else:
- fg = a.foreground
- return AttrSpec(fg, bg)