Commit d02e913c authored by Mattia Rizzolo's avatar Mattia Rizzolo

fix pep8 E261

Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mattia@debian.org>
parent e088169d
......@@ -316,7 +316,7 @@ class Changes(object):
checksums = self.get("Files")
field_name = "md5sum"
changed_files = None # appease pylint
changed_files = None # appease pylint
for changed_files in checksums:
if changed_files['name'] == os.path.basename(filename):
break
......
......@@ -84,10 +84,10 @@ class CbfsContainer(Archive):
CBFS_HEADER_MAGIC = 0x4F524243
CBFS_HEADER_VERSION1 = 0x31313131
CBFS_HEADER_VERSION2 = 0x31313132
CBFS_HEADER_SIZE = 8 * 4 # 8 * uint32_t
CBFS_HEADER_SIZE = 8 * 4 # 8 * uint32_t
# On 2015-12-15, the largest image produced by coreboot is 16 MiB
CBFS_MAXIMUM_FILE_SIZE = 24 * 2 ** 20 # 24 MiB
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)
......
......@@ -64,7 +64,7 @@ class Command(object, metaclass=abc.ABCMeta):
return ' '.join(map(lambda x: '{}' if x == self.path else shlex.quote(x), self.cmdline()))
def env(self):
return None # inherit parent environment by default
return None # inherit parent environment by default
# Define only if needed. We take care of closing stdin.
#def feed_stdin(self, stdin)
......
......@@ -112,7 +112,7 @@ class Container(object, metaclass=abc.ABCMeta):
def get_adjusted_members_sizes(self):
for name, member in self.get_adjusted_members():
if member.is_directory():
size = 4096 # default "size" of a directory
size = 4096 # default "size" of a directory
else:
size = path_apparent_size(member.path)
yield name, (member, size)
......
......@@ -36,7 +36,7 @@ try:
except ImportError: # noqa
tlsh = None
SMALL_FILE_THRESHOLD = 65536 # 64 kiB
SMALL_FILE_THRESHOLD = 65536 # 64 kiB
logger = logging.getLogger(__name__)
......@@ -58,7 +58,7 @@ def path_apparent_size(path=".", visited=None):
class File(object, metaclass=abc.ABCMeta):
if hasattr(magic, 'open'): # use Magic-file-extensions from file
if hasattr(magic, 'open'): # use Magic-file-extensions from file
@classmethod
def guess_file_type(self, path):
if not hasattr(self, '_mimedb'):
......@@ -72,7 +72,7 @@ class File(object, metaclass=abc.ABCMeta):
self._mimedb_encoding = magic.open(magic.MAGIC_MIME_ENCODING)
self._mimedb_encoding.load()
return self._mimedb_encoding.file(path)
else: # use python-magic
else: # use python-magic
@classmethod
def guess_file_type(self, path):
if not hasattr(self, '_mimedb'):
......@@ -125,14 +125,14 @@ class File(object, metaclass=abc.ABCMeta):
lambda m, t: t.search(m), file.magic_file_type),
(cls.FILE_TYPE_HEADER_PREFIX,
bytes.startswith, file.file_header),
) if test[0]] # filter out undefined tests
) if test[0]] # filter out undefined tests
all_tests = [test for test in (
(cls.FILE_EXTENSION_SUFFIX,
str.endswith, file.name),
(file_type_tests,
run_tests, any),
) if test[0]] # filter out undefined tests, inc. file_type_tests if it's empty
) if test[0]] # filter out undefined tests, inc. file_type_tests if it's empty
return run_tests(all, all_tests) if all_tests else False
......
......@@ -25,13 +25,13 @@ class Config(object):
max_diff_block_lines_saved = float("inf")
# hard limits, restricts single-file and multi-file formats
max_report_size = 40 * 2 ** 20 # 40 MB
max_diff_block_lines = 2 ** 10 # 1024 lines
max_report_size = 40 * 2 ** 20 # 40 MB
max_diff_block_lines = 2 ** 10 # 1024 lines
# structural limits, restricts single-file formats
# semi-restricts multi-file formats
max_page_size = 400 * 2 ** 10 # 400 kB
max_page_size_child = 200 * 2 ** 10 # 200 kB
max_page_diff_block_lines = 2 ** 7 # 128 lines
max_page_size = 400 * 2 ** 10 # 400 kB
max_page_size_child = 200 * 2 ** 10 # 200 kB
max_page_diff_block_lines = 2 ** 7 # 128 lines
max_text_report_size = 0
......
......@@ -293,7 +293,7 @@ def color_unified_diff(diff):
DIFFON = "\x01"
DIFFOFF = "\x02"
MAX_WF_SIZE = 1024 # any higher, and linediff takes >1 second and >200MB RAM
MAX_WF_SIZE = 1024 # any higher, and linediff takes >1 second and >200MB RAM
def _linediff_sane(x):
# turn non-printable chars into "."
......
......@@ -219,7 +219,7 @@ def output_node(ctx, difference, path, indentstr, indentnum):
ud_cont = ud_cont.send
udiff = udiff.pformatl(PartialString.of(ud_cont))
else:
for _ in ud_cont: pass # exhaust the iterator, avoids GeneratorExit
for _ in ud_cont: pass # exhaust the iterator, avoids GeneratorExit
ud_cont = None
# PartialString for this node
......@@ -237,7 +237,7 @@ def output_node(ctx, difference, path, indentstr, indentnum):
{-1}""", 2, cont).pformatl(indent, child)
t = cont(t, child)
assert len(t.holes) >= len(difference.details) + 1 # there might be extra holes for the unified diff continuation
assert len(t.holes) >= len(difference.details) + 1 # there might be extra holes for the unified diff continuation
return cont(t, u""), ud_cont
def output_header(css_url, our_css_url=False, icon_url=None):
......@@ -294,7 +294,7 @@ class HTMLSideBySidePresenter(object):
supports_visual_diffs = True
def __init__(self):
self.max_lines = Config().max_diff_block_lines # only for html-dir
self.max_lines = Config().max_diff_block_lines # only for html-dir
self.max_lines_parent = Config().max_page_diff_block_lines
self.max_page_size_child = Config().max_page_size_child
......@@ -370,11 +370,11 @@ class HTMLSideBySidePresenter(object):
if self.spl_rows >= self.max_lines:
raise DiffBlockLimitReached()
if self.spl_current_page == 0: # on parent page
if self.spl_current_page == 0: # on parent page
if self.spl_rows < self.max_lines_parent:
return False
logger.debug("new unified-diff subpage, parent page went over %s lines", self.max_lines_parent)
else: # on child page
else: # on child page
if self.bytes_max_total and self.bytes_written > self.bytes_max_total:
raise PrintLimitReached()
if self.spl_print_func.bytes_written < self.max_page_size_child:
......@@ -557,11 +557,11 @@ class HTMLPresenter(Presenter):
return templates.DIFFNODE_LIMIT
def output_difference(self, ctx, root_difference):
outputs = {} # nodes to their partial output
ancestors = {} # child nodes to ancestor nodes
outputs = {} # nodes to their partial output
ancestors = {} # child nodes to ancestor nodes
placeholder_len = len(self.output_node_placeholder("XXXXXXXXXXXXXXXX", not ctx.single_page))
continuations = {} # functions to print unified diff continuations (html-dir only)
printers = {} # nodes to their printers
continuations = {} # functions to print unified diff continuations (html-dir only)
printers = {} # nodes to their printers
def smallest_first(node, parscore):
depth = parscore[0] + 1 if parscore else 0
......@@ -569,7 +569,7 @@ class HTMLPresenter(Presenter):
# Difference is not comparable so use memory address in event of a tie
return depth, node.size_self(), id(node), parents + [node]
pruned = set() # children
pruned = set() # children
for node, score in root_difference.traverse_heapq(smallest_first, yield_score=True):
if node in pruned:
continue
......@@ -608,7 +608,7 @@ class HTMLPresenter(Presenter):
outputs[ancestor] = outputs[ancestor].pformat({node: placeholder})
self.maybe_print(ancestor, printers, outputs, continuations)
footer = output_footer()
if not make_new_subpage: # we hit a limit, either max-report-size or single-page
if not make_new_subpage: # we hit a limit, either max-report-size or single-page
if not outputs:
# no more holes, don't traverse any more nodes
break
......@@ -648,7 +648,7 @@ class HTMLPresenter(Presenter):
def ensure_jquery(self, jquery_url, basedir, default_override):
if jquery_url is None:
jquery_url = default_override
default_override = None # later, we can detect jquery_url was None
default_override = None # later, we can detect jquery_url was None
if jquery_url == 'disable' or not jquery_url:
return None
......
......@@ -79,7 +79,7 @@ def test_remove_temp_files_on_sigterm(capsys, tmpdir, monkeypatch):
os._exit(ret)
else:
_, ret = os.waitpid(pid, 0)
assert (ret >> 8) == 2 # having received SIGTERM is trouble
assert (ret >> 8) == 2 # having received SIGTERM is trouble
assert os.listdir(str(tmpdir)) == []
def test_ctrl_c_handling(tmpdir, monkeypatch, capsys):
......@@ -108,7 +108,7 @@ def test_no_differences(capsys):
def test_no_differences_directories(capsys, tmpdir):
def create_dir(x):
path = str(tmpdir.mkdir(x))
os.utime(path, (0, 0)) # Ensure consistent mtime
os.utime(path, (0, 0)) # Ensure consistent mtime
return path
ret, out, err = run(capsys, create_dir('a'), create_dir('b'))
......
......@@ -34,7 +34,7 @@ def run_read_write(capsys, diff, *args):
assert err == ''
assert exc.value.code == 1
assert out == get_data(diff) # presented-output is same as parsed-input
assert out == get_data(diff) # presented-output is same as parsed-input
return out
def run_diff_read(diffpath):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment