123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import os
- from pathlib import Path
- import typer
- import cognos7
- import config
- from misc import file_move
- app = typer.Typer()
- cfg = config.Config()
- @app.command()
- def iqd_convert():
- iqdconv = cognos7.IqdConverter()
- iqdconv.output_dir = f"{cfg.system_dir}\\SQL\\schema\\{cfg.system}\\views_imr"
- iqdconv.run_folder(f"{cfg.system_dir}\\IQD")
- @app.command()
- def mdl_convert(mdl_file: str):
- if not Path(mdl_file).exists():
- raise typer.Exit(code=1, message=f"Datei {mdl_file} nicht gefunden")
- if Path(mdl_file).is_dir():
- return cognos7.convert_folder(mdl_file)
- cognos7.convert_file(mdl_file)
- source = Path(mdl_file[:-4] + ".json")
- dest = f"{cfg.cognos11.specs_dir}\\..\\DataModel\\{source.name}"
- os.makedirs(os.path.dirname(dest), exist_ok=True)
- Path(dest).unlink(missing_ok=True)
- os.rename(source, dest)
- @app.command()
- def export_csv_sql():
- cognos7.create_format_xml_from_folder(f"{cfg.system_dir}\\Export")
- @app.command()
- def move_csv():
- print("Verschiebe CSV-Dateien von IQD zu Export...")
- res = file_move.move(cfg.system_dir)
- if res is False:
- print("* Keine CSV-Dateien im IQD-Ordner gefunden.\n")
- print("Pruefe Export-Ordner...")
- is_clean = file_move.check(cfg.system_dir)
- if is_clean:
- print("* Alle Dateien aktuell.\n")
- if __name__ == "__main__":
- # app()
- move_csv()
|