tklr-dgraham 0.0.0rc11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tklr-dgraham might be problematic. Click here for more details.
- tklr/__init__.py +0 -0
- tklr/cli/main.py +253 -0
- tklr/cli/migrate_etm_to_tklr.py +764 -0
- tklr/common.py +1296 -0
- tklr/controller.py +2602 -0
- tklr/item.py +3765 -0
- tklr/list_colors.py +234 -0
- tklr/model.py +3973 -0
- tklr/shared.py +654 -0
- tklr/sounds/alert.mp3 +0 -0
- tklr/tklr_env.py +461 -0
- tklr/use_system.py +64 -0
- tklr/versioning.py +21 -0
- tklr/view.py +2912 -0
- tklr/view_agenda.py +236 -0
- tklr/view_textual.css +296 -0
- tklr_dgraham-0.0.0rc11.dist-info/METADATA +699 -0
- tklr_dgraham-0.0.0rc11.dist-info/RECORD +21 -0
- tklr_dgraham-0.0.0rc11.dist-info/WHEEL +5 -0
- tklr_dgraham-0.0.0rc11.dist-info/entry_points.txt +2 -0
- tklr_dgraham-0.0.0rc11.dist-info/top_level.txt +1 -0
tklr/list_colors.py
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from rich.table import Table
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
|
|
5
|
+
# from rich.color import Color
|
|
6
|
+
from rich.style import Style
|
|
7
|
+
from colorsys import rgb_to_hls
|
|
8
|
+
|
|
9
|
+
import subprocess
|
|
10
|
+
|
|
11
|
+
import io
|
|
12
|
+
|
|
13
|
+
#
|
|
14
|
+
|
|
15
|
+
css_named_colors = {
|
|
16
|
+
"aliceblue": "#F0F8FF",
|
|
17
|
+
"antiquewhite": "#FAEBD7",
|
|
18
|
+
"aqua": "#00FFFF",
|
|
19
|
+
"aquamarine": "#7FFFD4",
|
|
20
|
+
"azure": "#F0FFFF",
|
|
21
|
+
"beige": "#F5F5DC",
|
|
22
|
+
"bisque": "#FFE4C4",
|
|
23
|
+
"black": "#000000",
|
|
24
|
+
"blue": "#0000FF",
|
|
25
|
+
"blueviolet": "#8A2BE2",
|
|
26
|
+
"brown": "#A52A2A",
|
|
27
|
+
"burlywood": "#DEB887",
|
|
28
|
+
"cadetblue": "#5F9EA0",
|
|
29
|
+
"chartreuse": "#7FFF00",
|
|
30
|
+
"chocolate": "#D2691E",
|
|
31
|
+
"coral": "#FF7F50",
|
|
32
|
+
"cornflowerblue": "#6495ED",
|
|
33
|
+
"cornsilk": "#FFF8DC",
|
|
34
|
+
"crimson": "#DC143C",
|
|
35
|
+
"cyan": "#00FFFF",
|
|
36
|
+
"darkblue": "#00008B",
|
|
37
|
+
"darkcyan": "#008B8B",
|
|
38
|
+
"darkgoldenrod": "#B8860B",
|
|
39
|
+
"darkgray": "#A9A9A9",
|
|
40
|
+
"darkgreen": "#006400",
|
|
41
|
+
"darkkhaki": "#BDB76B",
|
|
42
|
+
"darkmagenta": "#8B008B",
|
|
43
|
+
"darkolivegreen": "#556B2F",
|
|
44
|
+
"darkorange": "#FF8C00",
|
|
45
|
+
"darkorchid": "#9932CC",
|
|
46
|
+
"darkred": "#8B0000",
|
|
47
|
+
"darksalmon": "#E9967A",
|
|
48
|
+
"darkseagreen": "#8FBC8F",
|
|
49
|
+
"darkslateblue": "#483D8B",
|
|
50
|
+
"darkslategray": "#2F4F4F",
|
|
51
|
+
"darkturquoise": "#00CED1",
|
|
52
|
+
"darkviolet": "#9400D3",
|
|
53
|
+
"deeppink": "#FF1493",
|
|
54
|
+
"deepskyblue": "#00BFFF",
|
|
55
|
+
"dimgray": "#696969",
|
|
56
|
+
"dodgerblue": "#1E90FF",
|
|
57
|
+
"firebrick": "#B22222",
|
|
58
|
+
"floralwhite": "#FFFAF0",
|
|
59
|
+
"forestgreen": "#228B22",
|
|
60
|
+
"fuchsia": "#FF00FF",
|
|
61
|
+
"gainsboro": "#DCDCDC",
|
|
62
|
+
"ghostwhite": "#F8F8FF",
|
|
63
|
+
"gold": "#FFD700",
|
|
64
|
+
"goldenrod": "#DAA520",
|
|
65
|
+
"gray": "#808080",
|
|
66
|
+
"green": "#008000",
|
|
67
|
+
"greenyellow": "#ADFF2F",
|
|
68
|
+
"honeydew": "#F0FFF0",
|
|
69
|
+
"hotpink": "#FF69B4",
|
|
70
|
+
"indianred": "#CD5C5C",
|
|
71
|
+
"indigo": "#4B0082",
|
|
72
|
+
"ivory": "#FFFFF0",
|
|
73
|
+
"khaki": "#F0E68C",
|
|
74
|
+
"lavender": "#E6E6FA",
|
|
75
|
+
"lavenderblush": "#FFF0F5",
|
|
76
|
+
"lawngreen": "#7CFC00",
|
|
77
|
+
"lemonchiffon": "#FFFACD",
|
|
78
|
+
"lightblue": "#ADD8E6",
|
|
79
|
+
"lightcoral": "#F08080",
|
|
80
|
+
"lightcyan": "#E0FFFF",
|
|
81
|
+
"lightgoldenrodyellow": "#FAFAD2",
|
|
82
|
+
"lightgray": "#D3D3D3",
|
|
83
|
+
"lightgreen": "#90EE90",
|
|
84
|
+
"lightpink": "#FFB6C1",
|
|
85
|
+
"lightsalmon": "#FFA07A",
|
|
86
|
+
"lightseagreen": "#20B2AA",
|
|
87
|
+
"lightskyblue": "#87CEFA",
|
|
88
|
+
"lightslategray": "#778899",
|
|
89
|
+
"lightsteelblue": "#B0C4DE",
|
|
90
|
+
"lightyellow": "#FFFFE0",
|
|
91
|
+
"lime": "#00FF00",
|
|
92
|
+
"limegreen": "#32CD32",
|
|
93
|
+
"linen": "#FAF0E6",
|
|
94
|
+
"magenta": "#FF00FF",
|
|
95
|
+
"maroon": "#800000",
|
|
96
|
+
"mediumaquamarine": "#66CDAA",
|
|
97
|
+
"mediumblue": "#0000CD",
|
|
98
|
+
"mediumorchid": "#BA55D3",
|
|
99
|
+
"mediumpurple": "#9370DB",
|
|
100
|
+
"mediumseagreen": "#3CB371",
|
|
101
|
+
"mediumslateblue": "#7B68EE",
|
|
102
|
+
"mediumspringgreen": "#00FA9A",
|
|
103
|
+
"mediumturquoise": "#48D1CC",
|
|
104
|
+
"mediumvioletred": "#C71585",
|
|
105
|
+
"midnightblue": "#191970",
|
|
106
|
+
"mintcream": "#F5FFFA",
|
|
107
|
+
"mistyrose": "#FFE4E1",
|
|
108
|
+
"moccasin": "#FFE4B5",
|
|
109
|
+
"navajowhite": "#FFDEAD",
|
|
110
|
+
"navy": "#000080",
|
|
111
|
+
"oldlace": "#FDF5E6",
|
|
112
|
+
"olive": "#808000",
|
|
113
|
+
"olivedrab": "#6B8E23",
|
|
114
|
+
"orange": "#FFA500",
|
|
115
|
+
"orangered": "#FF4500",
|
|
116
|
+
"orchid": "#DA70D6",
|
|
117
|
+
"palegoldenrod": "#EEE8AA",
|
|
118
|
+
"palegreen": "#98FB98",
|
|
119
|
+
"paleturquoise": "#AFEEEE",
|
|
120
|
+
"palevioletred": "#DB7093",
|
|
121
|
+
"papayawhip": "#FFEFD5",
|
|
122
|
+
"peachpuff": "#FFDAB9",
|
|
123
|
+
"peru": "#CD853F",
|
|
124
|
+
"pink": "#FFC0CB",
|
|
125
|
+
"plum": "#DDA0DD",
|
|
126
|
+
"powderblue": "#B0E0E6",
|
|
127
|
+
"purple": "#800080",
|
|
128
|
+
"rebeccapurple": "#663399",
|
|
129
|
+
"red": "#FF0000",
|
|
130
|
+
"rosybrown": "#BC8F8F",
|
|
131
|
+
"royalblue": "#4169E1",
|
|
132
|
+
"saddlebrown": "#8B4513",
|
|
133
|
+
"salmon": "#FA8072",
|
|
134
|
+
"sandybrown": "#F4A460",
|
|
135
|
+
"seagreen": "#2E8B57",
|
|
136
|
+
"seashell": "#FFF5EE",
|
|
137
|
+
"sienna": "#A0522D",
|
|
138
|
+
"silver": "#C0C0C0",
|
|
139
|
+
"skyblue": "#87CEEB",
|
|
140
|
+
"slateblue": "#6A5ACD",
|
|
141
|
+
"slategray": "#708090",
|
|
142
|
+
"snow": "#FFFAFA",
|
|
143
|
+
"springgreen": "#00FF7F",
|
|
144
|
+
"steelblue": "#4682B4",
|
|
145
|
+
"tan": "#D2B48C",
|
|
146
|
+
"teal": "#008080",
|
|
147
|
+
"thistle": "#D8BFD8",
|
|
148
|
+
"tomato": "#FF6347",
|
|
149
|
+
"turquoise": "#40E0D0",
|
|
150
|
+
"violet": "#EE82EE",
|
|
151
|
+
"wheat": "#F5DEB3",
|
|
152
|
+
"white": "#FFFFFF",
|
|
153
|
+
"whitesmoke": "#F5F5F5",
|
|
154
|
+
"yellow": "#FFFF00",
|
|
155
|
+
"yellowgreen": "#9ACD32",
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def sort_colors(
|
|
160
|
+
color_dict: dict[str, str], method: str = "name"
|
|
161
|
+
) -> list[tuple[str, str]]:
|
|
162
|
+
if method == "hue":
|
|
163
|
+
|
|
164
|
+
def hex_to_hue(hex_value: str):
|
|
165
|
+
hex_value = hex_value.lstrip("#")
|
|
166
|
+
r, g, b = tuple(int(hex_value[i : i + 2], 16) / 255.0 for i in (0, 2, 4))
|
|
167
|
+
h, _, _ = rgb_to_hls(r, g, b)
|
|
168
|
+
return h
|
|
169
|
+
|
|
170
|
+
return sorted(color_dict.items(), key=lambda item: hex_to_hue(item[1]))
|
|
171
|
+
return sorted(color_dict.items()) # default name
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def get_contrasting_text_color(hex_color: str) -> str:
|
|
175
|
+
hex_color = hex_color.lstrip("#")
|
|
176
|
+
r, g, b = [int(hex_color[i : i + 2], 16) for i in (0, 2, 4)]
|
|
177
|
+
brightness = (r * 299 + g * 587 + b * 114) / 1000
|
|
178
|
+
return "black" if brightness > 128 else "white"
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
# @click.command()
|
|
182
|
+
# @click.option(
|
|
183
|
+
# "--sort",
|
|
184
|
+
# type=click.Choice(["name", "hue"], case_sensitive=False),
|
|
185
|
+
# default="name",
|
|
186
|
+
# help="Sort colors name or by hue",
|
|
187
|
+
# )
|
|
188
|
+
# def show_colors(sort):
|
|
189
|
+
# console = Console(record=True)
|
|
190
|
+
# table = Table(title=f"CSS Named Colors (--sort {sort})")
|
|
191
|
+
# table.add_column("Color Name")
|
|
192
|
+
# table.add_column("Hex Value")
|
|
193
|
+
#
|
|
194
|
+
# for name, hex_val in sort_colors(css_named_colors, sort):
|
|
195
|
+
# name_style = Style(color=hex_val)
|
|
196
|
+
# hex_style = Style(color=get_contrasting_text_color(hex_val), bgcolor=hex_val)
|
|
197
|
+
# table.add_row(f"[{hex_val}]{name}[/]", f"[{hex_style}]{hex_val}[/]")
|
|
198
|
+
#
|
|
199
|
+
# console.print(table)
|
|
200
|
+
# output = console.export_text()
|
|
201
|
+
# click.echo_via_pager(output)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
@click.command()
|
|
205
|
+
@click.option(
|
|
206
|
+
"--sort",
|
|
207
|
+
type=click.Choice(["name", "hue"], case_sensitive=False),
|
|
208
|
+
default="name",
|
|
209
|
+
help="Sort colors name or by hue",
|
|
210
|
+
)
|
|
211
|
+
def show_colors(sort):
|
|
212
|
+
with subprocess.Popen(["less", "-R"], stdin=subprocess.PIPE) as proc:
|
|
213
|
+
# Wrap binary stdin as a text stream
|
|
214
|
+
with io.TextIOWrapper(proc.stdin, encoding="utf-8") as text_stream:
|
|
215
|
+
console = Console(
|
|
216
|
+
file=text_stream, force_terminal=True, color_system="truecolor"
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
table = Table(title=f"CSS Named Colors (--sort {sort})")
|
|
220
|
+
table.add_column("Color Name")
|
|
221
|
+
table.add_column("Hex Value")
|
|
222
|
+
|
|
223
|
+
for name, hex_val in sort_colors(css_named_colors, sort):
|
|
224
|
+
name_style = Style(color=hex_val)
|
|
225
|
+
hex_style = Style(
|
|
226
|
+
color=get_contrasting_text_color(hex_val), bgcolor=hex_val
|
|
227
|
+
)
|
|
228
|
+
table.add_row(f"[{hex_val}]{name}[/]", f"[{hex_style}]{hex_val}[/]")
|
|
229
|
+
|
|
230
|
+
console.print(table)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
if __name__ == "__main__":
|
|
234
|
+
show_colors()
|