def _copy_or_move(ctx, src, dst, function, function_name): """ Helper function to simplify copies and moves. """ src = Path(src) dst = Path(dst).addroot(ctx.buildroot) if not dst.exists(): # if dst ends with the separator, treat it like a directory if dst.endswith(os.sep): dst.makedirs() dst = dst / src.name else: dst.parent.makedirs() elif dst.isdir(): # If the dst is a directory, we're just copying that file into that # directory. dst = dst / src.name ctx.logger.check(' * %s' % function_name, '%s -> %s' % (src, dst), color='yellow') function(src, dst) return dst