MCPcopy Index your code
hub / github.com/secdev/scapy / __make_table

Function __make_table

scapy/utils.py:3402–3480  ·  view source on GitHub ↗

Core function of the make_table suite, which generates the table

(
    yfmtfunc,  # type: Callable[[int], str]
    fmtfunc,  # type: Callable[[int], str]
    endline,  # type: str
    data,  # type: List[Tuple[Packet, Packet]]
    fxyz,  # type: Callable[[Packet, Packet], Tuple[Any, Any, Any]]
    sortx=None,  # type: Optional[Callable[[str], Tuple[Any, ...]]]
    sorty=None,  # type: Optional[Callable[[str], Tuple[Any, ...]]]
    seplinefunc=None,  # type: Optional[Callable[[int, List[int]], str]]
    dump=False  # type: bool
)

Source from the content-addressed store, hash-verified

3400
3401
3402def __make_table(
3403 yfmtfunc, # type: Callable[[int], str]
3404 fmtfunc, # type: Callable[[int], str]
3405 endline, # type: str
3406 data, # type: List[Tuple[Packet, Packet]]
3407 fxyz, # type: Callable[[Packet, Packet], Tuple[Any, Any, Any]]
3408 sortx=None, # type: Optional[Callable[[str], Tuple[Any, ...]]]
3409 sorty=None, # type: Optional[Callable[[str], Tuple[Any, ...]]]
3410 seplinefunc=None, # type: Optional[Callable[[int, List[int]], str]]
3411 dump=False # type: bool
3412):
3413 # type: (...) -> Optional[str]
3414 """Core function of the make_table suite, which generates the table"""
3415 vx = {} # type: Dict[str, int]
3416 vy = {} # type: Dict[str, Optional[int]]
3417 vz = {} # type: Dict[Tuple[str, str], str]
3418 vxf = {} # type: Dict[str, str]
3419
3420 tmp_len = 0
3421 for e in data:
3422 xx, yy, zz = [str(s) for s in fxyz(*e)]
3423 tmp_len = max(len(yy), tmp_len)
3424 vx[xx] = max(vx.get(xx, 0), len(xx), len(zz))
3425 vy[yy] = None
3426 vz[(xx, yy)] = zz
3427
3428 vxk = list(vx)
3429 vyk = list(vy)
3430 if sortx:
3431 vxk.sort(key=sortx)
3432 else:
3433 try:
3434 vxk.sort(key=int)
3435 except Exception:
3436 try:
3437 vxk.sort(key=atol)
3438 except Exception:
3439 vxk.sort()
3440 if sorty:
3441 vyk.sort(key=sorty)
3442 else:
3443 try:
3444 vyk.sort(key=int)
3445 except Exception:
3446 try:
3447 vyk.sort(key=atol)
3448 except Exception:
3449 vyk.sort()
3450
3451 s = ""
3452 if seplinefunc:
3453 sepline = seplinefunc(tmp_len, [vx[x] for x in vxk])
3454 s += sepline + "\n"
3455
3456 fmt = yfmtfunc(tmp_len)
3457 s += fmt % ""
3458 s += ' '
3459 for x in vxk:

Callers 3

make_tableFunction · 0.85
make_lined_tableFunction · 0.85
make_tex_tableFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected