forked from aboutcode-org/scancode-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_info.py
More file actions
57 lines (48 loc) · 2.01 KB
/
plugin_info.py
File metadata and controls
57 lines (48 loc) · 2.01 KB
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
49
50
51
52
53
54
55
56
57
#
# 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/nexB/scancode-toolkit for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
import attr
from plugincode.scan import ScanPlugin
from plugincode.scan import scan_impl
from commoncode.cliutils import PluggableCommandLineOption
from commoncode.cliutils import OTHER_SCAN_GROUP
@scan_impl
class InfoScanner(ScanPlugin):
"""
Scan a file Resource for miscellaneous information such as mime/filetype and
basic checksums.
"""
resource_attributes = dict([
('date', attr.ib(default=None, repr=False)),
('sha1', attr.ib(default=None, repr=False)),
('md5', attr.ib(default=None, repr=False)),
('sha256', attr.ib(default=None, repr=False)),
('mime_type', attr.ib(default=None, repr=False)),
('file_type', attr.ib(default=None, repr=False)),
('programming_language', attr.ib(default=None, repr=False)),
('is_binary', attr.ib(default=False, type=bool, repr=False)),
('is_text', attr.ib(default=False, type=bool, repr=False)),
('is_archive', attr.ib(default=False, type=bool, repr=False)),
('is_media', attr.ib(default=False, type=bool, repr=False)),
('is_source', attr.ib(default=False, type=bool, repr=False)),
('is_script', attr.ib(default=False, type=bool, repr=False)),
])
run_order = 0
sort_order = 0
options = [
PluggableCommandLineOption(('-i', '--info'),
is_flag=True, default=False,
help='Scan <input> for file information (size, checksums, etc).',
help_group=OTHER_SCAN_GROUP, sort_order=10
)
]
def is_enabled(self, info, **kwargs):
return info
def get_scanner(self, **kwargs):
from scancode.api import get_file_info
return get_file_info