X-Git-Url: http://users.mur.at/ms/git/gitweb/?p=OpenColorIO-Configs.git;a=blobdiff_plain;f=aces_1.0.0%2Fpython%2Faces_ocio%2Fprocess.py;h=47b968fc3f9ceccb560fe3301c5582f4e8cc9e29;hp=ad0b02e4e507ae432361962a70beb4ebb594a039;hb=e609947e7cc6ae0696dd5b8f82b80ac894e80565;hpb=a0dc64b95d92c314e80d0f85319290326f90818d 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 --- 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. """ - if (text_file != ''): - fp = open(text_file, 'rb') - # Create a text/plain message - text = (fp.read()) - fp.close() + if text_file != '': + with open(text_file, 'rb') as fp: + text = (fp.read()) return text @@ -62,11 +60,9 @@ def write_text(text, text_file): Return value description. """ - if (text_file != ''): - fp = open(text_file, 'wb') - # Create a text/plain message - fp.write(text) - fp.close() + if text_file != '': + with open(text_file, 'wb') as fp: + fp.write(text) return text @@ -309,16 +305,14 @@ class Process: if log_filename: try: - # This also doesn't seem like the best structure... + # TODO: Review statements. # 3.1 try: - log_handle = open(log_filename, - mode='wt', - encoding='utf-8') + log_handle = ( + open(log_filename, mode='wt', encoding='utf-8')) # 2.6 except: - log_handle = open(log_filename, - mode='wt') + log_handle = open(log_filename, mode='wt') except: print('Couldn\'t open log : %s' % log_filename) log_handle = None