#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#   This file is part of OpenTeacher.
#
#   OpenTeacher 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; version 3 of the License.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os, sys

if __name__ == "__main__":
    # Import the python package openteacher to find its path
    import openteacher as parent
    dirname = os.path.dirname(parent.__file__)
    
    # Insert its directory path as the first place to look for modules
    sys.path.insert(0, dirname)
    
    # We now need to delete the openteacher package from memory, to 
    # avoid clashes with similarly named module (openteacher.py)
    del parent, dirname
    if "openteacher" in sys.modules:
        del(sys.modules["openteacher"])
       
    # Import the module (openteacher.py)
    import openteacher
    
    # Run it
    openteacher.main()
