123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- import os
- from pathlib import Path
- import config
- import cognos11
- from pdf import pdf_merge, pdf_test
- import cognos7.mdl_convert
- import typer
- from enum import Enum
- class ExportFormat(Enum):
- PDF = "PDF"
- XML = "XML"
- app = typer.Typer()
- cfg = config.Config()
- @app.command()
- def export(folder="", overwrite="0"):
- exp = cognos11.c11_export(cfg)
- exp.export_folder(folder, overwrite=overwrite != "0")
- @app.command()
- def reportoutput(folder="", mailcsv=""):
- exp = cognos11.c11_export(cfg)
- # folder2 = exp.get_folder(folder)
- req_plan = exp.get_folder_pdf_request_plan(folder)
- merge_group = exp.get_merge_group(req_plan)
- exp.template(req_plan, merge_group)
- req_plan_filtered = exp.filter_request_plan(req_plan, cfg.xml_dir + "/" + mailcsv)
- exp.execute_request_plan(req_plan_filtered)
- pdf_test.missing_data(cfg.cognos11.reportoutput_dir + "/" + folder)
- pdf_merge.pdf_merge_files(merge_group)
- cognos11.get_converted_jobs(cfg)
- # pdf_merge.merge_reports_in_folder(self.cfg, folder2)
- @app.command()
- def merge(folder="", config=""):
- folder2 = cognos11.c11_export.get_folder(folder)
- config_json = pdf_merge.get_config_json(config, cfg.cognos11.config_dir)
- pdf_merge.merge_reports_in_folder(cfg, folder2, config_json)
- @app.command()
- def errors():
- exp = cognos11.c11_export(cfg)
- exp.export_errors()
- @app.command()
- def create(path: str):
- cognos11.c11_create(cfg).create_path(path)
- @app.command()
- def template():
- exp = cognos11.c11_export(cfg)
- cognos11.get_converted_jobs(cfg)
- req_plan = exp.get_folder_pdf_request_plan("")
- merge_group = exp.get_merge_group(req_plan)
- exp.template(req_plan, merge_group)
- @app.command()
- def mailtemplate():
- return template()
- @app.command()
- def mdlconvert(mdl_file):
- cognos7.mdl_convert.convert_file(mdl_file)
- source = mdl_file[:-4] + ".json"
- target = cfg.cognos11.specs_dir + "/../DataModel/" + Path(source).name
- os.makedirs(os.path.dirname(target), exist_ok=True)
- Path(target).unlink(missing_ok=True)
- os.rename(source, target)
- if __name__ == "__main__":
- # app()
- reportoutput()
|