• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(941)  |  Call(883)  |  Derive(0)  |  Import(58)
Recursively copy a directory tree using copy2().

The destination directory must not already exist.
If exception(s) occur, an Error is raised with a list of reasons.

If the optional symlinks flag is true, symbolic links in the
source tree result in symbolic links in the destination tree; if
it is false, the contents of the files pointed to by symbolic
links are copied.

The optional ignore argument is a callable. If given, it
is called with the `src` parameter, which is the directory
being visited by copytree(), and `names` which is the list of
`src` contents, as returned by os.listdir():

    callable(src, names) -> ignored_names

Since copytree() is called recursively, the callable will be
called once for each directory that is copied. It returns a
list of names relative to the `src` directory that should
not be copied.

XXX Consider this example code rather than the ultimate tool.

        def copytree(src, dst, symlinks=False, ignore=None):
    """Recursively copy a directory tree using copy2().

    The destination directory must not already exist.
    If exception(s) occur, an Error is raised with a list of reasons.

    If the optional symlinks flag is true, symbolic links in the
    source tree result in symbolic links in the destination tree; if
    it is false, the contents of the files pointed to by symbolic
    links are copied.

    The optional ignore argument is a callable. If given, it
    is called with the `src` parameter, which is the directory
    being visited by copytree(), and `names` which is the list of
    `src` contents, as returned by os.listdir():

        callable(src, names) -> ignored_names

    Since copytree() is called recursively, the callable will be
    called once for each directory that is copied. It returns a
    list of names relative to the `src` directory that should
    not be copied.

    XXX Consider this example code rather than the ultimate tool.

    """
    names = os.listdir(src)
    if ignore is not None:
        ignored_names = ignore(src, names)
    else:
        ignored_names = set()

    os.makedirs(dst)
    errors = []
    for name in names:
        if name in ignored_names:
            continue
        srcname = os.path.join(src, name)
        dstname = os.path.join(dst, name)
        try:
            if symlinks and os.path.islink(srcname):
                linkto = os.readlink(srcname)
                os.symlink(linkto, dstname)
            elif os.path.isdir(srcname):
                copytree(srcname, dstname, symlinks, ignore)
            else:
                # Will raise a SpecialFileError for unsupported file types
                copy2(srcname, dstname)
        # catch the Error from the recursive copytree so that we can
        # continue with other files
        except Error, err:
            errors.extend(err.args[0])
        except EnvironmentError, why:
            errors.append((srcname, dstname, str(why)))
    try:
        copystat(src, dst)
    except OSError, why:
        if WindowsError is not None and isinstance(why, WindowsError):
            # Copying file access times may fail on Windows
            pass
        else:
            errors.extend((src, dst, str(why)))
    if errors:
        raise Error, errors
        


src/c/y/cynote-HEAD/cynote/make_release.py   cynote(Download)
# Script to make a copy of CyNote for zipping and release
 
import os
import sys
from shutil import rmtree, copytree, copy2, ignore_patterns
 
def cleanup_cynote(new_cynote):
def copy_cynote(release, new_cynote):
    # Step 2: Copy CyNote to release directory
    print "Step 2: Copy %s to release directory: %s" % (new_cynote, release)
    copytree(new_cynote, release,
             ignore = ignore_patterns('.svn', '.hg', '*.pyc'))
    print "Step 2 completed"
    print

src/c/y/cynote-HEAD/cynote/update_cynote.py   cynote(Download)
import os
import zipfile
import time
from shutil import rmtree, copytree, copy2, ignore_patterns
 
def cleanup_new_cynote(new_cynote):
    # Step 1.1: remove contents of new_cynote's database directory
def replace_cynote(old_cynote, new_cynote):
    # Step 6: Copy new cynote to replace deleted old cynote
    print "Step 6: Copy %s to replace deleted %s" % (new_cynote, old_cynote)
    copytree(new_cynote, old_cynote,
             ignore = ignore_patterns('.svn', '.hg', '*.pyc'))
    print "Step 6 completed"
    print

src/m/y/mypy-0.255/mypy/cmd.py   mypy(Download)
import sys
from shutil import copytree
from os.path import join, dirname
 
PREFIX = dirname(__file__)
 
 
        if len_argv >= 2:
            name = argv[1]
            t = join(PREFIX, "project_template")
            copytree(t, name, ignore=ignore_new)
 
runcmd(sys.argv[1:])

src/g/a/gajim-HEAD/setup_osx.py   gajim(Download)
from setuptools import setup
import sys, glob, os, commands, types
from os import system, unlink, symlink, getcwd, mkdir, utime
from shutil import move, copy, copytree, rmtree
 
###
### Globals
def finishApp():
	# setup gajim dirs
	copytree("build/inst/share/gajim/data", APP_RS + "/data")
	copy("data/pixmaps/gajim.icns", APP_RS + "/data/pixmaps")
	copytree("build/inst/share/locale", APP_RS + "/locale")
	copytree("build/inst/share/man", APP_RS + "/man")
	force(lambda:unlink("dist/Gajim.app/Contents/data"))

src/e/z/ezgallery-HEAD/trunk/util/create_dist.py   ezgallery(Download)
import os
from os.path import join
import re
from shutil import copy, copytree, rmtree
import sys
import zipfile
 
 
    # copy the help directory
    #
    copytree('../help', join(prog_dir, 'help'), False)
    rmtree(join(prog_dir, 'help', 'CVS'), True)
    rmtree(join(prog_dir, 'help', 'images', 'CVS'), True)
 

src/m/o/morphix-HEAD/trunk/ibuild/src/intellibuild/clientlib/accessors/fs.py   morphix(Download)
  def cp(self, src, dst, fail=True, Sym=None):
    from shutil import copy2, copytree
    """
    Copy function
    If Sym is set, links are dereferenced.
 
    If you want not to fail if copy is not successful, 
      try:
        # copy now
        if os.path.isdir(src):
          copytree(src.encode('ascii'),dst.encode('ascii'),False)
        else:
          copy2(src,dst)
 

src/m/o/morphix-HEAD/trunk/ibuild/src/intellibuild/clientlib/accessors/filesystem.py   morphix(Download)
  def Copy(self, src, dst, fail=None):
      from shutil import copy2, copytree
      """ 
      New copy behaviour. It removes dst first and doesn't fail
      unless Fail is set
      """
      if self.__verbose:
        try:
          st = os.lstat(src)
          if stat.S_ISDIR(st.st_mode):
           copytree(src.encode('ascii'),dst.encode('ascii'),False)
          else:
           copy2(src,dst)
        except:

src/m/o/morphix-HEAD/ibuild/src/intellibuild/clientlib/accessors/fs.py   morphix(Download)
  def cp(self, src, dst, fail=True, Sym=None):
    from shutil import copy2, copytree
    """
    Copy function
    If Sym is set, links are dereferenced.
 
    If you want not to fail if copy is not successful, 
      try:
        # copy now
        if os.path.isdir(src):
          copytree(src.encode('ascii'),dst.encode('ascii'),False)
        else:
          copy2(src,dst)
 

src/m/o/morphix-HEAD/ibuild/src/intellibuild/clientlib/accessors/filesystem.py   morphix(Download)
  def Copy(self, src, dst, fail=None):
      from shutil import copy2, copytree
      """ 
      New copy behaviour. It removes dst first and doesn't fail
      unless Fail is set
      """
      if self.__verbose:
        try:
          st = os.lstat(src)
          if stat.S_ISDIR(st.st_mode):
           copytree(src.encode('ascii'),dst.encode('ascii'),False)
          else:
           copy2(src,dst)
        except:

src/e/z/ezgallery-HEAD/util/create_dist.py   ezgallery(Download)
import os
from os.path import join
import re
from shutil import copy, copytree, rmtree
import sys
import zipfile
 
 
    # copy the help directory
    #
    copytree('../help', join(prog_dir, 'help'), False)
    rmtree(join(prog_dir, 'help', 'CVS'), True)
    rmtree(join(prog_dir, 'help', 'images', 'CVS'), True)
 

  1 | 2 | 3 | 4 | 5 | 6  Next