Coverage for src/cappdata.py: 9.23%

47 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2024-12-30 22:19 -0800

1""" 

2Name: cappdata.py 

3Purpose: component lists and query function for use with 

4 xfce-repocapp.py and associated scripts 

5 

6source: https://gitlab.com/kevinbowen/xfce-repocapp 

7version: 0.8.7 

8updated: 20230109 

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-vala"] 

44 return bindings 

45 

46 elif component_group_list == "xfce": 

47 xfce = [ 

48 "exo", 

49 "garcon", 

50 "libxfce4ui", 

51 "libxfce4util", 

52 "libxfce4windowing", 

53 "thunar", 

54 "thunar-volman", 

55 "tumbler", 

56 "xfce4-appfinder", 

57 "xfce4-dev-tools", 

58 "xfce4-panel", 

59 "xfce4-power-manager", 

60 "xfce4-session", 

61 "xfce4-settings", 

62 "xfconf", 

63 "xfdesktop", 

64 "xfwm4", 

65 ] 

66 return xfce 

67 

68 elif component_group_list == "panel-plugins": 

69 panel_plugins = [ 

70 "xfce4-battery-plugin", 

71 "xfce4-calculator-plugin", 

72 "xfce4-clipman-plugin", 

73 "xfce4-cpufreq-plugin", 

74 "xfce4-cpugraph-plugin", 

75 "xfce4-datetime-plugin", 

76 "xfce4-diskperf-plugin", 

77 "xfce4-docklike-plugin", 

78 "xfce4-embed-plugin", 

79 "xfce4-eyes-plugin", 

80 "xfce4-fsguard-plugin", 

81 "xfce4-generic-slider", 

82 "xfce4-genmon-plugin", 

83 "xfce4-indicator-plugin", 

84 "xfce4-mailwatch-plugin", 

85 "xfce4-mount-plugin", 

86 "xfce4-mpc-plugin", 

87 "xfce4-netload-plugin", 

88 "xfce4-notes-plugin", 

89 "xfce4-places-plugin", 

90 "xfce4-pulseaudio-plugin", 

91 "xfce4-sample-plugin", 

92 "xfce4-sensors-plugin", 

93 "xfce4-smartbookmark-plugin", 

94 "xfce4-statusnotifier-plugin", 

95 "xfce4-stopwatch-plugin", 

96 "xfce4-systemload-plugin", 

97 "xfce4-time-out-plugin", 

98 "xfce4-timer-plugin", 

99 "xfce4-verve-plugin", 

100 "xfce4-wavelan-plugin", 

101 "xfce4-weather-plugin", 

102 "xfce4-whiskermenu-plugin", 

103 "xfce4-windowck-plugin", 

104 "xfce4-xkb-plugin", 

105 ] 

106 return panel_plugins 

107 

108 elif component_group_list == "thunar-plugins": 

109 thunar_plugins = [ 

110 "thunar-archive-plugin", 

111 "thunar-media-tags-plugin", 

112 "thunar-shares-plugin", 

113 "thunar-vcs-plugin", 

114 ] 

115 return thunar_plugins 

116 

117 elif component_group_list == "www": 

118 www = [ 

119 "archive.xfce.org", 

120 "blog.xfce.org", 

121 "cdn.xfce.org", 

122 "forum.xfce.org", 

123 "moka", 

124 "wiki.xfce.org", 

125 "www.xfce.org", 

126 ] 

127 return www 

128 

129 elif component_group_list == "all_components": 

130 all_components = { 

131 "apps": "apps", 

132 "bindings": "bindings", 

133 "xfce": "xfce", 

134 "panel-plugins": "panel-plugins", 

135 "thunar-plugins": "thunar-plugins", 

136 "www": "www", 

137 } 

138 return all_components 

139 

140 else: 

141 return None 

142 

143 

144def press_any_key(): 

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

146 file_descriptor = sys.stdin.fileno() 

147 tty_attributes = termios.tcgetattr(file_descriptor) 

148 try: 

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

150 tty.setraw(file_descriptor) 

151 return sys.stdin.read(1) 

152 finally: 

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

154 

155 

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

157 """ 

158 Handles confirmation prompts. Used in install_xfce.py 

159 and purge_xfce.py 

160 """ 

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

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

163 

164 while True: 

165 sys.stdout.write(question + prompt) 

166 choice = input().lower() 

167 try: 

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

169 return answer 

170 elif answer in valid: 

171 return valid[choice] 

172 except KeyError: 

173 sys.stdout.write( 

174 "Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n" 

175 )