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

Method process_codebase

src/summarycode/facet.py:131–154  ·  view source on GitHub ↗

Add facets to file resources using the `facet` definition of facets. Each entry in the `facet` sequence is a string as in :

(self, codebase, facet=(), **kwargs)

Source from the content-addressed store, hash-verified

129 return bool(facet)
130
131 def process_codebase(self, codebase, facet=(), **kwargs):
132 """
133 Add facets to file resources using the `facet` definition of facets.
134 Each entry in the `facet` sequence is a string as in <facet>:<pattern>
135 """
136
137 if not facet:
138 return
139
140 facet_definitions, _invalid_facet_definitions = build_facets(facet)
141
142 if TRACE:
143 logger_debug('facet_definitions:', facet_definitions)
144
145 # Walk the codebase and set the facets for each file (and only files)
146 for resource in codebase.walk(topdown=True):
147 if not resource.is_file:
148 continue
149 facets = compute_path_facets(resource.path, facet_definitions)
150 if facets:
151 resource.facets = facets
152 else:
153 resource.facets = [FACET_CORE]
154 resource.save(codebase)
155
156
157def compute_path_facets(path, facet_definitions):

Callers 1

check_pluginFunction · 0.45

Calls 5

build_facetsFunction · 0.85
compute_path_facetsFunction · 0.85
logger_debugFunction · 0.70
walkMethod · 0.45
saveMethod · 0.45

Tested by 1

check_pluginFunction · 0.36