コード例 #1
0
def LinkOrCopyFiles(sources, dest_dir):
    '''Copies a list of sources to a destination directory.'''
    def LinkOrCopyOneFile(src, dst):
        if not os.path.exists(os.path.dirname(dst)):
            os.makedirs(os.path.dirname(dst))
        if os.path.exists(dst):
            os.unlink(dst)
        try:
            os.link(src, dst)
        except:
            shutil.copy(src, dst)

    for source in sources:
        LinkOrCopyOneFile(source.GetInPath(),
                          os.path.join(dest_dir, source.GetOutPath()))
コード例 #2
0
def LinkOrCopyFiles(sources, dest_dir):
    '''Copies a list of sources to a destination directory.'''
    def LinkOrCopyOneFile(src, dst):
        try:
            os.makedirs(os.path.dirname(dst))
        except OSError as err:
            if err.errno != errno.EEXIST:
                raise
        if os.path.exists(dst):
            os.unlink(dst)
        try:
            os.link(src, dst)
        except:
            shutil.copy(src, dst)

    for source in sources:
        LinkOrCopyOneFile(source.GetInPath(),
                          os.path.join(dest_dir, source.GetOutPath()))
コード例 #3
0
def LinkOrCopyFiles(sources, dest_dir):
    '''Copies a list of sources to a destination directory.'''
    def LinkOrCopyOneFile(src, dst):
        if not os.path.exists(os.path.dirname(dst)):
            os.makedirs(os.path.dirname(dst))
        if os.path.exists(dst):
            # Avoid clobbering the inode if source and destination refer to the
            # same file already.
            if os.path.samefile(src, dst):
                return
            os.unlink(dst)
        try:
            os.link(src, dst)
        except:
            shutil.copy(src, dst)

    for source in sources:
        LinkOrCopyOneFile(source.GetInPath(),
                          os.path.join(dest_dir, source.GetOutPath()))
コード例 #4
0
 def GetOutPaths(self):
     return (source.GetOutPath() for source in self._added_sources)