Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
binary_c-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Izzard, Robert Dr (Maths & Physics)
binary_c-python
Commits
205d95bc
Commit
205d95bc
authored
3 years ago
by
Izzard, Robert Dr (Maths & Physics)
Browse files
Options
Downloads
Patches
Plain Diff
fix typos in new dataIO open()
parent
5e1a21ae
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
binarycpython/utils/dataIO.py
+12
-12
12 additions, 12 deletions
binarycpython/utils/dataIO.py
with
12 additions
and
12 deletions
binarycpython/utils/dataIO.py
+
12
−
12
View file @
205d95bc
...
@@ -119,7 +119,7 @@ class dataIO():
...
@@ -119,7 +119,7 @@ class dataIO():
object
.
persistent_data_memory_dict
=
persistent_data_memory_dict
object
.
persistent_data_memory_dict
=
persistent_data_memory_dict
self
.
NFS_flush_hack
(
filename
)
self
.
NFS_flush_hack
(
filename
)
# touch 'saved' file
# touch 'saved' file
saved
=
filename
+
'
.saved
'
saved
=
filename
+
'
.saved
'
self
.
HPC_touch
(
saved
)
self
.
HPC_touch
(
saved
)
...
@@ -227,7 +227,7 @@ class dataIO():
...
@@ -227,7 +227,7 @@ class dataIO():
size
=
os
.
path
.
getsize
(
filename
),
size
=
os
.
path
.
getsize
(
filename
),
modtime
=
modtime
,
modtime
=
modtime
,
))
))
newpop
=
self
.
load_population_object
(
filename
)
newpop
=
self
.
load_population_object
(
filename
)
try
:
try
:
...
@@ -365,7 +365,7 @@ class dataIO():
...
@@ -365,7 +365,7 @@ class dataIO():
file_type
=
file_type
,
file_type
=
file_type
,
)
)
)
)
def
write_binary_c_calls_to_file
(
def
write_binary_c_calls_to_file
(
self
,
self
,
output_dir
:
Union
[
str
,
None
]
=
None
,
output_dir
:
Union
[
str
,
None
]
=
None
,
...
@@ -495,7 +495,7 @@ class dataIO():
...
@@ -495,7 +495,7 @@ class dataIO():
f
.
write
(
string
)
f
.
write
(
string
)
f
.
close
()
f
.
close
()
self
.
NFS_flush_hack
(
path
)
self
.
NFS_flush_hack
(
path
)
# custom logging functions for HPC jobs
# custom logging functions for HPC jobs
if
self
.
HPC_job
():
if
self
.
HPC_job
():
self
.
HPC_set_status
(
string
)
self
.
HPC_set_status
(
string
)
...
@@ -529,7 +529,7 @@ class dataIO():
...
@@ -529,7 +529,7 @@ class dataIO():
time
.
sleep
(
0.25
)
time
.
sleep
(
0.25
)
while
os
.
path
.
isfile
(
filename
+
lock_suffix
):
while
os
.
path
.
isfile
(
filename
+
lock_suffix
):
time
.
sleep
(
0.25
)
time
.
sleep
(
0.25
)
def
locked_open_for_write
(
self
,
def
locked_open_for_write
(
self
,
filename
,
filename
,
encoding
=
"
utf-8
"
,
encoding
=
"
utf-8
"
,
...
@@ -541,7 +541,7 @@ class dataIO():
...
@@ -541,7 +541,7 @@ class dataIO():
vb
=
False
,
vb
=
False
,
**
kwargs
):
**
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.
filename for writing (mode
"
w
"
) and locks it.
We check whether the file
'
s lockfile already exists, in which
We check whether the file
'
s lockfile already exists, in which
...
@@ -560,7 +560,7 @@ class dataIO():
...
@@ -560,7 +560,7 @@ class dataIO():
fatal_open_errors: if open() fails and fatal_open_errors is True, exit.
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)
exists_ok: if False and the file at filename exists, return (None,None) (default False)
vb: verbose logging if True, defaults to False
vb: verbose logging if True, defaults to False
Returns:
Returns:
(file_object, lock_object) tuple.
(file_object, lock_object) tuple.
If the file was not opened, returns (None,None).
If the file was not opened, returns (None,None).
...
@@ -619,7 +619,7 @@ class dataIO():
...
@@ -619,7 +619,7 @@ class dataIO():
print
(
"
File at {} already exists (2): cannot write to it, unlocking and returning (None,None)
"
.
format
(
filename
))
print
(
"
File at {} already exists (2): cannot write to it, unlocking and returning (None,None)
"
.
format
(
filename
))
lock
.
unlock
()
lock
.
unlock
()
return
(
None
,
None
)
return
(
None
,
None
)
# All is apparently ok: file is locked
# All is apparently ok: file is locked
try
:
try
:
if
vb
:
if
vb
:
...
@@ -660,7 +660,7 @@ class dataIO():
...
@@ -660,7 +660,7 @@ class dataIO():
os
.
sync
()
os
.
sync
()
dir
=
os
.
path
.
dirname
(
filename
)
dir
=
os
.
path
.
dirname
(
filename
)
os
.
scandir
(
dir
)
os
.
scandir
(
dir
)
def
compression_type
(
self
,
filename
):
def
compression_type
(
self
,
filename
):
"""
"""
...
@@ -673,12 +673,12 @@ class dataIO():
...
@@ -673,12 +673,12 @@ class dataIO():
else
:
else
:
return
None
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.
Wrapper for open() with automatic compression based on the file extension.
"""
"""
if
compression
is
None
:
if
compression
is
None
:
compression
=
compression_type
(
file
)
compression
=
self
.
compression_type
(
file
)
if
compression
:
if
compression
:
if
compresslevel
is
None
:
if
compresslevel
is
None
:
compresslevel
=
9
compresslevel
=
9
...
@@ -704,5 +704,5 @@ class dataIO():
...
@@ -704,5 +704,5 @@ class dataIO():
errors
=
errors
,
errors
=
errors
,
newline
=
newline
,
newline
=
newline
,
closefd
=
closefd
,
closefd
=
closefd
,
opener
=
opener
)
opener
=
opener
)
return
file_object
return
file_object
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment