How to use the rebasehelper.archive.Archive function in rebasehelper

To help you get started, we’ve selected a few rebasehelper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rebase-helper / rebase-helper / test / test_archive.py View on Github external
def extraction_test(self, archive):
        """Generic test for extraction of all types of archives"""
        EXTRACT_DIR = os.path.join(os.getcwd(), 'dir')
        EXTRACTED_FILE = os.path.join(EXTRACT_DIR, self.ARCHIVED_FILE)

        archive = Archive(archive)
        archive.extract_archive(EXTRACT_DIR)

        #  check if the dir was created
        assert os.path.isdir(EXTRACT_DIR)
        #  check if the file was extracted
        assert os.path.isfile(EXTRACTED_FILE)
        #  check the content
        with open(EXTRACTED_FILE) as f:
            assert f.read().strip() == self.ARCHIVED_FILE_CONTENT
github rebase-helper / rebase-helper / test / test_git_helper.py View on Github external
def _extract_sources(self, archive, dir_name):
        archive = Archive(archive)
        archive.extract_archive(dir_name)
github rebase-helper / rebase-helper / rebasehelper / application.py View on Github external
def extract_archive(archive_path, destination):
        """
        Extracts given archive into the destination and handle all exceptions.

        :param archive_path: path to the archive to be extracted
        :param destination: path to a destination, where the archive should be extracted to
        :return:
        """
        archive = Archive(archive_path)

        try:
            archive.extract_archive(destination)
        except IOError:
            raise RebaseHelperError("Archive '{}' can not be extracted".format(archive_path))
        except (EOFError, SystemError):
            raise RebaseHelperError("Archive '{}' is damaged".format(archive_path))
github rebase-helper / rebase-helper / rebasehelper / application.py View on Github external
old_dir = os.path.join(old_dir, *dirs[1:])
            if new_tld == dirs[0]:
                new_dir = os.path.join(new_dir, *dirs[1:])

        new_dirname = os.path.relpath(new_dir, new_sources_dir)

        if new_dirname != '.':
            self.rebase_spec_file.update_setup_dirname(new_dirname)

        # extract rest of source archives to correct paths
        rest_sources = [self.old_rest_sources, self.new_rest_sources]
        spec_files = [self.spec_file, self.rebase_spec_file]
        sources_dirs = [old_sources_dir, new_sources_dir]
        for sources, spec_file, sources_dir in zip(rest_sources, spec_files, sources_dirs):
            for rest in sources:
                archive = [x for x in Archive.get_supported_archives() if rest.endswith(x)]
                if archive:
                    dest_dir = spec_file.find_archive_target_in_prep(rest)
                    if dest_dir:
                        Application.extract_sources(rest, os.path.join(sources_dir, dest_dir))

        return [old_dir, new_dir]