diff options
| author | jvoisin | 2011-07-26 14:37:32 +0200 |
|---|---|---|
| committer | jvoisin | 2011-07-26 14:37:32 +0200 |
| commit | 72e73f1f844d542ffe9d5d9cc18ad4290167d230 (patch) | |
| tree | d71d48978c3e1403a6f3207d2ca49b22c5c39601 | |
| parent | e62ae6a87f630cbd389cf1b75672b06cd56973c8 (diff) | |
Documentation, and more pylint conformity
| -rw-r--r-- | gui.py | 74 |
1 files changed, 45 insertions, 29 deletions
| @@ -16,7 +16,7 @@ SUPPORTED = (('image/png', 'image/jpeg', 'image/gif', | |||
| 16 | '*.tar', '*.tar.bz2', '*.tar.gz', '*.mp3')) | 16 | '*.tar', '*.tar.bz2', '*.tar.gz', '*.mp3')) |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | class cfile(GObject.GObject): | 19 | class CFile(GObject.GObject): |
| 20 | ''' | 20 | ''' |
| 21 | Contain the class-file of the file "path" | 21 | Contain the class-file of the file "path" |
| 22 | This class exist just to be "around" my parser.Generic_parser class, | 22 | This class exist just to be "around" my parser.Generic_parser class, |
| @@ -57,7 +57,7 @@ class ListStoreApp: | |||
| 57 | vbox.pack_start(content, True, True, 0) | 57 | vbox.pack_start(content, True, True, 0) |
| 58 | 58 | ||
| 59 | #parser.class - name - type - cleaned | 59 | #parser.class - name - type - cleaned |
| 60 | self.liststore= Gtk.ListStore(cfile, str, str, str) | 60 | self.liststore = Gtk.ListStore(CFile, str, str, str) |
| 61 | 61 | ||
| 62 | treeview = Gtk.TreeView(model=self.liststore) | 62 | treeview = Gtk.TreeView(model=self.liststore) |
| 63 | treeview.set_search_column(1) # name column is searchable | 63 | treeview.set_search_column(1) # name column is searchable |
| @@ -118,8 +118,8 @@ class ListStoreApp: | |||
| 118 | colname = ['Filename', 'Mimetype', 'Cleaned'] | 118 | colname = ['Filename', 'Mimetype', 'Cleaned'] |
| 119 | 119 | ||
| 120 | for i, j in enumerate(colname): | 120 | for i, j in enumerate(colname): |
| 121 | filenameColumn = Gtk.CellRendererText() | 121 | filename_column = Gtk.CellRendererText() |
| 122 | column = Gtk.TreeViewColumn(j, filenameColumn, text=i + 1) | 122 | column = Gtk.TreeViewColumn(j, filename_column, text=i + 1) |
| 123 | column.set_sort_column_id(i + 1) | 123 | column.set_sort_column_id(i + 1) |
| 124 | treeview.append_column(column) | 124 | treeview.append_column(column) |
| 125 | 125 | ||
| @@ -189,7 +189,7 @@ class ListStoreApp: | |||
| 189 | filter.add_pattern(item) | 189 | filter.add_pattern(item) |
| 190 | return filter | 190 | return filter |
| 191 | 191 | ||
| 192 | def add_files(self, button): | 192 | def add_files(self, _): |
| 193 | ''' | 193 | ''' |
| 194 | Add the files chosed by the filechoser ("Add" button) | 194 | Add the files chosed by the filechoser ("Add" button) |
| 195 | ''' | 195 | ''' |
| @@ -225,12 +225,15 @@ class ListStoreApp: | |||
| 225 | ''' | 225 | ''' |
| 226 | Append selected files by add_file to the self.liststore | 226 | Append selected files by add_file to the self.liststore |
| 227 | ''' | 227 | ''' |
| 228 | cf = cfile(item, self.backup, self.add2archive) | 228 | cf = CFile(item, self.backup, self.add2archive) |
| 229 | if cf.file is not None: | 229 | if cf.file is not None: |
| 230 | self.liststore.append([cf, cf.file.filename, | 230 | self.liststore.append([cf, cf.file.filename, |
| 231 | cf.file.mime, 'unknow']) | 231 | cf.file.mime, 'unknow']) |
| 232 | 232 | ||
| 233 | def about(self, button=None): | 233 | def about(self, _): |
| 234 | ''' | ||
| 235 | About popup | ||
| 236 | ''' | ||
| 234 | w = Gtk.AboutDialog() | 237 | w = Gtk.AboutDialog() |
| 235 | w.set_version(__version__) | 238 | w.set_version(__version__) |
| 236 | w.set_copyright('GNU Public License v2') | 239 | w.set_copyright('GNU Public License v2') |
| @@ -243,7 +246,7 @@ class ListStoreApp: | |||
| 243 | if click: | 246 | if click: |
| 244 | w.destroy() | 247 | w.destroy() |
| 245 | 248 | ||
| 246 | def preferences(self, button=None): | 249 | def preferences(self, _): |
| 247 | ''' | 250 | ''' |
| 248 | Preferences popup | 251 | Preferences popup |
| 249 | ''' | 252 | ''' |
| @@ -288,26 +291,36 @@ non-anonymised) file to outputed archive') | |||
| 288 | dialog.destroy() | 291 | dialog.destroy() |
| 289 | 292 | ||
| 290 | def invert(self, button, name): # still not better :/ | 293 | def invert(self, button, name): # still not better :/ |
| 294 | ''' | ||
| 295 | Invert a preference state | ||
| 296 | ''' | ||
| 291 | if name is 'force': | 297 | if name is 'force': |
| 292 | self.force = not self.force | 298 | self.force = not self.force |
| 293 | elif name is 'ugly': | 299 | elif name is 'add2archive': |
| 294 | self.ugly = not self.ugly | 300 | self.add2archive = not self.add2archive |
| 295 | elif name is 'backup': | 301 | elif name is 'backup': |
| 296 | self.backup = not self.backup | 302 | self.backup = not self.backup |
| 297 | 303 | ||
| 298 | def clear_model(self, button=None): | 304 | def clear_model(self, button=None): |
| 299 | self.liststore.clear() | 305 | self.liststore.clear() |
| 300 | 306 | ||
| 301 | def all_if_empy(self, iter): | 307 | def all_if_empy(self, iterator): |
| 302 | if not iter: | 308 | ''' |
| 309 | if no elements are selected, all elements are processed | ||
| 310 | thank's to this function | ||
| 311 | ''' | ||
| 312 | if not iterator: | ||
| 303 | return xrange(len(self.liststore)) | 313 | return xrange(len(self.liststore)) |
| 304 | else: | 314 | else: |
| 305 | return iter | 315 | return iterator |
| 306 | 316 | ||
| 307 | def mat_check(self, button=None): | 317 | def mat_check(self, _): |
| 308 | _, iter = self.selection.get_selected_rows() | 318 | ''' |
| 309 | iter = self.all_if_empy(iter) | 319 | Check if selected elements are clean |
| 310 | for i in iter: | 320 | ''' |
| 321 | _, iterator = self.selection.get_selected_rows() | ||
| 322 | iterator = self.all_if_empy(iterator) | ||
| 323 | for i in iterator: | ||
| 311 | if self.liststore[i][0].file.is_clean(): | 324 | if self.liststore[i][0].file.is_clean(): |
| 312 | string = 'clean' | 325 | string = 'clean' |
| 313 | else: | 326 | else: |
| @@ -315,10 +328,13 @@ non-anonymised) file to outputed archive') | |||
| 315 | logging.info('%s is %s' % (self.liststore[i][1], string)) | 328 | logging.info('%s is %s' % (self.liststore[i][1], string)) |
| 316 | self.liststore[i][3] = string | 329 | self.liststore[i][3] = string |
| 317 | 330 | ||
| 318 | def mat_clean(self, button=None): | 331 | def mat_clean(self, _): |
| 319 | _, iter = self.selection.get_selected_rows() | 332 | ''' |
| 320 | iter = self.all_if_empy(iter) | 333 | Clean selected elements |
| 321 | for i in iter: | 334 | ''' |
| 335 | _, iterator = self.selection.get_selected_rows() | ||
| 336 | iterator = self.all_if_empy(iterator) | ||
| 337 | for i in iterator: | ||
| 322 | logging.info('Cleaning %s' % self.liststore[i][1]) | 338 | logging.info('Cleaning %s' % self.liststore[i][1]) |
| 323 | if self.liststore[i][3] is not 'clean': | 339 | if self.liststore[i][3] is not 'clean': |
| 324 | if self.force: | 340 | if self.force: |
| @@ -328,10 +344,13 @@ non-anonymised) file to outputed archive') | |||
| 328 | self.liststore[i][0].file.remove_all() | 344 | self.liststore[i][0].file.remove_all() |
| 329 | self.liststore[i][3] = 'clean' | 345 | self.liststore[i][3] = 'clean' |
| 330 | 346 | ||
| 331 | def mat_clean_dirty(self, button=None): | 347 | def mat_clean_dirty(self, _): |
| 332 | _, iter = self.selection.get_selected_rows() | 348 | ''' |
| 333 | iter = self.all_if_empy(iter) | 349 | Clean selected elements (ugly way) |
| 334 | for i in iter: | 350 | ''' |
| 351 | _, iterator = self.selection.get_selected_rows() | ||
| 352 | iterator = self.all_if_empy(iterator) | ||
| 353 | for i in iterator: | ||
| 335 | logging.info('Cleaning (lossy way) %s' % self.liststore[i][1]) | 354 | logging.info('Cleaning (lossy way) %s' % self.liststore[i][1]) |
| 336 | if self.liststore[i][3] is not 'clean': | 355 | if self.liststore[i][3] is not 'clean': |
| 337 | if self.force: | 356 | if self.force: |
| @@ -342,9 +361,6 @@ non-anonymised) file to outputed archive') | |||
| 342 | self.liststore[i][3] = 'clean' | 361 | self.liststore[i][3] = 'clean' |
| 343 | 362 | ||
| 344 | 363 | ||
| 345 | def main(): | 364 | if __name__ == '__main__': |
| 346 | ListStoreApp() | 365 | ListStoreApp() |
| 347 | Gtk.main() | 366 | Gtk.main() |
| 348 | |||
| 349 | if __name__ == '__main__': | ||
| 350 | main() | ||
