mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Use Python JSON to format packages.json file (#5429)
The packages JSON file which includes the boards, tools, etc. and needs to have consistent formatting to be reproducible. The current boards.txt.py uses a REGEX to string-replace a bit of it, but that bit has a different indent than the rest of the file. Use Python's JSON writer to format the whole file repeatably.
This commit is contained in:
parent
f68362e78f
commit
2ec3daa225
@ -37,6 +37,7 @@ import sys
|
||||
import collections
|
||||
import getopt
|
||||
import re
|
||||
import json
|
||||
|
||||
# serial upload speed order in menu
|
||||
# default is 115 for every board unless specified with 'serial' in board
|
||||
@ -1416,9 +1417,11 @@ def package ():
|
||||
|
||||
newfilestr = re.sub(r'"boards":[^\]]*\],', substitution, filestr, re.MULTILINE)
|
||||
|
||||
# To get consistent indent/formatting read the JSON and write it out programattically
|
||||
if packagegen:
|
||||
with open(pkgfname, 'w') as package_file:
|
||||
package_file.write(newfilestr)
|
||||
filejson = json.loads(filestr, object_pairs_hook=collections.OrderedDict)
|
||||
package_file.write(json.dumps(filejson, indent=3, separators=(',',': ')))
|
||||
print("updated: %s" % pkgfname)
|
||||
else:
|
||||
sys.stdout.write(newfilestr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user