applier #1

Merged
pim merged 9 commits from applier into main 2025-11-23 07:31:34 +00:00
2 changed files with 9 additions and 13 deletions
Showing only changes of commit 63585671dc - Show all commits

View File

@@ -41,18 +41,14 @@ class Dumper(VPPApi):
def write(self, outfile):
"""Emit the configuration to either stdout (outfile=='-') or a filename"""
config = self.cache_to_config()
if outfile and outfile == "-":
file = sys.stdout
outfile = "(stdout)"
else:
file = open(outfile, "w", encoding="utf-8")
config = self.cache_to_config()
print(yaml.dump(config), file=file)
if file is not sys.stdout:
file.close()
else:
with open(outfile, "w", encoding="utf-8") as file:
print(yaml.dump(config), file=file)
self.logger.info(f"Wrote YAML config to {outfile}")
def cache_to_config(self):

View File

@@ -1530,11 +1530,11 @@ class Reconciler:
if outfile and outfile == "-":
file = sys.stdout
outfile = "(stdout)"
else:
file = open(outfile, "w", encoding="utf-8")
if len(output) > 0:
print("\n".join(output), file=file)
if file is not sys.stdout:
file.close()
else:
with open(outfile, "w", encoding="utf-8") as file:
if len(output) > 0:
print("\n".join(output), file=file)
self.logger.info(f"Wrote {len(output)} lines to {outfile}")