summaryrefslogtreecommitdiff
path: root/pywal/theme.py
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2018-04-01 09:55:11 +1000
committerDylan Araps <dylan.araps@gmail.com>2018-04-01 09:55:11 +1000
commitae13cae6f838212461ad12ae2b73e447b66cc05b (patch)
treeb7421b09eca911cdc8ae48ea9f90ca3d34a49db3 /pywal/theme.py
parent2bd4c7b75b9d4629c27bb16bd042f6019cb09197 (diff)
theme: cleanup
Diffstat (limited to 'pywal/theme.py')
-rw-r--r--pywal/theme.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/pywal/theme.py b/pywal/theme.py
index a049ad2..6439d40 100644
--- a/pywal/theme.py
+++ b/pywal/theme.py
@@ -30,6 +30,23 @@ def terminal_sexy_to_wal(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):
"""Import colorscheme from json file."""
theme_name = ".".join((input_file, "json"))
@@ -52,19 +69,7 @@ def file(input_file):
# Parse the theme file.
if os.path.isfile(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
+ return parse_theme(theme_file)
else:
print("No colorscheme file found, exiting...")