mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00

misc: Functions for transform object to other types. path: Functions for path handling. test: Functions for operations related to test cases and suites. [YOCTO #10232] (From OE-Core rev: 102d04ccca3ca89d41b76a8c44e0ca0f436b7004) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
38 lines
973 B
Python
38 lines
973 B
Python
# Copyright (C) 2016 Intel Corporation
|
|
# Released under the MIT license (see COPYING.MIT)
|
|
|
|
def toList(obj, obj_type, obj_name="Object"):
|
|
if isinstance(obj, obj_type):
|
|
return [obj]
|
|
elif isinstance(obj, list):
|
|
return obj
|
|
else:
|
|
raise TypeError("%s must be %s or list" % (obj_name, obj_type))
|
|
|
|
def toSet(obj, obj_type, obj_name="Object"):
|
|
if isinstance(obj, obj_type):
|
|
return {obj}
|
|
elif isinstance(obj, list):
|
|
return set(obj)
|
|
elif isinstance(obj, set):
|
|
return obj
|
|
else:
|
|
raise TypeError("%s must be %s or set" % (obj_name, obj_type))
|
|
|
|
def strToList(obj, obj_name="Object"):
|
|
return toList(obj, str, obj_name)
|
|
|
|
def strToSet(obj, obj_name="Object"):
|
|
return toSet(obj, str, obj_name)
|
|
|
|
def intToList(obj, obj_name="Object"):
|
|
return toList(obj, int, obj_name)
|
|
|
|
def dataStoteToDict(d, variables):
|
|
data = {}
|
|
|
|
for v in variables:
|
|
data[v] = d.getVar(v, True)
|
|
|
|
return data
|