capella2polarion package

The capella2polarion package.

Subpackages

Submodules

capella2polarion.cli module

Tool for CLI work.

class capella2polarion.cli.Capella2PolarionCli(debug: bool, polarion_project_id: str, polarion_url: str, polarion_pat: str, polarion_delete_work_items: bool, capella_model: MelodyModel | None, force_update: bool = False)

Bases: object

Call Level Interface.

load_synchronize_config(synchronize_config_io: TextIO, type_prefix: str = '', role_prefix: str = '') None

Read the sync config into SynchronizeConfigContent.

  • example in /tests/data/model_elements/config.yaml

print_state() None

Print the State of the cli tool.

setup_logger() None

Set the logger in the right mood.

capella2polarion.polarion_html_helper module

Functions for polarion specific HTMl elements.

class capella2polarion.polarion_html_helper.JinjaRendererMixin

Bases: object

A MixIn for converters which should render jinja frequently.

check_model_element(obj: object) ModelElement | AbstractDiagram | None

Check if a model element was passed.

Return None if no element and raise a TypeError if a wrong typed element was passed. Returns the element if it matches expectations.

jinja_envs: dict[str, Environment]
setup_env(env: Environment) None

Implement this method to adjust a newly created environment.

capella2polarion.polarion_html_helper.add_attachment_to_workitem(work_item: WorkItem, attachment: Capella2PolarionAttachment) None

Add the attachment to the workitem and add a PNG version if needed.

capella2polarion.polarion_html_helper.camel_case_to_words(camel_case_str: str) str

Split camel or dromedary case and return it as a space separated str.

Handle prefixed underscores as well.

Examples

>>> camel_case_to_words("camelCase")
'Camel Case'
>>> camel_case_to_words("_Prefix_camelCaseWithPrefix")
'Camel Case With Prefix (Prefix)'
capella2polarion.polarion_html_helper.ensure_fragments(html_content: str | list[HtmlElement | str]) list[HtmlElement | str]

Convert string to html elements.

capella2polarion.polarion_html_helper.extract_headings(html_content: str | list[HtmlElement | str]) list[str]

Return a list of work item IDs for all headings in the given content.

capella2polarion.polarion_html_helper.extract_work_items(html_content: str | list[HtmlElement | str], tag_regex: Pattern | None = None) list[str]

Return a list of work item IDs for work items in the given content.

capella2polarion.polarion_html_helper.generate_image_html(title: str, attachment_id: str, max_width: int, cls: str, caption: tuple[str, str] | None = None) str

Generate an image as HTMl with the given source.

capella2polarion.polarion_html_helper.get_layout_index(default_layouter: str, rendering_layouts: list[RenderingLayout], work_item_type: str) int

Return the index of the layout of the requested workitem.

If there is no rendering config yet, it will be created.

capella2polarion.polarion_html_helper.remove_table_ids(html_content: str | list[HtmlElement | str]) list[HtmlElement | str]

Remove the ID field from all tables.

This is necessary due to a bug in Polarion where Polarion does not ensure that the tables added in the UI have unique IDs. At the same time the REST-API does not allow posting or patching a document with multiple tables having the same ID.

capella2polarion.polarion_html_helper.strike_through(string: str) str

Return a striked-through html span from given string.