render¶
Private Methods
Private methods, if any (those starting with _), are documented
for completeness but do not offer any stability guarantees.
They may change or be removed at any time without notice.
XML rendering with release-based conditional content.
Uses XML namespaces to conditionally include/exclude elements and attributes based on the target Odoo release. The namespace URI encodes the release condition::
xmlns:PREFIX="https://polytropos.moduon.team/v1/rel/SPECIFIER"
Where SPECIFIER is a PEP 440 version specifier (e.g., >=18.0, <=18.0).
Use &lt; for the < character in specifiers, since < is not
allowed literally in XML attribute values.
_matches_specifier(release_version, specifier)
¶
Check if a release version matches a PEP 440 specifier string.
Source code in src/polytropos/render.py
_parse_release(release)
¶
Parse Odoo release string to Version object.
_process_attributes(element, release)
¶
Process namespace-qualified attributes on an element.
Non-matching attributes are removed. Matching attributes are renamed (namespace stripped) and may overwrite existing non-namespace attributes.
Source code in src/polytropos/render.py
_process_element(element, release)
¶
Process element and its children recursively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
Element
|
The XML element to process |
required |
release
|
Version
|
Target Odoo release version |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the element should be removed from its parent |
Source code in src/polytropos/render.py
_split_ns(tag)
¶
Split a Clark notation tag or attribute key into (namespace, local_name).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
A tag or attribute key, possibly in |
required |
Returns:
| Type | Description |
|---|---|
tuple[str | None, str]
|
Tuple of (namespace_uri, local_name). If no namespace, namespace is None. |
Source code in src/polytropos/render.py
render_xml(content, odoo_release)
¶
Render XML by removing elements/attributes not matching the target release.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
XML source content |
required |
odoo_release
|
str
|
Target Odoo release (e.g., "18.0") |
required |
Returns:
| Type | Description |
|---|---|
str
|
Rendered XML string with namespace conditions resolved |
Raises:
| Type | Description |
|---|---|
ParseError
|
If the XML content is malformed, with details about the problem location. |