Auto-format Python files with black

This patch is strictly the result of:
$ black $(git ls-files '*.py')

There have been no manual changes.
This commit is contained in:
Tom Krizek
2022-06-07 16:27:23 +02:00
parent 5d2b7cab08
commit c9cb8ae9eb
36 changed files with 1520 additions and 908 deletions

View File

@@ -14,29 +14,29 @@ import struct
class RawFormatHeader(dict):
'''
"""
A dictionary of raw-format header fields read from a zone file.
'''
"""
fields = [
'format',
'version',
'dumptime',
'flags',
'sourceserial',
'lastxfrin',
"format",
"version",
"dumptime",
"flags",
"sourceserial",
"lastxfrin",
]
def __init__(self, file_name):
header = struct.Struct('>IIIIII')
with open(file_name, 'rb') as data:
header = struct.Struct(">IIIIII")
with open(file_name, "rb") as data:
header_data = data.read(header.size)
super().__init__(zip(self.fields, header.unpack_from(header_data)))
def test_unsigned_serial_number():
'''
"""
Check whether all signed zone files in the "ns8" subdirectory contain the
serial number of the unsigned version of the zone in the raw-format header.
The test assumes that all "*.signed" files in the "ns8" subdirectory are in
@@ -51,18 +51,18 @@ def test_unsigned_serial_number():
- example[0-9][0-9].com.db.signed files are initially signed by
dnssec-signzone while the others - by named.
'''
"""
zones_with_unsigned_serial_missing = []
for signed_zone in sorted(glob.glob('ns8/*.signed')):
for signed_zone in sorted(glob.glob("ns8/*.signed")):
raw_header = RawFormatHeader(signed_zone)
# Ensure the unsigned serial number is placed where it is expected.
assert raw_header['format'] == 2
assert raw_header['version'] == 1
assert raw_header["format"] == 2
assert raw_header["version"] == 1
# Check whether the header flags indicate that the unsigned serial
# number is set and that the latter is indeed set.
if raw_header['flags'] & 0x02 == 0 or raw_header['sourceserial'] == 0:
if raw_header["flags"] & 0x02 == 0 or raw_header["sourceserial"] == 0:
zones_with_unsigned_serial_missing.append(signed_zone)
assert not zones_with_unsigned_serial_missing