# -*- coding: utf-8 -*-
"""
/***************************************************************************
 SemanticComponents
                                 A QGIS plugin
 Plugin enables processing, managing and visualizing spatial and graph data
 Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
                             -------------------
        begin                : 2023-02-05
        copyright            : (C) 2023 by WIZIPISI
        email                : wizipisi@wizipisi.pl
        git sha              : $Format:%H$
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
 This script initializes the plugin, making it known to QGIS.
"""
import os
import sys
from qgis.core import *


# noinspection PyPep8Naming
def classFactory(iface):  # pylint: disable=invalid-name
    """Load SemanticComponents class from file SemanticComponents.

    :param iface: A QGIS interface instance.
    :type iface: QgsInterface
    """
    #
    installDependencies(iface)
    from .sc_qgis import SemanticComponents
    return SemanticComponents(iface)


def installDependencies(iface):
    dependencies_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'dependencies')
    try:
        import isodate
    except ImportError:
        path = os.path.join(dependencies_dir, 'isodate-0.6.1-py2.py3-none-any.whl')
        sys.path.append(path)
        import isodate
    try:
        import rdflib
    except ImportError:
        path = os.path.join(dependencies_dir, 'rdflib-6.3.2-py3-none-any.whl')
        sys.path.append(path)
        import rdflib
    try:
        import SPARQLWrapper
    except ImportError:
        path = os.path.join(dependencies_dir, 'SPARQLWrapper-2.0.0-py3-none-any.whl')
        sys.path.append(path)
        import rdflib
