#!/usr/bin/python -S
# -*- coding: iso-8859-15 -*-
# ---------------------------------------------------------------------------
# Importing my local 'site.py', this launcher force the base encoding to
# unicode 'iso-8859-15' ; the xml manipulating scripts can't work with the
# default 'ascii' encoding.
# (note the -S in the python command to overide the standard 'site.py')
#
import site

import sys, string, re, os, codecs

__rel_lib_path__ = ('lib/python',)   #  relative library path
__parent_dir__ = ''                  #  python scripts installation directory

def _libpathAdjust (libPaths):
    global __parent_dir__
    script_dir = os.path.dirname (sys.argv[0])
    if len (script_dir) == 0:     script_dir = '.'
    if script_dir[0] != "/":
        script_dir = os.path.abspath(script_dir)
    __parent_dir__ = os.path.dirname (script_dir)
    for lp in libPaths:
        newPath = os.path.join (__parent_dir__, lp)
        if os.path.isdir (newPath):
            if newPath not in sys.path:
                sys.path.insert(0, newPath)
        else:
            print ("ERROR: Additionnal library path not exists\n\t[%s]"
                   % newPath)
    # -------------------------------------------------- _libpathAdjust()

if __rel_lib_path__:
    _libpathAdjust (__rel_lib_path__)

## print sys.getdefaultencoding()
command = os.path.join (__parent_dir__, 'bin', sys.argv[1])
## print command
execfile (command)



