baidupcs_py/common/downloader.py
def download(
        self,
        localpath: PathLike,
        task_id: Optional[TaskID],
        continue_: bool = False,
        done_callback: Optional[Callable[[Future], Any]] = None,
    ):
        """
        Download the url content to `localpath`

        The downloading work executing in the class ThreadPoolExecutor

        Args:
            continue_ (bool): If set to True, only downloading the remain content depended on
            the size of `localpath`
        """

        self._task_id = task_id

        if continue_:
            _path = Path(localpath)
            _offset = _path.stat().st_size if _path.exists() else 0
            _fd = _path.open("ab")
            _fd.seek(_offset, 0)
        else:
            _offset = 0
            _fd = open(localpath, "wb")

        self._offset = _offset
        self._fd = _fd

        cls = self.__class__
        cls._semaphore.acquire()

        fut = cls._executor.submit(
            sure_release,
            cls._semaphore,
            self.work,
        )
        if done_callback:
            fut.add_done_callback(done_callback)
        cls._futures.append(fut)

        Download the url content to `localpath`

        The downloading work executing in the class ThreadPoolExecutor

        Args:
            continue_ (bool): If set to True, only downloading the remain content depended on
            the size of `localpath`
        
Download the url content to `localpath`
The downloading work executing in the class ThreadPoolExecutor

continue_ (bool): If set to True, only downloading the remain content depended on
the size of `localpath`
Download the url content to ` localpath ` The downloading work executing in the class ThreadPoolExecutor continue_ ( bool ) : If set to True only downloading the remain content depended on the size of ` localpath `
def download(
        self,
        localpath: PathLike,
        task_id: Optional[TaskID],
        continue_: bool = False,
        done_callback: Optional[Callable[[Future], Any]] = None,
    ):
        self._task_id = task_id
        if continue_:
            _path = Path(localpath)
            _offset = _path.stat().st_size if _path.exists() else 0
            _fd = _path.open("ab")
            _fd.seek(_offset, 0)
        else:
            _offset = 0
            _fd = open(localpath, "wb")
        self._offset = _offset
        self._fd = _fd
        cls = self.__class__
        cls._semaphore.acquire()
        fut = cls._executor.submit(
            sure_release,
            cls._semaphore,
            self.work,
        )
        if done_callback:
            fut.add_done_callback(done_callback)
        cls._futures.append(fut)
def download ( self , localpath : PathLike , task_id : Optional [ TaskID ] , continue_ : bool = False , done_callback : Optional [ Callable [ [ Future ] , Any ] ] = None , ) : self . _task_id = task_id if continue_ : _path = Path ( localpath ) _offset = _path . stat ( ) . st_size if _path . exists ( ) else 0 _fd = _path . open ( "ab" ) _fd . seek ( _offset , 0 ) else : _offset = 0 _fd = open ( localpath , "wb" ) self . _offset = _offset self . _fd = _fd cls = self . __class__ cls . _semaphore . acquire ( ) fut = cls . _executor . submit ( sure_release , cls . _semaphore , self . work , ) if done_callback : fut . add_done_callback ( done_callback ) cls . _futures . append ( fut )
Download the url content to `localpath`
The downloading work executing in the class ThreadPoolExecutor
Download the url content to ` localpath ` The downloading work executing in the class ThreadPoolExecutor
"""
        Download the url content to `localpath`

        The downloading work executing in the class ThreadPoolExecutor

        Args:
            continue_ (bool): If set to True, only downloading the remain content depended on
            the size of `localpath`
        """
self
localpath
PathLike
task_id
Optional[TaskID]
continue_
bool
done_callback
Optional[Callable[[Future], Any]]