# -*- coding: utf-8 -*-
"""
/***************************************************************************
 Prisma
                                 A QGIS plugin
 Plugin para fazer caracterização de imóveis 
 Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
                             -------------------
        begin                : 2021-09-29
        copyright            : (C) 2021 by Zago
        email                : guilherme.nascimento@economia.gov.br
        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.
"""
from __future__ import absolute_import

import os
import sys
import subprocess
#from PyQt5.QtWidgets import QMessageBox
#subprocess.check_call([sys.executable, "-m", "pip", "install", "PyPDF2"])
# from .dependency import Dependency
from .settings.install_dependecies import instala_dependencias, verifica_flag_dependencias

arq_dependencias = os.path.join(os.path.dirname(__file__), 'settings', 'dependencies')
flag_dependencias = os.path.join(os.path.dirname(__file__), 'settings', 'flag_dependencies')

# currentDirectoryPath = os.path.dirname(__file__)
# #print currentDirectoryPath

# libraryDirectoryPath = os.path.join(currentDirectoryPath, 'penv/Lib/site-packages')
# #print libraryDirectoryPath
# sys.path.append(libraryDirectoryPath)

# libraryDirectoryPath = os.path.join(currentDirectoryPath, 'penv/Lib/distutils')
# #print libraryDirectoryPath
# #name_lib_dir  = name_lib_dir +'\.qgis2\python\plugins\AzimuthDistanceCalculator\ENV\Lib\distutils'
# sys.path.append(libraryDirectoryPath)

# libraryDirectoryPath = os.path.join(currentDirectoryPath, 'penv/Lib')
# #print libraryDirectoryPath
# #name_lib_dir  = name_lib_dir +'\.qgis2\python\plugins\AzimuthDistanceCalculator\ENV\Lib'
# sys.path.append(libraryDirectoryPath)

# libraryDirectoryPath = os.path.join(currentDirectoryPath, 'penv/Lib/distutils')
# #print libraryDirectoryPath
# #name_lib_dir  = name_lib_dir +'\.qgis2\python\plugins\AzimuthDistanceCalculator\ENV\Lib\distutils'

# libraryDirectoryPath = os.path.join(currentDirectoryPath, 'env/Lib/site-packages')
# #print libraryDirectoryPath
# sys.path.append(libraryDirectoryPath)


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

    :param iface: A QGIS interface instance.
    :type iface: QgsInterface
    """

    # if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'penv')):
    #     d = Dependency()
    #     d.exec_()
    try:
        import geopandas
    except ImportError:
        with open(flag_dependencias, "w", encoding='utf-8') as file:
            file.write("False")

    from .prisma import Prisma
    return Prisma(iface)
