def check_extention()

in python/base_component_image/build-push.py [0:0]


def check_extention(
        file_path: str, 
        type: str = '.yaml'):
    """
    This function checks if a file exists and has the specified extension.

    Args:
        file_path (str): The path to the file.
        type (str, optional): The file extension to check for. Defaults to '.yaml'.

    Returns:
        str: The file path if it exists and has the specified extension.

    Raises:
        FileNotFoundError: If the file does not exist.
        ArgumentTypeError: If the file path is not a string or the type is not a string.
    """
    if not isinstance(file_path, str):
        raise ArgumentTypeError("file_path must be a string")

    if not isinstance(type, str):
        raise ArgumentTypeError("type must be a string")
    
    if os.path.exists(file_path):
        if not file_path.lower().endswith(type):
            raise ArgumentTypeError(f"File provited must be {type}: {file_path}")
    else:
        raise FileNotFoundError(f"{file_path} does not exist")
    
    return file_path