[docs]@dataclasses.dataclassclassAfwfProject:""" Represents a Python project built with the afwf framework. Binds together: - The **source project** (``dir_project_root``) — the git repo you develop in - The **Alfred Workflow folder** (``alfred_workflow``) — where Alfred runs the code Typical project layout:: <dir_project_root>/ ├── <package_name>/ ← Python package (same as [project] name in pyproject.toml) ├── main.py ← entry point, copied to workflow folder on build ├── info.plist ← synced back from Alfred for version control ├── icon.png ← synced back from Alfred for version control └── pyproject.toml All attributes are lazily evaluated and cached on first access. :param dir_project_root: Root directory of the Python project. :param alfred_workflow: The Alfred Workflow this project deploys to. """dir_project_root:Pathalfred_workflow:AlfredWorkflowdef__post_init__(self):self.dir_project_root=Path(self.dir_project_root)# ------------------------------------------------------------------# Project-side paths# ------------------------------------------------------------------@cached_propertydefpath_pyproject_toml(self)->Path:"""``pyproject.toml`` at the project root."""returnself.dir_project_root/"pyproject.toml"@cached_propertydef_pyproject_data(self)->dict:"""Raw dict parsed from ``pyproject.toml``."""withself.path_pyproject_toml.open("rb")asfh:returntomllib.load(fh)@cached_propertydefpackage_name(self)->str:""" Python package name, read from the ``[project] name`` field in ``pyproject.toml``. """returnself._pyproject_data["project"]["name"]@cached_propertydefdir_package(self)->Path:"""The main Python package directory (``<root>/<package_name>/``)."""returnself.dir_project_root/self.package_name@cached_propertydefpath_project_main_py(self)->Path:"""``main.py`` at the project root (source, copied to workflow on build)."""returnself.dir_project_root/"main.py"@cached_propertydefpath_project_info_plist(self)->Path:"""``info.plist`` at the project root (synced back from Alfred for VCS)."""returnself.dir_project_root/"info.plist"@cached_propertydefpath_project_icon_png(self)->Path:"""``icon.png`` at the project root (synced back from Alfred for VCS)."""returnself.dir_project_root/"icon.png"# ------------------------------------------------------------------# Workflow-side paths (afwf convention on top of AlfredWorkflow)# ------------------------------------------------------------------@cached_propertydefpath_workflow_main_py(self)->Path:"""``main.py`` inside the Alfred Workflow folder."""returnself.alfred_workflow.dir_workflow/"main.py"@cached_propertydefdir_workflow_lib(self)->Path:"""``lib/`` inside the Alfred Workflow folder (pip install target)."""returnself.alfred_workflow.dir_workflow/"lib"