Library Reference

The lib.i18n Module

Localization management.

cioxml2.lib.i18n.translate(text, lang=None, request=None)[source]

Return text translated.

Parameters:
  • text (str) – Text to translate.

  • lang (str) – (optional) Language to use.

  • request (pyramid.request.Request) – (optional) Current request to find the current language.

Return type:

str

The lib.utils Module

Some various utilities.

cioxml2.lib.utils.special_protect(content: str) str[source]

Convert special characters (&, <, >) in a secure representation.

Parameters:

content (str) – Content to protect.

Return type:

str

cioxml2.lib.utils.special_unprotect(content: str) str[source]

Cancel the protection made by _special_protect().

Parameters:

content (str) – Protected content.

Return type:

str

cioxml2.lib.utils.image_base64(pbuild: PBuild, abs_path: str, html: str, remove_original: bool = True) str | None[source]

Replace image source with its content in base64.

Parameters:
  • pbuild (.lib.pbuild.PBuild) – Current processor build object.

  • abs_path (str) – Absolute path to current directory.

  • html (str) – HTML to process.

  • remove_original – bool If True, remove original image.

Return type:

str

cioxml2.lib.utils.remove_css_maps(pbuild: PBuild, step: dict)[source]

Remove CSS maps and their call.

Parameters:
  • build (cioprocessor.lib.build.PBuild) – Current build object.

  • step (dict) – Dictionary defining the current step.

cioxml2.lib.utils.ajust_css_maps(pbuild: PBuild, step: dict)[source]

Ajust CSS maps and their call.

Parameters:
  • build (cioprocessor.lib.build.PBuild) – Current build object.

  • step (dict) – Dictionary defining the current step.

cioxml2.lib.utils.pretty_print_json(pbuild: PBuild, step: dict) bool[source]

Pretty print JSON files.

Parameters:
  • build (cioprocessor.lib.build.PBuild) – Current build object.

  • step (dict) – Dictionary defining the current step.

Return type:

bool

cioxml2.lib.utils.calling_file(request: Request, rendering_type: str | None = None) tuple[Warehouse | None, CioPath | None, dict | None][source]

Return warehouse, CioPath and rendering of the URL found in the request.

Parameters:
  • request (pyramid.request.Request) – Current request.

  • rendering_type (str) – (optional) Type of rendering (‘viewing’ or ‘editing’)

Return type:

tuple

The lib.cioset Module

Cioset management.

cioxml2.lib.cioset.cioset_update(original: ElementTree, values: dict) ElementTree[source]

Update original Cioset XML according to values.

Parameters:
  • original (lxml.etree._ElementTree) – Initial content of the file as a XML DOM object.

  • values (dict) – Values of the form.

Return type:

lxml.etree._ElementTree

cioxml2.lib.cioset.value2string(elt: Element, value: str | None) str[source]

Convert a string value according to type type_.

Parameters:
  • elt (lxml.etree.Element) – DOM element owner of the value.

  • value (str) – Type of the value.

Return type:

str

cioxml2.lib.cioset.root_ciopath(ciopath: CioPath, elt: Element) CioPath[source]

Return the CioPath the root (division… the XML element elt.

Parameters:
Return type:

ciowarehouse2.lib.ciopath.CioPath

cioxml2.lib.cioset.file_ciopath(ciopath: CioPath, file_elt: Element) CioPath[source]

Return the CioPath of the file pointed by file_elt, possibly according to <root> tags.

Parameters:
Return type:

ciowarehouse2.lib.ciopath.CioPath