#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# =============================================================================
# Copyright Ostap developers
# =============================================================================
## @file ostap
#  
#     .oooooo.                .                        
#    d8P'  `Y8b             .o8                        
#   888      888  .oooo.o .o888oo  .oooo.   oo.ooooo.  
#   888      888 d88(  "8   888   `P  )88b   888' `88b 
#   888      888 `"Y88b.    888    .oP"888   888   888 
#   `88b    d88' o.  )88b   888 . d8(  888   888   888 
#    `Y8bood8P'  8""888P'   "888" `Y888""8o  888bod8P' 
#                                            888       
#                                           o888o      
#                                                    
#  Simple interactive PyRoot-based analysis environment to provide access
#  to zillions useful decorators for ROOT (and not only ROOT!) objects&classes  
# =============================================================================
"""
Simple interactive PyRoot-based analysis environment
to provide access to zillions useful decorators for ROOT
(and not only ROOT) objects&classes

``Python-based Interactive Environment for Smart and Friendly Physics Analysis''

The project has been designed with the kind help from Pere MATO and Andrey TSAREGORODTSEV. 

And it is based on the LoKi project: ``C++ ToolKit for Smart and Friendly Physics Analysis''
"""
# =============================================================================
## perform the actual start of ostap 
from   ostap.core.run_ostap import *
## 
import ostap.fixes.fixes
# =============================================================================


# =============================================================================
if with_ipython () :
    raise RuntimeError("Can't start Ostap from ipython!")

# ============================================================================= 
if arguments.batch :
    ## nothing to do 
    logger.debug  ('Bye, bye...')
    exit () 

# ============================================================================= 
if not arguments.simple : 
    try :
        import IPython
    except ImportError :
        logger.error ( "Can't use IPython, switch to ``simple'' interactive console" )
        arguments.simple = True
        arguments.embed  = False
        
# =============================================================================
if arguments.embed : ## the only one option up to Ostap v1r9

    logger.info ('Start embedded interactive shell')
    
    import IPython
    IPython.embed ()
    
elif arguments.simple : ## new from Ostap v1r10 
        
    _vars = globals().copy()
    _vars.update( locals() )
    
    import readline
    import code
    
    logger.info ('Start simple interactive shell') 
    
    shell = code.InteractiveConsole( _vars )
    shell.interact()
    
else :                   ## new from Ostap v1r10 

    _vars = globals().copy()
    _vars.update( locals() )
    
    logger.info ('Start interactive shell') 
    
    import IPython
    IPython.start_ipython ( argv = [] , user_ns = _vars )


exit ()  ##  bye-bye 

# =============================================================================
##                                                                      The END 
# =============================================================================
