Suffix#
- class maize.core.interface.Suffix(*suffixes: str)[source]#
Bases:
object
Utility class to annotate paths with restrictions on possible suffixes.
- Parameters:
suffixes – Any number of possible file suffixes without the leading dot
Examples
>>> path: Annotated[Path, Suffix("pdb", "gro", "tpr")] = Path("conf.xyz") >>> pred = get_args(path)[1] >>> pred(path) False
In practice it might look like this:
>>> class Example(Node): ... para = FileParameter[Annotated[Path, Suffix("pdb", "gro")]]() ... out = Output[int]() ... def run(self) -> None: ...
This will then raise a ValueError when trying to set the parameter with a file that doesn’t have the correct suffix.
See also
FileParameter
Parameter subclass using these annotations
Methods
__init__
(*suffixes)