本文整理汇总了Python中moments.path.Path.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Path.copy方法的具体用法?Python Path.copy怎么用?Python Path.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moments.path.Path
的用法示例。
在下文中一共展示了Path.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_up
# 需要导入模块: from moments.path import Path [as 别名]
# 或者: from moments.path.Path import copy [as 别名]
def copy_up(relative=''):
"""
find the item at the supplied path
and copy it up to the parent directory
this is useful for images that should show up as the default image
"""
global path_root
if re.match('~', relative):
relative = os.path.expanduser(relative)
full_path = os.path.join(path_root, relative)
path = Path(full_path, relative_prefix=path_root)
if path.type() == "Image":
cur_dir = path.parent()
parent = cur_dir.parent()
path.copy(parent)
#this should be sufficient
return "Success!"
else:
return "Failed"
示例2: copy_media
# 需要导入模块: from moments.path import Path [as 别名]
# 或者: from moments.path.Path import copy [as 别名]
def copy_media(source, source_root, destination_root):
m3u = M3U(source)
total_size = 0
total_items = 0
for item in m3u:
if re.match(source_root, item):
p = Path(item)
relative = p.to_relative(source_root)
sparent = p.parent()
destination = os.path.join(destination_root, relative)
dpath = Path(destination)
dparent = dpath.parent()
print(relative)
print(sparent)
print(destination)
if not os.path.exists(str(dparent)):
os.makedirs(str(dparent))
if not os.path.exists(destination):
p.copy(destination)
else:
print("already have: %s" % destination)
for option in os.listdir(str(sparent)):
soption = os.path.join(str(sparent), option)
spath = Path(soption)
print(spath.type())
if spath.type() != "Movie" and spath.type() != "Directory":
doption = os.path.join(str(dparent), option)
if not os.path.exists(doption):
print("copy here: %s, to %s" % (soption, doption))
shutil.copy(soption, doption)
print()