Example #1
0
def determineProjectFolder(compFilename, index) :
    comp = parse(compFilename)
    q = Query([
        name('Tools'), type('Loader'), name('Clips'), type('Clip'), name('Filename'),
        ])
    r = q.do(comp)
    for v in r :
        path = unescapeBS(v.values)
        if path.find(index) != -1 :
            return path[ 1: path.index(index)]
Example #2
0
def doWork(comp,oldIndex,newIndex) :
    # 1. rewrite indexes in Loaders
    print "rewrite indexes in Loaders"
    q = Query([
        name('Tools'), type('Loader'), name('Clips'), type('Clip'), name('Filename')
        ])
    r = q.do(comp)
    rewrite(r, oldIndex, newIndex)


    # 2. rewrite indexes in Savers
    print "rewrite indexes in Savers"
    q = Query([
        name('Tools'), type('Saver'), name('Inputs'), name('Clip'), name('Value'), name('Filename')
    ])
    r = q.do(comp)
    rewrite(r, oldIndex, newIndex)

    # 3. rewrite indexes in OutputClips
    print "rewrite indexes in OutputClips"
    q = Query([
        name('OutputClips'), any()
    ])
    r = q.do(comp)
    rewrite(r, oldIndex, newIndex)

    # 4. set GlobalRange
    # 4.1 determine range by ... first appropriate sequence
    sequence_name = ""
    q = Query([
        name('Tools'), type('Loader'), name('Clips'), type('Clip'), name('Filename')
    ])
    r = q.do(comp)
    for v in r:
        print "test sequence: " + v.values
        if v.values.find(newIndex) != -1 and checkHasNumbers(v.values) :
            sequence_name = unescapeBS(v.values[1:-9])
            break

    # 4.2 select files by sequence ..
    minFrame = maxFrame = 0
    print "sequence: " + sequence_name
    for f in os.listdir(getFolder(sequence_name)):
        if f.startswith(getFile(sequence_name)) :
            frame = selectFrameNumber(f)
            if frame < minFrame : minFrame = frame
            if frame > maxFrame : maxFrame = frame
    frameCount = maxFrame - minFrame
    print "fames: from " + str(maxFrame) + " to " + str(minFrame) + " count = " + str(frameCount)
    # 4.3 rewrite
    q = Query([
        name('GlobalRange')
    ])
    r = q.do(comp)
    r[0].values[0].values = str(minFrame)
    r[0].values[1].values = str(maxFrame + 1)

    # 5. set RenderRange
    q = Query([
        name('RenderRange')
    ])
    r = q.do(comp)
    r[0].values[0].values = str(minFrame)
    r[0].values[1].values = str(maxFrame)

    # 6. rewrite TrimIn/TrimOut/Length in Loaders
    q = Query([ name('Tools'), type('Loader'), name('Clips'), type('Clip')])
    r = q.do(comp)
    for v in r:
        print "++++: "
        fn = Query([name('Filename')]).do(v)
        if checkHasNumbers(fn[0].values):
            print "rewrite "
            Query([name('TrimIn')]).do(v)[0].values = str(minFrame)
            Query([name('TrimOut')]).do(v)[0].values = str(maxFrame)
            Query([name('Length')]).do(v)[0].values = str(frameCount + 1)
            Query([name('GlobalStart')]).do(v)[0].values = str(minFrame)
            Query([name('GlobalEnd')]).do(v)[0].values = str(maxFrame)