3
3
Add A Post-Scan Plugin
4
4
======================
5
5
6
+ Scan plugins in ``scancode-toolkit ``
7
+ ------------------------------------
8
+
9
+ A lot of scancode features are built-in plugins which are present with scancode-toolkit source code
10
+ and are usually enabled via the different scancode-toolkit CLI options and are grouped by the types
11
+ of plugins.
12
+
13
+ Here are the major types of plugins:
14
+
15
+ 1. Pre-scan plugins (`scancode_pre_scan ` in entry points)
16
+
17
+ These plugins are run before the main scanning steps and are usually
18
+ filtering of input files, or file classification steps, on whose results
19
+ the main scan plugins depend on. The base plugin class to be extended is ``PreScanPlugin `` at
20
+ `/src/plugincode/pre_scan.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/pre_scan.py >`_.
21
+
22
+ 2. Scan plugins (`scancode_scan ` in entry points)
23
+
24
+ The are the scancode plugins which does the file scanning for useful
25
+ information like license, copyrights, packages and others. These are
26
+ run on multiprocessing for speed as they are done on a per-file basis,
27
+ but there can also be post-processing steps on these which are run afterwards
28
+ and have access to all the per-file scan results. The base plugin class to be extended is
29
+ ``ScanPlugin `` at `/src/plugincode/scan.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/scan.py >`_.
30
+
31
+ 3. Post-scan plugins (`scancode_post_scan ` in entry points)
32
+
33
+ These are mainly data processing, summerizing and reporting plugins which
34
+ depend on all the results for the scan plugins. These add new codebase level
35
+ or file-level attributes, and even removes/modifies data as required
36
+ for consolidation or summarization. The base plugin class to be extended is ``PostScanPlugin ``
37
+ at `/src/plugincode/post_scan.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/post_scan.py >`_.
38
+
39
+ 4. Output plugins (`scancode_output ` in entry points)
40
+
41
+ Supported output options in scancode-toolkit are all plugins and
42
+ these can also be multiple output options selected. These convert, process
43
+ and writes the data in the specific file format as the output of the scanning
44
+ procedures. The base plugin class to be extended is ``OutputPlugin `` at
45
+ `/src/plugincode/output.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/output.py >`_.
46
+
47
+ 5. Output Filter Plugins (`scancode_output_filter ` in entry points)
48
+
49
+ There are also output filter plugins which apply filters to the outputs
50
+ and is modified. These filters can be based on whether resources had any
51
+ detections, ignorables present in licenses and others.
52
+ The base plugin class to be extended is ``OutputFilterPlugin `` at
53
+ `/src/plugincode/output_filter.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/output_filter.py >`_.
54
+
55
+ 6. Location Provider Plugins
56
+
57
+ These plugins provide pre-built binary libraries and utilities and their locations which
58
+ are packaged to be used in scancode-toolkit. The base plugin class to be extended is
59
+ ``LocationProviderPlugin `` at `/src/plugincode/location_provider.py <https://github.com/nexB/plugincode/blob/main/src/plugincode/location_provider.py >`_.
60
+
61
+
6
62
Built-In vs. Optional Installation
7
63
----------------------------------
8
64
9
65
Built-In
10
66
^^^^^^^^
11
67
12
- Some post-scan plugins are installed when ScanCode itself is installed, e.g., the
13
- :ref: `license_policy_plugin `, whose code is located here::
68
+ Some post-scan plugins are installed when ScanCode itself is installed, and they are specified at
69
+ ``[options.entry_points] `` in the `setup.cfg <https://github.com/nexB/scancode-toolkit/blob/develop/setup.cfg >`_ file.
70
+ For example, the :ref: `license_policy_plugin ` is a built-in plugin, whose code is located here::
14
71
15
72
https://github.com/nexB/scancode-toolkit/blob/develop/src/licensedcode/plugin_license_policy.py
16
73
@@ -23,7 +80,7 @@ Optional
23
80
ScanCode is also designed to use post-scan plugins that must be installed separately from the
24
81
installation of ScanCode. The code for this sort of plugin is located here::
25
82
26
- https://github.com/nexB/scancode-toolkit/tree/develop/ plugins/
83
+ https://github.com/nexB/scancode-plugins
27
84
28
85
This wiki page will focus on optional post-scan plugins.
29
86
@@ -45,26 +102,25 @@ We'll start by creating three folders:
45
102
1. Top-level folder -- ``/scancode-hello/ ``
46
103
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47
104
48
- - In the ``/ scancode-toolkit/ plugins/ `` directory, add a folder with a relevant name, e.g.,
49
- ``scancode-hello ``. This folder will hold all of your plugin code.
105
+ - In the ``scancode-plugins `` repository, in the `` misc `` directory, add a folder with
106
+ a relevant name, e.g., ``scancode-hello ``. This folder will hold all of your plugin code.
50
107
51
108
- Inside the ``/scancode-hello/ `` folder you'll need to add a folder named ``src `` and 7 files.
52
-
53
- 1. ``/src/ `` -- This folder will contain your primary Python code and is discussed in more detail
54
- in the following section.
109
+ ``/src/ `` -- This folder will contain your primary Python code and is discussed in more detail
110
+ in the following section.
55
111
56
112
The 7 Files are:
57
113
58
114
1. ``.gitignore `` -- See, e.g.,
59
- `/plugins/ scancode-ignore-binaries/.gitignore <https://github.com/nexB/scancode-toolkit /blob/develop/plugins /scancode-ignore-binaries/.gitignore >`_
115
+ `/scancode-ignore-binaries/.gitignore <https://github.com/nexB/scancode-plugins /blob/main/misc /scancode-ignore-binaries/.gitignore >`_
60
116
61
117
::
62
118
63
119
/build/
64
120
/dist/
65
121
66
122
2. ``apache-2.0.LICENSE `` -- See, e.g.,
67
- `/plugins/ scancode-ignore-binaries/apache-2.0.LICENSE <https://github.com/nexB/scancode-toolkit /blob/develop/plugins /scancode-ignore-binaries/apache-2.0.LICENSE >`_
123
+ `/scancode-ignore-binaries/apache-2.0.LICENSE <https://github.com/nexB/scancode-plugins /blob/main/misc /scancode-ignore-binaries/apache-2.0.LICENSE >`_
68
124
69
125
3. ``MANIFEST.in ``
70
126
@@ -83,7 +139,7 @@ The 7 Files are:
83
139
global-exclude *.py[co] __pycache__ *.*~
84
140
85
141
4. ``NOTICE `` -- See, e.g.,
86
- `/plugins/ scancode-ignore-binaries/NOTICE <https://github.com/nexB/scancode-toolkit /blob/develop/plugins /scancode-ignore-binaries/NOTICE >`__
142
+ `/scancode-ignore-binaries/NOTICE <https://github.com/nexB/scancode-plugins /blob/main/misc /scancode-ignore-binaries/NOTICE >`__
87
143
88
144
5. ``README.md ``
89
145
@@ -129,7 +185,7 @@ The 7 Files are:
129
185
long_description=desc,
130
186
author='nexB',
131
187
author_email='info@aboutcode.org',
132
- url='https://github.com/nexB/scancode-toolkit/ plugins/scancode-categories ',
188
+ url='https://github.com/nexB/scancode-plugins/blob/main/misc/ scancode-hello/ ',
133
189
packages=find_packages('src'),
134
190
package_dir={'': 'src'},
135
191
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
@@ -201,11 +257,11 @@ Create a ``PostScanPlugin`` class
201
257
"""""""""""""""""""""""""""""""""
202
258
203
259
The ``PostScanPlugin `` class
204
- `PostScanPlugin code <https://github.com/nexB/scancode-toolkit /blob/develop /src/plugincode/post_scan.py >`_)
260
+ `PostScanPlugin code <https://github.com/nexB/plugincode /blob/main /src/plugincode/post_scan.py >`_)
205
261
inherits from the ``CodebasePlugin `` class (see
206
- `CodebasePlugin code <https://github.com/nexB/scancode-toolkit /blob/794d7acf78480823084def703b5d61ade12efdf2 /src/plugincode/__init__.py#L139-L150 >`_),
262
+ `CodebasePlugin code <https://github.com/nexB/plugincode /blob/main /src/plugincode/__init__.py >`_),
207
263
which inherits from the ``BasePlugin `` class (see
208
- `BasePlugin code <https://github.com/nexB/scancode-toolkit /blob/794d7acf78480823084def703b5d61ade12efdf2 /src/plugincode/__init__.py#L38-L136 >`_).
264
+ `BasePlugin code <https://github.com/nexB/plugincode /blob/main /src/plugincode/__init__.py >`_).
209
265
210
266
::
211
267
0 commit comments