@@ -32,7 +32,7 @@ def __init__(self, record_name, mode="r"):
32
32
"""
33
33
self .record_name = record_name
34
34
# Only append .wfdb if it's not already there
35
- if record_name .endswith (' .wfdb' ):
35
+ if record_name .endswith (" .wfdb" ):
36
36
self .archive_path = record_name
37
37
else :
38
38
self .archive_path = f"{ record_name } .wfdb"
@@ -45,24 +45,19 @@ def __init__(self, record_name, mode="r"):
45
45
f"Archive not found: { self .archive_path } "
46
46
)
47
47
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" )
54
50
55
51
elif mode == "w" :
56
52
# Create archive file if needed
57
53
if not os .path .exists (self .archive_path ):
58
54
# 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 ,
62
58
)
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" )
66
61
67
62
def __enter__ (self ):
68
63
return self
0 commit comments