From 156cb98fd034ea891ac78bc4c51dff9a9992b483 Mon Sep 17 00:00:00 2001 From: dmiller Date: Sun, 29 Dec 2019 20:05:05 +0000 Subject: [PATCH] Fix up some LGTM issues in ndiff. #1834 --- ndiff/ndiff.py | 8 +++----- ndiff/test-scans/anonymize.py | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ndiff/ndiff.py b/ndiff/ndiff.py index 85abba411..6be4c12a8 100755 --- a/ndiff/ndiff.py +++ b/ndiff/ndiff.py @@ -69,11 +69,8 @@ class Scan(object): def load_from_file(self, filename): """Load a scan from the Nmap XML file with the given filename.""" - f = open(filename, "r") - try: + with open(filename, "r") as f: self.load(f) - finally: - f.close() def write_nmaprun_open(self, writer): attrs = {} @@ -327,6 +324,8 @@ class Port(object): def spec_string(self): return u"%d/%s" % self.spec + __hash__ = None + def __cmp__(self, other): d = cmp(self.spec, other.spec) if d != 0: @@ -560,7 +559,6 @@ class ScanDiff(object): h_diff = HostDiff(host_a, host_b) cost += h_diff.cost if h_diff.cost > 0 or verbose: - host = host_a or host_b self.output_host_diff(h_diff) post_script_result_diffs = ScriptResultDiff.diff_lists( diff --git a/ndiff/test-scans/anonymize.py b/ndiff/test-scans/anonymize.py index 9ba612ace..4ee2e29d8 100755 --- a/ndiff/test-scans/anonymize.py +++ b/ndiff/test-scans/anonymize.py @@ -102,7 +102,6 @@ def repl_hostname(match): def anonymize_file(f): for line in f: - repls = [] line = re.sub(mac_re, repl_addr, line) line = re.sub(ipv4_re, repl_addr, line) line = re.sub(ipv6_re, repl_addr, line)