mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Use 'with' statements for file open/close. #1834
This commit is contained in:
@@ -817,12 +817,9 @@ class NmapParserSAX(ParserBasics, ContentHandler):
|
||||
|
||||
def parse_file(self, filename):
|
||||
"""Parse an Nmap XML file from the named file."""
|
||||
f = open(filename, "r")
|
||||
try:
|
||||
with open(filename, "r") as f:
|
||||
self.parse(f)
|
||||
self.filename = filename
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
def _parse_nmaprun(self, attrs):
|
||||
run_tag = "nmaprun"
|
||||
|
||||
Reference in New Issue
Block a user