From: Erik Winkels Date: Fri, 13 Feb 2026 11:35:29 +0000 (+0100) Subject: Reinstate `while` usage. X-Git-Tag: rec-5.5.0-alpha0~1^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25deaed299b36c180733fefc70c831833aa210a9;p=thirdparty%2Fpdns.git Reinstate `while` usage. --- diff --git a/build-scripts/docker/repo-test/generate-repo-files.py b/build-scripts/docker/repo-test/generate-repo-files.py index 8b4f10e2a1..34d03a1c1b 100755 --- a/build-scripts/docker/repo-test/generate-repo-files.py +++ b/build-scripts/docker/repo-test/generate-repo-files.py @@ -94,31 +94,28 @@ def write_dockerfile (os, os_version, release): pkg = 'dnsdist' cmd = 'dnsdist' - f = open('{}{}.{}-{}'.format(g_dockerfile, release, os, os_version), 'w') - - # This comment was in the template for the `--nobest` part but that makes - # the template look even more different than the final output, so: - # - # > When should the logic be in the code and when in the template? :shrug: - # > I prefer it to be in the code but I also do not want to add extra vars - # > and logic to the code unless necessary. - f.write(tpl.render({ "os": os, - "os_image": os_image, - "os_version": os_version, - "release": release, - "cmd": cmd, - "pkg": pkg })) - f.close() + with open('{}{}.{}-{}'.format(g_dockerfile, release, os, os_version), 'w') as f: + # This comment was in the template for the `--nobest` part but that makes + # the template look even more different than the final output, so: + # + # > When should the logic be in the code and when in the template? :shrug: + # > I prefer it to be in the code but I also do not want to add extra vars + # > and logic to the code unless necessary. + f.write(tpl.render({ "os": os, + "os_image": os_image, + "os_version": os_version, + "release": release, + "cmd": cmd, + "pkg": pkg })) def write_list_file (os, os_version, release): tpl = g_env.get_template('pdns-list.jinja2') - f = open('pdns.list.{}.{}-{}'.format(release, os, os_version), 'w') - f.write(tpl.render({ "os": os, - "os_version": os_version, - "release": release })) - f.close() + with open('pdns.list.{}.{}-{}'.format(release, os, os_version), 'w') as f: + f.write(tpl.render({ "os": os, + "os_version": os_version, + "release": release })) def write_pkg_pin_file (release): @@ -129,9 +126,8 @@ def write_pkg_pin_file (release): elif release.startswith('dnsdist-'): pkg = 'dnsdist' - f = open('pkg-pin', 'w') - f.write(tpl.render({ "pkg": pkg })) - f.close() + with open('pkg-pin', 'w') as f: + f.write(tpl.render({ "pkg": pkg })) def write_release_files (release):