# 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
    def find_files_for_tar(self, context, silent_build):
        """
        Return [(filename, arcname), ...] for all the files.
        """
        if not context.enabled:
            return

        files = self.find_files(context, silent_build)

        for path in files:
            relname = os.path.relpath(path, context.parent_dir)
            arcname = "./{0}".format(relname.encode("utf-8").decode("ascii", "ignore"))
            if os.path.exists(path):
                yield path, arcname

    def find_files(self, context, silent_build):
        """
        Find the set of files from our parent_dir that we care about
        """
        first_layer = ["'{0}'".format(thing) for thing in os.listdir(context.parent_dir)]
        output, status = command_output(
            "find {0} -type l -or -type f {1} -follow -print".format(
                " ".join(first_layer), context.find_options
            ),
            cwd=context.parent_dir,
        )
        if status != 0:
            if context.ignore_find_errors:
                log.warning("The find command failed to run, will continue anyway")
            else:

# 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

    def find_files_for_tar(self, context, silent_build):
        """
        Return [(filename, arcname), ...] for all the files.
        """
        if not context.enabled:
            return

        files = self.find_files(context, silent_build)

        for path in files:
            relname = os.path.relpath(path, context.parent_dir)
            arcname = "./{0}".format(relname.encode("utf-8").decode("ascii", "ignore"))
            if os.path.exists(path):
                yield path, arcname

    def find_files(self, context, silent_build):
        """
        Find the set of files from our parent_dir that we care about
        """
        first_layer = ["'{0}'".format(thing) for thing in os.listdir(context.parent_dir)]
        output, status = command_output(
            "find {0} -type l -or -type f {1} -follow -print".format(
                " ".join(first_layer), context.find_options
            ),
            cwd=context.parent_dir,
        )
        if status != 0:
            if context.ignore_find_errors:
                log.warning("The find command failed to run, will continue anyway")
            else:

                raise HarpoonError(