Source code for pydmt.api.one_source_one_target
from typing import Generator, Tuple, Sequence
from pydmt.api.builder import Builder, SourceFile, TargetFile, Node
from pydmt.utils.digest import sha1_file
[docs]
class OneSourceOneTarget(Builder):
"""
This is a builder which has one source file and one target file
"""
def __init__(self, source: str, target: str):
# super().__init__()
self.source = source
self.target = target
self.sources: Sequence[Node] = [SourceFile(filename=source)]
self.targets: Sequence[Node] = [TargetFile(filename=target)]
[docs]
def get_sources(self) -> Sequence[Node]:
return self.sources
[docs]
def get_targets(self) -> Sequence[Node]:
return self.targets
[docs]
def yield_results(self) -> Generator[Tuple[str, str], None, None]:
yield sha1_file(self.target), self.target