Skip to content

Commit

Permalink
Add is_media field to CodebaseResource #238
Browse files Browse the repository at this point in the history
    * Update test results

Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Aug 3, 2021
1 parent c94fc15 commit ced8f38
Show file tree
Hide file tree
Showing 7 changed files with 384 additions and 377 deletions.
18 changes: 18 additions & 0 deletions scanpipe/migrations/0011_codebaseresource_is_media.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.6 on 2021-08-03 18:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('scanpipe', '0010_codebaseresource_is_key_file'),
]

operations = [
migrations.AddField(
model_name='codebaseresource',
name='is_media',
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions scanpipe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ class Type(models.TextChoices):
is_text = models.BooleanField(default=False)
is_archive = models.BooleanField(default=False)
is_key_file = models.BooleanField(default=False)
is_media = models.BooleanField(default=False)

class Compliance(models.TextChoices):
OK = "ok"
Expand Down
1 change: 0 additions & 1 deletion scanpipe/pipes/scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def get_resource_info(location):

# Missing fields on CodebaseResource model returned by `get_file_info`.
unsupported_fields = [
"is_media",
"is_source",
"is_script",
"date",
Expand Down
16 changes: 8 additions & 8 deletions scanpipe/pipes/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ def _tag_python_software(project):
python_root_pattern_compiled = re.compile(python_root_pattern)

python_versions_by_path = {}
for python_resource in qs.filter(rootfs_path__regex=r"(^/(Files/)?Python(\d+)?)/.*$"):
match = python_root_pattern_compiled.match(
python_resource.rootfs_path
)
for python_resource in qs.filter(
rootfs_path__regex=r"(^/(Files/)?Python(\d+)?)/.*$"
):
match = python_root_pattern_compiled.match(python_resource.rootfs_path)
if not match:
continue

Expand Down Expand Up @@ -167,7 +167,9 @@ def _tag_python_software(project):

def _tag_openjdk_software(project):
qs = project.codebaseresources.no_status()
openjdk_root_pattern = r"^(?P<root_path>/(Files/)?(open)?jdk(-(?P<version>(\d*)(\.\d+)*))*)/.*$"
openjdk_root_pattern = (
r"^(?P<root_path>/(Files/)?(open)?jdk(-(?P<version>(\d*)(\.\d+)*))*)/.*$"
)
openjdk_root_pattern_compiled = re.compile(openjdk_root_pattern)

openjdk_versions_by_path = {}
Expand Down Expand Up @@ -247,9 +249,7 @@ def tag_program_files(project):

program_files_dirname_by_path = {}
for program_file in qs.filter(rootfs_path__regex=r"^.*/Program Files( \(x86\))?"):
match = program_files_subdir_pattern_compiled.match(
program_file.rootfs_path
)
match = program_files_subdir_pattern_compiled.match(program_file.rootfs_path)
if not match:
continue

Expand Down
13 changes: 6 additions & 7 deletions scanpipe/tests/data/is-npm-1.0.0_scancode.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@
"headers": [
{
"tool_name": "scancode-toolkit",
"tool_version": "21.6.7",
"tool_version": "21.7.30",
"options": {
"input": [
"/Volumes/nexB/var/projects/wdsdadsadasd-bc9f8ade/codebase"
"/tmp/tmpkzp1f_pw/projects/analysis-03087122/codebase"
],
"--classify": true,
"--consolidate": true,
"--copyright": true,
"--email": true,
"--info": true,
"--is-license-text": true,
"--json-pp": "/Volumes/nexB/var/projects/wdsdadsadasd-bc9f8ade/output/scancode-2021-07-07-11-18-49.json",
"--json-pp": "/tmp/tmpkzp1f_pw/projects/analysis-03087122/output/scancode-2021-08-03-19-09-26.json",
"--license": true,
"--license-clarity-score": true,
"--license-text": true,
"--package": true,
"--processes": "4",
"--summary": true,
"--summary-key-files": true,
"--url": true
},
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
"start_timestamp": "2021-07-07T111850.232385",
"end_timestamp": "2021-07-07T111856.279366",
"duration": 6.047006845474243,
"start_timestamp": "2021-08-03T190927.407466",
"end_timestamp": "2021-08-03T190932.182255",
"duration": 4.774801015853882,
"message": null,
"errors": [],
"extra_data": {
Expand Down
Loading

0 comments on commit ced8f38

Please sign in to comment.