def happy_edges(row, prefix=None):
    """
    Convert a row in HAPPY file and yield edges.
    """
    trans = maketrans("[](){}", "      ")
    row = row.strip().strip("+")
    row = row.translate(trans)
    scfs = [x.strip("+") for x in row.split(":")]
    for a, b in pairwise(scfs):
        oa = '<' if a.strip()[0] == '-' else '>'
        ob = '<' if b.strip()[0] == '-' else '>'

        is_uncertain = a[-1] == ' ' or b[0] == ' '

        a = a.strip().strip('-')
        b = b.strip().strip('-')

        if prefix:
            a = prefix + a
            b = prefix + b

        yield (a, b, oa, ob), is_uncertain
def happy_edges ( row , prefix = None ) : trans = maketrans ( "[](){}" , "      " ) row = row . strip ( ) . strip ( "+" ) row = row . translate ( trans ) scfs = [ x . strip ( "+" ) for x in row . split ( ":" ) ] for a , b in pairwise ( scfs ) : oa = '<' if a . strip ( ) [ 0 ] == '-' else '>' ob = '<' if b . strip ( ) [ 0 ] == '-' else '>' is_uncertain = a [ - 1 ] == ' ' or b [ 0 ] == ' ' a = a . strip ( ) . strip ( '-' ) b = b . strip ( ) . strip ( '-' ) if prefix : a = prefix + a b = prefix + b yield ( a , b , oa , ob ) , is_uncertain
Convert a row in HAPPY file and yield edges.