Skip to content

Commit

Permalink
Streamline file reading for single segment records, record headers an…
Browse files Browse the repository at this point in the history
…d annotation files. These methods all now stack between the public functions, handling mainly i/o, and the parsing functions.
  • Loading branch information
Ivorforce committed Jul 30, 2024
1 parent 39cd94b commit 9de2d92
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 343 deletions.
15 changes: 10 additions & 5 deletions wfdb/io/_coreio.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import posixpath
import os

from wfdb.io import _url
from wfdb.io.download import config


def _open_file(
pn_dir,
file_name,
mode="r",
*,
dir_name="",
pn_dir=None,
buffering=-1,
encoding=None,
errors=None,
Expand All @@ -24,15 +26,18 @@ def _open_file(
Parameters
----------
pn_dir : str or None
The PhysioNet database directory where the file is stored, or None
if file_name is a local path.
file_name : str
The name of the file, either as a local filesystem path (if
`pn_dir` is None) or a URL path (if `pn_dir` is a string.)
mode : str, optional
The standard I/O mode for the file ("r" by default). If `pn_dir`
is not None, this must be "r", "rt", or "rb".
dir_name : str or None
If passed, and pn_dir is None, the directory will be prepended
to the file_name.
pn_dir : str or None
The PhysioNet database directory where the file is stored, or None
if file_name is a local path.
buffering : int, optional
Buffering policy.
encoding : str, optional
Expand All @@ -48,7 +53,7 @@ def _open_file(
"""
if pn_dir is None:
return open(
file_name,
os.path.join(dir_name, file_name),
mode,
buffering=buffering,
encoding=encoding,
Expand Down
Loading

0 comments on commit 9de2d92

Please sign in to comment.