Skip to content

Commit 326b65b

Browse files
authored
Merge pull request MIT-LCP#271 from MIT-LCP/fix_path
Fixes path parsing for Windows
2 parents a8cc498 + 5091613 commit 326b65b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

wfdb/io/annotation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ def rdann(record_name, extension, sampfrom=0, sampto=None, shift_samps=False,
16151615
16161616
"""
16171617
if (pn_dir is not None) and ('.' not in pn_dir):
1618-
dir_list = pn_dir.split(os.sep)
1618+
dir_list = pn_dir.split('/')
16191619
pn_dir = posixpath.join(dir_list[0],
16201620
record.get_version(dir_list[0]),
16211621
*dir_list[1:])
@@ -2248,7 +2248,7 @@ def ann2rr(record_name, extension, pn_dir=None, start_time=None,
22482248
22492249
"""
22502250
if (pn_dir is not None) and ('.' not in pn_dir):
2251-
dir_list = pn_dir.split(os.sep)
2251+
dir_list = pn_dir.split('/')
22522252
pn_dir = posixpath.join(dir_list[0], record.get_version(dir_list[0]),
22532253
*dir_list[1:])
22542254

wfdb/io/record.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ def get_version(pn_dir):
12421242
The version number of the most recent database.
12431243
12441244
"""
1245-
db_dir = pn_dir.split(os.sep)[0]
1245+
db_dir = pn_dir.split('/')[0]
12461246
url = posixpath.join(download.PN_CONTENT_URL, db_dir)
12471247
response = requests.get(url)
12481248
contents = [line.decode('utf-8').strip() for line in response.content.splitlines()]
@@ -1403,7 +1403,7 @@ def edf2mit(record_name, pn_dir=None, delete_file=True, record_only=False):
14031403
if pn_dir is not None:
14041404

14051405
if '.' not in pn_dir:
1406-
dir_list = pn_dir.split(os.sep)
1406+
dir_list = pn_dir.split('/')
14071407
pn_dir = posixpath.join(dir_list[0], get_version(dir_list[0]), *dir_list[1:])
14081408

14091409
file_url = posixpath.join(download.PN_INDEX_URL, pn_dir, record_name)
@@ -2131,7 +2131,7 @@ def wav2mit(record_name, pn_dir=None, delete_file=True, record_only=False):
21312131
if pn_dir is not None:
21322132

21332133
if '.' not in pn_dir:
2134-
dir_list = pn_dir.split(os.sep)
2134+
dir_list = pn_dir.split('/')
21352135
pn_dir = posixpath.join(dir_list[0], get_version(dir_list[0]), *dir_list[1:])
21362136

21372137
file_url = posixpath.join(download.PN_INDEX_URL, pn_dir, record_name)
@@ -2568,7 +2568,7 @@ def rdheader(record_name, pn_dir=None, rd_segments=False):
25682568
dir_name = os.path.abspath(dir_name)
25692569

25702570
if (pn_dir is not None) and ('.' not in pn_dir):
2571-
dir_list = pn_dir.split(os.sep)
2571+
dir_list = pn_dir.split('/')
25722572
pn_dir = posixpath.join(dir_list[0], get_version(dir_list[0]), *dir_list[1:])
25732573

25742574
# Read the header file. Separate comment and non-comment lines
@@ -3029,7 +3029,7 @@ def rdsamp(record_name, sampfrom=0, sampto=None, channels=None, pn_dir=None,
30293029
30303030
"""
30313031
if (pn_dir is not None) and ('.' not in pn_dir):
3032-
dir_list = pn_dir.split(os.sep)
3032+
dir_list = pn_dir.split('/')
30333033
pn_dir = posixpath.join(dir_list[0], get_version(dir_list[0]), *dir_list[1:])
30343034

30353035
record = rdrecord(record_name=record_name, sampfrom=sampfrom,
@@ -3081,7 +3081,7 @@ def sampfreq(record_name, pn_dir=None):
30813081
30823082
"""
30833083
if (pn_dir is not None) and ('.' not in pn_dir):
3084-
dir_list = pn_dir.split(os.sep)
3084+
dir_list = pn_dir.split('/')
30853085
pn_dir = posixpath.join(dir_list[0], get_version(dir_list[0]),
30863086
*dir_list[1:])
30873087

@@ -3133,7 +3133,7 @@ def signame(record_name, pn_dir=None, sig_nums=[]):
31333133
31343134
"""
31353135
if (pn_dir is not None) and ('.' not in pn_dir):
3136-
dir_list = pn_dir.split(os.sep)
3136+
dir_list = pn_dir.split('/')
31373137
pn_dir = posixpath.join(dir_list[0], get_version(dir_list[0]),
31383138
*dir_list[1:])
31393139

@@ -3376,8 +3376,8 @@ def dl_database(db_dir, dl_dir, records='all', annotators='all',
33763376
33773377
"""
33783378
# Full url PhysioNet database
3379-
if os.sep in db_dir:
3380-
dir_list = db_dir.split(os.sep)
3379+
if '/' in db_dir:
3380+
dir_list = db_dir.split('/')
33813381
db_dir = posixpath.join(dir_list[0], get_version(dir_list[0]), *dir_list[1:])
33823382
else:
33833383
db_dir = posixpath.join(db_dir, get_version(db_dir))

0 commit comments

Comments
 (0)