theme: cleanup

This commit is contained in:
Dylan Araps 2018-04-01 09:55:11 +10:00
parent 2bd4c7b75b
commit ae13cae6f8

View File

@ -30,6 +30,23 @@ def terminal_sexy_to_wal(data):
return data return data
def parse_theme(theme_file):
"""Parse the theme file."""
data = util.read_file_json(theme_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
def file(input_file): def file(input_file):
"""Import colorscheme from json file.""" """Import colorscheme from json file."""
theme_name = ".".join((input_file, "json")) theme_name = ".".join((input_file, "json"))
@ -52,19 +69,7 @@ def file(input_file):
# Parse the theme file. # Parse the theme file.
if os.path.isfile(theme_file): if os.path.isfile(theme_file):
data = util.read_file_json(theme_file) return parse_theme(theme_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: else:
print("No colorscheme file found, exiting...") print("No colorscheme file found, exiting...")