def Upload(self,directory,filename):
db = self._loadDB(directory)<EOL>logger.debug("<STR_LIT>"%(filename))<EOL>if db.has_key(filename):<EOL><INDENT>pid=db[filename]<EOL>logger.debug('<STR_LIT>'%(filename,pid))<EOL><DEDENT>else:<EOL><INDENT>pid=None<EOL><DEDENT>fullfile=os.path.join(directory,filename)<EOL>fid=open(fullfile,'<STR_LIT:r>');<EOL>post=self._readMetaAndContent(fid)<EOL>self._connectToWP()<EOL>if not pid:<EOL><INDENT>pid=self.wp.call(NewPost(post))<EOL>if pid:<EOL><INDENT>logger.debug("<STR_LIT>",pid)<EOL>db[filename]=pid<EOL>self._saveDB(directory,db)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>logger.error("<STR_LIT>")<EOL>return False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logger.debug("<STR_LIT>",pid)<EOL>self.wp.call(EditPost(pid,post))<EOL>return True<EOL><DEDENT>return False<EOL>
Uploads/Updates/Replaces files