file_copy: Allow copying directories

This commit is contained in:
Nicolas Braud-Santoni 2016-08-07 17:25:46 +02:00
parent 611154a426
commit 1000430aa0
No known key found for this signature in database
GPG key ID: 9D4F88010CFE19E3
2 changed files with 6 additions and 2 deletions

View file

@ -9,7 +9,7 @@ def validate_manifest(data, validator, error):
for i, file_entry in enumerate(data['plugins']['file_copy']['files']):
srcfile = file_entry['src']
if not os.path.isfile(srcfile):
if not os.path.exists(srcfile):
msg = 'The source file %s does not exist.' % srcfile
error(msg, ['plugins', 'file_copy', 'files', i])

View file

@ -47,5 +47,9 @@ class FileCopyCommand(Task):
# note that we don't use os.path.join because it can't
# handle absolute paths, which 'dst' most likely is.
final_destination = os.path.normpath("%s/%s" % (info.root, file_entry['dst']))
shutil.copy(file_entry['src'], final_destination)
if os.path.isfile(file_entry['src']):
shutil.copy(file_entry['src'], final_destination)
else:
shutil.copytree(file_entry['src'], final_destination)
modify_path(info, file_entry['dst'], file_entry)