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

Method __init__

src/commoncode/resource.py:270–345  ·  view source on GitHub ↗

Initialize a new codebase rooted at the ``location`` existing file or directory. Use an optional list of ``paths`` strings that are paths relative to the root ``location`` such that joining the root ``location`` and such a path is the ``location`` of this pa

(
        self,
        location,
        resource_attributes=None,
        codebase_attributes=None,
        temp_dir=temp_dir,
        max_in_memory=10000,
        max_depth=0,
        paths=tuple(),
        ignores=tuple(),
        includes=tuple(),
        *args,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

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,
291 the codebase will only contain these paths and no other path.
292
293 ``resource_attributes`` is an ordered mapping of attr Resource attributes
294 such as plugin-provided attributes: these will be added to a Resource
295 sub-class crafted for this codebase.
296
297 ``codebase_attributes`` is an ordered mapping of attr Codebase attributes
298 such as plugin-provided attributes: these will be added to a
299 CodebaseAttributes sub-class crafted for this codebase.
300
301 ``temp_dir`` is the base temporary directory to use to cache resources on
302 disk and other temporary files.
303
304 ``max_in_memory`` is the maximum number of Resource instances to keep in
305 memory. Beyond this number, Resource are saved on disk instead. -1 means
306 no memory is used and 0 means unlimited memory is used.
307
308 ``max_depth`` is the maximum depth of subdirectories to descend below and
309 including `location`.
310
311 ``paths`` is an optional list of of path strings that extend from the
312 root ``location``. If provided, the codebase will contain only these
313 paths.
314 """
315 self.max_depth = max_depth
316
317 # Resource sub-class to use: Configured with attributes in _populate
318 self.resource_class = Resource
319
320 self.resource_attributes = resource_attributes or {}
321 self.codebase_attributes = codebase_attributes or {}
322
323 # setup location
324 ########################################################################
325 location = os.fsdecode(location)
326 location = abspath(normpath(expanduser(location)))
327 location = location.rstrip("/\\")

Callers

nothing calls this directly

Calls 4

_setup_essentialsMethod · 0.95
_prepare_clean_pathsMethod · 0.95
_populateMethod · 0.95
boolFunction · 0.85

Tested by

no test coverage detected