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

Method update_counts

src/commoncode/resource.py:1095–1110  ·  view source on GitHub ↗

Update files_count, dirs_count and size_count attributes of each Resource in this codebase based on the current Resource data. If ``skip_filtered`` is True, resources with ``is_filtered`` set to True are not included in counts.

(self, skip_filtered=False)

Source from the content-addressed store, hash-verified

1093 return files_count, dirs_count, size_count
1094
1095 def update_counts(self, skip_filtered=False):
1096 """
1097 Update files_count, dirs_count and size_count attributes of each
1098 Resource in this codebase based on the current Resource data.
1099
1100 If ``skip_filtered`` is True, resources with ``is_filtered`` set to True are
1101 not included in counts.
1102 """
1103 # note: we walk bottom up to update things in the proper order
1104 # and the walk MUST NOT skip filtered, only the compute
1105 for resource in self.walk(topdown=False):
1106 try:
1107 resource._compute_children_counts(self, skip_filtered)
1108 except Exception as e:
1109 msg = f"ERROR: cannot compute children counts for: {resource.path}"
1110 raise Exception(msg) from e
1111
1112 def clear(self):
1113 """

Callers 1

compute_countsMethod · 0.95

Calls 2

walkMethod · 0.95

Tested by

no test coverage detected