mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Replace key existence tests with dict.get()
Replaced instances of this pattern:
if 'key' in somedict:
var = somedict['key']
else:
var = ""
...with this much simpler pattern:
var = somedict.get('key', "")
Some variations, like returning None if the key is not found were also
replaced.
This commit is contained in:
@@ -293,18 +293,12 @@ class ScanChooser(HIGVBox):
|
||||
"""Return the currently selected scan's parsed output as an NmapParser
|
||||
object, or None if no valid scan is selected."""
|
||||
selected_scan = self.combo_scan.child.get_text()
|
||||
if selected_scan in self.scan_dict:
|
||||
return self.scan_dict[selected_scan]
|
||||
# What's typed in the entry doesn't match a registered scan.
|
||||
return None
|
||||
return self.scan_dict.get(selected_scan)
|
||||
|
||||
def get_nmap_output(self):
|
||||
"""Return the currently selected scan's output as a string, or None if
|
||||
no valid scan is selected."""
|
||||
parsed = self.parsed_scan
|
||||
if parsed is not None:
|
||||
return parsed.nmap_output
|
||||
return None
|
||||
return self.parsed_scan
|
||||
|
||||
nmap_output = property(get_nmap_output)
|
||||
parsed_scan = property(get_parsed_scan)
|
||||
|
||||
Reference in New Issue
Block a user