Anyone knowledgable with python?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Anyone knowledgable with python?

Post by flying_circus »

Seemingly simple question. I'm using blender to export a collada file. The export errors and the error console indicates it cannot save the file to "c:\\"

Does python have anything comparable to PHP's stripslashes? Before this post I have about 5 minutes of python experience, so yes, I'm greener than green.

It errors on line 32, because filename has escaping slashes.

Code: Select all

def SaveDocumentToFile(self, filename):
        self.version = '1.4.0'
        self.xmlns = 'http://www.collada.org/2005/11/COLLADASchema'
        colladaNode = Element(DaeSyntax.COLLADA)
        colladaNode.setAttribute(DaeSyntax.VERSION, self.version)
        colladaNode.setAttribute(DaeSyntax.XMLNS, self.xmlns)
 
        colladaNode.appendChild(self.asset.SaveToXml(self))
 
        # add the libraries
#       print '\ndeb:SaveDocumentToFile self.controllersLibrary=', self.controllersLibrary #------
#       print '\ndeb:SaveDocumentToFile dir(self)', dir(self) #------
#       print '\ndeb:SaveDocumentToFile self.effectsLibrary=', self.effectsLibrary #------
        AppendChild(self,colladaNode,self.animationsLibrary)
        AppendChild(self,colladaNode,self.animationClipsLibrary)
        AppendChild(self,colladaNode,self.camerasLibrary)
        AppendChild(self,colladaNode,self.controllersLibrary)
        AppendChild(self,colladaNode,self.effectsLibrary)
        AppendChild(self,colladaNode,self.imagesLibrary)
        AppendChild(self,colladaNode,self.lightsLibrary)
        AppendChild(self,colladaNode,self.materialsLibrary)
        AppendChild(self,colladaNode,self.geometriesLibrary)
        AppendChild(self,colladaNode,self.nodesLibrary)
        AppendChild(self,colladaNode,self.visualScenesLibrary)
        AppendChild(self,colladaNode,self.physicsMaterialsLibrary)
        AppendChild(self,colladaNode,self.physicsModelsLibrary)
        AppendChild(self,colladaNode,self.physicsScenesLibrary)
 
        AppendChild(self,colladaNode,self.scene)
 
        # write xml to the file
        fileref = open(filename, 'w')
        fileref.write(xmlUtils.ToXml(colladaNode))
        fileref.flush()
        fileref.close()
        colladaNode.unlink()
Post Reply