Exemplo n.º 1
0
def handle_file(filename, index):
    """ cache file handling. """
    if h5r.is_valid_file(filename):
        # SIH5 file: nothing to do, the file will be loaded later
        return (index, filename)

    if icer.is_valid_file(filename):
        # load .icecache and save to SIH5 folder
        data_folder = os.path.join(os.path.dirname(filename), '.sih5')
        if not os.path.exists(data_folder):
            os.mkdir(data_folder, 777)

        # export only if file doesn't exist
        reader = icer.ICEReader(filename)
        reader.export(data_folder, CONSTS.SIH5_FMT, force=False)
        return (index, reader.export_filename)

    # unsupported file format
    return (None, None)
def handle_file( filename, index ):                        
    """ cache file handling. """
    if h5r.is_valid_file( filename ):
        # SIH5 file: nothing to do, the file will be loaded later
        return ( index, filename )

    if icer.is_valid_file( filename ):        
        # load .icecache and save to SIH5 folder
        data_folder = os.path.join( os.path.dirname( filename ), '.sih5' )
        if not os.path.exists( data_folder ):
            os.mkdir( data_folder, 777 )

        # export only if file doesn't exist
        reader = icer.ICEReader( filename )
        reader.export( data_folder, CONSTS.SIH5_FMT, force = False )
        return ( index, reader.export_filename )

    # unsupported file format 
    return ( None, None )    
Exemplo n.º 3
0
def is_valid_file( f ):
    return icer.is_valid_file(f) or h5r.is_valid_file(f)