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

All Samples(1049)  |  Call(1018)  |  Derive(0)  |  Import(31)
Copy data and all stat info ("cp -p src dst").

The destination may be a directory.

        def copy2(src, dst):
    """Copy data and all stat info ("cp -p src dst").

    The destination may be a directory.

    """
    if os.path.isdir(dst):
        dst = os.path.join(dst, os.path.basename(src))
    copyfile(src, dst)
    copystat(src, dst)
        


src/x/i/xix-utils-0.2.4/scripts/xix-coverage.py   xix-utils(Download)
 
import os, sys, time
from datetime import datetime
from shutil import copy2, copytree, rmtree
from glob import glob
from xix import getoutput, resource_filename
from StringIO import StringIO
        if not copy_compiled:
            cfiles = [ f for f in cfiles if f[-4:] not in ('.pyo', '.pyc') ]
        for file in cfiles:
            copy2(pj(root, file), pj(target_dir, file))
        [ dirs.remove(ex) for ex in exclude if ex in dirs ]
    for patt in depends:
        srcs = glob(patt)
        for src in srcs:
            if os.path.isdir(src):
                dst = pj(target, src)
                copytree(src, dst)
            else:
                copy2(src, target)
                copy2(src, target)
    cvg = pj(target, 'coverage.py')
    if not os.path.exists(cvg):
        copy2('.coverage.py', cvg)
 
def annotate(source):
    args = []
def main(opts):
    if not os.path.exists('.coverage.py'):
        path = resource_filename('xix', pj('data', 'coverage.py'))
        copy2(path, '.coverage.py')
    prepare_fs(opts.source, opts.copy_compiled, opts.exclude_dirs, opts.depends)
    _mkdir(opts.report_dir)
    reportdir = os.path.abspath(opts.report_dir)
    generateIndex(reportdir, opts.source, opts.report_xslt)
    # Copy over html assets (.png, .css files etc.)
    for asset in options.html_assets:
        copy2(asset, reportdir)
    if not options.html_assets: # make it perty by default
        fn = resource_filename('xix', pj('data', 'coverage.css'))
        copy2(fn, reportdir)

src/i/g/igor-HEAD/igor/utils.py   igor(Download)
from re import sub
from os import path, listdir, remove
from shutil import copytree, copy2, rmtree
 
"""
Mostly this module includes files for wrapping copying, listing and filtering
files, these are for the most part just tools included in the standard
def copy_file(source, destination):
    try:
        copy2(source, destination)
    except OSError:
        remove(destination)
        copy2(source, destination)
 

src/g/r/gramps4win-HEAD/trunk/py2exe/py2exeSetup.py   gramps4win(Download)
import os
import glob
import re
from shutil import copy2, copytree, rmtree
 
#-------------------------------------------------------------------------
#
 
)
 
copy2(gramps4win_dir + '\\patches\\all\\gramps.bat', dist_dir)
copytree(gramps4win_dir + '\\patches\\all\\lang', dist_dir + '\\lang') #need to code to remove svn files.
 
copytree('C:\\GTK\\etc', dist_dir + '\\etc')
copytree('C:\\GTK\\lib', dist_dir + '\\lib')
copytree('C:\\GTK\\share', dist_dir + '\\share')
copy2('C:\\GTK\\bin\\jpeg62.dll', dist_dir)

src/g/r/gramps4win-HEAD/py2exe/py2exeSetup.py   gramps4win(Download)
import os
import glob
import re
from shutil import copy2, copytree, rmtree
 
#-------------------------------------------------------------------------
#
 
)
 
copy2(gramps4win_dir + '\\patches\\all\\gramps.bat', dist_dir)
copytree(gramps4win_dir + '\\patches\\all\\lang', dist_dir + '\\lang') #need to code to remove svn files.
 
copytree('C:\\GTK\\etc', dist_dir + '\\etc')
copytree('C:\\GTK\\lib', dist_dir + '\\lib')
copytree('C:\\GTK\\share', dist_dir + '\\share')
copy2('C:\\GTK\\bin\\jpeg62.dll', dist_dir)

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, 
        if os.path.isdir(src):
          copytree(src.encode('ascii'),dst.encode('ascii'),False)
        else:
          copy2(src,dst)
 
        # check if it got copied
        if os.path.isdir(src) and os.path.isdir(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:
          if stat.S_ISDIR(st.st_mode):
           copytree(src.encode('ascii'),dst.encode('ascii'),False)
          else:
           copy2(src,dst)
        except:
          if fail is None:
           print "Couldn't find src file or some other error occured."

src/s/c/scrapy-HEAD/scrapy/utils/py26.py   scrapy(Download)
import os
import fnmatch
import pkgutil
from shutil import copy2, copystat
 
__all__ = ['cpu_count', 'copytree', 'ignore_patterns']
 
                elif os.path.isdir(srcname):
                    copytree(srcname, dstname, symlinks, ignore)
                else:
                    copy2(srcname, dstname)
                # XXX What about devices, sockets etc.?
            except (IOError, os.error), why:
                errors.append((srcname, dstname, str(why)))

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, 
        if os.path.isdir(src):
          copytree(src.encode('ascii'),dst.encode('ascii'),False)
        else:
          copy2(src,dst)
 
        # check if it got copied
        if os.path.isdir(src) and os.path.isdir(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:
          if stat.S_ISDIR(st.st_mode):
           copytree(src.encode('ascii'),dst.encode('ascii'),False)
          else:
           copy2(src,dst)
        except:
          if fail is None:
           print "Couldn't find src file or some other error occured."

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
    print "Step 2.1: remove contents of %s's database directory to \
%s's database directory" % (odirectory, ndirectory)
    for f in [t for t in os.walk(odirectory)][0][2]:
        copy2(os.sep.join([odirectory, f]), ndirectory)
        print '%s from %s copied to %s' % (f, odirectory, ndirectory)
    print "Step 2.1 completed"
    print
    print "Step 2.2: remove contents of %s's uploads directory to \
%s's uploads directory" % (odirectory, ndirectory)
    for f in [t for t in os.walk(odirectory)][0][2]:
        copy2(os.sep.join([odirectory, f]), ndirectory)
        print '%s from %s copied to %s' % (f, odirectory, ndirectory)
    print "Step 2.2 completed"
    print
    print "Step 2.3: move ad hoc database definitions from %s's models \
directory to %s's models directory" % (odirectory, ndirectory)
    try:
        copy2(odirectory, ndirectory)
        print '%s copied to %s' % (odirectory, ndirectory)
        print "Step 2.3 completed"
    except IOError:

  1 | 2 | 3 | 4  Next