Thanks for all the info.
In order to get this as simple as possible, Im now concentrating just on the Nuke version of it. And also, I will let all the matching scheme
for a later time. Even so, I do really appreciate the tips you gave me, Ill keep all them handy.
I tried to use the dstName pointing to a destination dir, and it works like a charm for most cases. Unfortunately, Im getting errors from the
OutputNameGenerator when instancing to the CopySequence class for certain sequence names. In this case 'shot001_v01_YGO.#.tif', which is
a very common name pattern that I generally use for outputs. Is there any workaround on this?
Traceback (most recent call last):
File "/Volumes/Video/_tools/py/scriptArchive_v01_YGO.py", line 68, in <module>
File "/Volumes/Video/_tools/py/scriptArchive_v01_YGO.py", line 58, in archive
b = sequence.CopySequence(a,'/Volumes/Video/tmp/', keepExt=True, verbose=True,resolveSrcLinks=True)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/cgkit/sequence.py", line 1984, in __init__
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/cgkit/sequence.py", line 1690, in __init__
for uiSrc,uiDst in ong.iterNames():
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/cgkit/sequence.py", line 1480, in iterNames
self._enforceDstRange, self._repeatSrc, self._keepExt):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/cgkit/sequence.py", line 1497, in _iterNames
res = self._outputNameSpec(srcSequence, dstName, dstRangeIter is not None)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/cgkit/sequence.py", line 1647, in _outputNameSpec
raise ValueError('Invalid destination name: "%s". There are not enough substitution patterns (expected %s).'%(dstName, expectedStr))
ValueError: Invalid destination name: "/Volumes/Video/tmp/shot001_v01_YGO.#.tif
". There are not enough substitution patterns (expected 0 or 2 patterns).
Certainly you have your reasons for that, but I would appreciate if you could explain it to me. Why does the class attempts to substitute patterns
on the sequence name if it is a 'simple' copy to a different directory?
Another question I have, lets assume that I have a sequence list that contains sequences from different directories, should I need to create an instance of sequence.CopySequence for each sequence that resides into a different path? As I need to supply a string for dstName, it is difficult for me to imagine how could I change the dstName pattern (which on my case will always be folders) accordingly to the path of the current source sequence that I want to copy.
And finally, yes, you are correct. '#' in Shake really means a four-padded number.
Sorry if Im asking just lame questions, and again, thanks for all the support and efforts.
Wed, 16 Dec 2009 21:49:10 +0000, Matthias Baas <matthias.baas@...> escreveu:
> Hi Ygor,
> > Im new to cgkit and first of all I would like to give my congrats for
> > such interesting package.
> > 1. Im creating a tool that will archive Shake and Nuke scripts, so Im
> > trying to use the sequence module to handle the input files.
> > Currently Im not able to use the CopySequence class to copy my files
> > keeping the same filename, the only thing I would like to change is
> > the path. I really dont need to change the filename, padding pattern
> > and so on. Im looking to the same functionality as seqcp.py gives me,
> > input sequence and output path. Is there any pattern, scheme or
> > anything else that would give me this option?!
> If the dstName argument of the CopySequence class refers to a directory,
> then the input files will keep their name. I will add this to the docs
> (I just noticed that this is not mentioned there).
> Here is an example using the OutputNameGenerator class (which is what
> the CopySequence class uses to produce source/destination name pairs):
> >>> from cgkit.sequence import *
> >>> seqs = buildSequences(["spam1_1.tif", "spam1_2.tif", "spam1_5.tif"])
> >>> for src,dst in OutputNameGenerator(seqs, "targetdir"):
> ... print src,"->",dst
> spam1_1.tif -> targetdir/spam1_1.tif
> spam1_2.tif -> targetdir/spam1_2.tif
> spam1_5.tif -> targetdir/spam1_5.tif
> In this example, "targetdir" must be an existing directory, otherwise it
> is interpreted as the new name for the sequence.
> But if you never need to rename sequences, then maybe it would be enough
> to just use the os.path module to construct the output paths (assuming
> you somehow managed to get a list of the source files).
> > 2. I will have to match the strings that I get from Shake and Nuke
> > with the files themselves. The problem is, I have strings that just
> > represents the numbering of the files instead of refering to the
> > exact padding on them. IE. shot001.1-230#.iff doesn't gives me any
> > hint if it has a three, four or five digit padding.
> Does that string come from a Shake script? If so, then the '#' indicates
> that it's a 4-padded number.
> > Would be the
> > 'usual' or 'right' way of matching this by testing the lenght of the
> > filepadding with something like len(fileName.split('.'))!?
> Well, you don't have to use split() to get to the numbers. You could use
> the SeqString class (that's basically what the module is for, handling
> strings that contain numbers):
> >>> s = SeqString("shot001.0017.iff")
> >>> s.numCount()
> (there are 2 numbers in the file name)
> >>> s.getNumWidth(-1)
> (the last number is a 4-padded number)
> >>> s.getNum(-1)
> (the value of the last number is 17)
> >>> s.getNumStr(-1)
> (this is the number as a string, just as it appears in the file name)
> Also have a look at the match() method which you could use to check what
> sequence a file name belongs to. You could also use the buildSequences()
> function or the glob() function (the one in the sequence module, not the
> one in the glob module) to create sequences from a directory content and
> then just work out which of the sequences file name pattern was
> referring to.
> I hope that helped.
> - Matthias -
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> cgkit-user mailing list