Ejemplo n.º 1
0
 def test20_move_file(self):
     vfs.copy(self.root + 'tmp/blah.txt', self.root + 'tmp/blah.txt.bak')
     vfs.move(self.root + 'tmp/blah.txt.bak',
              self.root + 'tmp/blah.txt.old')
     file = vfs.open(self.root + 'tmp/blah.txt.old')
     self.assertEqual(file.read(), 'BLAH!!!')
     self.assertEqual(vfs.exists(self.root + 'tmp/blah.txt.bak'), False)
Ejemplo n.º 2
0
 def test22_copy_folder(self):
     vfs.copy('vfs', 'mem:/tmp/folder-copy')
     with vfs.open('mem:/tmp/folder-copy/hello.txt') as file:
         self.assertEqual(file.read(), 'hello world\n')
     vfs.make_folder('mem:/tmp/folder-dest')
     vfs.copy('vfs', 'mem:/tmp/folder-dest')
     with vfs.open('mem:/tmp/folder-dest/vfs/hello.txt') as file:
         self.assertEqual(file.read(), 'hello world\n')
Ejemplo n.º 3
0
 def test22_copy_folder(self):
     vfs.copy('vfs', 'mem:/tmp/folder-copy')
     with vfs.open('mem:/tmp/folder-copy/hello.txt') as file:
         self.assertEqual(file.read(), 'hello world\n')
     vfs.make_folder('mem:/tmp/folder-dest')
     vfs.copy('vfs', 'mem:/tmp/folder-dest')
     with vfs.open('mem:/tmp/folder-dest/vfs/hello.txt') as file:
         self.assertEqual(file.read(), 'hello world\n')
Ejemplo n.º 4
0
 def test21_copy_file(self):
     url = self.root + 'tmp/dir/'
     vfs.make_folder(url)
     vfs.copy(self.root + 'tmp/blah.txt', url)
     file = vfs.open(url + 'blah.txt')
     self.assertEqual(file.read(), 'BLAH!!!')
     vfs.copy(self.root + 'tmp/blah.txt', url + 'blah2.txt')
     file = vfs.open(url + 'blah2.txt')
     self.assertEqual(file.read(), 'BLAH!!!')
Ejemplo n.º 5
0
 def test21_copy_file(self):
     url = self.root + "tmp/dir/"
     vfs.make_folder(url)
     vfs.copy(self.root + "tmp/blah.txt", url)
     file = vfs.open(url + "blah.txt")
     self.assertEqual(file.read(), "BLAH!!!")
     vfs.copy(self.root + "tmp/blah.txt", url + "blah2.txt")
     file = vfs.open(url + "blah2.txt")
     self.assertEqual(file.read(), "BLAH!!!")
Ejemplo n.º 6
0
 def test21_copy_file(self):
     url = self.root + 'tmp/dir/'
     vfs.make_folder(url)
     vfs.copy(self.root + 'tmp/blah.txt', url)
     file = vfs.open(url + 'blah.txt')
     self.assertEqual(file.read(), 'BLAH!!!')
     vfs.copy(self.root + 'tmp/blah.txt', url + 'blah2.txt')
     file = vfs.open(url + 'blah2.txt')
     self.assertEqual(file.read(), 'BLAH!!!')
Ejemplo n.º 7
0
 def backupCallback(self):
     # This is only called once, the first time the document is modified,
     # regardless of the outcome of this method.
     self.backup_saved = True
     
     if not vfs.exists(self.url):
         # The url may point to a nonexistent file because the user has
         # created a new file.  New files aren't saved in the vfs until the
         # user explicitly saves it, so because it doesn't exist in the vfs
         # it won't need to be backed up.
         return
     
     try:
         temp_url = self.stc.getBackupTemporaryFilename(self)
         if temp_url:
             if vfs.exists(temp_url):
                 vfs.remove(temp_url)
             vfs.copy(self.url, temp_url)
     except NotImplementedError:
         # Some URI schemes won't be writable, so don't cause a failure in
         # this case; just ignore it.
         pass
Ejemplo n.º 8
0
    def backupCallback(self):
        # This is only called once, the first time the document is modified,
        # regardless of the outcome of this method.
        self.backup_saved = True

        if not vfs.exists(self.url):
            # The url may point to a nonexistent file because the user has
            # created a new file.  New files aren't saved in the vfs until the
            # user explicitly saves it, so because it doesn't exist in the vfs
            # it won't need to be backed up.
            return

        try:
            temp_url = self.stc.getBackupTemporaryFilename(self)
            if temp_url:
                if vfs.exists(temp_url):
                    vfs.remove(temp_url)
                vfs.copy(self.url, temp_url)
        except NotImplementedError:
            # Some URI schemes won't be writable, so don't cause a failure in
            # this case; just ignore it.
            pass
Ejemplo n.º 9
0
 def test20_move_file(self):
     vfs.copy('mem:testfile.txt', 'mem:testfile.txt.bak')
     vfs.move('mem:testfile.txt.bak', 'mem:testfile.txt.old')
     file = vfs.open('mem:testfile.txt.old')
     self.assertEqual(file.read(), 'three\n')
     self.assertEqual(vfs.exists('mem:testfile.txt.bak'), False)
Ejemplo n.º 10
0
 def test_copy_folder_to_folder(self):
     vfs.copy('vfs', 'vfs-tmp')
     with vfs.open('vfs-tmp/vfs/hello.txt') as file:
         self.assertEqual(file.read(), 'hello world\n')
Ejemplo n.º 11
0
 def test_copy_file(self):
     vfs.copy('vfs/hello.txt', 'vfs-tmp/hello.txt.bak')
     with vfs.open('vfs-tmp/hello.txt.bak') as file:
         self.assertEqual(file.read(), 'hello world\n')
Ejemplo n.º 12
0
 def test17_move_file(self):
     vfs.copy('vfs/hello.txt', 'vfs/hello.txt.bak')
     vfs.move('vfs/hello.txt.bak', 'vfs/hello.txt.old')
     file = vfs.open('vfs/hello.txt.old')
     self.assertEqual(file.read(), 'hello world\n')
     self.assertEqual(vfs.exists('vfs/hello.txt.bak'), False)
Ejemplo n.º 13
0
 def test_copy_folder_to_folder(self):
     vfs.copy('vfs', 'vfs-tmp')
     with vfs.open('vfs-tmp/vfs/hello.txt') as file:
         self.assertEqual(file.read(), 'hello world\n')
Ejemplo n.º 14
0
 def test_copy_file(self):
     vfs.copy('vfs/hello.txt', 'vfs-tmp/hello.txt.bak')
     with vfs.open('vfs-tmp/hello.txt.bak') as file:
         self.assertEqual(file.read(), 'hello world\n')
Ejemplo n.º 15
0
 def test17_move_file(self):
     vfs.copy('vfs/hello.txt', 'vfs/hello.txt.bak')
     vfs.move('vfs/hello.txt.bak', 'vfs/hello.txt.old')
     file = vfs.open('vfs/hello.txt.old')
     self.assertEqual(file.read(), 'hello world\n')
     self.assertEqual(vfs.exists('vfs/hello.txt.bak'), False)
Ejemplo n.º 16
0
 def test20_move_file(self):
     vfs.copy(self.root + 'tmp/blah.txt', self.root + 'tmp/blah.txt.bak')
     vfs.move(self.root + 'tmp/blah.txt.bak', self.root + 'tmp/blah.txt.old')
     file = vfs.open(self.root + 'tmp/blah.txt.old')
     self.assertEqual(file.read(), 'BLAH!!!')
     self.assertEqual(vfs.exists(self.root + 'tmp/blah.txt.bak'), False)
Ejemplo n.º 17
0
 def test20_move_file(self):
     vfs.copy(self.root + "tmp/blah.txt", self.root + "tmp/blah.txt.bak")
     vfs.move(self.root + "tmp/blah.txt.bak", self.root + "tmp/blah.txt.old")
     file = vfs.open(self.root + "tmp/blah.txt.old")
     self.assertEqual(file.read(), "BLAH!!!")
     self.assertEqual(vfs.exists(self.root + "tmp/blah.txt.bak"), False)
Ejemplo n.º 18
0
 def handleFileDrop(self, x, y, filenames):
     self.dprint("%d file(s) dropped at %d,%d:" % (len(filenames), x, y))
     srcdir = None
     tocopy = []
     for src in filenames:
         filename = os.path.basename(src)
         if not srcdir:
             srcdir = os.path.dirname(src)
             srcdir += os.pathsep
         if os.path.isdir(src):
             self.dprint("dir: %s" % src)
             for root, dirs, files in os.walk(src):
                 for file in files:
                     child = os.path.join(root, file)
                     self.dprint("  file: %s" % child)
                     tocopy.append(child)
         elif os.path.isfile(src):
             self.dprint("file: %s" % src)
             tocopy.append(src)
         else:
             self.dprint("not file or dir: %s  NOT COPYING" % src)
     
     self.status_info.startProgress("Copying...", len(tocopy), delay=1.0)
     count = 0
     skipped = 0
     errors = []
     for src in tocopy:
         try:
             srcref = vfs.get_file_reference(src)
             relsrc = src[len(srcdir):]
             relref = vfs.get_file_reference(relsrc)
             dest = self.url.resolve2(relref)
             self.dprint("srcref=%s, relref=%s, dest=%s" % (srcref, relref, dest))
             self.dprint("copying: '%s' -> '%s'" % (src, dest))
             self.status_info.updateProgress(count, "Copying to %s" % str(dest))
             destdir = vfs.get_dirname(dest)
             if not vfs.exists(destdir):
                 # Need to recursively make directories
                 dirs = []
                 parent = destdir
                 maxdepth = len(parent.path)
                 while not vfs.exists(parent) and maxdepth > 0:
                     dirs.append(parent)
                     parent = vfs.get_dirname(parent)
                     maxdepth -= 1
                 dirs.reverse()
                 for dir in dirs:
                     self.dprint("Creating dir: %s" % dir)
                     vfs.make_folder(dir)
             copy = True
             self.dprint("src path: %s" % srcref.path)
             self.dprint("dest path: %s" % dest.path)
             if vfs.exists(dest):
                 self.dprint("exists: %s" % str(dest))
                 if vfs.is_folder(dest):
                     errors.append("Not copying folder %s; shouldn't be specified from %s" % (dest, src))
                     copy = False
                 else:
                     dlg = CustomOkDialog(self.frame, u"File exists!  Replace\n\n%s, %s, %s\n\nwith:\n\n%s, %s, %s" % (dest, vfs.get_mtime(dest), vfs.get_size(dest), src, os.path.getmtime(src), os.path.getsize(src)), "Replace", "Skip")
                     retval=dlg.ShowModal()
                     dlg.Destroy()
                     copy = retval==wx.ID_OK
                     if copy:
                         self.dprint("Removing %s" % dest)
                         vfs.remove(dest)
             if copy:
                 vfs.copy(srcref, dest)
             else:
                 skipped += 1
         except Exception, e:
             errors.append("%s: %s" % (src, e))
         count += 1
Ejemplo n.º 19
0
 def test20_move_file(self):
     vfs.copy('mem:testfile.txt', 'mem:testfile.txt.bak')
     vfs.move('mem:testfile.txt.bak', 'mem:testfile.txt.old')
     file = vfs.open('mem:testfile.txt.old')
     self.assertEqual(file.read(), 'three\n')
     self.assertEqual(vfs.exists('mem:testfile.txt.bak'), False)