Skip to content
Snippets Groups Projects
Commit 205d95bc authored by Izzard, Robert Dr (Maths & Physics)'s avatar Izzard, Robert Dr (Maths & Physics)
Browse files

fix typos in new dataIO open()

parent 5e1a21ae
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment