diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-06-30 10:15:59 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-06-30 10:15:59 +1000 |
| commit | 23571cc6207ec825749e4d999993b4a2568975b6 (patch) | |
| tree | 1459f29e60ffdd904706e9027f06250a46d1042c | |
| parent | 930c3c8e40ca5c563d0414e5057b23ad27aa7cf3 (diff) | |
general: Rename set_colors to sequences
| -rwxr-xr-x | pywal/__main__.py | 6 | ||||
| -rwxr-xr-x | pywal/gen_colors.py | 3 | ||||
| -rwxr-xr-x | pywal/sequences.py (renamed from pywal/set_colors.py) | 16 | ||||
| -rwxr-xr-x | pywal/util.py | 16 | ||||
| -rwxr-xr-x | tests/test_sequences.py | 26 | ||||
| -rwxr-xr-x | tests/test_set_colors.py | 33 | ||||
| -rwxr-xr-x | tests/test_util.py | 6 |
7 files changed, 52 insertions, 54 deletions
diff --git a/pywal/__main__.py b/pywal/__main__.py index 2cf6c32..9c1d000 100755 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -11,7 +11,7 @@ from pywal.settings import CACHE_DIR, __version__ from pywal import export from pywal import image from pywal import gen_colors -from pywal import set_colors +from pywal import sequences from pywal import reload from pywal import wallpaper from pywal import util @@ -79,7 +79,7 @@ def process_args(args): # -r if args.r: - set_colors.reload_colors(args.t) + sequences.reload_colors(args.t) # -v if args.v: @@ -102,7 +102,7 @@ def process_args(args): # -i or -f if args.i or args.f: - set_colors.send_sequences(colors_plain, args.t) + sequences.send_sequences(colors_plain, args.t) export.export_all_templates(colors_plain) reload.reload_env() diff --git a/pywal/gen_colors.py b/pywal/gen_colors.py index 7dd95b5..3006c72 100755 --- a/pywal/gen_colors.py +++ b/pywal/gen_colors.py @@ -6,7 +6,6 @@ import shutil import subprocess from pywal.settings import CACHE_DIR, COLOR_COUNT -from pywal import set_colors from pywal import util @@ -97,7 +96,7 @@ def sort_colors(colors): for index, color in enumerate(raw_colors)] # Color 8 - colors_hex["color8"] = set_colors.set_grey(raw_colors) + colors_hex["color8"] = util.set_grey(raw_colors) # Add the colors to a dict. colors = {} diff --git a/pywal/set_colors.py b/pywal/sequences.py index 756aa34..eb51497 100755 --- a/pywal/set_colors.py +++ b/pywal/sequences.py @@ -18,22 +18,6 @@ def set_color(index, color): return f"\033]4;{index};{color}\007" -def set_grey(colors): - """Set a grey color based on brightness of color0.""" - return { - 0: "#666666", - 1: "#666666", - 2: "#757575", - 3: "#999999", - 4: "#999999", - 5: "#8a8a8a", - 6: "#a1a1a1", - 7: "#a1a1a1", - 8: "#a1a1a1", - 9: "#a1a1a1", - }.get(int(colors[0][1]), colors[7]) - - def send_sequences(colors, vte): """Send colors to all open terminals.""" diff --git a/pywal/util.py b/pywal/util.py index 0b4977b..97fe03d 100755 --- a/pywal/util.py +++ b/pywal/util.py @@ -22,6 +22,22 @@ class Color(object): return hex_to_rgb(self.hex_color) +def set_grey(colors): + """Set a grey color based on brightness of color0.""" + return { + 0: "#666666", + 1: "#666666", + 2: "#757575", + 3: "#999999", + 4: "#999999", + 5: "#8a8a8a", + 6: "#a1a1a1", + 7: "#a1a1a1", + 8: "#a1a1a1", + 9: "#a1a1a1", + }.get(int(colors[0][1]), colors[7]) + + def read_file(input_file): """Read colors from a file.""" with open(input_file) as file: diff --git a/tests/test_sequences.py b/tests/test_sequences.py new file mode 100755 index 0000000..2a19470 --- /dev/null +++ b/tests/test_sequences.py @@ -0,0 +1,26 @@ +"""Test sequence functions.""" +import unittest + +from pywal import sequences +from pywal import util + + +# Import colors. +COLORS = util.read_file_json("tests/test_files/test_file.json") + + +class Testsequences(unittest.TestCase): + """Test the sequence functions.""" + + def test_set_special(self): + """> Create special escape sequence.""" + result = sequences.set_special(11, COLORS["special"]["background"]) + self.assertEqual(result, "\x1b]11;#3A5130\x07") + + def test_set_color(self): + """> Create color escape sequence.""" + result = sequences.set_color(11, COLORS["colors"]["color0"]) + self.assertEqual(result, "\033]4;11;#3A5130\007") + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_set_colors.py b/tests/test_set_colors.py deleted file mode 100755 index 983e7e6..0000000 --- a/tests/test_set_colors.py +++ /dev/null @@ -1,33 +0,0 @@ -"""Test set functions.""" -import unittest - -from pywal import set_colors -from pywal import util - - -# Import colors. -COLORS = util.read_file_json("tests/test_files/test_file.json") - - -class TestSetColors(unittest.TestCase): - """Test the set_colors functions.""" - - def test_set_special(self): - """> Create special escape sequence.""" - result = set_colors.set_special(11, COLORS["special"]["background"]) - self.assertEqual(result, "\x1b]11;#3A5130\x07") - - def test_set_color(self): - """> Create color escape sequence.""" - result = set_colors.set_color(11, COLORS["colors"]["color0"]) - self.assertEqual(result, "\033]4;11;#3A5130\007") - - def test_set_grey(self): - """> Create special escape sequence.""" - colors = [list(COLORS["colors"].values())] - result = set_colors.set_grey(colors[0]) - self.assertEqual(result, "#999999") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_util.py b/tests/test_util.py index cf2b716..67ec3f7 100755 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -12,6 +12,12 @@ COLORS = util.read_file_json("tests/test_files/test_file.json") class TestUtil(unittest.TestCase): """Test the util functions.""" + def test_set_grey(self): + """> Get grey color based on brightness of color0""" + colors = [list(COLORS["colors"].values())] + result = util.set_grey(colors[0]) + self.assertEqual(result, "#999999") + def test_read_file(self): """> Read colors from a file.""" result = util.read_file("tests/test_files/test_file") |
