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

All Samples(1076)  |  Call(1023)  |  Derive(0)  |  Import(53)
Recursively move a file or directory to another location. This is
similar to the Unix "mv" command.

If the destination is a directory or a symlink to a directory, the source
is moved inside the directory. The destination path must not already
exist.

If the destination already exists but is not a directory, it may be
overwritten depending on os.rename() semantics.

If the destination is on our current filesystem, then rename() is used.
Otherwise, src is copied to the destination and then removed.
A lot more could be done here...  A look at a mv.c shows a lot of
the issues this implementation glosses over.

        def move(src, dst):
    """Recursively move a file or directory to another location. This is
    similar to the Unix "mv" command.

    If the destination is a directory or a symlink to a directory, the source
    is moved inside the directory. The destination path must not already
    exist.

    If the destination already exists but is not a directory, it may be
    overwritten depending on os.rename() semantics.

    If the destination is on our current filesystem, then rename() is used.
    Otherwise, src is copied to the destination and then removed.
    A lot more could be done here...  A look at a mv.c shows a lot of
    the issues this implementation glosses over.

    """
    real_dst = dst
    if os.path.isdir(dst):
        real_dst = os.path.join(dst, _basename(src))
        if os.path.exists(real_dst):
            raise Error, "Destination path '%s' already exists" % real_dst
    try:
        os.rename(src, real_dst)
    except OSError:
        if os.path.isdir(src):
            if _destinsrc(src, dst):
                raise Error, "Cannot move a directory '%s' into itself '%s'." % (src, dst)
            copytree(src, real_dst, symlinks=True)
            rmtree(src)
        else:
            copy2(src, real_dst)
            os.unlink(src)
        


src/m/a/matplotlib-HEAD/py4science/examples/mkprob.py   matplotlib(Download)
def mvforce(src,dest):
    """Forceful file copy that overwrites destination files."""
    if os.path.isfile(dest):
        os.remove(dest)
    shutil.move(src,dest)
 
 

src/k/f/kforge-0.18/src/kforge/plugin/example.py   kforge(Download)
            trashIndex += 1
        try:
            import shutil
            shutil.move(servicePath, trashNew)
        except Exception, inst:
            msg = "Couldn't move service files into trash: moving %s to %s: %s" % (
                servicePath, trashNew

src/n/o/notmm-0.4.1/examples/lib/satchmo_utils/thumbnail/utils.py   notmm(Download)
def _rename(old_name, new_name):
    """ rename image old_name -> name """
    try:
        shutil.move(os.path.join(settings.MEDIA_ROOT, old_name), os.path.join(settings.MEDIA_ROOT, new_name))
        return new_name
    except IOError:
        return old_name

src/m/o/MOAI-1.1.2/src/moai/examples/simple/config.py   MOAI(Download)
    def get_database(self):
        if os.path.isfile('/tmp/moai.new.db'):
            shutil.move('/tmp/moai.new.db',
                        '/tmp/moai.db')
 
        return SQLiteDatabase('/tmp/moai.db', 'r')
 

src/m/o/MOAI-1.1.2/src/moai/examples/example_configuration.py   MOAI(Download)
    def get_database(self):
        if os.path.isfile('/tmp/moai.new.db'):
            shutil.move('/tmp/moai.new.db',
                        '/tmp/moai.db')
 
        return SQLiteDatabase('/tmp/moai.db', 'r')
 

src/p/y/pycopia-HEAD/QA/pycopia/remote/PosixServer.py   pycopia(Download)
    def move(self, src, dst):
        return shutil.move(src, dst)
 
    def rmtree(self, path):
        self._rmtree_errors = []
        shutil.rmtree(path, ignore_errors=True, onerror=self._rmtree_error_cb)
        return self._rmtree_errors

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 setupPrep():
	copy("src/osx/prep_py2app.py", APP_RS)
	move("dist/Gajim.app/Contents/Resources/__boot__.py",
		 "dist/Gajim.app/Contents/Resources/__boot__.py.org")
	new = open("dist/Gajim.app/Contents/Resources/__boot__.py", "w+")
	org = open("dist/Gajim.app/Contents/Resources/__boot__.py.org")
	for line in org:
	symlink("Resources/data", "dist/Gajim.app/Contents/data")
	copy("src/gajim-remote.py", "dist/Gajim.app/Contents/Resources")
	# Nuke libs that are in the framework
	move("dist/Gajim.app/Contents/Frameworks/Python.framework",
		 "dist/Gajim.app/Contents/Python.framework")
	rmtree("dist/Gajim.app/Contents/Frameworks")
	mkdir("dist/Gajim.app/Contents/Frameworks")
	move("dist/Gajim.app/Contents/Python.framework",
		 "dist/Gajim.app/Contents/Frameworks/Python.framework")
	# Adjust the running of the app
	move("dist/Gajim.app/Contents/MacOS/Gajim",

src/p/y/pycopia-QA-1.0/pycopia/remote/PosixServer.py   pycopia-QA(Download)
    def move(self, src, dst):
        return shutil.move(src, dst)
 
    def rmtree(self, path):
        self._rmtree_errors = []
        shutil.rmtree(path, ignore_errors=True, onerror=self._rmtree_error_cb)
        return self._rmtree_errors

src/o/b/oblivionworks-HEAD/Tags/Wrye Bash/290/Mopy/bolt.py   oblivionworks(Download)
            os.makedirs(destPath._shead)
        elif destPath.exists():
            os.remove(destPath._s)
        shutil.move(self._s,destPath._s)
    def touch(self):
        """Like unix 'touch' command. Creates a file with current date/time."""
        if self.exists():
    def untemp(self,doBackup=False):
        """Replaces file with temp version, optionally making backup of file first."""
        if self.exists():
            if doBackup:
                self.backup.remove()
                shutil.move(self._s, self.backup._s)
            else:
                os.remove(self._s)
        shutil.move(self.temp._s, self._s)

src/o/b/oblivionworks-HEAD/Tags/Wrye Bash/289/Mopy/bolt.py   oblivionworks(Download)
            os.makedirs(destPath._shead)
        elif destPath.exists():
            os.remove(destPath._s)
        shutil.move(self._s,destPath._s)
    def touch(self):
        """Like unix 'touch' command. Creates a file with current date/time."""
        if self.exists():
    def untemp(self,doBackup=False):
        """Replaces file with temp version, optionally making backup of file first."""
        if self.exists():
            if doBackup:
                self.backup.remove()
                shutil.move(self._s, self.backup._s)
            else:
                os.remove(self._s)
        shutil.move(self.temp._s, self._s)

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next