Skip to content

Commit f512fa8

Browse files
author
Johannes Holland
committed
black: fix formatting
1 parent a3a6450 commit f512fa8

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/tpmstream/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def parse_all_types(format_in, buffer):
267267
format_in_arg = {
268268
"dest": "format_in",
269269
"type": str,
270-
"choices": ["binary", "hex", "pcapng", "swtpm-log" ,"auto"],
270+
"choices": ["binary", "hex", "pcapng", "swtpm-log", "auto"],
271271
"default": "auto",
272272
"help": "input stream format, default is auto (--in=auto only works with --type=CommandResponseStream)",
273273
}

src/tpmstream/io/swtpm_log/marshal.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
VALID_HEX = b"0123456789ABCDEF"
77
VALID_WS = b" \r\n"
88

9-
STATE_WANT_CMD_MARKER = 0
10-
STATE_WANT_CMD_START = 1
9+
STATE_WANT_CMD_MARKER = 0
10+
STATE_WANT_CMD_START = 1
1111
STATE_WANT_HIGH_NIBBLE = 2
12-
STATE_WANT_LOW_NIBBLE = 3
12+
STATE_WANT_LOW_NIBBLE = 3
1313

1414
# File format we're parsing looks like this:
1515
#
@@ -44,6 +44,7 @@
4444
# TPM commands and responses respectively, where we
4545
# capture the following data and convert to binary.
4646

47+
4748
def parse_hex_string(buffer):
4849
"""Generator: hex string to bytes."""
4950
buffer = iter(buffer)
@@ -63,7 +64,7 @@ def parse_hex_string(buffer):
6364
if len(marker) != 0:
6465
raise ValueError("Incomplete command marker '%s'" % str(marker))
6566
return
66-
elif b == CMD_MARKER[len(marker):len(marker)+1]:
67+
elif b == CMD_MARKER[len(marker) : len(marker) + 1]:
6768
marker += b
6869

6970
if marker == CMD_MARKER:
@@ -75,11 +76,11 @@ def parse_hex_string(buffer):
7576
elif state == STATE_WANT_CMD_START:
7677
if b is None:
7778
raise ValueError("Missing command payload")
78-
elif b == b'\n':
79+
elif b == b"\n":
7980
state = STATE_WANT_HIGH_NIBBLE
8081
else:
8182
continue
82-
elif state == STATE_WANT_HIGH_NIBBLE:
83+
elif state == STATE_WANT_HIGH_NIBBLE:
8384
if b is None:
8485
return
8586
elif b in VALID_WS:

test/test_events.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
from tpmstream.io import bytes_from_files
1515
from tpmstream.io.binary import Binary
1616
from tpmstream.io.swtpm_log import SWTPMLog
17-
from tpmstream.spec.commands import CommandResponseStream, Command, Response, command_handle_types
17+
from tpmstream.spec.commands import (
18+
Command,
19+
CommandResponseStream,
20+
Response,
21+
command_handle_types,
22+
)
1823
from tpmstream.spec.structures.attribute_structures import TPMA_SESSION
1924
from tpmstream.spec.structures.constants import TPM_CC
2025

@@ -285,10 +290,7 @@ def test_binary_marshalling_unmarshalling_response(
285290

286291
class TestSWTPMLogs:
287292

288-
@pytest.mark.parametrize(
289-
"log_name",
290-
[ "fedora38", "win11" ]
291-
)
293+
@pytest.mark.parametrize("log_name", ["fedora38", "win11"])
292294
def test_marshalling(self, log_name):
293295
log_file = os.path.join("test", "swtpm", log_name + "-swtpm.log")
294296
with open(log_file, "rb") as log:

0 commit comments

Comments
 (0)