From 8f7cb6dad05aefeeee09b8c124fba0429aba4062 Mon Sep 17 00:00:00 2001 From: William Ballenthin Date: Thu, 2 Jul 2020 11:01:18 -0600 Subject: [PATCH] pep8 --- capa/features/__init__.py | 2 +- capa/render/vverbose.py | 16 ++++++++-------- tests/test_main.py | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/capa/features/__init__.py b/capa/features/__init__.py index 21d3dc30..c37ad4bd 100644 --- a/capa/features/__init__.py +++ b/capa/features/__init__.py @@ -17,7 +17,7 @@ def bytes_to_str(b): def hex_string(h): """ render hex string e.g. "0a40b1" as "0A 40 B1" """ - return ' '.join(h[i:i + 2] for i in range(0, len(h), 2)).upper() + return " ".join(h[i : i + 2] for i in range(0, len(h), 2)).upper() class Feature(object): diff --git a/capa/render/vverbose.py b/capa/render/vverbose.py index 0d8b0a93..db28baa0 100644 --- a/capa/render/vverbose.py +++ b/capa/render/vverbose.py @@ -40,11 +40,11 @@ def render_statement(ostream, match, statement, indent=0): # there's no additional logic in the feature part, just the existence of a feature. # so, we have to inline some of the feature rendering here. - child = statement['child'] - value = rutils.bold2(child[child['type']]) + child = statement["child"] + value = rutils.bold2(child[child["type"]]) - if child.get('description'): - ostream.write('count(%s(%s = %s)): ' % (child['type'], value, child['description'])) + if child.get("description"): + ostream.write("count(%s(%s = %s)): " % (child["type"], value, child["description"])) else: ostream.write("count(%s(%s)): " % (child["type"], value)) @@ -72,11 +72,11 @@ def render_statement(ostream, match, statement, indent=0): def render_feature(ostream, match, feature, indent=0): - ostream.write(' ' * indent) + ostream.write(" " * indent) - ostream.write(feature['type']) - ostream.write(': ') - ostream.write(rutils.bold2(feature[feature['type']])) + ostream.write(feature["type"]) + ostream.write(": ") + ostream.write(rutils.bold2(feature[feature["type"]])) if "description" in feature: ostream.write(" = ") diff --git a/tests/test_main.py b/tests/test_main.py index c434e414..356e970b 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -11,9 +11,9 @@ from capa.engine import * def test_main(sample_9324d1a8ae37a36ae560c37448c9705a): # tests rules can be loaded successfully and all output modes - assert capa.main.main([sample_9324d1a8ae37a36ae560c37448c9705a.path, '-vv']) == 0 - assert capa.main.main([sample_9324d1a8ae37a36ae560c37448c9705a.path, '-v']) == 0 - assert capa.main.main([sample_9324d1a8ae37a36ae560c37448c9705a.path, '-j']) == 0 + assert capa.main.main([sample_9324d1a8ae37a36ae560c37448c9705a.path, "-vv"]) == 0 + assert capa.main.main([sample_9324d1a8ae37a36ae560c37448c9705a.path, "-v"]) == 0 + assert capa.main.main([sample_9324d1a8ae37a36ae560c37448c9705a.path, "-j"]) == 0 assert capa.main.main([sample_9324d1a8ae37a36ae560c37448c9705a.path]) == 0 @@ -35,10 +35,10 @@ def test_main_single_rule(sample_9324d1a8ae37a36ae560c37448c9705a, tmpdir): def test_main_shellcode(sample_499c2a85f6e8142c3f48d4251c9c7cd6_raw32): - assert capa.main.main([sample_499c2a85f6e8142c3f48d4251c9c7cd6_raw32.path, '-vv', '-f', 'sc32']) == 0 - assert capa.main.main([sample_499c2a85f6e8142c3f48d4251c9c7cd6_raw32.path, '-v', '-f', 'sc32']) == 0 - assert capa.main.main([sample_499c2a85f6e8142c3f48d4251c9c7cd6_raw32.path, '-j', '-f', 'sc32']) == 0 - assert capa.main.main([sample_499c2a85f6e8142c3f48d4251c9c7cd6_raw32.path, '-f', 'sc32']) == 0 + assert capa.main.main([sample_499c2a85f6e8142c3f48d4251c9c7cd6_raw32.path, "-vv", "-f", "sc32"]) == 0 + assert capa.main.main([sample_499c2a85f6e8142c3f48d4251c9c7cd6_raw32.path, "-v", "-f", "sc32"]) == 0 + assert capa.main.main([sample_499c2a85f6e8142c3f48d4251c9c7cd6_raw32.path, "-j", "-f", "sc32"]) == 0 + assert capa.main.main([sample_499c2a85f6e8142c3f48d4251c9c7cd6_raw32.path, "-f", "sc32"]) == 0 def test_ruleset():