diff --git a/capella2polarion/__main__.py b/capella2polarion/__main__.py index b5174d8..e781feb 100644 --- a/capella2polarion/__main__.py +++ b/capella2polarion/__main__.py @@ -58,10 +58,10 @@ def cli( polarion_url: str, polarion_pat: str, polarion_delete_work_items: bool, - capella_model: capellambse.MelodyModel, + capella_model: capellambse.MelodyModel | None, ) -> None: """Synchronise data from Capella to Polarion.""" - if capella_model.diagram_cache is None: + if capella_model is not None and capella_model.diagram_cache is None: logger.warning("It's highly recommended to define a diagram cache!") capella2polarion_cli = Capella2PolarionCli( @@ -128,6 +128,7 @@ def synchronize( ) capella_to_polarion_cli.force_update = force_update + assert capella_to_polarion_cli.capella_model is not None converter = model_converter.ModelConverter( capella_to_polarion_cli.capella_model, capella_to_polarion_cli.polarion_params.project_id, @@ -199,6 +200,7 @@ def render_documents( configs.iterate_documents() ) + assert capella_to_polarion_cli.capella_model is not None renderer = document_renderer.DocumentRenderer( polarion_worker.polarion_data_repo, capella_to_polarion_cli.capella_model, diff --git a/capella2polarion/cli.py b/capella2polarion/cli.py index 1628445..a972896 100644 --- a/capella2polarion/cli.py +++ b/capella2polarion/cli.py @@ -26,7 +26,7 @@ def __init__( polarion_url: str, polarion_pat: str, polarion_delete_work_items: bool, - capella_model: capellambse.MelodyModel, + capella_model: capellambse.MelodyModel | None, force_update: bool = False, ) -> None: self.debug = debug diff --git a/ci-templates/gitlab/render_documents.yaml b/ci-templates/gitlab/render_documents.yaml index e6156b6..1f03b54 100644 --- a/ci-templates/gitlab/render_documents.yaml +++ b/ci-templates/gitlab/render_documents.yaml @@ -21,4 +21,4 @@ capella2polarion_render_documents: script: - pip install "capella2polarion${CAPELLA2POLARION_VERSION:+==$CAPELLA2POLARION_VERSION}" - - python -m capella2polarion render-documents + - capella2polarion render-documents diff --git a/ci-templates/gitlab/synchronise_elements.yml b/ci-templates/gitlab/synchronise_elements.yml index 72fd944..674d33f 100644 --- a/ci-templates/gitlab/synchronise_elements.yml +++ b/ci-templates/gitlab/synchronise_elements.yml @@ -21,4 +21,4 @@ capella2polarion_synchronise_elements: script: - pip install "capella2polarion${CAPELLA2POLARION_VERSION:+==$CAPELLA2POLARION_VERSION}" - - python -m capella2polarion synchronize + - capella2polarion synchronize diff --git a/pyproject.toml b/pyproject.toml index 3890852..42cac83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,9 @@ test = [ "pytest-cov", ] +[project.scripts] +capella2polarion = "capella2polarion.__main__:cli" + [tool.black] line-length = 79 target-version = ["py312"]