From 205d95bcae79c689c326dec9da7c8bd1ed6f8027 Mon Sep 17 00:00:00 2001 From: Robert Izzard <r.izzard@surrey.ac.uk> Date: Sun, 28 Nov 2021 10:38:17 +0000 Subject: [PATCH] fix typos in new dataIO open() --- binarycpython/utils/dataIO.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/binarycpython/utils/dataIO.py b/binarycpython/utils/dataIO.py index dd1d98a19..1bcf59a7a 100644 --- a/binarycpython/utils/dataIO.py +++ b/binarycpython/utils/dataIO.py @@ -119,7 +119,7 @@ class dataIO(): object.persistent_data_memory_dict = persistent_data_memory_dict self.NFS_flush_hack(filename) - + # touch 'saved' file saved = filename + '.saved' self.HPC_touch(saved) @@ -227,7 +227,7 @@ class dataIO(): size=os.path.getsize(filename), modtime=modtime, )) - + newpop = self.load_population_object(filename) try: @@ -365,7 +365,7 @@ class dataIO(): file_type=file_type, ) ) - + def write_binary_c_calls_to_file( self, output_dir: Union[str, None] = None, @@ -495,7 +495,7 @@ class dataIO(): f.write(string) f.close() self.NFS_flush_hack(path) - + # custom logging functions for HPC jobs if self.HPC_job(): self.HPC_set_status(string) @@ -529,7 +529,7 @@ class dataIO(): time.sleep(0.25) while os.path.isfile(filename + lock_suffix): time.sleep(0.25) - + def locked_open_for_write(self, filename, encoding="utf-8", @@ -541,7 +541,7 @@ class dataIO(): vb=False, **kwargs): """ - Wrapper for Python's open(filename) which opens a file at + Wrapper for Python's open(filename) which opens a file at filename for writing (mode "w") and locks it. We check whether the file's lockfile already exists, in which @@ -560,7 +560,7 @@ class dataIO(): fatal_open_errors: if open() fails and fatal_open_errors is True, exit. exists_ok: if False and the file at filename exists, return (None,None) (default False) vb: verbose logging if True, defaults to False - + Returns: (file_object, lock_object) tuple. If the file was not opened, returns (None,None). @@ -619,7 +619,7 @@ class dataIO(): print("File at {} already exists (2): cannot write to it, unlocking and returning (None,None)".format(filename)) lock.unlock() return (None,None) - + # All is apparently ok: file is locked try: if vb: @@ -660,7 +660,7 @@ class dataIO(): os.sync() dir = os.path.dirname(filename) os.scandir(dir) - + def compression_type(self,filename): """ @@ -673,12 +673,12 @@ class dataIO(): else: return None - def open(self,file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, compression=None, compresslevel=None) + def open(self,file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, compression=None, compresslevel=None): """ Wrapper for open() with automatic compression based on the file extension. """ if compression is None: - compression = compression_type(file) + compression = self.compression_type(file) if compression: if compresslevel is None: compresslevel = 9 @@ -704,5 +704,5 @@ class dataIO(): errors=errors, newline=newline, closefd=closefd, - opener=opener) + opener=opener) return file_object -- GitLab