lib.ExecApp: Move .path_filter into the app's ExecContext

Create an app's exec context with the user-specified path filter, and drop
the ExecApp.path_filter property, now a duplicate of
exec_context.path_filter. Use the latter in the two call sites.

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
This commit is contained in:
Jan Lindemann 2026-11-03 17:37:49 +01:00
commit 09d76249f3
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
4 changed files with 11 additions and 24 deletions

View file

@ -389,7 +389,7 @@ class App(Base):
self.__distro = await Distro.instantiate(
ec = self.exec_context,
id = self.args.distro_id,
default_pkg_filter = self.path_filter,
default_pkg_filter = self.exec_context.path_filter,
)
@override

View file

@ -67,5 +67,5 @@ class CmdCopy(Cmd): # export
mode = int(args.mode, 0) if args.mode is not None else None,
recursive = args.recursive,
parents = args.parents,
default_path_filter = self.app.path_filter,
default_path_filter = self.app.exec_context.path_filter,
)

View file

@ -3,10 +3,9 @@ from __future__ import annotations
import os
import sys
from typing import TYPE_CHECKING, Any, Literal, override
from typing import TYPE_CHECKING, Any, override
from .App import App as Base
from .PathFilter import PathFilter
if TYPE_CHECKING:
@ -21,7 +20,6 @@ class ExecApp(Base): # export
self.__opt_interactive: bool | None = None
self.__opt_verbose: bool | None = None
self.__exec_context: ExecContext | None = None
self.__path_filter: PathFilter | None | Literal[False] = None
@override
async def __aexit__(self, exc_type: Any, exc: Any, tb: Any) -> None:
@ -52,7 +50,8 @@ class ExecApp(Base): # export
)
parser.add_argument(
'--pkg-filter',
help = 'Default filter for all distribution package-related operations',
help = 'Default path filter for the exec context, '
'as a name:spec loader string',
)
@property
@ -81,30 +80,18 @@ class ExecApp(Base): # export
assert self.__opt_verbose is not None
return self.__opt_verbose
@property
def path_filter(self) -> PathFilter | None:
if self.__path_filter is None:
spec = self.args.pkg_filter
if spec is None:
spec = os.getenv('JW_DEFAULT_PKG_FILTER')
if spec is None:
self.__path_filter = False
else:
self.__path_filter = PathFilter.create(
spec = spec, file_context = self.exec_context
)
if not self.__path_filter:
return None
return self.__path_filter
@property
def exec_context(self) -> ExecContext:
if self.__exec_context is None:
from .ExecContext import ExecContext
spec = self.args.pkg_filter
if spec is None:
spec = os.getenv('JW_DEFAULT_PKG_FILTER')
self.__exec_context = ExecContext.create(
self.args.target,
interactive = self.interactive,
verbose_default = self.verbose,
default_path_filter = spec,
)
return self.__exec_context

View file

@ -26,8 +26,8 @@ options:
distro level (default: False)
--target TARGET Run commands on this host (default: local)
--pkg-filter PKG_FILTER
Default filter for all distribution package-related
operations (default: None)
Default path filter for the exec context, as a
name:spec loader string (default: None)
-t, --topdir TOPDIR Project Path (default: None)
--topdir-format TOPDIR_FORMAT
Output references to topdir as one of "make:<var-