Conditions | 2 |
Total Lines | 81 |
Code Lines | 67 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | # -*- coding: utf-8 -*- |
||
109 | def msg_curse(self, args=None, max_width=None): |
||
110 | """Return the list to display in the curse interface.""" |
||
111 | # Init the return message |
||
112 | ret = [] |
||
113 | |||
114 | # Build the string message |
||
115 | # Header |
||
116 | ret.append(self.curse_add_line(self.view_data['version'], 'TITLE')) |
||
117 | ret.append(self.curse_add_line(self.view_data['psutil_version'])) |
||
118 | ret.append(self.curse_new_line()) |
||
119 | |||
120 | # Configuration file path |
||
121 | if 'configuration_file' in self.view_data: |
||
122 | ret.append(self.curse_new_line()) |
||
123 | ret.append(self.curse_add_line(self.view_data['configuration_file'])) |
||
124 | ret.append(self.curse_new_line()) |
||
125 | |||
126 | # Keys |
||
127 | ret.append(self.curse_new_line()) |
||
128 | ret.append(self.curse_add_line(self.view_data['sort_auto'])) |
||
129 | ret.append(self.curse_add_line(self.view_data['sort_network'])) |
||
130 | ret.append(self.curse_new_line()) |
||
131 | ret.append(self.curse_add_line(self.view_data['sort_cpu'])) |
||
132 | ret.append(self.curse_add_line(self.view_data['show_hide_alert'])) |
||
133 | ret.append(self.curse_new_line()) |
||
134 | |||
135 | ret.append(self.curse_add_line(self.view_data['sort_mem'])) |
||
136 | ret.append(self.curse_add_line(self.view_data['delete_warning_alerts'])) |
||
137 | ret.append(self.curse_new_line()) |
||
138 | ret.append(self.curse_add_line(self.view_data['sort_user'])) |
||
139 | ret.append(self.curse_add_line(self.view_data['delete_warning_critical_alerts'])) |
||
140 | ret.append(self.curse_new_line()) |
||
141 | ret.append(self.curse_add_line(self.view_data['sort_proc'])) |
||
142 | ret.append(self.curse_add_line(self.view_data['percpu'])) |
||
143 | ret.append(self.curse_new_line()) |
||
144 | ret.append(self.curse_add_line(self.view_data['sort_io'])) |
||
145 | ret.append(self.curse_add_line(self.view_data['show_hide_ip'])) |
||
146 | ret.append(self.curse_new_line()) |
||
147 | ret.append(self.curse_add_line(self.view_data['sort_cpu_times'])) |
||
148 | ret.append(self.curse_add_line(self.view_data['enable_disable_docker'])) |
||
149 | ret.append(self.curse_new_line()) |
||
150 | ret.append(self.curse_add_line(self.view_data['show_hide_diskio'])) |
||
151 | ret.append(self.curse_add_line(self.view_data['view_network_io_combination'])) |
||
152 | ret.append(self.curse_new_line()) |
||
153 | ret.append(self.curse_add_line(self.view_data['show_hide_filesystem'])) |
||
154 | ret.append(self.curse_add_line(self.view_data['view_cumulative_network'])) |
||
155 | ret.append(self.curse_new_line()) |
||
156 | ret.append(self.curse_add_line(self.view_data['show_hide_network'])) |
||
157 | ret.append(self.curse_add_line(self.view_data['show_hide_filesytem_freespace'])) |
||
158 | ret.append(self.curse_new_line()) |
||
159 | ret.append(self.curse_add_line(self.view_data['show_hide_sensors'])) |
||
160 | ret.append(self.curse_add_line(self.view_data['generate_graphs'])) |
||
161 | ret.append(self.curse_new_line()) |
||
162 | ret.append(self.curse_add_line(self.view_data['show_hide_left_sidebar'])) |
||
163 | ret.append(self.curse_add_line(self.view_data['reset_history'])) |
||
164 | ret.append(self.curse_new_line()) |
||
165 | ret.append(self.curse_add_line(self.view_data['enable_disable_process_stats'])) |
||
166 | ret.append(self.curse_add_line(self.view_data['show_hide_help'])) |
||
167 | ret.append(self.curse_new_line()) |
||
168 | ret.append(self.curse_add_line(self.view_data['enable_disable_quick_look'])) |
||
169 | ret.append(self.curse_add_line(self.view_data['diskio_iops'])) |
||
170 | ret.append(self.curse_new_line()) |
||
171 | ret.append(self.curse_add_line(self.view_data['enable_disable_top_extends_stats'])) |
||
172 | ret.append(self.curse_add_line(self.view_data['show_hide_top_menu'])) |
||
173 | ret.append(self.curse_new_line()) |
||
174 | ret.append(self.curse_add_line(self.view_data['enable_disable_short_processname'])) |
||
175 | ret.append(self.curse_add_line(self.view_data['show_hide_irq'])) |
||
176 | ret.append(self.curse_new_line()) |
||
177 | ret.append(self.curse_add_line(self.view_data['enable_disable_gpu'])) |
||
178 | ret.append(self.curse_add_line(self.view_data['enable_disable_mean_gpu'])) |
||
179 | ret.append(self.curse_new_line()) |
||
180 | ret.append(self.curse_add_line(self.view_data['enable_disable_irix'])) |
||
181 | ret.append(self.curse_add_line(self.view_data['quit'])) |
||
182 | ret.append(self.curse_new_line()) |
||
183 | |||
184 | ret.append(self.curse_new_line()) |
||
185 | |||
186 | ret.append(self.curse_add_line(self.view_data['edit_pattern_filter'])) |
||
187 | |||
188 | # Return the message with decoration |
||
189 | return ret |
||
190 |