parameters: (self, n, tofolder, ton)
docstring: Copy one message over a specific destination message,
          which may or may not already exist.
docstring_summary: Copy one message over a specific destination message,
          which may or may not already exist.
docstring_tokens: Copy one message over a specific destination message which may or may not already exist .
function: def copymessage(self, n, tofolder, ton):
          """Copy 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
          ok = 0
          try:
              tofolder.setlast(None)
              shutil.copy2(path, topath)
              ok = 1
          finally:
              if not ok:
                  try:
                      os.unlink(topath)
                  except os.error:
                      pass
function_tokens: def copymessage ( 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 ok = 0 try : tofolder . setlast ( None ) shutil . copy2 ( path , topath ) ok = 1 finally : if not ok : try : os . unlink ( topath ) except os . error : pass