本文整理汇总了Python中abl.vpath.base.URI.copy方法的典型用法代码示例。如果您正苦于以下问题:Python URI.copy方法的具体用法?Python URI.copy怎么用?Python URI.copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类abl.vpath.base.URI
的用法示例。
在下文中一共展示了URI.copy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_copy_recursive_with_preservelinks
# 需要导入模块: from abl.vpath.base import URI [as 别名]
# 或者: from abl.vpath.base.URI import copy [as 别名]
def test_copy_recursive_with_preservelinks(self):
src_path = URI(self.baseurl) / 'folder'
base_path = src_path / 'gaz'
foo_path = base_path / 'foo'
bar_path = foo_path / 'tmp'
bar_path.makedirs()
mee_path = foo_path / 'mee.txt'
create_file(mee_path)
mee2_path = bar_path / 'mee2.txt'
create_file(mee2_path)
dest_path = URI(self.baseurl) / 'helloworld'
src_path.copy(dest_path, recursive=True, followlinks=False)
self.assertTrue((dest_path / 'gaz' / 'foo' / 'mee.txt').isfile())
self.assertTrue((dest_path / 'gaz' / 'foo' / 'tmp').isdir())
示例2: test_copy_and_move_file
# 需要导入模块: from abl.vpath.base import URI [as 别名]
# 或者: from abl.vpath.base.URI import copy [as 别名]
def test_copy_and_move_file(self):
single_file = URI(self.non_existing_file)
target_file = URI(self.baseurl) / 'target_file.txt'
create_file(single_file)
single_file.copy(target_file)
self.assertTrue(target_file.exists())
self.assertTrue(target_file.isfile())
self.assertEqual(load_file(target_file), 'content')
target_file.remove()
self.assertTrue(not target_file.exists())
single_file.move(target_file)
self.assertTrue(not single_file.exists())
self.assertTrue(target_file.exists())
self.assertTrue(target_file.isfile())
self.assertEqual(load_file(target_file), 'content')
target_file.remove()
示例3: test_copy_and_move_dir
# 需要导入模块: from abl.vpath.base import URI [as 别名]
# 或者: from abl.vpath.base.URI import copy [as 别名]
def test_copy_and_move_dir(self):
folder = URI(self.baseurl) / 'folder'
folder.makedirs()
self.assertTrue(folder.isdir())
afile = folder / 'afile.txt'
create_file(afile)
target = URI(self.baseurl) / 'target'
self.assertTrue(not target.exists())
folder.copy(target, recursive=True)
self.assertTrue(target.exists())
target_file = target / 'afile.txt'
self.assertTrue(target_file.exists())
self.assertEqual(load_file(target_file), 'content')
target.remove(recursive=True)
self.assertTrue(not target.exists())
target.makedirs()
folder.copy(target, recursive=True)
newtarget = target / 'folder'
self.assertTrue(newtarget.exists())
self.assertTrue(newtarget.isdir())
newtarget_file = newtarget / 'afile.txt'
self.assertTrue(newtarget_file.exists())
self.assertTrue(newtarget_file.isfile())
target.remove(recursive=True)
folder.move(target)
self.assertTrue(not folder.exists())
self.assertTrue(target.exists())
self.assertTrue(target.isdir())
self.assertTrue(target_file.exists())
self.assertTrue(target_file.isfile())
target.remove(recursive=True)
示例4: test_copy
# 需要导入模块: from abl.vpath.base import URI [as 别名]
# 或者: from abl.vpath.base.URI import copy [as 别名]
def test_copy(self):
p = URI(str(self.foo_dir))
p.mkdir()
dest = URI(self.bar_dir)
p.copy(dest, recursive=True)