#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © %YEAR% %USER% <%MAIL%>
#
# Distributed under terms of the %LICENSE% license.

"""
%HERE%
"""

from loguru import logger



# logger = logging.getLogger()
import os.path as op
import sys
path_to_script = op.dirname(op.abspath(__file__))
pth = op.join(path_to_script, "../../seededitorqt/")
sys.path.insert(0, pth)
pth = op.join(path_to_script, "../../imtools/")
sys.path.insert(0, pth)
sys.path.insert(0, op.expanduser(r"~/projects/imtools/"))
sys.path.insert(0, op.expanduser(r"~/projects/seededitorqt/"))
sys.path.insert(0, op.expanduser(r"~/projects/skelet3d/"))
sys.path.insert(0, op.expanduser(r"~/projects/fibrous/"))

import argparse



def lisa_main():
    import argparse



    parser = argparse.ArgumentParser(
        # Turn off help, so we print all options in response to -h
        add_help=False
    )
    parser.add_argument(
        '-ni', '--no_interactivity', action='store_true',
        help='run in no interactivity mode, seeds must be defined')
    parser.add_argument(
        '--autolisa',
        action='store_true',
        help='run autolisa in dir',
        default=False
    )
    knownargs, unknownargs = parser.parse_known_args()
    # Read alternative config file. First is loaded default config. Then user
    # config in lisa_data directory. After that is readed config defined by
    # --configfile parameter

    if knownargs.no_interactivity or knownargs.autolisa:
        from . import organ_segmentation


        organ_segmentation.main()
    else:
        import PyQt5
        import PyQt5.QtGui
        import sys


        from PyQt5.QtWidgets import QApplication
        app = QApplication(sys.argv)
        # Create and display the splash screen
        from . import splash_screen


        splash = splash_screen.splash_screen(app)
        from . import organ_segmentation


        organ_segmentation.main(app, splash)


if __name__ == "__main__":
    lisa_main()
