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

Class Codebase

src/commoncode/resource.py:233–1175  ·  view source on GitHub ↗

Represent a codebase being scanned. A Codebase is a list of Resources.

Source from the content-addressed store, hash-verified

231
232
233class Codebase:
234 """
235 Represent a codebase being scanned. A Codebase is a list of Resources.
236 """
237
238 # we do not really need slots but this is a way to ensure we have tight
239 # control on object attributes
240 __slots__ = (
241 "max_depth",
242 "location",
243 "includes",
244 "ignores",
245 "has_single_resource",
246 "resource_attributes",
247 "resource_class",
248 "root",
249 "is_file",
250 "temp_dir",
251 "resources_by_path",
252 "resources_count",
253 "paths",
254 "max_in_memory",
255 "all_in_memory",
256 "all_on_disk",
257 "cache_dir",
258 "headers",
259 "current_header",
260 "codebase_attributes",
261 "attributes",
262 "counters",
263 "timings",
264 "errors",
265 )
266
267 # the value returned if the resource is cached
268 CACHED_RESOURCE = 1
269
270 def __init__(
271 self,
272 location,
273 resource_attributes=None,
274 codebase_attributes=None,
275 temp_dir=temp_dir,
276 max_in_memory=10000,
277 max_depth=0,
278 paths=tuple(),
279 ignores=tuple(),
280 includes=tuple(),
281 *args,
282 **kwargs,
283 ):
284 """
285 Initialize a new codebase rooted at the ``location`` existing file or
286 directory.
287
288 Use an optional list of ``paths`` strings that are paths relative to the
289 root ``location`` such that joining the root ``location`` and such a
290 path is the ``location`` of this path. If these ``paths`` are provided,

Calls

no outgoing calls