X-Git-Url: http://users.mur.at/ms/git/gitweb/?a=blobdiff_plain;f=aces_1.0.0%2Fpython%2Faces_ocio%2Fcreate_aces_config.py;h=44dc56588618cebe0cb7e02f9c7f02814096438a;hb=e609947e7cc6ae0696dd5b8f82b80ac894e80565;hp=6d37f718c85939394e527d0a3db4bc1b14c1e352;hpb=7d0167135cd080045ca2ee658fd48ff90cfa3e42;p=OpenColorIO-Configs.git diff --git a/aces_1.0.0/python/aces_ocio/create_aces_config.py b/aces_1.0.0/python/aces_ocio/create_aces_config.py index 6d37f71..44dc565 100755 --- a/aces_1.0.0/python/aces_ocio/create_aces_config.py +++ b/aces_1.0.0/python/aces_ocio/create_aces_config.py @@ -29,7 +29,7 @@ from aces_ocio.generate_lut import ( generate_3d_LUT_from_CTL, write_SPI_1d) from aces_ocio.process import Process -from aces_ocio.utilities import ColorSpace, mat44_from_mat33 +from aces_ocio.utilities import ColorSpace, mat44_from_mat33, sanitize_path __author__ = 'ACES Developers' __copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers' @@ -145,9 +145,8 @@ def write_config(config, config_path, sanity_check=True): return # sys.exit() - file_handle = open(config_path, mode='w') - file_handle.write(config.serialize()) - file_handle.close() + with open(config_path, mode='w') as fp: + fp.write(config.serialize()) def generate_OCIO_transform(transforms): @@ -454,8 +453,7 @@ def generate_LUTs(odt_info, 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')] lut = '%s_to_ACES.spi1d' % name - # Remove spaces and parentheses - lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_') + lut = sanitize_path(lut) generate_1d_LUT_from_CTL( os.path.join(lut_directory, lut), @@ -513,8 +511,7 @@ def generate_LUTs(odt_info, 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')] lut = '%s_to_aces.spi1d' % name - # Remove spaces and parentheses - lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_') + lut = sanitize_path(lut) generate_1d_LUT_from_CTL( os.path.join(lut_directory, lut), @@ -766,8 +763,7 @@ def generate_LUTs(odt_info, 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl')] lut = '%s_to_aces.spi1d' % name - # Remove spaces and parentheses - lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_') + lut = sanitize_path(lut) generate_1d_LUT_from_CTL( os.path.join(lut_directory, lut), @@ -860,8 +856,7 @@ def generate_LUTs(odt_info, os.path.join(aces_CTL_directory, lmt_values['transformCTL'])] lut = '%s.%s.spi3d' % (shaper_name, lmt_name) - # Remove spaces and parentheses - lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_') + lut = sanitize_path(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), @@ -895,8 +890,7 @@ def generate_LUTs(odt_info, ] lut = 'Inverse.%s.%s.spi3d' % (odt_name, shaper_name) - # Remove spaces and parentheses - lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_') + lut = sanitize_path(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), @@ -1061,8 +1055,7 @@ def generate_LUTs(odt_info, odt_values['transformCTL'])] lut = '%s.RRT.a1.0.0.%s.spi3d' % (shaper_name, odt_name) - # Remove spaces and parentheses - lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_') + lut = sanitize_path(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), @@ -1118,8 +1111,7 @@ def generate_LUTs(odt_info, ] lut = 'InvRRT.a1.0.0.%s.%s.spi3d' % (odt_name, shaper_name) - # Remove spaces and parentheses - lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_') + lut = sanitize_path(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), @@ -1532,11 +1524,8 @@ def get_transform_info(ctl_transform): Return value description. """ - # TODO: Use *with* statement. - fp = open(ctl_transform, 'rb') - - # Read lines - lines = fp.readlines() + with open(ctl_transform, 'rb') as fp: + lines = fp.readlines() # Grab transform ID and User Name transform_ID = lines[1][3:].split('<')[1].split('>')[1].strip() @@ -1546,7 +1535,6 @@ def get_transform_info(ctl_transform): transform_user_name_prefix = ( lines[2][3:].split('<')[1].split('>')[1].split('-')[0].strip()) # print(transformUserName) - fp.close() return transform_ID, transform_user_name, transform_user_name_prefix