Add "minimal mode" to OML generator, omitting additional XML attributes and non-text nodes
This commit is contained in:
parent
e9e83da78b
commit
dffe13e9a7
2 changed files with 37 additions and 23 deletions
|
|
@ -1,12 +1,17 @@
|
|||
// Warning: Generated code! Do not edit!
|
||||
// Input file: '{{inputfile}}'
|
||||
// Generator: https://msdl.uantwerpen.be/git/jexelmans/xopp2py
|
||||
{%- if minimal %}
|
||||
// Minimal mode enabled: All XML attributes and non-text nodes are omitted.
|
||||
{%- endif %}
|
||||
|
||||
description <{{namespaces.description}}#> as {{namespaces.shorthand}} {
|
||||
|
||||
uses <{{namespaces.xopp}}#> as xopp
|
||||
uses <{{namespaces.object_diagram}}#> as object_diagram
|
||||
{%- if not minimal %}
|
||||
uses <{{namespaces.dict}}#> as dict
|
||||
{%- endif %}
|
||||
|
||||
ci model : xopp:Model []
|
||||
|
||||
|
|
@ -20,7 +25,8 @@ description <{{namespaces.description}}#> as {{namespaces.shorthand}} {
|
|||
object_diagram:inModel model
|
||||
]
|
||||
|
||||
{% for page_index, page in enumerate(file.pages) %}
|
||||
{%- for page_index, page in enumerate(file.pages) %}
|
||||
|
||||
ci p{{page_index}} : xopp:Page [
|
||||
xopp:hasWidth {{ page.width }}
|
||||
xopp:hasHeight {{ page.height }}
|
||||
|
|
@ -32,27 +38,34 @@ description <{{namespaces.description}}#> as {{namespaces.shorthand}} {
|
|||
]
|
||||
|
||||
{%- for layer_index, layer in enumerate(page.layers) %}
|
||||
|
||||
ci p{{page_index}}l{{layer_index}} : xopp:Layer [
|
||||
xopp:inPage p{{page_index}}
|
||||
object_diagram:inModel model
|
||||
]
|
||||
|
||||
{%- for el_index, el in enumerate(layer.elements) %}
|
||||
{%- if not minimal or el.__class__.__name__ == "Text" %}
|
||||
|
||||
ci p{{page_index}}l{{layer_index}}e{{el_index}} : xopp:{{el.__class__.__name__}} [
|
||||
xopp:hasText {{el.text | to_oml_string_literal}}
|
||||
xopp:inLayer p{{page_index}}l{{layer_index}}
|
||||
object_diagram:inModel model
|
||||
]
|
||||
|
||||
{%- if not minimal %}
|
||||
{%- for key, value in el.attributes.items() %}
|
||||
|
||||
ci p{{page_index}}l{{layer_index}}e{{el_index}}a{{loop.index}} : xopp:XMLAttribute [
|
||||
dict:hasKey {{key | to_oml_string_literal}}
|
||||
dict:hasValue {{value | to_oml_string_literal}}
|
||||
xopp:ofLayerElement p{{page_index}}l{{layer_index}}e{{el_index}}
|
||||
object_diagram:inModel model
|
||||
]
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ def writeOML(xournalFile: abstract_syntax.XournalFile, inputfile:str, namespace:
|
|||
|
||||
template = environment.get_template("template.oml")
|
||||
for piece in template.generate(
|
||||
minimal=True,
|
||||
file=xournalFile,
|
||||
inputfile=inputfile,
|
||||
enumerate=enumerate,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue