"""sophon python module
"""
__all__ = []

try:
    import numpy
except ImportError:
    print('SAIL bindings requires "numpy" package.')
    print('Install it via command:')
    print('   pip3 install numpy')
    raise

import os
from sqlite_vfs.core import SQLiteVFS
import json


def get_config(json_path: str, is_vfs: bool = False, vfs_path: str="./application.svfs"):
    if is_vfs:
        vfs = SQLiteVFS(vfs_path)
        data = json.loads(vfs.read_file(json_path))
    else:
        with open(json_path, 'r') as file:
            data = json.load(file)
    return data


def is_img(file_name):
    """judge the file is available image or not
    Args:
        file_name (str): input file name
    Returns:
        (bool) : whether the file is available image
    """
    fmt = os.path.splitext(file_name)[-1]
    if isinstance(fmt, str) and fmt.lower() in ['.jpg','.png','.jpeg','.bmp','.jpeg','.webp']:
        return True
    else:
        return False

