Skip to content

Commit ba7992a

Browse files
committed
Fix style.
1 parent 8971d79 commit ba7992a

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

wfdb/io/_signal.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,8 +1712,9 @@ def _rd_dat_file(
17121712
if wfdb_archive is not None:
17131713
# If the exact file name isn't found, look for any .dat file
17141714
if not wfdb_archive.exists(file_name):
1715-
dat_files = [f for f in wfdb_archive.zipfile.namelist()
1716-
if f.endswith('.dat')]
1715+
dat_files = [
1716+
f for f in wfdb_archive.zipfile.namelist() if f.endswith(".dat")
1717+
]
17171718
if not dat_files:
17181719
raise FileNotFoundError(
17191720
f"No dat file found in archive for {file_name}"

wfdb/io/archive.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, record_name, mode="r"):
3232
"""
3333
self.record_name = record_name
3434
# Only append .wfdb if it's not already there
35-
if record_name.endswith('.wfdb'):
35+
if record_name.endswith(".wfdb"):
3636
self.archive_path = record_name
3737
else:
3838
self.archive_path = f"{record_name}.wfdb"
@@ -45,24 +45,19 @@ def __init__(self, record_name, mode="r"):
4545
f"Archive not found: {self.archive_path}"
4646
)
4747
if not zipfile.is_zipfile(self.archive_path):
48-
raise ValueError(
49-
f"Invalid WFDB archive: {self.archive_path}"
50-
)
51-
self.zipfile = zipfile.ZipFile(
52-
self.archive_path, mode="r"
53-
)
48+
raise ValueError(f"Invalid WFDB archive: {self.archive_path}")
49+
self.zipfile = zipfile.ZipFile(self.archive_path, mode="r")
5450

5551
elif mode == "w":
5652
# Create archive file if needed
5753
if not os.path.exists(self.archive_path):
5854
# Create the directory if it doesn't exist
59-
os.makedirs(os.path.dirname(os.path.abspath(self.archive_path)), exist_ok=True)
60-
WFDBArchive.make_archive_file(
61-
[], self.archive_path
55+
os.makedirs(
56+
os.path.dirname(os.path.abspath(self.archive_path)),
57+
exist_ok=True,
6258
)
63-
self.zipfile = zipfile.ZipFile(
64-
self.archive_path, mode="a"
65-
)
59+
WFDBArchive.make_archive_file([], self.archive_path)
60+
self.zipfile = zipfile.ZipFile(self.archive_path, mode="a")
6661

6762
def __enter__(self):
6863
return self

wfdb/io/record.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,9 +2054,13 @@ def rdrecord(
20542054
wfdb_archive = get_archive(record_base)
20552055

20562056
# Find any .hea file in the archive
2057-
hea_files = [f for f in wfdb_archive.zipfile.namelist() if f.endswith('.hea')]
2057+
hea_files = [
2058+
f for f in wfdb_archive.zipfile.namelist() if f.endswith(".hea")
2059+
]
20582060
if not hea_files:
2059-
raise FileNotFoundError(f"No header file found in archive {record_name}")
2061+
raise FileNotFoundError(
2062+
f"No header file found in archive {record_name}"
2063+
)
20602064
hea_file = hea_files[0] # Use the first header file found
20612065

20622066
import tempfile

0 commit comments

Comments
 (0)