[PATCH 1/7] rteval: rteval-cmd: Use "with" with open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use "with" for resource allocating operation open

Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>
---
 rteval-cmd | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/rteval-cmd b/rteval-cmd
index 2c775ee52f69..4598ba514ddc 100755
--- a/rteval-cmd
+++ b/rteval-cmd
@@ -72,15 +72,13 @@ def summarize(repfile, xslt):
         isarchive = True
 
     # Load the XSLT template
-    xsltfp = open(xslt, "r")
-    xsltdoc = lxml.etree.parse(xsltfp)
-    xsltprs = lxml.etree.XSLT(xsltdoc)
-    xsltfp.close()
+    with open(xslt, "r") as xsltfp:
+        xsltdoc = lxml.etree.parse(xsltfp)
+        xsltprs = lxml.etree.XSLT(xsltdoc)
 
     # Load the summay.xml report - with some simple sanity checks
-    xmlfp = open(summaryfile, "r")
-    xmldoc = lxml.etree.parse(xmlfp)
-    xmlfp.close()
+    with open(summaryfile, "r") as xmlfp:
+        xmldoc = lxml.etree.parse(xmlfp)
 
     if xmldoc.docinfo.root_name != 'rteval':
         raise RuntimeError("The report doesn't seem like a rteval summary report")
-- 
2.36.1




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux