Passed
Push — main ( e3a6d2...e30615 )
by Sat CFDI
01:54
created

satdigitalinvoice.environments.tag()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 2
1
from html import escape as html_escape
2
3
import jinja2
4
from jinja2 import Environment
5
from jinja2.filters import do_mark_safe
6
# noinspection PyUnresolvedReferences
7
from satcfdi.transform.catalog import CATALOGS
8
9
environment_default = Environment(
10
    loader=jinja2.FileSystemLoader(searchpath=['templates']),
11
    autoescape=False,
12
    trim_blocks=True,
13
    lstrip_blocks=True,
14
    undefined=jinja2.StrictUndefined,
15
)
16
17
18
def finalize_html(val):
19
    return do_mark_safe(
20
        tag(html_escape(val), "b")
21
    )
22
23
24
environment_bold_escaped = Environment(
25
    loader=jinja2.FileSystemLoader(searchpath=['templates']),
26
    autoescape=True,
27
    trim_blocks=True,
28
    lstrip_blocks=True,
29
    undefined=jinja2.StrictUndefined,
30
    finalize=finalize_html
31
)
32
33
34
def tag(text, tag):
35
    return '<' + tag + '>' + text + '</' + tag + '>'
36