generated from aboutcode-org/skeleton
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin_fingerprint.py
48 lines (40 loc) · 1.62 KB
/
plugin_fingerprint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/aboutcode-org/scancode-toolkit for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
import attr
from commoncode.cliutils import SCAN_GROUP
from commoncode.cliutils import PluggableCommandLineOption
from plugincode.scan import ScanPlugin
from plugincode.scan import scan_impl
from matchcode_toolkit.fingerprinting import compute_codebase_directory_fingerprints
from matchcode_toolkit.fingerprinting import get_file_fingerprint_hashes
@scan_impl
class FingerprintScanner(ScanPlugin):
resource_attributes = dict(
directory_content_fingerprint=attr.ib(default=None, repr=False),
directory_structure_fingerprint=attr.ib(default=None, repr=False),
halo1=attr.ib(default=None, repr=False),
snippets=attr.ib(default=None, repr=False),
)
sort_order = 6
options = [
PluggableCommandLineOption(
("--fingerprint",),
is_flag=True,
default=False,
help="Compute directory and resource fingerprints that are used for matching",
help_group=SCAN_GROUP,
sort_order=20,
)
]
def is_enabled(self, fingerprint, **kwargs):
return fingerprint
def get_scanner(self, **kwargs):
return get_file_fingerprint_hashes
def process_codebase(self, codebase, **kwargs):
codebase = compute_codebase_directory_fingerprints(codebase)