Skip to content

Commit e574fa9

Browse files
hyounes4560tdruez
andauthored
Improve Pipelines and Pipes docstrings 258 (#261)
* Improve Pipelines and Pipes docstrings * Update doctrsings when applicable * Update a screenshot in the the user interface chapter Signed-off-by: hyounes4560 <hyounes4560@conestogac.on.ca> * Fix the line length for validity #258 * Fix failing test #258 Co-authored-by: Thomas Druez <tdruez@nexb.com>
1 parent aaa0800 commit e574fa9

21 files changed

+178
-175
lines changed

docs/images/user-interface-5.png

-1.15 KB
Loading

scanpipe/api/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#
2020
# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
2121
# Visit https://github.com/nexB/scancode.io for support and download.
22+
2223
import json
2324

2425
from django.apps import apps

scanpipe/pipelines/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
class Pipeline:
4040
"""
41-
Base class for all Pipelines.
41+
Base class for all pipelines.
4242
"""
4343

4444
def __init__(self, run):
@@ -56,7 +56,7 @@ def steps(cls):
5656
@classmethod
5757
def get_steps(cls):
5858
"""
59-
Raise a deprecation warning when the steps are defined as a tuple in place of
59+
Raises a deprecation warning when the steps are defined as a tuple instead of
6060
a classmethod.
6161
"""
6262
if callable(cls.steps):
@@ -71,14 +71,14 @@ def get_steps(cls):
7171
@classmethod
7272
def get_doc(cls):
7373
"""
74-
Return the docstring.
74+
Returns a docstring.
7575
"""
7676
return getdoc(cls)
7777

7878
@classmethod
7979
def get_graph(cls):
8080
"""
81-
Return the graph of steps.
81+
Returns a graph of steps.
8282
"""
8383
return [
8484
{"name": step.__name__, "doc": getdoc(step)} for step in cls.get_steps()
@@ -87,7 +87,7 @@ def get_graph(cls):
8787
@classmethod
8888
def get_info(cls):
8989
"""
90-
Return a dict of combined data about this Pipeline.
90+
Returns a dictctionary of combined data about the current pipeline.
9191
"""
9292
return {
9393
"description": cls.get_doc(),
@@ -96,7 +96,7 @@ def get_info(cls):
9696

9797
def log(self, message):
9898
"""
99-
Log the `message` to this module logger and to the Run instance.
99+
Logs the given `message` to the current module logger and Run instance.
100100
"""
101101
now_as_localtime = timezone.localtime(timezone.now())
102102
timestamp = now_as_localtime.strftime("%Y-%m-%d %H:%M:%S.%f")[:-4]
@@ -146,15 +146,15 @@ def save_errors(self, *exceptions):
146146

147147
def is_pipeline(obj):
148148
"""
149-
Return True if the `obj` is a subclass of `Pipeline` except for the
149+
Returns True if the `obj` is a subclass of `Pipeline` except for the
150150
`Pipeline` class itself.
151151
"""
152152
return inspect.isclass(obj) and issubclass(obj, Pipeline) and obj is not Pipeline
153153

154154

155155
def profile(step):
156156
"""
157-
Profile a Pipeline step and save the results as HTML in the project output
157+
Profiles a Pipeline step and save the results as HTML file in the project output
158158
directory.
159159
160160
Usage:

scanpipe/pipelines/docker.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
class Docker(root_filesystems.RootFS):
2929
"""
30-
A pipeline to analyze a Docker image.
30+
A pipeline to analyze Docker images.
3131
"""
3232

3333
@classmethod
@@ -49,52 +49,52 @@ def steps(cls):
4949

5050
def extract_images(self):
5151
"""
52-
Extract the images from tarballs.
52+
Extracts images from input tarballs.
5353
"""
5454
self.images, errors = docker.extract_images_from_inputs(self.project)
5555
if errors:
5656
self.add_error("\n".join(errors))
5757

5858
def extract_layers(self):
5959
"""
60-
Extract layers from images.
60+
Extracts layers from input images.
6161
"""
6262
errors = docker.extract_layers_from_images(self.project, self.images)
6363
if errors:
6464
self.add_error("\n".join(errors))
6565

6666
def find_images_linux_distro(self):
6767
"""
68-
Find the linux distro of the images.
68+
Finds the linux distro of input images.
6969
"""
7070
for image in self.images:
7171
image.get_and_set_distro()
7272

7373
def collect_images_information(self):
7474
"""
75-
Collect images information and store on project.
75+
Collects and stores image information in a project.
7676
"""
7777
images_data = [docker.get_image_data(image) for image in self.images]
7878
self.project.update_extra_data({"images": images_data})
7979

8080
def collect_and_create_codebase_resources(self):
8181
"""
82-
Collect and create all image files as CodebaseResource.
82+
Collects and labels all image files as CodebaseResources.
8383
"""
8484
for image in self.images:
8585
docker.create_codebase_resources(self.project, image)
8686

8787
def collect_and_create_system_packages(self):
8888
"""
89-
Collect installed system packages for each layer based on the distro.
89+
Collects installed system packages for each layer based on the distro.
9090
"""
9191
with self.save_errors(rootfs.DistroNotFound, rootfs.DistroNotSupported):
9292
for image in self.images:
9393
docker.scan_image_for_system_packages(self.project, image)
9494

9595
def tag_uninteresting_codebase_resources(self):
9696
"""
97-
Flag remaining files not from a system package.
97+
Flags files that don't belong to any system package.
9898
"""
9999
docker.tag_whiteout_codebase_resources(self.project)
100100
rootfs.tag_uninteresting_codebase_resources(self.project)

scanpipe/pipelines/load_inventory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
class LoadInventory(Pipeline):
2828
"""
29-
A pipeline to load a files and packages inventory from a ScanCode JSON scan.
30-
(assumed to contain file information and package scan data).
29+
A pipeline to load an inventory of files and packages from a ScanCode JSON scan.
30+
(Presumably containing file information and package scan data).
3131
"""
3232

3333
@classmethod
@@ -39,7 +39,7 @@ def steps(cls):
3939

4040
def get_scan_json_input(self):
4141
"""
42-
Locate the JSON scan input from the project input/ directory.
42+
Locates a JSON scan input from a project's input/ directory.
4343
"""
4444
inputs = list(self.project.inputs(pattern="*.json"))
4545
if len(inputs) != 1:
@@ -48,7 +48,7 @@ def get_scan_json_input(self):
4848

4949
def build_inventory_from_scan(self):
5050
"""
51-
Process the JSON scan to populate resources and packages.
51+
Processes a given JSON scan input to populate codebase resources and packages.
5252
"""
5353
project = self.project
5454
scanned_codebase = scancode.get_virtual_codebase(project, self.input_location)

scanpipe/pipelines/root_filesystems.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
class RootFS(Pipeline):
3232
"""
33-
A pipeline to analyze a Linux root filesystem aka. rootfs.
33+
A pipeline to analyze a Linux root filesystem, aka rootfs.
3434
"""
3535

3636
@classmethod
@@ -52,7 +52,7 @@ def steps(cls):
5252

5353
def extract_input_files_to_codebase_directory(self):
5454
"""
55-
Extract root filesystem input archives with extractcode.
55+
Extracts root filesystem input archives with extractcode.
5656
"""
5757
input_files = self.project.inputs("*")
5858
target_path = self.project.codebase_path
@@ -68,13 +68,13 @@ def extract_input_files_to_codebase_directory(self):
6868

6969
def find_root_filesystems(self):
7070
"""
71-
Find the root filesystems in project codebase/.
71+
Finds root filesystems in the project's codebase/.
7272
"""
7373
self.root_filesystems = list(rootfs.RootFs.from_project_codebase(self.project))
7474

7575
def collect_rootfs_information(self):
7676
"""
77-
Collect rootfs information and store on project.
77+
Collects and stores rootfs information in the project.
7878
"""
7979
rootfs_data = {}
8080
for rfs in self.root_filesystems:
@@ -85,14 +85,14 @@ def collect_rootfs_information(self):
8585

8686
def collect_and_create_codebase_resources(self):
8787
"""
88-
Collect and create all image files as CodebaseResource.
88+
Collects and labels all image files as CodebaseResource.
8989
"""
9090
for rfs in self.root_filesystems:
9191
rootfs.create_codebase_resources(self.project, rfs)
9292

9393
def collect_and_create_system_packages(self):
9494
"""
95-
Collect installed system packages for each rootfs based on the distro.
95+
Collects installed system packages for each rootfs based on the distro.
9696
The collection of system packages is only available for known distros.
9797
"""
9898
with self.save_errors(rootfs.DistroNotFound, rootfs.DistroNotSupported):
@@ -101,25 +101,25 @@ def collect_and_create_system_packages(self):
101101

102102
def tag_uninteresting_codebase_resources(self):
103103
"""
104-
Flag remaining files not from a system package if they are not worth tracking.
104+
Flags filesnot worth tracking—that don’t belong to any system packages.
105105
"""
106106
rootfs.tag_uninteresting_codebase_resources(self.project)
107107

108108
def tag_empty_files(self):
109109
"""
110-
Flag empty files.
110+
Flags empty files.
111111
"""
112112
rootfs.tag_empty_codebase_resources(self.project)
113113

114114
def scan_for_application_packages(self):
115115
"""
116-
Scan unknown resources for packages infos.
116+
Scans unknown resources for packages information.
117117
"""
118118
scancode.scan_for_application_packages(self.project)
119119

120120
def match_not_analyzed_to_system_packages(self):
121121
"""
122-
Match not-yet-analyzed files to files already related to system packages.
122+
Matches "not-yet-analyzed" files to files already belong to system packages.
123123
"""
124124
rootfs.match_not_analyzed(
125125
self.project,
@@ -129,7 +129,7 @@ def match_not_analyzed_to_system_packages(self):
129129

130130
def match_not_analyzed_to_application_packages(self):
131131
"""
132-
Match not-yet-analyzed files to files already related to application packages.
132+
Matches "not-yet-analyzed" files to files already belong to application packages.
133133
"""
134134
# TODO: do it one rootfs at a time e.g. for rfs in self.root_filesystems:
135135
rootfs.match_not_analyzed(
@@ -140,18 +140,18 @@ def match_not_analyzed_to_application_packages(self):
140140

141141
def scan_for_files(self):
142142
"""
143-
Scan unknown resources for copyrights, licenses, emails, and urls.
143+
Scans unknown resources for copyrights, licenses, emails, and urls.
144144
"""
145145
scancode.scan_for_files(self.project)
146146

147147
def analyze_scanned_files(self):
148148
"""
149-
Analyze single file scan results for completeness.
149+
Analyzes single file scan results for completeness.
150150
"""
151151
pipes.analyze_scanned_files(self.project)
152152

153153
def tag_not_analyzed_codebase_resources(self):
154154
"""
155-
Check for leftover files for sanity. We should have none.
155+
Checks for any leftover files for sanity; there should be none.
156156
"""
157157
pipes.tag_not_analyzed_codebase_resources(self.project)

scanpipe/pipelines/scan_codebase.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
class ScanCodebase(Pipeline):
3030
"""
31-
A pipeline to scan a codebase with ScanCode-toolkit.
31+
A pipeline to scan a codebase resource with ScanCode-toolkit.
3232
33-
The input files are copied to the project codebase/ directory and extracted
33+
Input files are copied to the project's codebase/ directory and are extracted
3434
in place before running the scan.
3535
Alternatively, the code can be manually copied to the project codebase/
3636
directory.
@@ -62,14 +62,14 @@ def steps(cls):
6262

6363
def copy_inputs_to_codebase_directory(self):
6464
"""
65-
Copy input files to the project codebase/ directory.
65+
Copies input files to the project's codebase/ directory.
6666
The code can also be copied there prior to running the Pipeline.
6767
"""
6868
copy_inputs(self.project.inputs(), self.project.codebase_path)
6969

7070
def run_extractcode(self):
7171
"""
72-
Extract with extractcode.
72+
Extracts with extractcode.
7373
"""
7474
with self.save_errors(scancode.ScancodeError):
7575
scancode.run_extractcode(
@@ -80,7 +80,7 @@ def run_extractcode(self):
8080

8181
def run_scancode(self):
8282
"""
83-
Scan extracted codebase/ content.
83+
Scans extracted codebase/ content.
8484
"""
8585
self.scan_output = self.project.get_output_file_path("scancode", "json")
8686

@@ -97,7 +97,7 @@ def run_scancode(self):
9797

9898
def build_inventory_from_scan(self):
9999
"""
100-
Process the JSON scan results to populate resources and packages.
100+
Processes the JSON scan results to determine resources and packages.
101101
"""
102102
project = self.project
103103
scanned_codebase = scancode.get_virtual_codebase(project, str(self.scan_output))
@@ -106,6 +106,6 @@ def build_inventory_from_scan(self):
106106

107107
def csv_output(self):
108108
"""
109-
Generate csv outputs.
109+
Generates a .csv output.
110110
"""
111111
output.to_csv(self.project)

scanpipe/pipelines/scan_package.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
class ScanPackage(ScanCodebase):
3434
"""
3535
A pipeline to scan a single package archive with ScanCode-toolkit.
36-
The output is a summary of scan results as a JSON file.
36+
The output is a summary of the scan results in JSON format.
3737
"""
3838

3939
@classmethod
@@ -58,7 +58,7 @@ def steps(cls):
5858

5959
def get_package_archive_input(self):
6060
"""
61-
Locate the package archive in the project input/ directory.
61+
Locates the input package archive in the project's input/ directory.
6262
"""
6363
input_files = self.project.input_files
6464
inputs = list(self.project.inputs())
@@ -70,7 +70,7 @@ def get_package_archive_input(self):
7070

7171
def collect_archive_information(self):
7272
"""
73-
Collect information about the input archive and store the data on project.
73+
Collects and store information about the input archive in the project.
7474
"""
7575
self.project.update_extra_data(
7676
{
@@ -82,7 +82,7 @@ def collect_archive_information(self):
8282

8383
def extract_archive_to_codebase_directory(self):
8484
"""
85-
Extract package archive with extractcode.
85+
Extracts package archive with extractcode.
8686
"""
8787
extract_errors = scancode.extract(self.archive_path, self.project.codebase_path)
8888

@@ -91,7 +91,7 @@ def extract_archive_to_codebase_directory(self):
9191

9292
def make_summary_from_scan_results(self):
9393
"""
94-
Build a summary from the JSON scan results.
94+
Builds a summary in JSON format from the generated scan results.
9595
"""
9696
summary = scancode.make_results_summary(self.project, str(self.scan_output))
9797
output_file = self.project.get_output_file_path("summary", "json")

0 commit comments

Comments
 (0)