File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change
1
+ from pathlib import Path
2
+
3
+ from nibabel .cifti2 .caretspec import *
4
+
5
+ from nibabel .testing import data_path
6
+
7
+
8
+ def test_CaretSpecFile ():
9
+ fsLR = CaretSpecFile .from_filename (Path (data_path ) / "fsLR.wb.spec" )
10
+
11
+ assert fsLR .metadata == {}
12
+ assert fsLR .version == "1.0"
13
+ assert len (fsLR .data_files ) == 5
14
+
15
+ for df in fsLR .data_files :
16
+ assert isinstance (df , CaretSpecDataFile )
17
+ if df .data_file_type == 'SURFACE' :
18
+ assert isinstance (df , SurfaceDataFile )
Original file line number Diff line number Diff line change @@ -573,11 +573,13 @@ def to_bytes(self):
573
573
return bio .getvalue ()
574
574
575
575
@classmethod
576
- def from_url (klass , url ):
576
+ def from_url (klass , url , timeout = 5 ):
577
577
""" Fetch image from remote location and construct an image
578
578
579
579
Requires the ``requests`` library to be installed.
580
580
"""
581
581
import requests
582
- res = requests .get (url )
582
+ res = requests .get (url , timeout = timeout )
583
+ if not res .ok :
584
+ raise IOError (f"[Error { res .status_code } ] Could not retrieve { url } " )
583
585
return klass .from_bytes (res .content )
You can’t perform that action at this time.
0 commit comments