(filename, working_directory, url_source)
| 2439 | |
| 2440 | # We first define a download function, supporting both Python 2 and 3. |
| 2441 | def _download(filename, working_directory, url_source): |
| 2442 | |
| 2443 | progress_bar = progressbar.ProgressBar() |
| 2444 | |
| 2445 | def _dlProgress(count, blockSize, totalSize, pbar=progress_bar): |
| 2446 | if (totalSize != 0): |
| 2447 | |
| 2448 | if not pbar.max_value: |
| 2449 | totalBlocks = math.ceil(float(totalSize) / float(blockSize)) |
| 2450 | pbar.max_value = int(totalBlocks) |
| 2451 | |
| 2452 | pbar.update(count, force=True) |
| 2453 | |
| 2454 | filepath = os.path.join(working_directory, filename) |
| 2455 | |
| 2456 | logging.info('Downloading %s...\n' % filename) |
| 2457 | |
| 2458 | urlretrieve(url_source + filename, filepath, reporthook=_dlProgress) |
| 2459 | |
| 2460 | exists_or_mkdir(working_directory, verbose=False) |
| 2461 | filepath = os.path.join(working_directory, filename) |
no outgoing calls
no test coverage detected
searching dependent graphs…