striplog/canstrat.py
def parse_canstrat(text):
    """
    Read all the rows and return a dict of the results.
    """
    result = {}
    for row in text.split('\n'):
        if not row:
            continue

        if len(row) < 8:  # Not a real record.
            continue

        # Read the metadata for this row/
        row_header = _process_row(row, columns_) or {'card': None}
        card = row_header['card']

        # Now we know the card type for this row, we can process it.
        if card is not None:
            item = _process_row(row, columns[card])

        this_list = result.get(card, [])
        this_list.append(item)
        result[card] = this_list

    # Flatten if possible.
    for c, d in result.items():
        if len(d) == 1:
            result[c] = d[0]

    return result
def parse_canstrat(text):
    """
    Read all the rows and return a dict of the results.
    """
    result = {}
    for row in text.split('\n'):
        if not row:
            continue

        if len(row) < 8:  # Not a real record.
            continue

        # Read the metadata for this row/
        row_header = _process_row(row, columns_) or {'card': None}
        card = row_header['card']

        # Now we know the card type for this row, we can process it.
        if card is not None:
            item = _process_row(row, columns[card])

        this_list = result.get(card, [])
        this_list.append(item)
        result[card] = this_list

    # Flatten if possible.
    for c, d in result.items():
        if len(d) == 1:
            result[c] = d[0]

    return result
def parse_canstrat ( text ) : result = { } for row in text . split ( '\n' ) : if not row : continue if len ( row ) < 8 : # Not a real record. continue # Read the metadata for this row/ row_header = _process_row ( row , columns_ ) or { 'card' : None } card = row_header [ 'card' ] # Now we know the card type for this row, we can process it. if card is not None : item = _process_row ( row , columns [ card ] ) this_list = result . get ( card , [ ] ) this_list . append ( item ) result [ card ] = this_list # Flatten if possible. for c , d in result . items ( ) : if len ( d ) == 1 : result [ c ] = d [ 0 ] return result
Read all the rows and return a dict of the results.
Read all the rows and return a dict of the results .