Package nukescripts :: Module reads
[hide private]
[frames] | no frames]

Source Code for Module nukescripts.reads

 1  # Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved. 
 2   
 3  import os.path 
 4  import re 
 5  import nuke 
 6   
 7  #################### 
 8  # 
 9  # this function returns filenames from all Read nodes 
10  # options : 
11  # file - outputs only file names 
12  # dir  - outputs only dir names 
13  # long - entire path 
14  # 
15   
16 -def get_reads(method):
17 """Returns file names from all Read nodes. 18 19 Options: 20 file - outputs only file names 21 dir - outputs only directory names 22 long - outputs the entire path""" 23 24 # create variable for the text 25 finalmsg = "" 26 #go thru all the nodes 27 allnodes = nuke.allNodes(group = nuke.root()) 28 for i in allnodes: 29 _class = i.Class() 30 if _class == "Read": 31 # get the name of the file dir (just the last part) 32 # use this to get only the filename 33 curname = "" 34 name = nuke.filename(i) 35 if name is None: 36 continue 37 if method == "file": 38 curname = os.path.basename(name) 39 # use this to get only the dir 40 if method == "dir" or method == "": 41 curname = os.path.dirname(name) 42 # get the whole path 43 if method == "long": 44 curname = name 45 46 curname = re.sub("\.%.*", "", curname) 47 48 # add on to existing variable 49 # make sure to avoid adding the slate image :) 50 match = re.search("slate", curname) 51 if match is None: 52 finalmsg += curname 53 54 finalmsg += "\n" 55 56 return finalmsg
57