37ef2c69f22a6e2d1232782dd3e192a003731a75,scanpy/readwrite.py,,_download,#Any#Any#,915

Before Change


        with \
            tqdm(unit="B", unit_scale=True, miniters=1, desc=path.name) as t, \
            path.open("wb") as f, \
            urlopen(Request(url, headers={"User-agent": "scanpy-user"})) as resp:

            t.total = int(resp.info().get("content-length", 0))

            block = resp.read(blocksize)
            while block:
                f.write(block)

After Change


        ) as resp:
            resp.raise_for_status()
            total = resp.headers.get("content-length", None)
            with tqdm(
                unit="B",
                unit_scale=True,
                miniters=1,
                unit_divisor=1024,
                total=total if total is None else int(total),
            ) as t, path.open("wb") as f:
                for chunk in resp.iter_content(chunk_size=8 * 1024):
                    t.update(len(chunk))
                    f.write(chunk)
    except (KeyboardInterrupt, Exception):
        // Make sure file doesn’t exist half-downloaded
        if path.is_file():
            path.unlink()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: theislab/scanpy
Commit Name: 37ef2c69f22a6e2d1232782dd3e192a003731a75
Time: 2020-11-25
Author: michal.klein@protonmail.com
File Name: scanpy/readwrite.py
Class Name:
Method Name: _download


Project Name: theislab/scanpy
Commit Name: ab9247bdf8b7a3decc34a15b26fec813ea8fba0d
Time: 2020-07-31
Author: ivirshup@gmail.com
File Name: scanpy/readwrite.py
Class Name:
Method Name: _download


Project Name: tensorflow/datasets
Commit Name: a3e9a51bb758111edf59f7b6dbcc5205d0f0364b
Time: 2018-12-06
Author: pierrot@google.com
File Name: tensorflow_datasets/core/download/downloader.py
Class Name: _Downloader
Method Name: _sync_download