Skip to content

Commit

Permalink
Merge branch 'mr/change_post' into 'master'
Browse files Browse the repository at this point in the history
Review signature of post and pre parameters for primitives

See merge request it/e3-core!22
  • Loading branch information
Nikokrock committed Aug 14, 2024
2 parents c35fe3f + 4b6226d commit c5daf0a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/e3/anod/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,26 +617,30 @@ def get_qualifier(self, qualifier_name: str) -> str | bool | frozenset[str] | No
@classmethod
def primitive(
cls,
pre: Callable[[Anod], dict] | None = None,
post: Callable[..., None] | None = None,
pre: str | None = None,
post: str | None = None,
version: Callable[..., str] | None = None,
require: Callable[[Anod], bool] | None = None,
post_install: bool = False,
) -> Callable:
"""Declare an anod primitive.
Catch all exceptions and raise AnodError with the traceback
:param pre: None or a special function to call before running the
primitive. The function takes a unique parameter `self` and
:param pre: None or name of method in the spec to call before running
the primitive. The method takes a unique parameter `self` and
returns a dict
:param post: None or a callback function to call after running the
primitive
:param post: None or "install". This parameter is obsolete and should
not be used. Prefer "post_install=True" to achieve the same effect
:param version: None or a callback function returning the version
that will be evaluated as a string. This callback is called
after running the primitive
:param require: None or a special function to call before running the
primitive. The function takes a unique parameter `self` and
returns a boolean
:param post_install: if True call the install primitive after the build
primitive. Note that between the two a binary package might be generated
depending on the context. This is equivalent to post="install"
:raise: AnodError
"""

Expand Down Expand Up @@ -672,6 +676,7 @@ def primitive_func(self, *args, **kwargs): # type: ignore
primitive_func.is_primitive = True
primitive_func.pre = pre
primitive_func.post = post
primitive_func.post_install = post_install or (post == "install")
primitive_func.version = version
primitive_func.require = require
return primitive_func
Expand Down

0 comments on commit c5daf0a

Please sign in to comment.