MCPcopy
hub / github.com/persepolisdm/persepolis / sortByStatus2

Method sortByStatus2

persepolis/scripts/mainwindow.py:3381–3465  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3379 self.sortByStatus2()
3380
3381 def sortByStatus2(self):
3382
3383 # find name of selected category
3384 current_category_tree_text = str(current_category_tree_index.data())
3385
3386 # find gid and status of downloads
3387 gid_status_dict = {}
3388 for row in range(self.download_table.rowCount()):
3389 status = self.download_table.item(row, 1).text()
3390 gid = self.download_table.item(row, 8).text()
3391 # assign a number to every status
3392 if status == 'complete':
3393 status_int = 1
3394 elif status == 'stopped':
3395 status_int = 2
3396 elif status == 'error':
3397 status_int = 3
3398 elif status == 'downloading':
3399 status_int = 4
3400 elif status == 'waiting':
3401 status_int = 5
3402 else:
3403 status_int = 6
3404
3405 # create a dictionary from gid and size_int of files in Bytes
3406 gid_status_dict[gid] = status_int
3407
3408 # sort gid_status_dict
3409 gid_sorted_list = sorted(gid_status_dict, key=gid_status_dict.get)
3410
3411 # get download information from data base
3412 if current_category_tree_text == 'All Downloads':
3413 downloads_dict = self.persepolis_db.returnItemsInDownloadTable()
3414 else:
3415 downloads_dict = self.persepolis_db.returnItemsInDownloadTable(current_category_tree_text)
3416
3417 # clear download_table
3418 self.download_table.clearContents()
3419
3420 j = 0
3421
3422 for gid in gid_sorted_list:
3423 # enter download rows according to gid_sorted_list
3424 download_info = downloads_dict[gid]
3425
3426 keys_list = ['file_name',
3427 'status',
3428 'size',
3429 'downloaded_size',
3430 'percent',
3431 'connections',
3432 'rate',
3433 'estimate_time_left',
3434 'gid',
3435 'link',
3436 'first_try_date',
3437 'last_try_date',
3438 'category'

Callers 1

sortByStatusMethod · 0.95

Calls 3

QTableWidgetItemClass · 0.90
updateCategoryTableMethod · 0.80

Tested by

no test coverage detected