Skip to content

Commit 3116310

Browse files
committed
typos fixed
1 parent 5227226 commit 3116310

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

package/MDAnalysis/web/downloaders.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ class BaseDownloader(ABC):
2525

2626
def __str__(self):
2727
return f"Metadata: id={self.id}, file_format={self.file_format}, "
28+
29+
def __del__(self):
30+
if self._file is not None:
31+
self._file.close() # Ensure file-like object is closed in child classes
2832

2933
def __init__(self, id, file_format):
3034
"""Declares attributes meant to be manipulated by child classes"""
3135

3236
# Attributes are meant to get updated by child instances
3337
self.id = id
3438
self.file_format = file_format
35-
39+
3640
self._file = None
3741

3842
@abstractmethod
@@ -73,7 +77,8 @@ def _open_file(self, cache_path):
7377

7478
# Found Cache, so don't download anything and open existing file
7579
if named_file_path.exists() and named_file_path.is_file():
76-
self._file = open(named_file_path,"r")
80+
self._file = open(named_file_path,"r")
81+
self._download = False
7782

7883
else: # No cache found, so create Cache
7984
self._file = open(named_file_path, 'w+t')
@@ -94,7 +99,7 @@ def download(self, cache_path=None, timeout=None):
9499
r.raise_for_status()
95100
self._file.write(r.text)
96101
except requests.HTTPError:
97-
# This also deletes the undownloaded file
102+
# This also deletes the undownloaded file since write() hasn't been called yet
98103
raise FileDownloadPDBError
99104
finally:
100105
# Closes File safely if saving to cache

0 commit comments

Comments
 (0)