Package nuke :: Module utils
[hide private]
[frames] | no frames]

Source Code for Module nuke.utils

 1  # Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved. 
 2   
 3  import os.path 
 4  import nuke 
 5   
6 -class FnPySingleton(object):
7 - def __new__(type, *args, **kwargs):
8 if not '_the_instance' in type.__dict__: 9 type._the_instance = object.__new__(type) 10 return type._the_instance
11
12 -def script_directory():
13 14 # Use thisRoot to ensure we're using the root node of the current 15 # context (which may or may not be the node graph's global root). 16 # 17 # This sometimes gets called before the Root node is attached. Fixing this is 18 # quite difficult, so handle the exception that results if we try and access 19 # the node in this state 20 try: 21 scriptFilePath = nuke.thisRoot().knob("name").value() 22 except ValueError: 23 scriptFilePath = None 24 25 if not scriptFilePath: 26 return "" 27 28 return os.path.dirname(scriptFilePath)
29