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

Function set_resource_tallies

src/summarycode/utils.py:79–94  ·  view source on GitHub ↗

Set `value` as the "tallies" value for the `key` tallies attribute of a resource This is set either in a direct Resource.tallies attribute if `as_attribute` is True or as a Resource.extra_data tallies item otherwise.

(resource, key, value, as_attribute=False)

Source from the content-addressed store, hash-verified

77
78
79def set_resource_tallies(resource, key, value, as_attribute=False):
80 """
81 Set `value` as the "tallies" value for the `key` tallies attribute of a
82 resource
83
84 This is set either in a direct Resource.tallies attribute if `as_attribute`
85 is True or as a Resource.extra_data tallies item otherwise.
86 """
87 if as_attribute:
88 resource.tallies[key] = value
89 else:
90 tallies = resource.extra_data.get('tallies')
91 if not tallies:
92 tallies = dict([(key, value)])
93 resource.extra_data['tallies'] = tallies
94 tallies[key] = value

Callers 4

build_talliesFunction · 0.90
license_talliesFunction · 0.90
language_talliesFunction · 0.90
package_talliesFunction · 0.90

Calls 1

getMethod · 0.65

Tested by

no test coverage detected