• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ESSS / qmxgraph / 6829152840

10 Nov 2023 08:06PM UTC coverage: 87.84% (-1.6%) from 89.483%
6829152840

push

github

web-flow
Merge pull request #174 from ESSS/fb-ASIM-5273-drop-py36-qmx

Drop python 3.6

1 of 1 new or added line in 1 file covered. (100.0%)

36 existing lines in 6 files now uncovered.

968 of 1102 relevant lines covered (87.84%)

3.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.07
/src/qmxgraph/render.py
1
import json
4✔
2

3

4
def render_embedded_html(options, styles, stencils, mxgraph_path, own_path):
4✔
5
    """
6
    Renders an HTML that is able to load graph drawing widget page embedded
7
    in a Qt widget.
8

9
    :param GraphOptions options: Options of graph drawing widget.
10
    :param GraphStyles styles: Styles available in graph drawing widget.
11
    :param iterable[str] stencils: Stencils available in graph drawing
12
        widget.
13
    :param str mxgraph_path: Resource path where mxGraph static files
14
        are located.
15
    :param str own_path: Resource path where QmxGraph's own static files
16
        are located.
17
    :rtype: str
18
    :return: HTML contents necessary to load graph drawing widget page.
19
    """
20
    from PyQt5.QtCore import QFile
4✔
21

22
    html_file = QFile(own_path + '/graph.html')
4✔
23

24
    from PyQt5.QtCore import QIODevice
4✔
25

26
    if not html_file.open(QIODevice.ReadOnly | QIODevice.Text):
4✔
27
        assert False
×
28

29
    try:
4✔
30
        from jinja2 import Template
4✔
31

32
        html_data = html_file.readAll().data()
4✔
33
        template = Template(html_data.decode('utf8'))
4✔
34
    finally:
35
        html_file.close()
4✔
36

37
    def qrc_prefixed(path):
4✔
38
        return 'qrc{}'.format(path)
4✔
39

40
    mxgraph_path = qrc_prefixed(mxgraph_path)
4✔
41
    own_path = qrc_prefixed(own_path)
4✔
42
    stencils = [qrc_prefixed(s) for s in stencils]
4✔
43

44
    return _render(template, options, styles, stencils, mxgraph_path, own_path, embedded=True)
4✔
45

46

47
def render_hosted_html(options, styles, stencils, mxgraph_path, own_path, template_path):
4✔
48
    """
49
    Renders an HTML that is able to load graph drawing widget page in a hosted
50
    server.
51

52
    :param GraphOptions options: Options of graph drawing widget.
53
    :param GraphStyles styles: Styles available in graph drawing widget.
54
    :param iterable[str] stencils: Stencils available in graph drawing
55
        widget.
56
    :param str mxgraph_path: Path where mxGraph static files are served by
57
        host server.
58
    :param str own_path: Path where QmxGraph's own static files are served
59
        by host server.
60
    :param str template_path: Path in file system where HTML templates are
61
        found.
62
    :rtype: str
63
    :return: HTML contents necessary to load graph drawing widget page.
64
    """
UNCOV
65
    from jinja2 import FileSystemLoader
×
UNCOV
66
    from jinja2.environment import Environment
×
67

UNCOV
68
    env = Environment()
×
UNCOV
69
    env.loader = FileSystemLoader(template_path)
×
UNCOV
70
    template = env.get_template('graph.html')
×
71

UNCOV
72
    return _render(template, options, styles, stencils, mxgraph_path, own_path, embedded=False)
×
73

74

75
def _render(template, options, styles, stencils, mxgraph_path, own_path, embedded):
4✔
76
    return template.render(
4✔
77
        mxgraph=mxgraph_path,
78
        own=own_path,
79
        options=json.dumps(options.as_dict()),
80
        styles=json.dumps(styles.as_dict()),
81
        stencils=json.dumps(stencils),
82
        embedded=embedded,
83
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc