Coverage for src/xfrepos.py: 0.00%
74 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-02 08:57 -0700
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-02 08:57 -0700
1#!/usr/bin/env python
3"""
4Name: xfrepos.py
5Purpose: Clones Xfce repositories pulled from https://gitlab.xfce.org/
7source: https://gitlab.com/kevinbowen/xfrepos
8version: 0.8.7
9updated: 20260901
10@author: kevin.bowen@gmail.com
11"""
13import os
14import subprocess # ruff: ignore[suspicious-subprocess-import]
15import sys
16from pathlib import Path
18from cappdata import press_any_key
20menus = {
21 "clone": [
22 "apps",
23 "bindings",
24 "panel-plugins",
25 "thunar-plugins",
26 "www",
27 "xfce",
28 "all",
29 ],
30 "build": [
31 "apps",
32 "bindings",
33 "panel-plugins",
34 "thunar-plugins",
35 "xfce",
36 "all",
37 ],
38 "install": [
39 "apps",
40 "bindings",
41 "panel-plugins",
42 "thunar-plugins",
43 "xfce",
44 "all",
45 ],
46 "clean": [
47 "apps",
48 "bindings",
49 "panel-plugins",
50 "thunar-plugins",
51 "xfce",
52 "all",
53 ],
54 "pull": [
55 "apps",
56 "bindings",
57 "panel-plugins",
58 "thunar-plugins",
59 "www",
60 "xfce",
61 "all",
62 ],
63 "purge": [
64 "apps",
65 "bindings",
66 "panel-plugins",
67 "thunar-plugins",
68 "www",
69 "xfce",
70 "all",
71 ],
72 "quit": "quit",
73}
75path = Path(__file__).parent.resolve()
76os.chdir(path)
79def main_menu():
80 """Display selection of available actions to take with repositories."""
81 os.system("/usr/bin/clear") # ruff: ignore[start-process-with-a-shell]
82 main_banner = "\u2248: xfrepos: local Xfce repository maintenance :\u2248"
83 border = "\u2248" * len(main_banner)
84 print(f"{border}\n{main_banner}\n{border}")
85 main_list = list(menus.keys())
86 selection = range(1, len(main_list) + 1)
87 for select, m_list in zip(selection, main_list, strict=False):
88 print(f"{select}. {m_list.title()}")
89 print(f"{border}")
90 question = f"Please enter your choice[1-{len(menus)}]: "
91 try:
92 choice = int(input(question))
93 if choice not in selection:
94 print("Invalid input. Try again.")
95 main_menu()
96 else:
97 if choice == selection[-1]:
98 print("Goodbye!")
99 sys.exit()
100 else:
101 action = main_list[choice - 1]
102 sub_menus(action)
103 except (ValueError, EOFError):
104 print("Invalid input. Try again.")
105 main_menu()
108def sub_menus(action):
109 """Display actions to take upon a specific repository."""
110 os.system("/usr/bin/clear") # ruff: ignore[start-process-with-a-shell]
111 banner = f"\u2248: xfrepos: {action} local Xfce repositories :\u2248"
112 border = "\u2248" * len(banner)
113 print(f"{border}\n{banner}\n{border}")
114 selection = list(range(1, len(menus[action]) + 1))
115 for select, component in zip(selection, menus[action], strict=False):
116 print(f"{select}. {action.title()} {component}")
117 # Add numbers to selection list for menu options not in action list.
118 selection.append(selection[-1] + 1)
119 selection.append(selection[-1] + 1)
120 print(f"{selection[-2]}. Return to Main Menu")
121 print(f"{selection[-1]}. Quit")
122 print(f"{border}")
123 question = f"Please enter your choice[1-{len(selection)}]: "
124 try:
125 answer = int(input(question))
126 if answer not in selection:
127 sub_menus(action)
128 else:
129 if answer == selection[-1]:
130 print("Goodbye!")
131 sys.exit()
132 elif answer == selection[-2]:
133 main_menu()
134 else:
135 component_list = list(menus[action])
136 if component_list[answer - 1] == "all":
137 component = "all_components"
138 else:
139 component = component_list[answer - 1]
140 script = action + "_xfce.py"
141 command = f"{path}/{script} -c {component}"
142 subprocess.run([command], shell=True) # ruff: ignore[subprocess-popen-with-shell-equals-true]
143 press_any_key()
144 main_menu()
145 except (ValueError, EOFError):
146 print("Invalid input. Try again.")
147 sub_menus(action)
150if __name__ == "__main__":
151 try:
152 main_menu()
153 except KeyboardInterrupt:
154 print()
155 print("Stopped xfrepos. Exiting...")
156 sys.exit()