# Path: scar/exceptions.py
# class GitHubTagNotFoundError(ScarError):
#     """
#     The specified tag was not found in the GitHub repository
# 
#     :ivar version: Tag used for the search
#     """
# 
#     fmt = "The tag '{tag}' was not found in the GitHub repository."
# 
# class YamlFileNotFoundError(ScarError):
#     """
#     The yaml configuration file does not exist
# 
#     :ivar file_path: Path of the file
#     """
#     fmt = "Unable to find the yaml file '{file_path}'"


import base64
import json
import os
import re
import shutil
import subprocess
import tarfile
import tempfile
import uuid
import sys
import yaml
import scar.logger as logger
import scar.http.request as request
from copy import deepcopy
from zipfile import ZipFile
from io import BytesIO
from typing import Optional, Dict, List, Generator, Union, Any, Tuple
from distutils import dir_util
from packaging import version
from scar.exceptions import GitHubTagNotFoundError, YamlFileNotFoundError
            tar.extractall(path=destination_path)

    @staticmethod
    def unzip_folder(zip_path: str, folder_where_unzip_path: str, msg: str='') -> None:
        """Must use the unzip binary to preserve the file properties and the symlinks."""
        zip_exe = '/usr/bin/unzip'
        SysUtils.execute_command_with_msg([zip_exe, zip_path],
                                          cmd_wd=folder_where_unzip_path,
                                          cli_msg=msg)

    @staticmethod
    def zip_folder(zip_path: str, folder_to_zip_path: str, msg: str='') -> None:
        """Must use the zip binary to preserve the file properties and the symlinks."""
        zip_exe = '/usr/bin/zip'
        SysUtils.execute_command_with_msg([zip_exe, '-r9y', zip_path, '.'],
                                          cmd_wd=folder_to_zip_path,
                                          cli_msg=msg)

    @staticmethod
    def is_file(file_path: str):
        """Test whether a path is a regular file."""
        return os.path.isfile(file_path)

    @staticmethod
    def load_yaml(file_path: str) -> Dict:
        """Returns the content of a YAML file as a Dict."""
        if os.path.isfile(file_path):
            with open(file_path) as cfg_file:
                return yaml.safe_load(cfg_file)
        else:

# Path: scar/exceptions.py
# class GitHubTagNotFoundError(ScarError):
#     """
#     The specified tag was not found in the GitHub repository
# 
#     :ivar version: Tag used for the search
#     """
# 
#     fmt = "The tag '{tag}' was not found in the GitHub repository."
# 
# class YamlFileNotFoundError(ScarError):
#     """
#     The yaml configuration file does not exist
# 
#     :ivar file_path: Path of the file
#     """
#     fmt = "Unable to find the yaml file '{file_path}'"


# Path: scar/utils.py
import base64
import json
import os
import re
import shutil
import subprocess
import tarfile
import tempfile
import uuid
import sys
import yaml
import scar.logger as logger
import scar.http.request as request
from copy import deepcopy
from zipfile import ZipFile
from io import BytesIO
from typing import Optional, Dict, List, Generator, Union, Any, Tuple
from distutils import dir_util
from packaging import version
from scar.exceptions import GitHubTagNotFoundError, YamlFileNotFoundError

            tar.extractall(path=destination_path)

    @staticmethod
    def unzip_folder(zip_path: str, folder_where_unzip_path: str, msg: str='') -> None:
        """Must use the unzip binary to preserve the file properties and the symlinks."""
        zip_exe = '/usr/bin/unzip'
        SysUtils.execute_command_with_msg([zip_exe, zip_path],
                                          cmd_wd=folder_where_unzip_path,
                                          cli_msg=msg)

    @staticmethod
    def zip_folder(zip_path: str, folder_to_zip_path: str, msg: str='') -> None:
        """Must use the zip binary to preserve the file properties and the symlinks."""
        zip_exe = '/usr/bin/zip'
        SysUtils.execute_command_with_msg([zip_exe, '-r9y', zip_path, '.'],
                                          cmd_wd=folder_to_zip_path,
                                          cli_msg=msg)

    @staticmethod
    def is_file(file_path: str):
        """Test whether a path is a regular file."""
        return os.path.isfile(file_path)

    @staticmethod
    def load_yaml(file_path: str) -> Dict:
        """Returns the content of a YAML file as a Dict."""
        if os.path.isfile(file_path):
            with open(file_path) as cfg_file:
                return yaml.safe_load(cfg_file)
        else:

            raise YamlFileNotFoundError(file_path=file_path)