Skip to content

Commit 9de2d92

Browse files
committed
Streamline file reading for single segment records, record headers and annotation files. These methods all now stack between the public functions, handling mainly i/o, and the parsing functions.
1 parent 39cd94b commit 9de2d92

File tree

5 files changed

+192
-343
lines changed

5 files changed

+192
-343
lines changed

wfdb/io/_coreio.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import posixpath
2+
import os
23

34
from wfdb.io import _url
45
from wfdb.io.download import config
56

67

78
def _open_file(
8-
pn_dir,
99
file_name,
1010
mode="r",
1111
*,
12+
dir_name="",
13+
pn_dir=None,
1214
buffering=-1,
1315
encoding=None,
1416
errors=None,
@@ -24,15 +26,18 @@ def _open_file(
2426
2527
Parameters
2628
----------
27-
pn_dir : str or None
28-
The PhysioNet database directory where the file is stored, or None
29-
if file_name is a local path.
3029
file_name : str
3130
The name of the file, either as a local filesystem path (if
3231
`pn_dir` is None) or a URL path (if `pn_dir` is a string.)
3332
mode : str, optional
3433
The standard I/O mode for the file ("r" by default). If `pn_dir`
3534
is not None, this must be "r", "rt", or "rb".
35+
dir_name : str or None
36+
If passed, and pn_dir is None, the directory will be prepended
37+
to the file_name.
38+
pn_dir : str or None
39+
The PhysioNet database directory where the file is stored, or None
40+
if file_name is a local path.
3641
buffering : int, optional
3742
Buffering policy.
3843
encoding : str, optional
@@ -48,7 +53,7 @@ def _open_file(
4853
"""
4954
if pn_dir is None:
5055
return open(
51-
file_name,
56+
os.path.join(dir_name, file_name),
5257
mode,
5358
buffering=buffering,
5459
encoding=encoding,

0 commit comments

Comments
 (0)