-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpretty_formatter.py
35 lines (28 loc) · 1.16 KB
/
pretty_formatter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from rich.console import Console
from rich.table import Table
from rich import box
from rich import print
from rich.panel import Panel
import pdb
console = Console()
def createTable(layer_two, layer_three, layer_four, packet, debug):
sourceMac = layer_two['sourceMac']
destMac = layer_two['destMac']
ethernetType = layer_two['ethernetType']
sourceIp = layer_three['sourceIp']
destIp = layer_three['destIp']
protocol = layer_four['protocol']
print(Panel.fit("Packet [red]{}".format(packet)))
table = Table(show_header=True, header_style="bold white", box=box.MINIMAL)
table.add_column("Identifier", style="green", width=20)
table.add_column("Value", style="dim", width=20)
table.add_row('Destination Mac Address', destMac)
table.add_row("Source Mac Address", sourceMac)
table.add_row('Ethernet Type', ethernetType)
table.add_row('Destination IP Address', destIp)
table.add_row('Source IP Address', sourceIp)
if protocol is not None:
table.add_row('Protocol', str(protocol))
console.print(table)
if debug is not None:
print(Panel.fit(debug))