-
-
Notifications
You must be signed in to change notification settings - Fork 795
Expand file tree
/
Copy pathplugin_email.py
More file actions
56 lines (46 loc) · 1.71 KB
/
Copy pathplugin_email.py
File metadata and controls
56 lines (46 loc) · 1.71 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
#
# 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.
#
from functools import partial
import attr
from commoncode.cliutils import PluggableCommandLineOption
from commoncode.cliutils import SCAN_OPTIONS_GROUP
from plugincode.scan import ScanPlugin
from plugincode.scan import scan_impl
from commoncode.cliutils import OTHER_SCAN_GROUP
@scan_impl
class EmailScanner(ScanPlugin):
"""
Scan a Resource for emails.
"""
resource_attributes = dict(emails=attr.ib(default=attr.Factory(list)))
run_order = 7
sort_order = 7
options = [
PluggableCommandLineOption(('-e', '--email',),
is_flag=True, default=False,
help='Scan <input> for emails.',
help_group=OTHER_SCAN_GROUP),
PluggableCommandLineOption(('--max-email',),
type=int, default=50,
metavar='INT',
show_default=True,
required_options=['email'],
help='Report only up to INT emails found in a file. Use 0 for no limit.',
help_group=SCAN_OPTIONS_GROUP),
]
def is_enabled(self, email, **kwargs):
return email
def get_scanner(self, max_email=50, test_slow_mode=False, test_error_mode=False, **kwargs):
from scancode.api import get_emails
return partial(
get_emails,
threshold=max_email,
test_slow_mode=test_slow_mode,
test_error_mode=test_error_mode
)