@@ -68,7 +68,7 @@ def _open_file(self, cache_path):
6868
6969 # create temporary file to save pdb file
7070 if cache_path is None :
71- self ._file = tempfile .NamedTemporaryFile (mode = 'w+t ' )
71+ self ._file = tempfile .NamedTemporaryFile (mode = 'wb ' )
7272 self ._download = True
7373
7474 # Create/Parse download cache
@@ -77,11 +77,11 @@ def _open_file(self, cache_path):
7777
7878 # Found Cache, so don't download anything and open existing file
7979 if named_file_path .exists () and named_file_path .is_file ():
80- self ._file = open (named_file_path ,"r" )
80+ self ._file = open (named_file_path , 'r' )
8181 self ._download = False
8282
8383 else : # No cache found, so create Cache
84- self ._file = open (named_file_path , 'w+t ' )
84+ self ._file = open (named_file_path , 'wb ' )
8585 self ._download = True
8686
8787
@@ -97,7 +97,7 @@ def download(self, cache_path=None, timeout=None):
9797 r = requests .get (f"https://files.rcsb.org/download/{ self .id } .{ self .file_format } " ,
9898 timeout = timeout )
9999 r .raise_for_status ()
100- self ._file .write (r .text )
100+ self ._file .write (r .content )
101101 except requests .HTTPError :
102102 # This also deletes the undownloaded file since write() hasn't been called yet
103103 raise FileDownloadPDBError
0 commit comments