diff options
author | Frederick Muriuki Muriithi | 2022-06-02 12:57:18 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-06-02 12:57:18 +0300 |
commit | 2f84b2eb1fecab4c381ad2dfd31277717cc9df2d (patch) | |
tree | c8a9080401ba40869454f55c88cd359bdbc393dd /quality_control | |
parent | 219248568252e7291f20105ce589c87c5a85f433 (diff) | |
download | gn-uploader-2f84b2eb1fecab4c381ad2dfd31277717cc9df2d.tar.gz |
Enable user abortion of file parsing
Enable the user to abort the background parsing of the file.
Diffstat (limited to 'quality_control')
-rw-r--r-- | quality_control/parsing.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/quality_control/parsing.py b/quality_control/parsing.py index 5b1809b..9f8e8ee 100644 --- a/quality_control/parsing.py +++ b/quality_control/parsing.py @@ -4,7 +4,7 @@ import os import collections from enum import Enum from functools import partial -from typing import Union, Iterable, Generator, Callable +from typing import Iterable, Generator, Callable, Optional import quality_control.average as avg import quality_control.standard_error as se @@ -65,7 +65,8 @@ def se_errors(line_number, fields): def collect_errors( filepath: str, filetype: FileType, strains: list, - update_progress: Union[Callable, None] = None) -> Generator: + update_progress: Optional[Callable] = None, + user_aborted: Optional[Callable] = lambda: False) -> Generator: """Run checks against file and collect all the errors""" errors = tuple() def __process_errors__(line_number, line, error_checker_fn, errors = tuple()): @@ -80,6 +81,9 @@ def collect_errors( with open(filepath, encoding="utf-8") as input_file: for line_number, line in enumerate(input_file, start=1): + if user_aborted(): + break + if line_number == 1: for error in __process_errors__( line_number, line, partial(header_errors, strains=strains), |