From 59501916ccfc2d979b55b1043aee23e354a469d0 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 12 Feb 2019 15:02:51 +0000 Subject: [PATCH] added **kwargs to allow flexible downloading --- openmc/_utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/openmc/_utils.py b/openmc/_utils.py index 4a2f548f6a..ee3f0d4932 100644 --- a/openmc/_utils.py +++ b/openmc/_utils.py @@ -7,7 +7,7 @@ from urllib.request import urlopen _BLOCK_SIZE = 16384 -def download(url, checksum=None, context=None): +def download(url, checksum=None, **kwargs): """Download file from a URL Parameters @@ -16,8 +16,11 @@ def download(url, checksum=None, context=None): URL from which to download checksum : str or None MD5 checksum to check against - context : ssl.SSLContext instance or None - For example ssl._create_unverified_context() + **kwargs : dict + Optional arguements passed to urlopen() + context: ssl.SSLContext object + Describes the various SSL options, + e.g. context=ssl._create_unverified_context() Returns ------- @@ -25,8 +28,8 @@ def download(url, checksum=None, context=None): Name of file written locally """ - req = urlopen(url, context=context) - + req = urlopen(url, **kwargs) + print(kwargs) # Get file size from header file_size = req.length