File size: 825 Bytes
c19ca42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from __future__ import annotations

import navi
from nodes.base_output import BaseOutput


class DirectoryOutput(BaseOutput):
    """Output for saving to a directory"""

    def __init__(
        self,
        label: str = "Directory",
        of_input: int | None = None,
        output_type: str = "Directory",
    ):
        directory_type = (
            "Directory"
            if of_input is None
            else f"splitFilePath(Input{of_input}.path).dir"
        )
        directory_type = navi.intersect(directory_type, output_type)
        super().__init__(directory_type, label, associated_type=str)

    def get_broadcast_type(self, value: str):
        return navi.named("Directory", {"path": navi.literal(value)})

    def enforce(self, value) -> str:
        assert isinstance(value, str)
        return value