(self)
| 3479 | self.sortByFirstTry2() |
| 3480 | |
| 3481 | def sortByFirstTry2(self): |
| 3482 | # find gid and first try date |
| 3483 | gid_try_dict = {} |
| 3484 | for row in range(self.download_table.rowCount()): |
| 3485 | first_try_date = self.download_table.item(row, 10).text() |
| 3486 | gid = self.download_table.item(row, 8).text() |
| 3487 | |
| 3488 | # convert date and hour in first_try_date to a number |
| 3489 | # for example , first_try_date = '2016/11/05 , 07:45:38' |
| 3490 | # must be converted to 20161105074538 |
| 3491 | first_try_date_splited = first_try_date.split(' , ') |
| 3492 | date_list = first_try_date_splited[0].split('/') |
| 3493 | hour_list = first_try_date_splited[1].split(':') |
| 3494 | date_joind = "".join(date_list) |
| 3495 | hour_joind = "".join(hour_list) |
| 3496 | date_hour_str = date_joind + hour_joind |
| 3497 | date_hour = int(date_hour_str) |
| 3498 | |
| 3499 | # create a dictionary |
| 3500 | # gid as key and date_hour as value |
| 3501 | gid_try_dict[gid] = date_hour |
| 3502 | |
| 3503 | # sort |
| 3504 | gid_sorted_list = sorted( |
| 3505 | gid_try_dict, key=gid_try_dict.get, reverse=True) |
| 3506 | |
| 3507 | # clear download_table |
| 3508 | self.download_table.clearContents() |
| 3509 | |
| 3510 | # find name of selected category |
| 3511 | current_category_tree_text = str(current_category_tree_index.data()) |
| 3512 | |
| 3513 | # get download information from data base |
| 3514 | if current_category_tree_text == 'All Downloads': |
| 3515 | downloads_dict = self.persepolis_db.returnItemsInDownloadTable() |
| 3516 | else: |
| 3517 | downloads_dict = self.persepolis_db.returnItemsInDownloadTable(current_category_tree_text) |
| 3518 | |
| 3519 | j = 0 |
| 3520 | |
| 3521 | for gid in gid_sorted_list: |
| 3522 | # enter download rows according to gid_sorted_list |
| 3523 | download_info = downloads_dict[gid] |
| 3524 | |
| 3525 | keys_list = ['file_name', |
| 3526 | 'status', |
| 3527 | 'size', |
| 3528 | 'downloaded_size', |
| 3529 | 'percent', |
| 3530 | 'connections', |
| 3531 | 'rate', |
| 3532 | 'estimate_time_left', |
| 3533 | 'gid', |
| 3534 | 'link', |
| 3535 | 'first_try_date', |
| 3536 | 'last_try_date', |
| 3537 | 'category' |
| 3538 | ] |
no test coverage detected