# import logging
import win32com.client
from pathlib import Path


class transformer7:
    def __init__(self):
        self.app = win32com.client.Dispatch('CognosPowerPlay.Report')   # "CognosTransformer.Application")
        print(self.app)
        self.app.visible = 1
        print(self.app.Version)

    def open(self, file, format=None):
        filename = Path(file).resolve()
        # path = str(filename.parent.resolve())
        print(filename)
        try:
            model = self.app.OpenModel(filename)
            cube = model.Cubes.Item(1)
            cube.Update()
            model.CreateMDCFiles()
        except Exception as e:
            print(e)


if __name__ == '__main__':
    transformer7().open('Model\\NW_GW_VK.pyi')
