From 7b357b7d72816bc803311909899a409a78075125 Mon Sep 17 00:00:00 2001 From: Michael Richardson Date: Tue, 17 Jan 2023 17:12:41 -0500 Subject: [PATCH] rather than removing a file (and possibly the carefully crafted symlink), just truncate the file after opening --- pyang/plugins/sid.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyang/plugins/sid.py b/pyang/plugins/sid.py index 97265662..fdf39fa2 100644 --- a/pyang/plugins/sid.py +++ b/pyang/plugins/sid.py @@ -761,10 +761,8 @@ def generate_file(self): for item in self.content['items']: del item['status'] - if os.path.exists(self.output_file_name): - os.remove(self.output_file_name) - with open(self.output_file_name, 'w') as outfile: + outfile.truncate(0) json.dump(self.content, outfile, indent=2) ########################################################