def gen_binary_files_from_urls(
        urls: Iterable[str],
        on_disk: bool = False,
        show_info: bool = True) -> Generator[BinaryIO, None, None]:
    """
    Generate binary files from a series of URLs (one per URL).

    Args:
        urls: iterable of URLs
        on_disk: if ``True``, yields files that are on disk (permitting
            random access); if ``False``, yields in-memory files (which will
            not permit random access)
        show_info: show progress to the log?

    Yields:
        files, each of type :class:`BinaryIO`

    """
    for url in urls:
        if on_disk:
            # Necessary for e.g. zip processing (random access)
            with tempfile.TemporaryDirectory() as tmpdir:
                filename = os.path.join(tmpdir, "tempfile")
                download(url=url, filename=filename)
                with open(filename, 'rb') as f:
                    yield f
        else:
            if show_info:
                log.info("Reading from URL: {}", url)
            with urllib.request.urlopen(url) as f:
                yield f
        if show_info:
            log.info("... finished reading from URL: {}", url)
def gen_binary_files_from_urls ( urls : Iterable [ str ] , on_disk : bool = False , show_info : bool = True ) -> Generator [ BinaryIO , None , None ] : for url in urls : if on_disk : with tempfile . TemporaryDirectory ( ) as tmpdir : filename = os . path . join ( tmpdir , "tempfile" ) download ( url = url , filename = filename ) with open ( filename , 'rb' ) as f : yield f else : if show_info : log . info ( "Reading from URL: {}" , url ) with urllib . request . urlopen ( url ) as f : yield f if show_info : log . info ( "... finished reading from URL: {}" , url )
Generate binary files from a series of URLs (one per URL).

    Args:
        urls: iterable of URLs
        on_disk: if ``True``, yields files that are on disk (permitting
            random access); if ``False``, yields in-memory files (which will
            not permit random access)
        show_info: show progress to the log?

    Yields:
        files, each of type :class:`BinaryIO`