Преглед изворни кода

Add Jinja2 template for beakerlib translate script

Alois Mahdal пре 6 година
родитељ
комит
22fcfaee2a
3 измењених фајлова са 75 додато и 0 уклоњено
  1. 1
    0
      packaging/debian/jattool-report.install
  2. 1
    0
      packaging/template.spec
  3. 73
    0
      src/jinja2/jat2rl.j2

+ 1
- 0
packaging/debian/jattool-report.install Прегледај датотеку

@@ -1,3 +1,4 @@
1 1
 /usr/libexec/jattool/jattool-export
2 2
 /usr/share/jattool/jinja2/html.j2
3
+/usr/share/jattool/jinja2/jat2rl.j2
3 4
 /usr/share/jattool/python/jat.py

+ 1
- 0
packaging/template.spec Прегледај датотеку

@@ -88,6 +88,7 @@ make %{?_smp_mflags} PREFIX=/usr
88 88
 
89 89
 %files report
90 90
 %{_datadir}/jattool/jinja2/html.j2
91
+%{_datadir}/jattool/jinja2/jat2rl.j2
91 92
 %{_datadir}/jattool/python/jat.py*
92 93
 %{_libexecdir}/%{name}/%{name}-export
93 94
 

+ 73
- 0
src/jinja2/jat2rl.j2 Прегледај датотеку

@@ -0,0 +1,73 @@
1
+
2
+#######
3
+# JINJA MACROS (ie. empty in resulting file)
4
+#######
5
+
6
+{% macro assert(A) -%}
7
+_distribution_jats__j2b_assert "{{A.verdict}}" "{{A.hint}}"
8
+{% if A.data %}
9
+_distribution_jats__j2b_assert_data "{{A.verdict}}" <<'EOD'
10
+{{A.data}}
11
+EOD
12
+{% endif %}
13
+{%- endmacro %}
14
+
15
+{% macro message(M) -%}
16
+_distribution_jats__j2b_message "{{M.severity}}" "{{M.message}}"
17
+{% if M.data %}
18
+_distribution_jats__j2b_message_data "{{M.severity}}" <<'EOD'
19
+{{M.data}}
20
+EOD
21
+{% endif %}
22
+{%- endmacro %}
23
+
24
+{% macro lint(L) -%}
25
+rlFail "{{ L.msg }}"
26
+_distribution_jats__j2b_lint_data <<'EOD'
27
+{{L._data}}
28
+EOD
29
+{%- endmacro %}
30
+
31
+{% macro phase(P) -%}
32
+_distribution_jats__j2b_pstart "{{P.verdict}}" "{{P.name}}" "{{P.type}}"
33
+    {% for e in P.children %}
34
+        {% if e.is_assert %}
35
+            {{ assert(e) }}
36
+        {% elif e.is_message %}
37
+            {{ message(e) }}
38
+        {% endif %}
39
+    {% endfor %}
40
+    rlLogInfo "phase verdict: {{P.verdict}}"
41
+rlPhaseEnd
42
+{%- endmacro %}
43
+
44
+
45
+##########
46
+# CODE
47
+##########
48
+
49
+SESS_ID="{{session.id}} {{session.test.id}} {{session.test.version}}"
50
+
51
+rlLogInfo "ACTING OUT JAT SESSION: $SESS_ID"
52
+
53
+{% if session.lints %}
54
+rlPhaseStartCleanup "$SESS_ID lints"
55
+{% for l in session.lints %}
56
+{{ lint(l) }}
57
+{% endfor %}
58
+rlPhaseEnd
59
+{% endif %}
60
+
61
+{% if session.eventtree.children %}
62
+{% for e in session.eventtree.children %}
63
+    {% if e.is_phase %}
64
+        {{ phase(e) }}
65
+    {% elif e.is_message %}
66
+        {{ message(e) }}
67
+    {% elif e.is_assert %}
68
+        {{ assert(e) }}
69
+    {% endif %}
70
+{% endfor %}
71
+{% endif %}
72
+
73
+# vim: set filetype=txt: