Skip to content

Commit

Permalink
Minor code clean-up after lint testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
devttys0 committed Aug 20, 2018
1 parent a4945a9 commit cd8ca7a
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 24 deletions.
12 changes: 6 additions & 6 deletions src/binwalk/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ def file_size(filename):
os.close(fd)


def strip_quoted_strings(string):
def strip_quoted_strings(quoted_string):
'''
Strips out data in between double quotes.
@string - String to strip.
@quoted_string - String to strip.
Returns a sanitized string.
'''
Expand All @@ -120,14 +120,14 @@ def strip_quoted_strings(string):
# double quotes, and this function should ignore those. However, it also means that any
# data between two quoted strings (ex: '"quote 1" you won't see me "quote
# 2"') will also be stripped.
return re.sub(r'\"(.*)\"', "", string)
return re.sub(r'\"(.*)\"', "", quoted_string)


def get_quoted_strings(string):
def get_quoted_strings(quoted_string):
'''
Returns a string comprised of all data in between double quotes.
@string - String to get quoted data from.
@quoted_string - String to get quoted data from.
Returns a string of quoted data on success.
Returns a blank string if no quoted data is present.
Expand All @@ -139,7 +139,7 @@ def get_quoted_strings(string):
# double quotes, and this function should ignore those. However, it also means that any
# data between two quoted strings (ex: '"quote 1" non-quoted data
# "quote 2"') will also be included.
return re.findall(r'\"(.*)\"', string)[0]
return re.findall(r'\"(.*)\"', quoted_string)[0]
except KeyboardInterrupt as e:
raise e
except Exception:
Expand Down
7 changes: 3 additions & 4 deletions src/binwalk/core/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,17 @@ class Signature(object):
Class to hold signature data and generate signature regular expressions.
'''

def __init__(self, id, first_line):
def __init__(self, sid, first_line):
'''
Class constructor.
@id - A ID value to uniquely identify this signature.
@sid - A ID value to uniquely identify this signature.
@first_line - The first SignatureLine of the signature (subsequent
SignatureLines should be added via self.append).
Returns None.
'''
self.id = id
self.id = sid
self.lines = [first_line]
self.title = first_line.format
self.offset = first_line.offset
Expand Down Expand Up @@ -551,7 +551,6 @@ def _analyze(self, signature, offset):
Returns a dictionary of tags parsed from the data.
'''
description = []
tag_strlen = None
max_line_level = 0
previous_line_end = 0
tags = {'id': signature.id, 'offset':
Expand Down
3 changes: 0 additions & 3 deletions src/binwalk/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import binwalk.core.common
import binwalk.core.settings
import binwalk.core.plugin
from threading import Thread
from binwalk.core.compat import *
from binwalk.core.exceptions import *

Expand Down Expand Up @@ -881,8 +880,6 @@ def argv(self, module, argv=sys.argv[1:]):
'''
kwargs = {'enabled': False}
last_priority = {}
longs = []
shorts = ""
parser = argparse.ArgumentParser(add_help=False)
# Hack: This allows the ListActionParser class to correllate short options to long options.
# There is probably a built-in way to do this in the
Expand Down
1 change: 0 additions & 1 deletion src/binwalk/core/plugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Core code for supporting and managing plugins.

import os
import sys
import imp
import inspect
import binwalk.core.common
Expand Down
2 changes: 1 addition & 1 deletion src/binwalk/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from binwalk.core.compat import *


class Settings:
class Settings(object):

'''
Binwalk settings class, used for accessing user and system file paths and general configuration settings.
Expand Down
1 change: 0 additions & 1 deletion src/binwalk/core/statuserver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Provides scan status information via a TCP socket service.
# Currently only works for signature scans.

import sys
import time
import errno
import threading
Expand Down
4 changes: 0 additions & 4 deletions src/binwalk/modules/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def build_headers(self):
def decompress(self, data):
result = None
description = None
i = 0

for header in self.headers:
i += 1
Expand Down Expand Up @@ -197,9 +196,6 @@ def extractor(self, file_name):
return retval

def decompress(self, data):
valid = True
description = None

# Looking for either a valid decompression, or an error indicating
# truncated input data
try:
Expand Down
1 change: 0 additions & 1 deletion src/binwalk/modules/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import os
import re
import sys
import stat
import shlex
import tempfile
Expand Down
1 change: 0 additions & 1 deletion src/binwalk/modules/hexdiff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import sys
import string
import binwalk.core.common as common
Expand Down
2 changes: 0 additions & 2 deletions src/binwalk/modules/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ def validate(self, r):
self.one_of_many = None

def scan_file(self, fp):
current_file_offset = 0

while True:
(data, dlen) = fp.read_block()
if dlen < 1:
Expand Down

0 comments on commit cd8ca7a

Please sign in to comment.