Return a sorted sequence of direct children Resource objects for this Resource or an empty sequence. Sorting is by resources without children, then resource with children (e.g. directories or files with children), then case-insentive name.
(self, codebase, names=())
| 1468 | return bool(self.children_names) |
| 1469 | |
| 1470 | def children(self, codebase, names=()): |
| 1471 | """ |
| 1472 | Return a sorted sequence of direct children Resource objects for this |
| 1473 | Resource or an empty sequence. |
| 1474 | |
| 1475 | Sorting is by resources without children, then resource with children |
| 1476 | (e.g. directories or files with children), then case-insentive name. |
| 1477 | """ |
| 1478 | children_names = self.children_names or [] |
| 1479 | if not children_names: |
| 1480 | return [] |
| 1481 | |
| 1482 | if names: |
| 1483 | kids = set(children_names) |
| 1484 | children_names = [n for n in names if n in kids] |
| 1485 | if not children_names: |
| 1486 | return [] |
| 1487 | |
| 1488 | child_path = partial(posixpath_join, self.path) |
| 1489 | get_child = codebase.get_resource |
| 1490 | children = [get_child(path=child_path(name)) for name in children_names] |
| 1491 | |
| 1492 | def _sorter(r): |
| 1493 | return (r.has_children(), r.name.lower(), r.name) |
| 1494 | |
| 1495 | return sorted((c for c in children if c), key=_sorter) |
| 1496 | |
| 1497 | def has_parent(self): |
| 1498 | """ |
no test coverage detected