# Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved.

## init.py
## loaded by nuke before menu.py

import os
import sys
import KEnv

nuke.pluginAddPath('./gizmos')
nuke.pluginAddPath('./icons')
nuke.pluginAddPath('./ndk')

# KEnv
try:
    project = os.getenv('PROJECT')
except:
    project = "GEN"

env = KEnv.create(PROJECT=project, APP_ID='nuke')
PYTHON_LIBS_NUKE = env.get('PYTHON_LIBS_NUKE')

# project path
try:
    sys.path.insert(1, PYTHON_LIBS_NUKE)
except:
    "init.py: cannot find project libs path specified"

# Paths
nuke_path = os.getenv('NUKE_PATH')
plugin_path = os.path.join(nuke_path, 'plugins')
icon_path = os.path.join(nuke_path, 'icons')

# Plugins
nuke.pluginAppendPath(plugin_path, icon_path)

def filenameFix(s):
    s = s.replace("/Volumes/O/", "//calculon/o/", 1)
    s = s.replace("/Volumes/P/", "//hades/p/", 1)
    s = s.replace("O:/", "//calculon/o/", 1)
    s = s.replace("P:/", "//hades/p/", 1)
    s = s.replace("o:/", "//calculon/o/", 1)
    s = s.replace("p:/", "//hades/p/", 1)
    return s

# Needs to be loaded last?
import kellerPluginCore
kellerPluginCore.start( os.path.join( nuke_path ,"pythonplugins") )

import cryptomatte_utilities
cryptomatte_utilities.setup_cryptomatte()