From 9c04223086bf606eaac6dc2848af80518210d823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Tue, 23 Jul 2019 13:30:08 +0200 Subject: New upstream version 3.1.0 --- engine/SCons/Tool/rpmutils.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'engine/SCons/Tool/rpmutils.py') diff --git a/engine/SCons/Tool/rpmutils.py b/engine/SCons/Tool/rpmutils.py index 6c87f73..a2400ff 100644 --- a/engine/SCons/Tool/rpmutils.py +++ b/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 a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan" +__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 -- cgit v1.2.3