Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/model.py
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
class DirectoryEntry: | class DirectoryEntry: | ||||
def __init__(self, id: Sha1Git, name: bytes = b"") -> None: | def __init__(self, id: Sha1Git, name: bytes = b"") -> None: | ||||
self.id = id | self.id = id | ||||
self.name = name | self.name = name | ||||
self._files: Optional[List[FileEntry]] = None | self._files: Optional[List[FileEntry]] = None | ||||
self._dirs: Optional[List[DirectoryEntry]] = None | self._dirs: Optional[List[DirectoryEntry]] = None | ||||
def retrieve_children(self, archive: ArchiveInterface) -> None: | def retrieve_children(self, archive: ArchiveInterface, minsize: int = 0) -> None: | ||||
if self._files is None and self._dirs is None: | if self._files is None and self._dirs is None: | ||||
self._files = [] | self._files = [] | ||||
self._dirs = [] | self._dirs = [] | ||||
for child in archive.directory_ls(self.id): | for child in archive.directory_ls(self.id, minsize=minsize): | ||||
if child["type"] == "dir": | if child["type"] == "dir": | ||||
self._dirs.append( | self._dirs.append( | ||||
DirectoryEntry(child["target"], name=child["name"]) | DirectoryEntry(child["target"], name=child["name"]) | ||||
) | ) | ||||
elif child["type"] == "file": | elif child["type"] == "file": | ||||
self._files.append(FileEntry(child["target"], child["name"])) | self._files.append(FileEntry(child["target"], child["name"])) | ||||
@property | @property | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |