def _read_txt(path):
    """Read a txt crashfile

    >>> new_path = Path(__file__).resolve().parent.parent
    >>> test_data_path = new_path / 'data' / 'tests'
    >>> info = _read_txt(test_data_path / 'crashfile.txt')
    >>> info['node']  # doctest: +ELLIPSIS
    '...func_preproc_task_machinegame_run_02_wf.carpetplot_wf.conf_plot'
    >>> info['traceback']  # doctest: +ELLIPSIS
    '...ValueError: zero-size array to reduction operation minimum which has no identity'

    """
    from pathlib import Path
    lines = Path(path).read_text().splitlines()
    data = {'file': str(path)}
    traceback_start = 0
    if lines[0].startswith('Node'):
        data['node'] = lines[0].split(': ', 1)[1].strip()
        data['node_dir'] = lines[1].split(': ', 1)[1].strip()
        inputs = []
        cur_key = ''
        cur_val = ''
        for i, line in enumerate(lines[5:]):
            if not line.strip():
                continue

            if line[0].isspace():
                cur_val += line
                continue

            if cur_val:
                inputs.append((cur_key, cur_val.strip()))

            if line.startswith("Traceback ("):
                traceback_start = i + 5
                break

            cur_key, cur_val = tuple(line.split(' = ', 1))

        data['inputs'] = sorted(inputs)
    else:
        data['node_dir'] = "Node crashed before execution"
    data['traceback'] = '\n'.join(lines[traceback_start:]).strip()
    return data
def _read_txt ( path ) : from pathlib import Path lines = Path ( path ) . read_text ( ) . splitlines ( ) data = { 'file' : str ( path ) } traceback_start = 0 if lines [ 0 ] . startswith ( 'Node' ) : data [ 'node' ] = lines [ 0 ] . split ( ': ' , 1 ) [ 1 ] . strip ( ) data [ 'node_dir' ] = lines [ 1 ] . split ( ': ' , 1 ) [ 1 ] . strip ( ) inputs = [ ] cur_key = '' cur_val = '' for i , line in enumerate ( lines [ 5 : ] ) : if not line . strip ( ) : continue if line [ 0 ] . isspace ( ) : cur_val += line continue if cur_val : inputs . append ( ( cur_key , cur_val . strip ( ) ) ) if line . startswith ( "Traceback (" ) : traceback_start = i + 5 break cur_key , cur_val = tuple ( line . split ( ' = ' , 1 ) ) data [ 'inputs' ] = sorted ( inputs ) else : data [ 'node_dir' ] = "Node crashed before execution" data [ 'traceback' ] = '\n' . join ( lines [ traceback_start : ] ) . strip ( ) return data
Read a txt crashfile

    >>> new_path = Path(__file__).resolve().parent.parent
    >>> test_data_path = new_path / 'data' / 'tests'
    >>> info = _read_txt(test_data_path / 'crashfile.txt')
    >>> info['node']  # doctest: +ELLIPSIS
    '...func_preproc_task_machinegame_run_02_wf.carpetplot_wf.conf_plot'
    >>> info['traceback']  # doctest: +ELLIPSIS
    '...ValueError: zero-size array to reduction operation minimum which has no identity'