From a358bce0d99eff3154954f9ae044f257dea3464a Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Sat, 17 Feb 2018 17:25:50 +0300 Subject: [PATCH] boards.txt.py: fix extra newline at the end of JSON output --- package/package_esp8266com_index.template.json | 1 - tools/boards.txt.py | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/package/package_esp8266com_index.template.json b/package/package_esp8266com_index.template.json index 177a866b20..1d08279b3d 100644 --- a/package/package_esp8266com_index.template.json +++ b/package/package_esp8266com_index.template.json @@ -261,4 +261,3 @@ } ] } - diff --git a/tools/boards.txt.py b/tools/boards.txt.py index 066ccf52b6..cbf076d0c5 100755 --- a/tools/boards.txt.py +++ b/tools/boards.txt.py @@ -1190,14 +1190,10 @@ def package (): newfilestr = re.sub(r'"boards":[^\]]*\],', substitution, filestr, re.MULTILINE) if packagegen: - realstdout = sys.stdout - sys.stdout = open(pkgfname, 'w') - - print newfilestr - - if packagegen: - sys.stdout.close() - sys.stdout = realstdout + with open(pkgfname, 'w') as package_file: + package_file.write(newfilestr) + else: + sys.stdout.write(newfilestr) ################################################################