Skip to content
Commits on Source (2)
......@@ -103,9 +103,16 @@ CBFS_MAXIMUM_FILE_SIZE = 24 * 2 ** 20 # 24 MiB
def is_header_valid(buf, size, offset=0):
magic, version, romsize, bootblocksize, align, cbfs_offset, architecture, pad = struct.unpack_from(
'!IIIIIIII', buf, offset
)
(
magic,
version,
romsize,
bootblocksize,
align,
cbfs_offset,
architecture,
pad,
) = struct.unpack_from('!IIIIIIII', buf, offset)
return (
magic == CBFS_HEADER_MAGIC
and (
......
......@@ -56,13 +56,20 @@ def parse_entries(f):
pos = f.tell()
x['ctime'], x['ctime_nano'], x['mtime'], x['mtime_nano'], x['dev'], x[
'inode'
], x['mode'], x['uid'], x['gid'], x['size'], x['sha'], x[
'flags'
] = struct.unpack(
'>LLLLLLLLLL20sH', f.read((4 * 10) + 20 + 2)
)
(
x['ctime'],
x['ctime_nano'],
x['mtime'],
x['mtime_nano'],
x['dev'],
x['inode'],
x['mode'],
x['uid'],
x['gid'],
x['size'],
x['sha'],
x['flags'],
) = struct.unpack('>LLLLLLLLLL20sH', f.read((4 * 10) + 20 + 2))
x['path'] = f.read(x['flags'] & 0x0FFF)
......
......@@ -624,9 +624,12 @@ class SideBySideDiff:
if m:
yield from self.empty_buffer()
hunk_data = map(lambda x: x == "" and 1 or int(x), m.groups())
self.hunk_off1, self.hunk_size1, self.hunk_off2, self.hunk_size2 = (
hunk_data
)
(
self.hunk_off1,
self.hunk_size1,
self.hunk_off2,
self.hunk_size2,
) = hunk_data
self.line1, self.line2 = self.hunk_off1, self.hunk_off2
yield "H", (
self.hunk_off1,
......
......@@ -162,7 +162,7 @@ def test_dot_changes_no_differences_exclude_buildinfo(
@skip_unless_module_exists('debian.deb822')
def test_dot_changes_identical_contents_and_different_files(
dot_changes_differences_identical_contents_and_different_files
dot_changes_differences_identical_contents_and_different_files,
):
assert dot_changes_differences_identical_contents_and_different_files[0]
expected_diff = get_data(
......@@ -178,7 +178,7 @@ def test_dot_changes_identical_contents_and_different_files(
@skip_unless_module_exists('debian.deb822')
def test_dot_changes_different_contents_and_identical_files(
dot_changes_differences_different_contents_and_identical_files
dot_changes_differences_different_contents_and_identical_files,
):
assert dot_changes_differences_different_contents_and_identical_files[0]
assert dot_changes_differences_different_contents_and_identical_files[1]
......
......@@ -22,7 +22,7 @@ import glob
import diffoscope
import subprocess
from .utils.tools import skip_unless_tools_exist
from .utils.tools import skip_unless_tool_is_at_least
ALLOWED_TEST_FILES = {
# Data files we would prefer to generate dynamically
......@@ -238,7 +238,15 @@ ALLOWED_TEST_FILES = {
}
@skip_unless_tools_exist('black')
def black_version():
try:
out = subprocess.check_output(('black', '--version'))
except subprocess.CalledProcessError as e:
out = e.output
return out.decode('utf-8').rsplit(' ', 1)[-1]
@skip_unless_tool_is_at_least('black', black_version, '19.10b0')
def test_code_is_black_clean():
output = subprocess.check_output(
('black', '--diff', '.'), stderr=subprocess.PIPE
......