pf.Pkg._access(): Use Distro.paths()
Distro.paths() now allows to spare a detour in Pkg._access() - we can directly get to the list of paths instead of via Distro.select() -> pkg_paths(). Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
dc9ef58c8b
commit
ea751d3949
2 changed files with 13 additions and 2 deletions
|
|
@ -65,8 +65,9 @@ class PackageFilter(FileContextFilter): # export
|
|||
async def _access(self, path: str, mode: int = os.F_OK) -> bool:
|
||||
if self.__space is None:
|
||||
distro = await self.distro()
|
||||
names = [p.name for p in await distro.select([], filter = self)]
|
||||
self.__space = set(self.__add_parent_paths(await distro.pkg_paths(names)))
|
||||
self.__space = set(
|
||||
self.__add_parent_paths(await distro.paths(filter = self))
|
||||
)
|
||||
return path in self.__space
|
||||
|
||||
class Pkg(PackageFilter): # export
|
||||
|
|
|
|||
|
|
@ -92,6 +92,16 @@ class _FakeDistro:
|
|||
ret.extend(files)
|
||||
return ret
|
||||
|
||||
async def paths(self, filter: Any = None, pkg_names: Any = []) -> list[str]:
|
||||
ret: list[str] = []
|
||||
for p, files in self.__pkgs:
|
||||
if filter is not None and not filter.match_pkg(p):
|
||||
continue
|
||||
if pkg_names and p.name not in pkg_names:
|
||||
continue
|
||||
ret.extend(files)
|
||||
return ret
|
||||
|
||||
fake = _FakeDistro(
|
||||
[
|
||||
(
|
||||
|
|
|
|||
Loading…
Reference in a new issue