Skip to content

Commit 4ffdc51

Browse files
author
Benjamin Moody
committed
get_version: use openurl in place of requests.get.
Note that this will handle errors (e.g. a file that does not exist) and raise an exception, rather than trying to parse the error document.
1 parent 7b6b15f commit 4ffdc51

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

wfdb/io/record.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,8 +1245,9 @@ def get_version(pn_dir):
12451245
"""
12461246
db_dir = pn_dir.split('/')[0]
12471247
url = posixpath.join(download.PN_CONTENT_URL, db_dir) + '/'
1248-
response = requests.get(url)
1249-
contents = [line.decode('utf-8').strip() for line in response.content.splitlines()]
1248+
with _url.openurl(url, 'rb') as f:
1249+
content = f.read()
1250+
contents = [line.decode('utf-8').strip() for line in content.splitlines()]
12501251
version_number = [v for v in contents if 'Version:' in v]
12511252
version_number = version_number[0].split(':')[-1].strip().split('<')[0]
12521253

0 commit comments

Comments
 (0)