format with Black
diff --git a/apps/show.py b/apps/show.py
index a4efe04..6329791 100644
--- a/apps/show.py
+++ b/apps/show.py
@@ -30,10 +30,10 @@
Reader that reads HCI packets from a "snoop" file (based on RFC 1761, but not exactly the same...)
'''
- DATALINK_H1 = 1001
- DATALINK_H4 = 1002
+ DATALINK_H1 = 1001
+ DATALINK_H4 = 1002
DATALINK_BSCP = 1003
- DATALINK_H5 = 1004
+ DATALINK_H5 = 1004
def __init__(self, source):
self.source = source
@@ -41,9 +41,16 @@
# Read the header
identification_pattern = source.read(8)
if identification_pattern.hex().lower() != '6274736e6f6f7000':
- raise ValueError('not a valid snoop file, unexpected identification pattern')
- (self.version_number, self.data_link_type) = struct.unpack('>II', source.read(8))
- if self.data_link_type != self.DATALINK_H4 and self.data_link_type != self.DATALINK_H1:
+ raise ValueError(
+ 'not a valid snoop file, unexpected identification pattern'
+ )
+ (self.version_number, self.data_link_type) = struct.unpack(
+ '>II', source.read(8)
+ )
+ if (
+ self.data_link_type != self.DATALINK_H4
+ and self.data_link_type != self.DATALINK_H1
+ ):
raise ValueError(f'datalink type {self.data_link_type} not supported')
def next_packet(self):
@@ -57,7 +64,7 @@
packet_flags,
cumulative_drops,
timestamp_seconds,
- timestamp_microsecond
+ timestamp_microsecond,
) = struct.unpack('>IIIIII', header)
# Abort on truncated packets
@@ -79,7 +86,10 @@
else:
packet_type = hci.HCI_ACL_DATA_PACKET
- return (packet_flags & 1, bytes([packet_type]) + self.source.read(included_length))
+ return (
+ packet_flags & 1,
+ bytes([packet_type]) + self.source.read(included_length),
+ )
else:
return (packet_flags & 1, self.source.read(included_length))
@@ -88,7 +98,12 @@
# Main
# -----------------------------------------------------------------------------
@click.command()
[email protected]('--format', type=click.Choice(['h4', 'snoop']), default='h4', help='Format of the input file')
[email protected](
+ '--format',
+ type=click.Choice(['h4', 'snoop']),
+ default='h4',
+ help='Format of the input file',
+)
@click.argument('filename')
def main(format, filename):
input = open(filename, 'rb')
@@ -97,6 +112,7 @@
def read_next_packet():
(0, packet_reader.next_packet())
+
else:
packet_reader = SnoopPacketReader(input)
read_next_packet = packet_reader.next_packet