summaryrefslogtreecommitdiffstats
path: root/.config
diff options
context:
space:
mode:
authorPavel Egorov <[email protected]>2025-12-19 03:21:01 +0300
committerPavel Egorov <[email protected]>2025-12-19 03:21:01 +0300
commit989c2857d4da3fa163dc77289b67cbd2eeb59d26 (patch)
treec5c8999501e6936d18ec5a5353788eac3cb1bcd3 /.config
parentabbdb8e6e57dc7627bcf31282ef0eaf9e4241a4c (diff)
downloaddotfiles-989c2857d4da3fa163dc77289b67cbd2eeb59d26.tar.gz
dotfiles-989c2857d4da3fa163dc77289b67cbd2eeb59d26.zip
[fastfetch] simplify module construction code
Diffstat (limited to '.config')
-rw-r--r--.config/fastfetch/confgen.py35
1 files changed, 13 insertions, 22 deletions
diff --git a/.config/fastfetch/confgen.py b/.config/fastfetch/confgen.py
index c368582..3925140 100644
--- a/.config/fastfetch/confgen.py
+++ b/.config/fastfetch/confgen.py
@@ -21,7 +21,6 @@ class Node:
21 text: Optional[str] 21 text: Optional[str]
22 additional_entries: Optional[dict[str, type[Any]]] 22 additional_entries: Optional[dict[str, type[Any]]]
23 font_effect: Optional[str] 23 font_effect: Optional[str]
24 neighbour_branches: str
25 children: list["Node"] 24 children: list["Node"]
26 25
27 def __init__(self, module, key, format=None, additional_entries=None, text=None, font_effect=None): 26 def __init__(self, module, key, format=None, additional_entries=None, text=None, font_effect=None):
@@ -42,28 +41,10 @@ class Node:
42 def construct_module(self) -> dict[str, type[Any]]: 41 def construct_module(self) -> dict[str, type[Any]]:
43 42
44 module = {"type": self.module} 43 module = {"type": self.module}
45
46 # if self.font_effect:
47 # font_effect = self.font_effect
48 # else:
49 # font_effect = font_effects["reset"]
50 # key = {"key": f"{{{font_effect}}} {self.key}"}
51 key = {"key": self.key} 44 key = {"key": self.key}
52 45 format = {"format": self.format} if self.format else {}
53 if self.format: 46 text = {"text": self.text} if self.text else {}
54 format = {"format": self.format} 47 additional_entries = self.additional_entries if self.additional_entries else {}
55 else:
56 format = {}
57
58 if self.text:
59 text = {"text": self.text}
60 else:
61 text = {}
62
63 if self.additional_entries:
64 additional_entries = self.additional_entries
65 else:
66 additional_entries = {}
67 48
68 return module | key | format | text | additional_entries 49 return module | key | format | text | additional_entries
69 50
@@ -81,6 +62,14 @@ class Node:
81 return 62 return
82 node.remove_module(module) 63 node.remove_module(module)
83 64
65 def prettify(self, font_effect=None, key_prefix="") -> None:
66 if key_prefix:
67 self.key = key_prefix + f'{graphics["hbar"]} ' + self.key
68 if self.font_effect:
69 font_effect = self.font_effect
70 for i, node in enumerate(self.children):
71 node.prettify(font_effect, key_prefix)
72
84 73
85font_effects = { 74font_effects = {
86 "reset": "#0", 75 "reset": "#0",
@@ -237,6 +226,8 @@ def main():
237 test_config = build_config(roots) 226 test_config = build_config(roots)
238 test_data = get_test_response(test_config) 227 test_data = get_test_response(test_config)
239 filtered_roots = filter_roots(roots, test_data) 228 filtered_roots = filter_roots(roots, test_data)
229 for root in filtered_roots:
230 root.prettify()
240 final_config = build_config(filtered_roots) 231 final_config = build_config(filtered_roots)
241 print(json.dumps(final_config)) 232 print(json.dumps(final_config))
242 233