(f, version, validate_hash=True)
Download the CMU data into a file object that has been opened for write.
Download the CMU data into a file object that has been opened for write.
Download the CMU data into a file object that has been opened for write .
def _download_into_file(f, version, validate_hash=True):
  """Download the CMU data into a file object that has been opened for write."""
  with requests.get(H5_URL[version], stream=True) as req:
    req.raise_for_status()
    total_bytes = int(req.headers['Content-Length'])
    progress_bar = tqdm.tqdm(
        desc='Downloading CMU mocap data', total=total_bytes,
        unit_scale=True, unit_divisor=1024)
    try:
      for chunk in req.iter_content(chunk_size=102400):
        if chunk:
          f.write(chunk)
        progress_bar.update(len(chunk))
    finally:
      progress_bar.close()

  if validate_hash:
    f.seek(0)
    if hashlib.sha256(f.read()).hexdigest() != H5_SHA256[version]:
      raise RuntimeError('downloaded file is corrupted')
def _download_into_file ( f , version , validate_hash = True ) : with requests . get ( H5_URL [ version ] , stream = True ) as req : req . raise_for_status ( ) total_bytes = int ( req . headers [ 'Content-Length' ] ) progress_bar = tqdm . tqdm ( desc = 'Downloading CMU mocap data' , total = total_bytes , unit_scale = True , unit_divisor = 1024 ) try : for chunk in req . iter_content ( chunk_size = 102400 ) : if chunk : f . write ( chunk ) progress_bar . update ( len ( chunk ) ) finally : progress_bar . close ( ) if validate_hash : f . seek ( 0 ) if hashlib . sha256 ( f . read ( ) ) . hexdigest ( ) != H5_SHA256 [ version ] : raise RuntimeError ( 'downloaded file is corrupted' )