MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / _rehydrate_list

Function _rehydrate_list

src/packagedcode/models.py:990–1004  ·  view source on GitHub ↗

Yield ``cls`` objects built from a ``values`` list of mappings.

(cls, values)

Source from the content-addressed store, hash-verified

988
989
990def _rehydrate_list(cls, values):
991 """
992 Yield ``cls`` objects built from a ``values`` list of mappings.
993 """
994 # Since we have a list_item_type, value must be a list of mappings:
995 # we transform it in a list of objects.
996 base_msg = 'Invalid package "scan_data "with unknown data structure.'
997 if not isinstance(values, list) and not all(isinstance(v, dict) for v in values):
998 raise Exception(
999 f'{base_msg}. Expected the value to be a list of dicts and not: '
1000 f'{type(values)!r} for class: {cls!r}'
1001 )
1002
1003 for val in values:
1004 yield cls.from_dict(val)
1005
1006
1007def add_to_package(package_uid, resource, codebase):

Callers 1

from_dictMethod · 0.85

Calls 2

typeClass · 0.50
from_dictMethod · 0.45

Tested by

no test coverage detected