Source code for Muscat.IO.UniversalReader

# -*- coding: utf-8 -*-
#
# This file is subject to the terms and conditions defined in
# file 'LICENSE.txt', which is part of this source code package.
#

"""Universal file reader
"""


[docs]def InitAllReaders(): from Muscat.IO.IOFactory import InitAllReaders as IAR IAR()
[docs]def ReadMesh(filename, out=None, timeToRead=-1): import os.path dirname = os.path.dirname(filename) basename, extention = os.path.splitext(os.path.basename(filename)) from Muscat.IO.IOFactory import CreateReader reader = CreateReader("." + filename.split(".")[-1]) reader.SetFileName(filename) if reader.canHandleTemporal: reader.ReadMetaData() reader.SetTimeToRead(timeToRead) if timeToRead == -1: print("Reading last available time step") else: print("Reading Time") print(timeToRead) return reader.Read()
[docs]def CheckIntegrity(): import os from Muscat.TestData import GetTestDataPath InitAllReaders() ReadMesh(os.path.join(GetTestDataPath(), "UtExample","cube.ut" ), timeToRead=0 ) ReadMesh(os.path.join(GetTestDataPath(), "UtExample","cube.ut" ) ) return "ok"
if __name__ == "__main__": print(CheckIntegrity()) # pragma: no cover