mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-20 09:37:42 +02:00
general: Rename set_colors to sequences
This commit is contained in:
parent
930c3c8e40
commit
23571cc620
@ -11,7 +11,7 @@ from pywal.settings import CACHE_DIR, __version__
|
|||||||
from pywal import export
|
from pywal import export
|
||||||
from pywal import image
|
from pywal import image
|
||||||
from pywal import gen_colors
|
from pywal import gen_colors
|
||||||
from pywal import set_colors
|
from pywal import sequences
|
||||||
from pywal import reload
|
from pywal import reload
|
||||||
from pywal import wallpaper
|
from pywal import wallpaper
|
||||||
from pywal import util
|
from pywal import util
|
||||||
@ -79,7 +79,7 @@ def process_args(args):
|
|||||||
|
|
||||||
# -r
|
# -r
|
||||||
if args.r:
|
if args.r:
|
||||||
set_colors.reload_colors(args.t)
|
sequences.reload_colors(args.t)
|
||||||
|
|
||||||
# -v
|
# -v
|
||||||
if args.v:
|
if args.v:
|
||||||
@ -102,7 +102,7 @@ def process_args(args):
|
|||||||
|
|
||||||
# -i or -f
|
# -i or -f
|
||||||
if args.i or args.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)
|
export.export_all_templates(colors_plain)
|
||||||
reload.reload_env()
|
reload.reload_env()
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from pywal.settings import CACHE_DIR, COLOR_COUNT
|
from pywal.settings import CACHE_DIR, COLOR_COUNT
|
||||||
from pywal import set_colors
|
|
||||||
from pywal import util
|
from pywal import util
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +96,7 @@ def sort_colors(colors):
|
|||||||
for index, color in enumerate(raw_colors)]
|
for index, color in enumerate(raw_colors)]
|
||||||
|
|
||||||
# Color 8
|
# 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.
|
# Add the colors to a dict.
|
||||||
colors = {}
|
colors = {}
|
||||||
|
@ -18,22 +18,6 @@ def set_color(index, color):
|
|||||||
return f"\033]4;{index};{color}\007"
|
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):
|
def send_sequences(colors, vte):
|
||||||
"""Send colors to all open terminals."""
|
"""Send colors to all open terminals."""
|
||||||
|
|
@ -22,6 +22,22 @@ class Color(object):
|
|||||||
return hex_to_rgb(self.hex_color)
|
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):
|
def read_file(input_file):
|
||||||
"""Read colors from a file."""
|
"""Read colors from a file."""
|
||||||
with open(input_file) as file:
|
with open(input_file) as file:
|
||||||
|
26
tests/test_sequences.py
Executable file
26
tests/test_sequences.py
Executable file
@ -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()
|
@ -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()
|
|
@ -12,6 +12,12 @@ COLORS = util.read_file_json("tests/test_files/test_file.json")
|
|||||||
class TestUtil(unittest.TestCase):
|
class TestUtil(unittest.TestCase):
|
||||||
"""Test the util functions."""
|
"""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):
|
def test_read_file(self):
|
||||||
"""> Read colors from a file."""
|
"""> Read colors from a file."""
|
||||||
result = util.read_file("tests/test_files/test_file")
|
result = util.read_file("tests/test_files/test_file")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user