Coverage for src/cappdata.py: 9.23%

47 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-02 08:58 -0700

1""" 

2Name: cappdata.py 

3Purpose: component lists and query function for use with 

4 xfrepos.py and associated scripts 

5 

6source: https://gitlab.com/kevinbowen/xfrepos 

7version: 0.8.7 

8updated: 20260827 

9@author: kevin.bowen@gmail.com 

10""" 

11 

12import sys 

13import termios 

14import tty 

15 

16 

17def component_list(component_group_list): 

18 """returns lists of components.""" 

19 if component_group_list == "apps": 

20 apps = [ 

21 "catfish", 

22 "gigolo", 

23 "mousepad", 

24 "orage", 

25 "parole", 

26 "ristretto", 

27 "xfburn", 

28 "xfce4-dict", 

29 "xfce4-mixer", 

30 "xfce4-notifyd", 

31 "xfce4-panel-profiles", 

32 "xfce4-screensaver", 

33 "xfce4-screenshooter", 

34 "xfce4-taskmanager", 

35 "xfce4-terminal", 

36 "xfce4-volumed-pulse", 

37 "xfdashboard", 

38 "xfmpc", 

39 ] 

40 return apps 

41 

42 elif component_group_list == "bindings": 

43 bindings = ["thunarx-python", "xfce4-rs", "xfce4-vala"] 

44 return bindings 

45 

46 elif component_group_list == "panel-plugins": 

47 panel_plugins = [ 

48 "xfce4-battery-plugin", 

49 "xfce4-calculator-plugin", 

50 "xfce4-clipman-plugin", 

51 "xfce4-cpufreq-plugin", 

52 "xfce4-cpugraph-plugin", 

53 "xfce4-diskperf-plugin", 

54 "xfce4-docklike-plugin", 

55 "xfce4-eyes-plugin", 

56 "xfce4-fsguard-plugin", 

57 "xfce4-generic-slider", 

58 "xfce4-genmon-plugin", 

59 "xfce4-indicator-plugin", 

60 "xfce4-mailwatch-plugin", 

61 "xfce4-mount-plugin", 

62 "xfce4-mpc-plugin", 

63 "xfce4-netload-plugin", 

64 "xfce4-notes-plugin", 

65 "xfce4-places-plugin", 

66 "xfce4-pulseaudio-plugin", 

67 "xfce4-sample-plugin", 

68 "xfce4-sensors-plugin", 

69 "xfce4-smartbookmark-plugin", 

70 "xfce4-stopwatch-plugin", 

71 "xfce4-systemload-plugin", 

72 "xfce4-time-out-plugin", 

73 "xfce4-timer-plugin", 

74 "xfce4-verve-plugin", 

75 "xfce4-wavelan-plugin", 

76 "xfce4-weather-plugin", 

77 "xfce4-whiskermenu-plugin", 

78 "xfce4-windowck-plugin", 

79 "xfce4-xkb-plugin", 

80 ] 

81 return panel_plugins 

82 

83 elif component_group_list == "thunar-plugins": 

84 thunar_plugins = [ 

85 "thunar-archive-plugin", 

86 "thunar-media-tags-plugin", 

87 "thunar-shares-plugin", 

88 "thunar-vcs-plugin", 

89 ] 

90 return thunar_plugins 

91 

92 elif component_group_list == "www": 

93 www = [ 

94 "blog.xfce.org", 

95 "cdn.xfce.org", 

96 "forum.xfce.org", 

97 "moka", 

98 "wiki.xfce.org", 

99 "www.xfce.org", 

100 ] 

101 return www 

102 

103 elif component_group_list == "xfce": 

104 xfce = [ 

105 "exo", 

106 "garcon", 

107 "libxfce4ui", 

108 "libxfce4util", 

109 "libxfce4windowing", 

110 "thunar", 

111 "thunar-volman", 

112 "tumbler", 

113 "xfce4-appfinder", 

114 "xfce4-dev-tools", 

115 "xfce4-panel", 

116 "xfce4-power-manager", 

117 "xfce4-session", 

118 "xfce4-settings", 

119 "xfce-wayland-protocols", 

120 "xfconf", 

121 "xfdesktop", 

122 "xfwl4", 

123 "xfwm4", 

124 ] 

125 return xfce 

126 

127 elif component_group_list == "all_components": 

128 all_components = { 

129 "apps": "apps", 

130 "bindings": "bindings", 

131 "panel-plugins": "panel-plugins", 

132 "thunar-plugins": "thunar-plugins", 

133 "xfce": "xfce", 

134 "www": "www", 

135 } 

136 return all_components 

137 

138 else: 

139 return None 

140 

141 

142def press_any_key(): 

143 """Doesn't work for shift/control keys.""" 

144 file_descriptor = sys.stdin.fileno() 

145 tty_attributes = termios.tcgetattr(file_descriptor) 

146 try: 

147 print("Press any to continue...") 

148 tty.setraw(file_descriptor) 

149 return sys.stdin.read(1) 

150 finally: 

151 termios.tcsetattr(file_descriptor, termios.TCSADRAIN, tty_attributes) 

152 

153 

154def query_yes_no(question, answer="no"): 

155 """ 

156 Handles confirmation prompts. Used in install_xfce.py 

157 and purge_xfce.py 

158 """ 

159 valid = {"yes": "yes", "y": "yes", "no": "no", "n": "no"} 

160 prompt = " [(Y)es/(N)o/Default: No] " 

161 

162 while True: 

163 sys.stdout.write(question + prompt) 

164 choice = input().lower() 

165 try: 

166 if answer is not None and choice == "": 

167 return answer 

168 elif answer in valid: 

169 return valid[choice] 

170 except KeyError: 

171 sys.stdout.write("Please respond with 'yes' or 'no' (or 'y' or 'n').\n")