From 88bdd9ab013bad324e1f3f4ad8516fd6d55ca312 Mon Sep 17 00:00:00 2001 From: dylan araps Date: Thu, 20 Jul 2017 13:40:31 +1000 Subject: api: Use wal file in __main__.py --- pywal/util.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pywal/util.py') diff --git a/pywal/util.py b/pywal/util.py index 6c5b420..deab13c 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -98,3 +98,8 @@ def disown(*cmd): stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setpgrp) + + +def str_to_path(str_path): + """Convert a string to a Path type.""" + return pathlib.Path(str_path) -- cgit v1.2.3 From 52cd5e5f1a7c972a593fe55a853afd43111531e9 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 20 Jul 2017 23:19:13 +1000 Subject: General: Unhardcode all CACHE_DIR and COLOR_COUNT usage. --- pywal/util.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'pywal/util.py') diff --git a/pywal/util.py b/pywal/util.py index deab13c..6c5b420 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -98,8 +98,3 @@ def disown(*cmd): stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setpgrp) - - -def str_to_path(str_path): - """Convert a string to a Path type.""" - return pathlib.Path(str_path) -- cgit v1.2.3 From 3d1f11b1bd70b17567808849fd9eb3346599bb53 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 21 Jul 2017 11:19:17 +1000 Subject: util: Add new msg function. --- pywal/util.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pywal/util.py') diff --git a/pywal/util.py b/pywal/util.py index 6c5b420..1030b60 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -98,3 +98,12 @@ def disown(*cmd): stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, preexec_fn=os.setpgrp) + + +def msg(input_msg, quiet): + """Print to the terminal and a libnotify + notification.""" + if not quiet: + disown("notify-send", input_msg) + + print(input_msg) -- cgit v1.2.3 From 12f9211cd4a255226d151545e0532c8507af7361 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 09:46:45 +1000 Subject: general: Remove comments that just repeat what the code does. --- pywal/util.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'pywal/util.py') diff --git a/pywal/util.py b/pywal/util.py index 1030b60..0891feb 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -44,24 +44,31 @@ def set_grey(colors): def read_file(input_file): - """Read data from a file.""" - with open(input_file) as file: + """Read data from a file and trim newlines.""" + with open(input_file, "r") as file: data = file.read().splitlines() return data def read_file_json(input_file): """Read data from a json file.""" - with open(input_file) as json_file: + with open(input_file, "r") as json_file: data = json.load(json_file) - # If wallpaper is unset, set it to "None" if "wallpaper" not in data: data["wallpaper"] = "None" return data +def read_file_raw(input_file): + """Read data from a file as is, don't strip + newlines or other special characters..""" + with open(input_file, "r") as file: + data = file.readlines() + return data + + def save_file(data, export_file): """Write data to a file.""" with open(export_file, "w") as file: -- cgit v1.2.3 From d8d0297d8968380879718758493fd135b5234591 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 09:50:35 +1000 Subject: general: Fix comment --- pywal/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pywal/util.py') diff --git a/pywal/util.py b/pywal/util.py index 0891feb..b109744 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -108,7 +108,7 @@ def disown(*cmd): def msg(input_msg, quiet): - """Print to the terminal and a libnotify + """Print to the terminal and display a libnotify notification.""" if not quiet: disown("notify-send", input_msg) -- cgit v1.2.3 From a34a9c597722056f4eba4b689775f9f202a35822 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 11:19:17 +1000 Subject: api: Cleanup --- pywal/util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pywal/util.py') diff --git a/pywal/util.py b/pywal/util.py index b109744..6338989 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -71,12 +71,16 @@ def read_file_raw(input_file): def save_file(data, export_file): """Write data to a file.""" + create_dir(os.path.dirname(export_file)) + with open(export_file, "w") as file: file.write(data) def save_file_json(data, export_file): """Write data to a json file.""" + create_dir(os.path.dirname(export_file)) + with open(export_file, "w") as file: json.dump(data, file, indent=4) @@ -107,10 +111,10 @@ def disown(*cmd): preexec_fn=os.setpgrp) -def msg(input_msg, quiet): +def msg(input_msg, notify): """Print to the terminal and display a libnotify notification.""" - if not quiet: + if notify: disown("notify-send", input_msg) print(input_msg) -- cgit v1.2.3 From 38fcae33a09fae218fff7211725e3781f287f5a6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 23 Jul 2017 14:51:42 +1000 Subject: api: Added function to load colors from file. --- pywal/util.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'pywal/util.py') diff --git a/pywal/util.py b/pywal/util.py index 6338989..1df3c9f 100644 --- a/pywal/util.py +++ b/pywal/util.py @@ -55,9 +55,6 @@ def read_file_json(input_file): with open(input_file, "r") as json_file: data = json.load(json_file) - if "wallpaper" not in data: - data["wallpaper"] = "None" - return data -- cgit v1.2.3