(self)
| 37 | return [] |
| 38 | |
| 39 | def load_json_tasks(self) -> List[FileTranscriptionTask]: |
| 40 | task_ids: List[int] |
| 41 | try: |
| 42 | with open(self.tasks_list_file_path) as file: |
| 43 | task_ids = json.load(file) |
| 44 | except json.JSONDecodeError: |
| 45 | logging.debug( |
| 46 | "Got JSONDecodeError while reading tasks list file path, " |
| 47 | "resetting cache..." |
| 48 | ) |
| 49 | task_ids = [] |
| 50 | |
| 51 | tasks = [] |
| 52 | for task_id in task_ids: |
| 53 | try: |
| 54 | with open(self.get_task_path(task_id=task_id)) as file: |
| 55 | tasks.append(FileTranscriptionTask.from_json(file.read())) |
| 56 | except (FileNotFoundError, json.JSONDecodeError): |
| 57 | pass |
| 58 | |
| 59 | return tasks |
| 60 | |
| 61 | def save_json_tasks(self, tasks: List[FileTranscriptionTask]): |
| 62 | json_str = json.dumps([task.id for task in tasks]) |
no test coverage detected