# Path: harpoon/errors.py
# class HarpoonError(DelfickError):
#     pass
# 
# class BadOption(HarpoonError):
#     desc = "Bad Option"
# 
# Path: harpoon/helpers.py
# @contextmanager
# def a_temp_file():
#     """Yield the name of a temporary file and ensure it's removed after use"""
#     filename = None
#     try:
#         tmpfile = tempfile.NamedTemporaryFile(delete=False)
#         filename = tmpfile.name
#         yield tmpfile
#     finally:
#         if filename and os.path.exists(filename):
#             os.remove(filename)


from harpoon.errors import HarpoonError, BadOption
from harpoon.helpers import a_temp_file
from contextlib import contextmanager
from io import BytesIO
            from harpoon.ship.runner import Runner, ContainerRunner
import subprocess
import tempfile
import tarfile
import fnmatch
import logging
import shutil
import docker
import shlex
import os
import re
                        extra_included.append(filename)
                        break
            if not silent_build:
                log.info("Adding back %s items\tincluding=%s", len(extra_included), context.include)
            combined = set(list(combined) + extra_included)

        files = sorted(os.path.join(context.parent_dir, filename) for filename in combined)
        if not silent_build:
            log.info("Adding %s things from %s to the context", len(files), context.parent_dir)
        return files

    def convert_nonascii(self, lst):
        """Convert the strange outputs from git commands"""
        for item in lst:
            if item.startswith('"') and item.endswith('"'):
                item = item[1:-1]
                yield item.encode("utf-8").decode("unicode-escape")
            else:
                yield item.encode("utf-8").decode("unicode-escape")

    def find_notignored_git_files(self, context, silent_build):
        """
        Return a list of files that are not ignored by git
        """

        def git(args, error_message, cwd=context.parent_dir, **error_kwargs):
            output, status = command_output("git {0}".format(args), cwd=cwd)
            if status != 0:
                error_kwargs["output"] = output
                error_kwargs["directory"] = context.parent_dir

# Path: harpoon/errors.py
# class HarpoonError(DelfickError):
#     pass
# 
# class BadOption(HarpoonError):
#     desc = "Bad Option"
# 
# Path: harpoon/helpers.py
# @contextmanager
# def a_temp_file():
#     """Yield the name of a temporary file and ensure it's removed after use"""
#     filename = None
#     try:
#         tmpfile = tempfile.NamedTemporaryFile(delete=False)
#         filename = tmpfile.name
#         yield tmpfile
#     finally:
#         if filename and os.path.exists(filename):
#             os.remove(filename)


# Path: harpoon/ship/context.py
from harpoon.errors import HarpoonError, BadOption
from harpoon.helpers import a_temp_file
from contextlib import contextmanager
from io import BytesIO
            from harpoon.ship.runner import Runner, ContainerRunner
import subprocess
import tempfile
import tarfile
import fnmatch
import logging
import shutil
import docker
import shlex
import os
import re

                        extra_included.append(filename)
                        break
            if not silent_build:
                log.info("Adding back %s items\tincluding=%s", len(extra_included), context.include)
            combined = set(list(combined) + extra_included)

        files = sorted(os.path.join(context.parent_dir, filename) for filename in combined)
        if not silent_build:
            log.info("Adding %s things from %s to the context", len(files), context.parent_dir)
        return files

    def convert_nonascii(self, lst):
        """Convert the strange outputs from git commands"""
        for item in lst:
            if item.startswith('"') and item.endswith('"'):
                item = item[1:-1]
                yield item.encode("utf-8").decode("unicode-escape")
            else:
                yield item.encode("utf-8").decode("unicode-escape")

    def find_notignored_git_files(self, context, silent_build):
        """
        Return a list of files that are not ignored by git
        """

        def git(args, error_message, cwd=context.parent_dir, **error_kwargs):
            output, status = command_output("git {0}".format(args), cwd=cwd)
            if status != 0:
                error_kwargs["output"] = output
                error_kwargs["directory"] = context.parent_dir

                raise HarpoonError(error_message, **error_kwargs)