(output_filename, options)
Runs the postprocessing command on the file provided.
Runs the postprocessing command on the file provided.
Runs the postprocessing command on the file provided .
def postprocess(output_filename, options):
    '''Runs the postprocessing command on the file provided.'''

    assert options.postprocess_cmd

    base, _ = os.path.splitext(output_filename)
    post_filename = base + options.postprocess_ext

    cmd = options.postprocess_cmd
    cmd = cmd.replace('%i', output_filename)
    cmd = cmd.replace('%o', post_filename)
    cmd = cmd.replace('%e', options.postprocess_ext)

    subprocess_args = shlex.split(cmd)

    if os.path.exists(post_filename):
        os.unlink(post_filename)

    if not options.quiet:
        logger.info('  running "{}"...'.format(cmd), end=' ')

    try:
        result = subprocess.call(subprocess_args)
        before = os.stat(output_filename).st_size
        after = os.stat(post_filename).st_size
    except OSError:
        result = -1

    if result == 0:

        if not options.quiet:
            logger.info('{:.1f}% reduction'.format(
                100 * (1.0 - float(after) / before)))

        return post_filename

    else:

        logger.error('warning: postprocessing failed!\n')
        return None
def postprocess ( output_filename , options ) : assert options . postprocess_cmd base , _ = os . path . splitext ( output_filename ) post_filename = base + options . postprocess_ext cmd = options . postprocess_cmd cmd = cmd . replace ( '%i' , output_filename ) cmd = cmd . replace ( '%o' , post_filename ) cmd = cmd . replace ( '%e' , options . postprocess_ext ) subprocess_args = shlex . split ( cmd ) if os . path . exists ( post_filename ) : os . unlink ( post_filename ) if not options . quiet : logger . info ( '  running "{}"...' . format ( cmd ) , end = ' ' ) try : result = subprocess . call ( subprocess_args ) before = os . stat ( output_filename ) . st_size after = os . stat ( post_filename ) . st_size except OSError : result = - 1 if result == 0 : if not options . quiet : logger . info ( '{:.1f}% reduction' . format ( 100 * ( 1.0 - float ( after ) / before ) ) ) return post_filename else : logger . error ( 'warning: postprocessing failed!\n' ) return None