summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Tool/rpmutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Tool/rpmutils.py')
-rw-r--r--src/engine/SCons/Tool/rpmutils.py41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py
index 10bb28d..a2400ff 100644
--- a/src/engine/SCons/Tool/rpmutils.py
+++ b/src/engine/SCons/Tool/rpmutils.py
@@ -36,7 +36,7 @@ exact syntax.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/rpmutils.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/rpmutils.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import platform
@@ -482,9 +482,11 @@ def updateRpmDicts(rpmrc, pyfile):
"""
try:
# Read old rpmutils.py file
- oldpy = open(pyfile,"r").readlines()
+ with open(pyfile,"r") as f:
+ oldpy = f.readlines()
# Read current rpmrc.in file
- rpm = open(rpmrc,"r").readlines()
+ with open(rpmrc,"r") as f:
+ rpm = f.readlines()
# Parse for data
data = {}
# Allowed section names that get parsed
@@ -511,24 +513,23 @@ def updateRpmDicts(rpmrc, pyfile):
# Insert data
data[key][tokens[1]] = tokens[2:]
# Write new rpmutils.py file
- out = open(pyfile,"w")
- pm = 0
- for l in oldpy:
- if pm:
- if l.startswith('# End of rpmrc dictionaries'):
- pm = 0
+ with open(pyfile,"w") as out:
+ pm = 0
+ for l in oldpy:
+ if pm:
+ if l.startswith('# End of rpmrc dictionaries'):
+ pm = 0
+ out.write(l)
+ else:
out.write(l)
- else:
- out.write(l)
- if l.startswith('# Start of rpmrc dictionaries'):
- pm = 1
- # Write data sections to single dictionaries
- for key, entries in data.items():
- out.write("%s = {\n" % key)
- for arch in sorted(entries.keys()):
- out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch])))
- out.write("}\n\n")
- out.close()
+ if l.startswith('# Start of rpmrc dictionaries'):
+ pm = 1
+ # Write data sections to single dictionaries
+ for key, entries in data.items():
+ out.write("%s = {\n" % key)
+ for arch in sorted(entries.keys()):
+ out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch])))
+ out.write("}\n\n")
except:
pass