# Path: shipwright/_lib/msg.py
# class BuildComplete(Message, namedtuple('BuildComplete', ['target'])):
#     """
#     A message to signify that the build has finished for a target.
# 
#     The build may not have completed succesfully
#     """


from . import build, dependencies
from .msg import BuildComplete
from __future__ import absolute_import



class Shipwright(object):
    def __init__(self, source_control, docker_client, tags, cache):
        self.source_control = source_control
        self.docker_client = docker_client
        self.tags = tags
        self._cache = cache

    def targets(self):
        return self.source_control.targets()

    def build(self, build_targets):
        targets = dependencies.eval(build_targets, self.targets())
        this_ref_str = self.source_control.this_ref_str()
        return self._build(this_ref_str, targets)

    def _build(self, this_ref_str, targets):
        client = self.docker_client
        ref = this_ref_str
        tags = self.source_control.default_tags() + self.tags + [this_ref_str]
        for evt in build.do_build(client, ref, targets, self._cache):

# Path: shipwright/_lib/msg.py
# class BuildComplete(Message, namedtuple('BuildComplete', ['target'])):
#     """
#     A message to signify that the build has finished for a target.
# 
#     The build may not have completed succesfully
#     """


# Path: shipwright/_lib/base.py
from . import build, dependencies
from .msg import BuildComplete

from __future__ import absolute_import



class Shipwright(object):
    def __init__(self, source_control, docker_client, tags, cache):
        self.source_control = source_control
        self.docker_client = docker_client
        self.tags = tags
        self._cache = cache

    def targets(self):
        return self.source_control.targets()

    def build(self, build_targets):
        targets = dependencies.eval(build_targets, self.targets())
        this_ref_str = self.source_control.this_ref_str()
        return self._build(this_ref_str, targets)

    def _build(self, this_ref_str, targets):
        client = self.docker_client
        ref = this_ref_str
        tags = self.source_control.default_tags() + self.tags + [this_ref_str]
        for evt in build.do_build(client, ref, targets, self._cache):

            if isinstance(evt, BuildComplete):