1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 05:01:29 +00:00

Use 'with' statements for file open/close. #1834

This commit is contained in:
dmiller
2019-12-30 06:46:34 +00:00
parent 02212559d2
commit 3e58be1551
5 changed files with 9 additions and 36 deletions

View File

@@ -485,13 +485,10 @@ for dir in dirs:
if INSTALLED_FILES_NAME == self.record:
distutils.log.warn("warning: installation record is overwriting "
"--record file '%s'." % self.record)
f = open(INSTALLED_FILES_NAME, "w")
try:
with open(INSTALLED_FILES_NAME, "w") as f:
for output in self.get_installed_files():
assert "\n" not in output
print >> f, output
finally:
f.close()
class my_uninstall(Command):