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 pathlib filename = pathlib.Path(filename) from Muscat.IO.IOFactory import CreateReader reader = CreateReader(filename.suffix) 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" ) ) ## Check working with pathlib import pathlib path = pathlib.Path(GetTestDataPath()) / "UtExample" / "cube.ut" ReadMesh(path, timeToRead=0 ) ReadMesh(path) return "ok"
if __name__ == "__main__": print(CheckIntegrity()) # pragma: no cover