Skip to content

Commit 08efe22

Browse files
committed
only call abspath for local files
1 parent cdea434 commit 08efe22

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

wfdb/io/record.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,20 +1828,16 @@ def rdheader(record_name, pn_dir=None, rd_segments=False):
18281828
18291829
"""
18301830
dir_name, base_record_name = os.path.split(record_name)
1831-
dir_name = os.path.abspath(dir_name)
18321831
file_name = f"{base_record_name}.hea"
18331832

18341833
# If this is a cloud path, use posixpath to construct the path
18351834
if any(dir_name.startswith(proto) for proto in CLOUD_PROTOCOLS):
1836-
with fsspec.open(
1837-
posixpath.join(dir_name, file_name),
1838-
mode="rb"
1839-
) as f:
1835+
with fsspec.open(posixpath.join(dir_name, file_name), mode="rb") as f:
18401836
header_content = f.read()
18411837

18421838
# If it isn't a cloud path, construct the download path using the database version
1843-
elif (pn_dir is not None):
1844-
if ("." not in pn_dir):
1839+
elif pn_dir is not None:
1840+
if "." not in pn_dir:
18451841
dir_list = pn_dir.split("/")
18461842
pn_dir = posixpath.join(
18471843
dir_list[0], download.get_version(dir_list[0]), *dir_list[1:]
@@ -1851,6 +1847,7 @@ def rdheader(record_name, pn_dir=None, rd_segments=False):
18511847

18521848
# If it isn't a cloud path or a PhysioNet path, we treat as a local file
18531849
else:
1850+
dir_name = os.path.abspath(dir_name)
18541851
with fsspec.open(
18551852
os.path.join(dir_name, file_name),
18561853
"r",

0 commit comments

Comments
 (0)