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

Function scan

etc/scripts/scancli.py:27–57  ·  view source on GitHub ↗

Scan the list of paths at `location` and return the results as an iterable of JSON strings. If `deserialize` is True the iterable contains a python data instead. Each location is scanned independently.

(locations, deserialize=False, scancode_root_dir=None)

Source from the content-addressed store, hash-verified

25
26
27def scan(locations, deserialize=False, scancode_root_dir=None):
28 """
29 Scan the list of paths at `location` and return the results as an iterable
30 of JSON strings. If `deserialize` is True the iterable contains a python data
31 instead.
32 Each location is scanned independently.
33 """
34 if not scancode_root_dir:
35 scancode_root_dir = abspath(normpath(__file__))
36 scancode_root_dir = dirname(dirname(dirname(scancode_root_dir)))
37 python2 = join(scancode_root_dir, "venv", "bin", "python")
38 spec = "popen//python={python2}".format(**locals())
39 gateway = execnet.makegateway(spec) # NOQA
40 channel = gateway.remote_exec(scanserv)
41
42 for location in locations:
43 # build a mapping of options to use for this scan
44 scan_kwargs = dict(
45 location=location,
46 license=True,
47 license_text=True,
48 copyright=True,
49 info=True,
50 processes=0,
51 )
52
53 channel.send(scan_kwargs) # execute func-call remotely
54 results = channel.receive()
55 if deserialize:
56 results = json.loads(results)
57 yield results
58
59
60if __name__ == "__main__":

Callers 1

scancli.pyFile · 0.85

Calls 2

loadsMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected