Source code for Muscat.IO.ProxyWriter

# -*- 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.
#


"""ProxyWriter class
"""


[docs]class ProxyWriter(object): """Class to operate on more than one write at the same time Parameters ---------- object : object with the same API _description_ """ def __init__(self): super().__init__() self.writers = [] def __getattribute__(self, name): writers = object.__getattribute__(self, "writers") def newfunc(*args, **kwargs): for w in writers: res = w.__getattribute__(name)(*args, **kwargs) return res return newfunc
[docs]def CheckIntegrity(GUI: bool = False): from Muscat.Helpers.IO.TemporaryDirectory import TemporaryDirectory tempdir = TemporaryDirectory.GetTempPath() from Muscat.IO.StlWriter import StlWriter stlR = StlWriter() stlR.Open(tempdir + "TestProwyWriter.stl") from Muscat.IO.GeofWriter import GeofWriter geofR = GeofWriter() geofR.Open(tempdir + "TestProwyWriter.geof") pWriter = ProxyWriter() pWriter.writers = [stlR, geofR] from Muscat.Containers.MeshCreationTools import CreateCube mesh = CreateCube() pWriter.Write(mesh) pWriter.Close() return "ok"
if __name__ == "__main__": print(CheckIntegrity(GUI=True)) # pragma: no cover