forked from platformio/platformio-core
API to update BoardConfig manifest
This commit is contained in:
@ -665,6 +665,15 @@ class PlatformBoardConfig(object):
|
|||||||
else:
|
else:
|
||||||
raise KeyError("Invalid board option '%s'" % path)
|
raise KeyError("Invalid board option '%s'" % path)
|
||||||
|
|
||||||
|
def update(self, path, value):
|
||||||
|
newdict = None
|
||||||
|
for key in path.split(".")[::-1]:
|
||||||
|
if newdict is None:
|
||||||
|
newdict = {key: value}
|
||||||
|
else:
|
||||||
|
newdict = {key: newdict}
|
||||||
|
util.merge_dicts(self._manifest, newdict)
|
||||||
|
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
try:
|
try:
|
||||||
self.get(key)
|
self.get(key)
|
||||||
|
@ -754,6 +754,18 @@ def format_filesize(filesize):
|
|||||||
return "%d%sB" % ((base * filesize / unit), suffix)
|
return "%d%sB" % ((base * filesize / unit), suffix)
|
||||||
|
|
||||||
|
|
||||||
|
def merge_dicts(d1, d2, path=None):
|
||||||
|
if path is None:
|
||||||
|
path = []
|
||||||
|
for key in d2:
|
||||||
|
if (key in d1 and isinstance(d1[key], dict)
|
||||||
|
and isinstance(d2[key], dict)):
|
||||||
|
merge_dicts(d1[key], d2[key], path + [str(key)])
|
||||||
|
else:
|
||||||
|
d1[key] = d2[key]
|
||||||
|
return d1
|
||||||
|
|
||||||
|
|
||||||
def rmtree_(path):
|
def rmtree_(path):
|
||||||
|
|
||||||
def _onerror(_, name, __):
|
def _onerror(_, name, __):
|
||||||
|
Reference in New Issue
Block a user