diff mbox series

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

Message ID 20220603161224.10947-1-jkacur@redhat.com
State New
Headers show
Series [1/7] rteval: rteval-cmd: Use "with" with open | expand

Commit Message

John Kacur June 3, 2022, 4:12 p.m. UTC
Use "with" for resource allocating operation open

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 rteval-cmd | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
diff mbox series

Patch

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")