All pastes #37069 Raw Edit

parsePipe-function

public python v1 · immutable
#37069 ·published 2006-01-17 14:13 UTC
rendered paste body
def parsePipe(data):    """    Parses pipe-separated fields and handles escaped piped. Escape character    is backslash.    """    ret = []    splitted = data.split("|")    for s in splitted:        if ret and ret[-1].endswith("\\"):            ret[-1] = "%s|%s"%(ret[-1], s)        else:            ret.append(s)    return ret