Example #1
0
    def execute(self):
        productionLocation = self.productionDetails[2]
        fileLocation = self.fileDetails[3]
        fileLocation = os.path.join(productionLocation, fileLocation)
        fileLocationDir = os.path.dirname(fileLocation)
        absRefLoc = os.path.normcase(
            posixpath.normpath(
                os.path.join(self.productionDetails[2],
                             self.currentFileLocation)))
        absNewLoc = absRefLoc[0:len(absRefLoc) -
                              len(self.currentFilename)] + self.newFilename
        newpath = "//" + _relpath(absNewLoc, fileLocationDir)
        handle = blendfile.openBlendFile(fileLocation, 'r+b')
        for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):

            relPath = libraryblock.Get("name").split("\0")[0].replace(
                "\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)

            if normPath == absRefLoc:
                libraryblock.Set("name", newpath)

        for imageblock in handle.FindBlendFileBlocksWithCode("IM"):

            relPath = imageblock.Get("name").split("\0")[0].replace("\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath == absRefLoc:
                imageblock.Set("name", newpath)

        handle.close()
    def execute(self):
        productionLocation = self.productionDetails[2]
        fileLocation = self.fileDetails[3]
        fileLocation = os.path.join(productionLocation, fileLocation)
        fileLocationDir = os.path.dirname(fileLocation)
        absRefLoc = os.path.normcase(posixpath.normpath(os.path.join(self.productionDetails[2], self.currentFileLocation)))
        absNewLoc = absRefLoc[0:len(absRefLoc)-len(self.currentFilename)]+self.newFilename
        newpath = "//"+_relpath(absNewLoc, fileLocationDir)
        handle = blendfile.openBlendFile(fileLocation, 'r+b')
        for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):
                
            relPath = libraryblock.Get("name").split("\0")[0].replace("\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)

            if normPath==absRefLoc:
                libraryblock.Set("name", newpath)

        for imageblock in handle.FindBlendFileBlocksWithCode("IM"):
            
            relPath = imageblock.Get("name").split("\0")[0].replace("\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath==absRefLoc:
                imageblock.Set("name", newpath)
            
        handle.close()
    def execute(self):
        productionLocation = self.productionDetails[indexer.INDEX_PRODUCTION_LOCATION]
        fileLocation = self.fileDetails[indexer.INDEX_FILE_LOCATION]
        fileLocation = os.path.join(productionLocation, fileLocation)
        subDirs = fileLocation.replace(self.sourceDirectory, self.targetDirectory, 1)
        fileLocationDir = os.path.dirname(subDirs)
        absRefLoc = os.path.normcase(posixpath.normpath(os.path.join(self.productionDetails[2], subDirs)))
        
        absNewLoc = os.path.normcase(posixpath.normpath(os.path.join(self.productionDetails[2], self.referenceFileDetails[indexer.INDEX_FILE_LOCATION])))
        newpath = "//"+_relpath(absNewLoc, fileLocationDir)
        handle = blendfile.openBlendFile(fileLocation, 'r+b')
        for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):
            
            relPath = libraryblock.Get("name").split("\0")[0].replace("\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath==absNewLoc:
                libraryblock.Set("name", newpath)

        for imageblock in handle.FindBlendFileBlocksWithCode("IM"):
            
            relPath = imageblock.Get("name").split("\0")[0].replace("\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath==absNewLoc:
                imageblock.Set("name", newpath)
            
        handle.close()
Example #4
0
    def execute(self):
        productionLocation = self.productionDetails[2]
        fileLocation = self.fileDetails[3]
        fileLocation = os.path.join(productionLocation, fileLocation)
        fileLocationDir = os.path.dirname(fileLocation)
        absRefLoc = os.path.normcase(
            posixpath.normpath(
                os.path.join(self.productionDetails[2],
                             self.currentFileLocation)))
        handle = blendfile.openBlendFile(fileLocation, 'r+b')
        libRef = 0
        for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):
            relPath = libraryblock.Get("name").split("\0")[0]
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath == absRefLoc:
                libRef = libraryblock.OldAddress

        for idblock in handle.FindBlendFileBlocksWithCode("ID"):
            lib = idblock.Get("lib")
            if lib == libRef:
                name = idblock.Get("name").split("\0")[0]
                if name == self.elementDetails[2]:
                    idblock.Set("name", self.newElementName)

        handle.close()
Example #5
0
    def execute(self):
        productionLocation = self.productionDetails[2]
        fileLocation = self.fileDetails[3]
        currentFileLocation = os.path.normcase(
            os.path.normpath(os.path.join(productionLocation, fileLocation)))
        newFileLocation = os.path.normcase(
            os.path.normpath(
                os.path.join(
                    productionLocation,
                    os.path.join(self.newLocation, self.currentFilename))))
        dirLocation = os.path.normcase(
            os.path.normpath(os.path.dirname(newFileLocation)))

        #create target directory if not existing
        if not os.path.exists(dirLocation):
            os.makedirs(dirLocation)

        if svn.isKnownSVNFile(currentFileLocation):
            svn.svnMove(currentFileLocation, newFileLocation)
        else:
            shutil.move(currentFileLocation, newFileLocation)

        #update ID and IM tags of blend files.
        if self.currentFilename.endswith(".blend"):
            handle = blendfile.openBlendFile(newFileLocation, 'r+b')

            for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):
                relPath = libraryblock.Get("name").split("\0")[0]
                absPath = blendfile.blendPath2AbsolutePath(
                    currentFileLocation, relPath)
                normPath = os.path.normcase(os.path.normpath(absPath))
                newRelPath = _relpath(normPath, dirLocation)
                libraryblock.Set("name", "//" + newRelPath)

            for libraryblock in handle.FindBlendFileBlocksWithCode("IM"):
                relPath = libraryblock.Get("name").split("\0")[0]
                if len(relPath) > 0:
                    absPath = blendfile.blendPath2AbsolutePath(
                        currentFileLocation, relPath)
                    normPath = os.path.normcase(os.path.normpath(absPath))
                    newRelPath = _relpath(normPath, dirLocation)
                    libraryblock.Set("name", "//" + newRelPath)

            handle.close()

        pass
    def execute(self):
        productionLocation = self.productionDetails[2]
        fileLocation = self.fileDetails[3]
        currentFileLocation = os.path.normcase(os.path.normpath(os.path.join(productionLocation, fileLocation)))
        newFileLocation = os.path.normcase(os.path.normpath(os.path.join(productionLocation, os.path.join(self.newLocation, self.currentFilename))))
        dirLocation = os.path.normcase(os.path.normpath(os.path.dirname(newFileLocation)))
        
        #create target directory if not existing
        if not os.path.exists(dirLocation):
            os.makedirs(dirLocation)
            
        if svn.isKnownSVNFile(currentFileLocation):
            svn.svnMove(currentFileLocation, newFileLocation)
        else:
            shutil.move(currentFileLocation, newFileLocation)
        
        #update ID and IM tags of blend files.
        if self.currentFilename.endswith(".blend"):
            handle = blendfile.openBlendFile(newFileLocation, 'r+b')

            for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):            
                relPath = libraryblock.Get("name").split("\0")[0]
                absPath = blendfile.blendPath2AbsolutePath(currentFileLocation, relPath)
                normPath = os.path.normcase(os.path.normpath(absPath))
                newRelPath = _relpath(normPath, dirLocation)
                libraryblock.Set("name", "//"+newRelPath)
    
            for libraryblock in handle.FindBlendFileBlocksWithCode("IM"):            
                relPath = libraryblock.Get("name").split("\0")[0]
                if len(relPath)>0:
                    absPath = blendfile.blendPath2AbsolutePath(currentFileLocation, relPath)
                    normPath = os.path.normcase(os.path.normpath(absPath))
                    newRelPath = _relpath(normPath, dirLocation)
                    libraryblock.Set("name", "//"+newRelPath)

            handle.close()
            
        pass
Example #7
0
    def execute(self):
        productionLocation = self.productionDetails[
            indexer.INDEX_PRODUCTION_LOCATION]
        fileLocation = self.fileDetails[indexer.INDEX_FILE_LOCATION]
        fileLocation = os.path.join(productionLocation, fileLocation)
        subDirs = fileLocation.replace(self.sourceDirectory,
                                       self.targetDirectory, 1)
        fileLocationDir = os.path.dirname(subDirs)
        absRefLoc = os.path.normcase(
            posixpath.normpath(os.path.join(self.productionDetails[2],
                                            subDirs)))

        absNewLoc = os.path.normcase(
            posixpath.normpath(
                os.path.join(
                    self.productionDetails[2],
                    self.referenceFileDetails[indexer.INDEX_FILE_LOCATION])))
        newpath = "//" + _relpath(absNewLoc, fileLocationDir)
        handle = blendfile.openBlendFile(fileLocation, 'r+b')
        for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):

            relPath = libraryblock.Get("name").split("\0")[0].replace(
                "\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath == absNewLoc:
                libraryblock.Set("name", newpath)

        for imageblock in handle.FindBlendFileBlocksWithCode("IM"):

            relPath = imageblock.Get("name").split("\0")[0].replace("\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath == absNewLoc:
                imageblock.Set("name", newpath)

        handle.close()
    def execute(self):
        productionLocation = self.productionDetails[2]
        fileLocation = self.fileDetails[3]
        fileLocation = os.path.join(productionLocation, fileLocation)
        fileLocationDir = os.path.dirname(fileLocation)
        absRefLoc = os.path.normcase(posixpath.normpath(os.path.join(self.productionDetails[2], self.currentFileLocation)))
        handle = blendfile.openBlendFile(fileLocation, 'r+b')
        libRef = 0
        for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):
            relPath = libraryblock.Get("name").split("\0")[0]
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath==absRefLoc:
                libRef = libraryblock.OldAddress

        for idblock in handle.FindBlendFileBlocksWithCode("ID"):
            lib = idblock.Get("lib")
            if lib == libRef:
                name = idblock.Get("name").split("\0")[0]
                if name == self.elementDetails[2]:
                    idblock.Set("name", self.newElementName)
        
        handle.close()