parameters: (self, n, tofolder, ton)
docstring: Move one message over a specific destination message,
          which may or may not already exist.
docstring_summary: Move one message over a specific destination message,
          which may or may not already exist.
docstring_tokens: Move one message over a specific destination message which may or may not already exist .
function: def movemessage(self, n, tofolder, ton):
          """Move one message over a specific destination message,
          which may or may not already exist."""
          path = self.getmessagefilename(n)
          # Open it to check that it exists
          f = open(path)
          f.close()
          del f
          topath = tofolder.getmessagefilename(ton)
          backuptopath = tofolder.getmessagefilename(',%d' % ton)
          try:
              os.rename(topath, backuptopath)
          except os.error:
              pass
          try:
              os.rename(path, topath)
          except os.error:
              # Try copying
              ok = 0
              try:
                  tofolder.setlast(None)
                  shutil.copy2(path, topath)
                  ok = 1
              finally:
                  if not ok:
                      try:
                          os.unlink(topath)
                      except os.error:
                          pass
              os.unlink(path)
          self.removefromallsequences([n])
function_tokens: def movemessage ( self , n , tofolder , ton ) : path = self . getmessagefilename ( n ) # Open it to check that it exists f = open ( path ) f . close ( ) del f topath = tofolder . getmessagefilename ( ton ) backuptopath = tofolder . getmessagefilename ( ',%d' % ton ) try : os . rename ( topath , backuptopath ) except os . error : pass try : os . rename ( path , topath ) except os . error : # Try copying ok = 0 try : tofolder . setlast ( None ) shutil . copy2 ( path , topath ) ok = 1 finally : if not ok : try : os . unlink ( topath ) except os . error : pass os . unlink ( path ) self . removefromallsequences ( [ n ] )