poky/meta/lib/oe/data.py
Richard Purdie ffae400179 meta/lib+scripts: Convert to SPDX license headers
This adds SPDX license headers in place of the wide assortment of things
currently in our script headers. We default to GPL-2.0-only except for the
oeqa code where it was clearly submitted and marked as MIT on the most part
or some scripts which had the "or later" GPL versioning.

The patch also drops other obsolete bits of file headers where they were
encoountered such as editor modelines, obsolete maintainer information or
the phrase "All rights reserved" which is now obsolete and not required in
copyright headers (in this case its actually confusing for licensing as all
rights were not reserved).

More work is needed for OE-Core but this takes care of the bulk of the scripts
and meta/lib directories.

The top level LICENSE files are tweaked to match the new structure and the
SPDX naming.

(From OE-Core rev: f8c9c511b5f1b7dbd45b77f345cb6c048ae6763e)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-09 16:31:55 +01:00

52 lines
1.5 KiB
Python

#
# SPDX-License-Identifier: GPL-2.0-only
#
import json
import oe.maketype
def typed_value(key, d):
"""Construct a value for the specified metadata variable, using its flags
to determine the type and parameters for construction."""
var_type = d.getVarFlag(key, 'type')
flags = d.getVarFlags(key)
if flags is not None:
flags = dict((flag, d.expand(value))
for flag, value in list(flags.items()))
else:
flags = {}
try:
return oe.maketype.create(d.getVar(key) or '', var_type, **flags)
except (TypeError, ValueError) as exc:
bb.msg.fatal("Data", "%s: %s" % (key, str(exc)))
def export2json(d, json_file, expand=True, searchString="",replaceString=""):
data2export = {}
keys2export = []
for key in d.keys():
if key.startswith("_"):
continue
elif key.startswith("BB"):
continue
elif key.startswith("B_pn"):
continue
elif key.startswith("do_"):
continue
elif d.getVarFlag(key, "func"):
continue
keys2export.append(key)
for key in keys2export:
try:
data2export[key] = d.getVar(key, expand).replace(searchString,replaceString)
except bb.data_smart.ExpansionError:
data2export[key] = ''
except AttributeError:
pass
with open(json_file, "w") as f:
json.dump(data2export, f, skipkeys=True, indent=4, sort_keys=True)