diff options
| author | Dylan Araps <dylanaraps@users.noreply.github.com> | 2017-06-29 22:52:21 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-29 22:52:21 +1000 |
| commit | 27e73e5bba414e30caea0dace5fc5073538359d7 (patch) | |
| tree | d574432dc7a64b50b5e146fec5ff7db526b020f9 /pywal/util.py | |
| parent | 06d726a66cec0c5626c31975397ab340349ff39b (diff) | |
| parent | 3283d38e07d4b20ad3a0646d28284fe205fcdc57 (diff) | |
Merge pull request #16 from dylanaraps/json
colors: Store colors in a json format.
Diffstat (limited to 'pywal/util.py')
| -rwxr-xr-x | pywal/util.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pywal/util.py b/pywal/util.py index 67baa6a..69a9d9d 100755 --- a/pywal/util.py +++ b/pywal/util.py @@ -1,6 +1,7 @@ """ Misc helper functions. """ +import json import os import pathlib import subprocess @@ -13,12 +14,25 @@ def read_file(input_file): return colors +def read_file_json(input_file): + """Read colors from a json file.""" + with open(input_file) as json_file: + colors = json.load(json_file) + return colors + + def save_file(colors, export_file): """Write the colors to the file.""" with open(export_file, "w") as file: file.write(colors) +def save_file_json(colors, export_file): + """Write the colors to a json file.""" + with open(export_file, "w") as file: + json.dump(colors, file, indent=4) + + def create_dir(directory): """Alias to create the cache dir.""" pathlib.Path(directory).mkdir(parents=True, exist_ok=True) |
