<commit_before>import os
import click
import shutil

from shellfoundry.utilities.archive_creator import ArchiveCreator


class ShellPackageBuilder(object):

    def is_tosca_based_shell(self, path):
        """
        Determines whether a shell is a TOSCA based shell
        :param path: Path to shell
        :return:
        :rtype: bool
        """
        return os.path.exists(self._get_tosca_meta_path(path))

    def pack(self):
        package_path = 'shell-package'

        self._copy_tosca_meta(package_path, '')
        self._copy_shell_definition(package_path, '')
        self._copy_shell_icon(package_path, '')
        self._create_driver('', package_path)
        zip_path = self._zip_package(package_path, '', 'shell-package')

        shutil.rmtree(path=package_path, ignore_errors=True)
        click.echo(u'Shell package was successfully created:')
        click.echo(zip_path)

    def _copy_shell_icon(self, package_path, path):
        self._copy_file(
            src_file_path=os.path.join(path, 'shell-icon.png'),
            dest_dir_path=package_path)

    def _copy_shell_definition(self, package_path, path):
        self._copy_file(
            src_file_path=os.path.join(path, 'shell-definition.yml'),
            dest_dir_path=package_path)

    def _copy_tosca_meta(self, package_path, path):
        self._copy_file(
            src_file_path=self._get_tosca_meta_path(path),
            dest_dir_path=os.path.join(package_path, 'TOSCA-Metadata'))

    @staticmethod
    def _get_tosca_meta_path(path):
        return os.path.join(path, 'TOSCA-Metadata', 'TOSCA.meta')

    @staticmethod
    def _create_driver(path, package_path):
        dir_to_zip = os.path.join(path, 'src')
        zip_file_path = os.path.join(package_path, 'shell-driver')
        ArchiveCreator.make_archive(zip_file_path, 'zip', dir_to_zip)

    @staticmethod
    def _copy_file(src_file_path, dest_dir_path):
        if not os.path.exists(dest_dir_path):
            os.makedirs(dest_dir_path)
        shutil.copy(src_file_path, dest_dir_path)

    @staticmethod
    def _zip_package(package_path, path, package_name):
        zip_file_path = os.path.join(path, 'dist', package_name)
        return ArchiveCreator.make_archive(zip_file_path, 'zip', package_path)
<commit_msg>attempt to fix tests2<commit_after>import os
import click
import shutil

from shellfoundry.utilities.archive_creator import ArchiveCreator


class ShellPackageBuilder(object):

    def is_tosca_based_shell(self, path):
        """
        Determines whether a shell is a TOSCA based shell
        :param path: Path to shell
        :return:
        :rtype: bool
        """
        return os.path.exists(self._get_tosca_meta_path(path))

    def pack(self):
        package_path = 'shell-package'

        self._copy_tosca_meta(package_path, '')
        self._copy_shell_definition(package_path, '')
        self._copy_shell_icon(package_path, '')
        self._create_driver('', package_path)
        zip_path = self._zip_package(package_path, '', 'shell-package')

        if os.path.exists(package_path):
            shutil.rmtree(path=package_path, ignore_errors=True)

        click.echo(u'Shell package was successfully created:')
        click.echo(zip_path)

    def _copy_shell_icon(self, package_path, path):
        self._copy_file(
            src_file_path=os.path.join(path, 'shell-icon.png'),
            dest_dir_path=package_path)

    def _copy_shell_definition(self, package_path, path):
        self._copy_file(
            src_file_path=os.path.join(path, 'shell-definition.yml'),
            dest_dir_path=package_path)

    def _copy_tosca_meta(self, package_path, path):
        self._copy_file(
            src_file_path=self._get_tosca_meta_path(path),
            dest_dir_path=os.path.join(package_path, 'TOSCA-Metadata'))

    @staticmethod
    def _get_tosca_meta_path(path):
        return os.path.join(path, 'TOSCA-Metadata', 'TOSCA.meta')

    @staticmethod
    def _create_driver(path, package_path):
        dir_to_zip = os.path.join(path, 'src')
        zip_file_path = os.path.join(package_path, 'shell-driver')
        ArchiveCreator.make_archive(zip_file_path, 'zip', dir_to_zip)

    @staticmethod
    def _copy_file(src_file_path, dest_dir_path):
        if not os.path.exists(dest_dir_path):
            os.makedirs(dest_dir_path)
        shutil.copy(src_file_path, dest_dir_path)

    @staticmethod
    def _zip_package(package_path, path, package_name):
        zip_file_path = os.path.join(path, 'dist', package_name)
        return ArchiveCreator.make_archive(zip_file_path, 'zip', package_path)

{'fraction_non_alphanumeric': 0.1021598272138229, 'fraction_numerical': 0.00021598272138228941, 'mean_word_length': 3.1683168316831685, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2972241', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1503, 'n_words': 247}