def __make_table(yfmtfunc, fmtfunc, endline, data, fxyz, sortx=None, sorty=None, seplinefunc=None):  # noqa: E501
    """Core function of the make_table suite, which generates the table"""
    vx = {}
    vy = {}
    vz = {}
    vxf = {}

    # Python 2 backward compatibility
    fxyz = lambda_tuple_converter(fxyz)

    tmp_len = 0
    for e in data:
        xx, yy, zz = [str(s) for s in fxyz(*e)]
        tmp_len = max(len(yy), tmp_len)
        vx[xx] = max(vx.get(xx, 0), len(xx), len(zz))
        vy[yy] = None
        vz[(xx, yy)] = zz

    vxk = list(vx)
    vyk = list(vy)
    if sortx:
        vxk.sort(key=sortx)
    else:
        try:
            vxk.sort(key=int)
        except Exception:
            try:
                vxk.sort(key=atol)
            except Exception:
                vxk.sort()
    if sorty:
        vyk.sort(key=sorty)
    else:
        try:
            vyk.sort(key=int)
        except Exception:
            try:
                vyk.sort(key=atol)
            except Exception:
                vyk.sort()

    if seplinefunc:
        sepline = seplinefunc(tmp_len, [vx[x] for x in vxk])
        print(sepline)

    fmt = yfmtfunc(tmp_len)
    print(fmt % "", end=' ')
    for x in vxk:
        vxf[x] = fmtfunc(vx[x])
        print(vxf[x] % x, end=' ')
    print(endline)
    if seplinefunc:
        print(sepline)
    for y in vyk:
        print(fmt % y, end=' ')
        for x in vxk:
            print(vxf[x] % vz.get((x, y), "-"), end=' ')
        print(endline)
    if seplinefunc:
        print(sepline)
def __make_table ( yfmtfunc , fmtfunc , endline , data , fxyz , sortx = None , sorty = None , seplinefunc = None ) : vx = { } vy = { } vz = { } vxf = { } fxyz = lambda_tuple_converter ( fxyz ) tmp_len = 0 for e in data : xx , yy , zz = [ str ( s ) for s in fxyz ( * e ) ] tmp_len = max ( len ( yy ) , tmp_len ) vx [ xx ] = max ( vx . get ( xx , 0 ) , len ( xx ) , len ( zz ) ) vy [ yy ] = None vz [ ( xx , yy ) ] = zz vxk = list ( vx ) vyk = list ( vy ) if sortx : vxk . sort ( key = sortx ) else : try : vxk . sort ( key = int ) except Exception : try : vxk . sort ( key = atol ) except Exception : vxk . sort ( ) if sorty : vyk . sort ( key = sorty ) else : try : vyk . sort ( key = int ) except Exception : try : vyk . sort ( key = atol ) except Exception : vyk . sort ( ) if seplinefunc : sepline = seplinefunc ( tmp_len , [ vx [ x ] for x in vxk ] ) print ( sepline ) fmt = yfmtfunc ( tmp_len ) print ( fmt % "" , end = ' ' ) for x in vxk : vxf [ x ] = fmtfunc ( vx [ x ] ) print ( vxf [ x ] % x , end = ' ' ) print ( endline ) if seplinefunc : print ( sepline ) for y in vyk : print ( fmt % y , end = ' ' ) for x in vxk : print ( vxf [ x ] % vz . get ( ( x , y ) , "-" ) , end = ' ' ) print ( endline ) if seplinefunc : print ( sepline )
Core function of the make_table suite, which generates the table