====
copy
====

The copy recipe copies a source directory to a target directory.

  >>> import os

Define source directory and a source file:

  >>> root = tmpdir('root')
  >>> source = os.path.join(root, 'source')
  >>> mkdir(source)
  >>> sourceFile = os.path.join(source, 'source.txt')
  >>> write(sourceFile, 'nada')
  >>> os.listdir(source)
  ['source.txt']

Define target directory path:

  >>> target = os.path.join(root, 'target')

Lets create a minimal `buildout.cfg` file:

  >>> import os
  >>> write('buildout.cfg',
  ... '''
  ... [buildout]
  ... parts = copy
  ... offline = true
  ...
  ... [copy]
  ... recipe = p01.recipe.setup:copy
  ... source = %s
  ... target = %s
  ... ''' % (source, target))

  >>> print(system(buildout))
  copy: Missing 'remove-existing' (yes, true, True, 1, on) or (no, false, False, 0, off)
  While:
    Installing.
    Getting section copy.
    Initializing section copy.
  Error: Missing 'remove-existing' (yes, true, True, 1, on) or (no, false, False, 0, off)

As you can see we must defined a 'remove-existing' value which explicit
defines if a directory must get removed or not on update call:

  >>> import os
  >>> write('buildout.cfg',
  ... '''
  ... [buildout]
  ... parts = copy
  ... offline = true
  ...
  ... [copy]
  ... recipe = p01.recipe.setup:copy
  ... remove-existing = true
  ... mode = 0777
  ... source = %s
  ... target = %s
  ... ''' % (source, target))

  >>> print(system(buildout))
  Installing copy.
  copy: Copy source '/root/source' to '/root/target'
  copy: Change mode ... for /root/target

  >>> ls(sample_buildout)
  -  .installed.cfg
  d  bin
  -  buildout.cfg
  d  develop-eggs
  d  eggs
  d  parts

  >>> ls(target)
  -  source.txt
