diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2018-03-18 10:03:48 +1100 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2018-03-18 10:03:48 +1100 |
| commit | 1cff79bcc6f64c8b52c255c9dd161cd5564bf748 (patch) | |
| tree | 83cdf5ba3ce1a50575c17e28521530e2deea4ac8 /pywal/colors.py | |
| parent | 20ae5f8d7a3367bf0483cc8aae018419fbdb1ef0 (diff) | |
theme: Move theme handling to own file.
Diffstat (limited to 'pywal/colors.py')
| -rw-r--r-- | pywal/colors.py | 56 |
1 files changed, 6 insertions, 50 deletions
diff --git a/pywal/colors.py b/pywal/colors.py index 6ce3443..90f7ba2 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -7,8 +7,9 @@ import shutil import subprocess import sys -from .settings import CACHE_DIR, COLOR_COUNT, MODULE_DIR, \ - CONF_DIR, __cache_version__ +from . import theme + +from .settings import CACHE_DIR, COLOR_COUNT, __cache_version__ from . import util @@ -112,7 +113,7 @@ def get(img, cache_dir=CACHE_DIR, % (cache_file, color_type, __cache_version__)) if os.path.isfile(cache_file): - colors = file(cache_file) + colors = theme.file(cache_file) util.Color.alpha_num = colors["alpha"] print("colors: Found cached colorscheme.") @@ -128,51 +129,6 @@ def get(img, cache_dir=CACHE_DIR, return colors -def terminal_sexy_to_wal(data): - """Convert terminal.sexy json schema to wal.""" - data["colors"] = {} - data["special"] = { - "foreground": data["foreground"], - "background": data["background"], - "cursor": data["color"][9] - } - - for i, color in enumerate(data["color"]): - data["colors"]["color%s" % i] = color - - return data - - def file(input_file): - """Import colorscheme from json file.""" - theme_file = ".".join((input_file, "json")) - user_theme_dir = os.path.join(CONF_DIR, "colorschemes") - user_theme_file = os.path.join(user_theme_dir, theme_file) - theme_file = os.path.join(MODULE_DIR, "colorschemes", theme_file) - - util.create_dir(user_theme_dir) - - if os.path.isfile(user_theme_file): - input_file = user_theme_file - - elif os.path.isfile(theme_file): - input_file = theme_file - - if os.path.isfile(input_file): - data = util.read_file_json(input_file) - - if "wallpaper" not in data: - data["wallpaper"] = "None" - - if "alpha" not in data: - data["alpha"] = "100" - - # Terminal.sexy format. - if "color" in data: - data = terminal_sexy_to_wal(data) - - return data - - else: - print("No colorscheme file found, exiting...") - sys.exit(1) + """Deprecated: symbolic link to --> theme.file""" + return theme.file(input_file) |
