diff --git a/src/cli/cpl/cli/model/cpl_structure_model.py b/src/cli/cpl/cli/model/cpl_structure_model.py index 3d9434c1..79566412 100644 --- a/src/cli/cpl/cli/model/cpl_structure_model.py +++ b/src/cli/cpl/cli/model/cpl_structure_model.py @@ -11,9 +11,13 @@ T = TypeVar("T", bound="CPLStructureModel") class CPLStructureModel: - def __init__(self, path: Optional[str] = None): + def __init__(self, path: Optional[str] = None, ignore_fields: Optional[List[str]] = None): self._path = path + self._ignore = {"_ignore", "_path"} + if ignore_fields is not None: + self._ignore.update(ignore_fields) + @property def path(self) -> Optional[str]: return self._path @@ -68,7 +72,7 @@ class CPLStructureModel: def to_json(self) -> Dict[str, Any]: result: Dict[str, Any] = {} for key, value in self.__dict__.items(): - if not key.startswith("_") or key == "_path": + if not key.startswith("_") or key in self._ignore: continue out_key = _self_or_cls_snake_to_camel(key[1:]) diff --git a/src/cli/cpl/cli/model/workspace.py b/src/cli/cpl/cli/model/workspace.py index b991190c..c063e068 100644 --- a/src/cli/cpl/cli/model/workspace.py +++ b/src/cli/cpl/cli/model/workspace.py @@ -24,7 +24,7 @@ class Workspace(CPLStructureModel): default_project: Optional[str], scripts: Dict[str, str], ): - CPLStructureModel.__init__(self, path) + CPLStructureModel.__init__(self, path, ["_actual_projects", "_project_names"]) self._name = name self._projects = projects