Fall back to ASCII-only theme in case of non-unicode locale

This commit is contained in:
ZyX 2014-08-27 22:24:27 +04:00
parent 289a08c539
commit 285a6aa3ce
2 changed files with 12 additions and 4 deletions

View File

@ -94,7 +94,8 @@ Common configuration is a subdictionary that is a value of ``common`` key in
``default_top_theme``
String, determines which top-level theme will be used as the default.
Defaults to ``powerline``. See `Themes`_ section for more details.
Defaults to ``powerline`` in unicode locales and ``ascii`` in non-unicode
locales. See `Themes`_ section for more details.
Extension-specific configuration
--------------------------------

View File

@ -5,14 +5,15 @@ import os
import sys
import logging
from locale import getpreferredencoding
from threading import Lock, Event
from powerline.colorscheme import Colorscheme
from powerline.lib.config import ConfigLoader
from powerline.lib.unicode import safe_unicode, FailedUnicode
from powerline.config import DEFAULT_SYSTEM_CONFIG_DIR
from powerline.lib import mergedicts
from threading import Lock, Event
def _config_loader_condition(path):
if path and os.path.isfile(path):
@ -234,8 +235,14 @@ def finish_common_config(common_config):
Copy of common configuration with all configuration keys and expanded
paths.
'''
encoding = getpreferredencoding().lower()
if encoding.startswith('utf') or encoding.startswith('ucs'):
default_top_theme = 'powerline'
else:
default_top_theme = 'ascii'
common_config = common_config.copy()
common_config.setdefault('default_top_theme', 'powerline')
common_config.setdefault('default_top_theme', default_top_theme)
common_config.setdefault('paths', [])
common_config.setdefault('watcher', 'auto')
common_config.setdefault('log_level', 'WARNING')