@@ -1837,6 +1837,12 @@ def rdheader(record_name, pn_dir=None, rd_segments=False):
18371837
18381838 # If the PhysioNet database path is provided, construct the download path using the database version
18391839 elif pn_dir is not None :
1840+ # check to make sure a cloud path isn't being passed under pn_dir
1841+ if any (pn_dir .startswith (proto ) for proto in CLOUD_PROTOCOLS ):
1842+ raise ValueError (
1843+ "Cloud paths should be passed under record_name, not under pn_dir"
1844+ )
1845+
18401846 if "." not in pn_dir :
18411847 dir_list = pn_dir .split ("/" )
18421848 pn_dir = posixpath .join (
@@ -2032,11 +2038,17 @@ def rdrecord(
20322038 dir_name = os .path .abspath (dir_name )
20332039
20342040 # Read the header fields
2035- if (pn_dir is not None ) and ("." not in pn_dir ):
2036- dir_list = pn_dir .split ("/" )
2037- pn_dir = posixpath .join (
2038- dir_list [0 ], download .get_version (dir_list [0 ]), * dir_list [1 :]
2039- )
2041+ if pn_dir is not None :
2042+ # check to make sure a cloud path isn't being passed under pn_dir
2043+ if any (pn_dir .startswith (proto ) for proto in CLOUD_PROTOCOLS ):
2044+ raise ValueError (
2045+ "Cloud paths should be passed under record_name, not under pn_dir"
2046+ )
2047+ if "." not in pn_dir :
2048+ dir_list = pn_dir .split ("/" )
2049+ pn_dir = posixpath .join (
2050+ dir_list [0 ], download .get_version (dir_list [0 ]), * dir_list [1 :]
2051+ )
20402052
20412053 record = rdheader (record_name , pn_dir = pn_dir , rd_segments = False )
20422054
@@ -2320,11 +2332,17 @@ def rdsamp(
23202332 channels=[1,3])
23212333
23222334 """
2323- if (pn_dir is not None ) and ("." not in pn_dir ):
2324- dir_list = pn_dir .split ("/" )
2325- pn_dir = posixpath .join (
2326- dir_list [0 ], download .get_version (dir_list [0 ]), * dir_list [1 :]
2327- )
2335+ if pn_dir is not None :
2336+ # check to make sure a cloud path isn't being passed under pn_dir
2337+ if any (pn_dir .startswith (proto ) for proto in CLOUD_PROTOCOLS ):
2338+ raise ValueError (
2339+ "Cloud paths should be passed under record_name, not under pn_dir"
2340+ )
2341+ if "." not in pn_dir :
2342+ dir_list = pn_dir .split ("/" )
2343+ pn_dir = posixpath .join (
2344+ dir_list [0 ], download .get_version (dir_list [0 ]), * dir_list [1 :]
2345+ )
23282346
23292347 record = rdrecord (
23302348 record_name = record_name ,
0 commit comments