projects
/
OpenColorIO-Configs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement usage of "with" statement on relevant IO operations.
[OpenColorIO-Configs.git]
/
aces_1.0.0
/
python
/
aces_ocio
/
process.py
diff --git
a/aces_1.0.0/python/aces_ocio/process.py
b/aces_1.0.0/python/aces_ocio/process.py
index
ad0b02e
..
47b968f
100755
(executable)
--- a/
aces_1.0.0/python/aces_ocio/process.py
+++ b/
aces_1.0.0/python/aces_ocio/process.py
@@
-39,11
+39,9
@@
def read_text(text_file):
Return value description.
\r
"""
\r
\r
Return value description.
\r
"""
\r
\r
- if (text_file != ''):
\r
- fp = open(text_file, 'rb')
\r
- # Create a text/plain message
\r
- text = (fp.read())
\r
- fp.close()
\r
+ if text_file != '':
\r
+ with open(text_file, 'rb') as fp:
\r
+ text = (fp.read())
\r
return text
\r
\r
\r
return text
\r
\r
\r
@@
-62,11
+60,9
@@
def write_text(text, text_file):
Return value description.
\r
"""
\r
\r
Return value description.
\r
"""
\r
\r
- if (text_file != ''):
\r
- fp = open(text_file, 'wb')
\r
- # Create a text/plain message
\r
- fp.write(text)
\r
- fp.close()
\r
+ if text_file != '':
\r
+ with open(text_file, 'wb') as fp:
\r
+ fp.write(text)
\r
return text
\r
\r
\r
return text
\r
\r
\r
@@
-309,16
+305,14
@@
class Process:
\r
if log_filename:
\r
try:
\r
\r
if log_filename:
\r
try:
\r
- # T
his also doesn't seem like the best structure..
.
\r
+ # T
ODO: Review statements
.
\r
# 3.1
\r
try:
\r
# 3.1
\r
try:
\r
- log_handle = open(log_filename,
\r
- mode='wt',
\r
- encoding='utf-8')
\r
+ log_handle = (
\r
+ open(log_filename, mode='wt', encoding='utf-8'))
\r
# 2.6
\r
except:
\r
# 2.6
\r
except:
\r
- log_handle = open(log_filename,
\r
- mode='wt')
\r
+ log_handle = open(log_filename, mode='wt')
\r
except:
\r
print('Couldn\'t open log : %s' % log_filename)
\r
log_handle = None
\r
except:
\r
print('Couldn\'t open log : %s' % log_filename)
\r
log_handle = None
\r