當前位置: 首頁>>代碼示例>>Python>>正文


Python base.FS類代碼示例

本文整理匯總了Python中fs.base.FS的典型用法代碼示例。如果您正苦於以下問題:Python FS類的具體用法?Python FS怎麽用?Python FS使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FS類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: move

 def move(self, src, dst, **kwds):
     if self.getmeta("atomic.rename",False):
         if kwds.get("overwrite",False) or not self.exists(dst):
             try:
                 self.rename(src,dst)
                 return
             except FSError:
                 pass
     FS.move(self, src, dst, **kwds)
開發者ID:offlinehacker,項目名稱:pyfilesystem,代碼行數:9,代碼來源:limitsizefs.py

示例2: movefile

def movefile(src_fs, src_path, dst_fs, dst_path, overwrite=True, chunk_size=64*1024):
    """Move a file from one filesystem to another. Will use system copyfile, if both files have a syspath.
    Otherwise file will be copied a chunk at a time.

    :param src_fs: Source filesystem object
    :param src_path: Source path
    :param dst_fs: Destination filesystem object
    :param dst_path: Destination filesystem object
    :param chunk_size: Size of chunks to move if system copyfile is not available (default 64K)

    """
    src_syspath = src_fs.getsyspath(src_path, allow_none=True)
    dst_syspath = dst_fs.getsyspath(dst_path, allow_none=True)

    if not overwrite and dst_fs.exists(dst_path):
        raise DestinationExistsError(dst_path)

    if src_fs is dst_fs:
        src_fs.move(src_path, dst_path, overwrite=overwrite)
        return

    # System copy if there are two sys paths
    if src_syspath is not None and dst_syspath is not None:
        FS._shutil_movefile(src_syspath, dst_syspath)
        return

    src_lock = getattr(src_fs, '_lock', None)

    if src_lock is not None:
        src_lock.acquire()

    try:
        src = None
        try:
            # Chunk copy
            src = src_fs.open(src_path, 'rb')
            dst_fs.setcontents(dst_path, src, chunk_size=chunk_size)
        except:
            raise
        else:
            src_fs.remove(src_path)
        finally:
            if src is not None:
                src.close()
    finally:
        if src_lock is not None:
            src_lock.release()
開發者ID:ctismer,項目名稱:pyfilesystem,代碼行數:47,代碼來源:utils.py

示例3: copyfile

def copyfile(src_fs, src_path, dst_fs, dst_path, overwrite=True, update=False,
             chunk_size=64*1024):
    """Copy a file from one filesystem to another. Will use system copyfile, if both files have a syspath.
    Otherwise file will be copied a chunk at a time. In the case where ``overwrite`` is False and
    ``update`` is True, the behaviour of ``update`` takes precedence.

    :param src_fs: Source filesystem object
    :param src_path: -- Source path
    :param dst_fs: Destination filesystem object
    :param dst_path: Destination filesystem object
    :param overwrite: Write to destination files even if they already exist
    :param update: Write to destination files only if the source is newer
    :param chunk_size: Size of chunks to move if system copyfile is not available (default 64K)

    """

    assert_write(src_fs, src_path, dst_fs, dst_path, overwrite, update)

    # If the src and dst fs objects are the same, then use a direct copy
    if src_fs is dst_fs:
        src_fs.copy(src_path, dst_path, overwrite=overwrite)
        return

    src_syspath = src_fs.getsyspath(src_path, allow_none=True)
    dst_syspath = dst_fs.getsyspath(dst_path, allow_none=True)

    # System copy if there are two sys paths
    if src_syspath is not None and dst_syspath is not None:
        FS._shutil_copyfile(src_syspath, dst_syspath)
        return

    src_lock = getattr(src_fs, '_lock', None)

    if src_lock is not None:
        src_lock.acquire()

    try:
        src = None
        try:
            src = src_fs.open(src_path, 'rb')
            dst_fs.setcontents(dst_path, src, chunk_size=chunk_size)
        finally:
            if src is not None:
                src.close()
    finally:
        if src_lock is not None:
            src_lock.release()
開發者ID:Garcia6l20,項目名稱:pyfilesystem,代碼行數:47,代碼來源:utils.py

示例4: copydir

 def copydir(self, src, dst, overwrite=False, ignore_errors=False, chunk_size=16384):
     if self.getmeta("read_only"):
         raise errors.UnsupportedError('read only filesystem')
     # FIXME: this is out of date; how to do native tahoe copy?
     # FIXME: Workaround because isfile() not exists on _TahoeLAFS
     FS.copydir(self, src, dst, overwrite, ignore_errors, chunk_size)
開發者ID:DANCEcollaborative,項目名稱:forum-xblock,代碼行數:6,代碼來源:__init__.py

示例5: copydir

 def copydir(self, src, dst, **kwds):
     FS.copydir(self,src,dst,**kwds)
開發者ID:benroeder,項目名稱:pyfilesystem,代碼行數:2,代碼來源:limitsizefs.py

示例6: movedir

 def movedir(self, src, dst, **kwds):
     FS.movedir(self,src,dst,**kwds)
開發者ID:benroeder,項目名稱:pyfilesystem,代碼行數:2,代碼來源:limitsizefs.py

示例7: move

 def move(self, src, dst, **kwds):
     FS.move(self,src,dst,**kwds)
     path = relpath(normpath(src))
     with self._size_lock:
         self._file_sizes.pop(path,None)
開發者ID:benroeder,項目名稱:pyfilesystem,代碼行數:5,代碼來源:limitsizefs.py

示例8: __init__

    def __init__(self):
        FS.__init__(self, thread_synchronize=True)

        self.fs_sequence = []
        self.fs_lookup =  {}
開發者ID:svn2github,項目名稱:pyfilesystem,代碼行數:5,代碼來源:multifs.py

示例9: close

 def close(self):
     self._olefile.close()
     FS.close(self)
開發者ID:mete0r,項目名稱:mete0r.olefilefs,代碼行數:3,代碼來源:fs.py


注:本文中的fs.base.FS類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。