Skip to content

Commit 12baea7

Browse files
committed
Merge branch 'main' of github.com:nexB/scancode.io into main
2 parents ebd9fe3 + 6ece1ad commit 12baea7

File tree

7 files changed

+1047
-9
lines changed

7 files changed

+1047
-9
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
calling XlsxWriter and report and error if the truncated can be truncated.
2323
https://github.com/nexB/scancode.io/issues/206
2424

25+
- Add support for VMWare Photon-based Docker images and rootfs. This is an RPM-based
26+
Linux distribution
27+
2528
### v21.6.10
2629

2730
- Add support for VM image formats extraction such as VMDK, VDI and QCOW.
@@ -298,4 +301,4 @@
298301

299302
### v1.0.0 (2020-09-09)
300303

301-
- Initial release
304+
- Initial release

scanpipe/models.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from django.db.models import Q
3636
from django.db.models import TextField
3737
from django.db.models.functions import Cast
38+
from django.db.models.functions import Lower
3839
from django.forms import model_to_dict
3940
from django.urls import reverse
4041
from django.utils import timezone
@@ -1160,12 +1161,35 @@ def children(self, codebase=None):
11601161
Return a QuerySet of direct children CodebaseResource objects using a
11611162
Database query on this CodebaseResource `path`.
11621163
1164+
Paths are returned in lower-cased sorted path order to reflect the
1165+
behavior of `commoncode.resource.Resource.children()`
1166+
https://github.com/nexB/commoncode/blob/76a03d9c1cd2a582dcec4351c768c3ef646e1b31/src/commoncode/resource.py#L1199
1167+
11631168
`codebase` is not used in this context but required for compatibility
11641169
with the commoncode.resource.VirtualCodebase class API.
11651170
"""
11661171
exactly_one_sub_directory = "[^/]+$"
11671172
children_regex = rf"^{self.path}/{exactly_one_sub_directory}"
1168-
return self.descendants().filter(path__regex=children_regex)
1173+
return (
1174+
self.descendants()
1175+
.filter(path__regex=children_regex)
1176+
.order_by(Lower("path"))
1177+
)
1178+
1179+
def walk(self, topdown=True):
1180+
"""
1181+
Yield all descendant Resources of this Resource. Does not include self.
1182+
1183+
Walk the tree top-down, depth-first if `topdown` is True, otherwise walk
1184+
bottom-up.
1185+
"""
1186+
for child in self.children().iterator():
1187+
if topdown:
1188+
yield child
1189+
for subchild in child.walk(topdown=topdown):
1190+
yield subchild
1191+
if not topdown:
1192+
yield child
11691193

11701194
def get_absolute_url(self):
11711195
return reverse("resource_detail", args=[self.project_id, self.pk])

scanpipe/pipes/codebase.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,14 @@ def root(self):
7676
def resources(self):
7777
return self.project.codebaseresources.all()
7878

79-
def walk(self):
80-
yield from self.resources.iterator()
79+
def walk(self, topdown=True):
80+
root = self.root
81+
if topdown:
82+
yield root
83+
for resource in root.walk(topdown=topdown):
84+
yield resource
85+
if not topdown:
86+
yield root
8187

8288
def get_tree(self):
8389
return get_tree(self.root, fields=["name", "path"])

scanpipe/pipes/rootfs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"sles": rpm.package_getter,
4848
"opensuse": rpm.package_getter,
4949
"opensuse-tumbleweed": rpm.package_getter,
50+
"photon": rpm.package_getter,
5051
}
5152

5253

0 commit comments

Comments
 (0)