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

Function run_scan

src/scancode/cli.py:559–1108  ·  view source on GitHub ↗

Run a scan on `input` path (or a list of input paths) and return a tuple of (success, results) where success is a boolean and results is a list of "files" items using the same data structure as the "files" in the JSON scan results but as native Python. Raise Exceptions (e.g. Scancod

(
    input,  # 
    ignore=[],
    from_json=False,
    strip_root=False,
    full_root=False,
    max_in_memory=10000,
    processes=1,
    timeout=120,
    quiet=True,
    verbose=False,
    max_depth=0,
    echo_func=None,
    timing=False,
    keep_temp_files=False,
    # TODO: Review return_results as it does not return Packages and Dependencies
    return_results=True,
    return_codebase=False,
    test_mode=False,
    test_slow_mode=False,
    test_error_mode=False,
    pretty_params=None,
    plugin_options=plugin_options,
    outdated=None,
    *args,
    **kwargs
)

Source from the content-addressed store, hash-verified

557
558
559def run_scan(
560 input, #
561 ignore=[],
562 from_json=False,
563 strip_root=False,
564 full_root=False,
565 max_in_memory=10000,
566 processes=1,
567 timeout=120,
568 quiet=True,
569 verbose=False,
570 max_depth=0,
571 echo_func=None,
572 timing=False,
573 keep_temp_files=False,
574 # TODO: Review return_results as it does not return Packages and Dependencies
575 return_results=True,
576 return_codebase=False,
577 test_mode=False,
578 test_slow_mode=False,
579 test_error_mode=False,
580 pretty_params=None,
581 plugin_options=plugin_options,
582 outdated=None,
583 *args,
584 **kwargs
585):
586 """
587 Run a scan on `input` path (or a list of input paths) and return a tuple of
588 (success, results) where success is a boolean and results is a list of
589 "files" items using the same data structure as the "files" in the JSON scan
590 results but as native Python. Raise Exceptions (e.g. ScancodeError) on
591 error. See scancode() for arguments details.
592 """
593
594 assert not (return_results is True and return_codebase is True), 'Only one of return_results and return_codebase can be True'
595
596 if return_codebase and max_in_memory > 0:
597 # We're keeping temp files otherwise the codebase is gone
598 keep_temp_files = True
599
600 plugins_option_defaults = {clio.name: clio.default for clio in plugin_options}
601 requested_options = dict(plugins_option_defaults)
602 requested_options.update(kwargs)
603
604 if not echo_func:
605
606 def echo_func(*_args, **_kwargs):
607 pass
608
609 if not input:
610 msg = 'At least one input path is required.'
611 raise ScancodeError(msg)
612
613 # To support multiple path inputs
614 include = []
615
616 if not isinstance(input, (list, tuple)):

Calls 15

ScancodeErrorClass · 0.90
as_posixpathFunction · 0.90
time2tstampFunction · 0.90
get_resultsFunction · 0.90
echo_funcFunction · 0.85
run_codebase_pluginsFunction · 0.85
run_scannersFunction · 0.85
collect_errorsFunction · 0.85
display_summaryFunction · 0.85
addMethod · 0.80