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

saitoha / libsixel / 23158179538

16 Mar 2026 05:39PM UTC coverage: 84.356% (+0.2%) from 84.191%
23158179538

push

github

saitoha
ci: fallback emscripten coverage capture to gcovr

27866 of 63178 branches covered (44.11%)

52362 of 62073 relevant lines covered (84.36%)

4398304.96 hits per line

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

80.56
/python/libsixel/encoder.py
1
#!/usr/bin/env python
2
#
3
# Copyright (c) 2014-2016 Hayaki Saito
4
#
5
# Permission is hereby granted, free of charge, to any person obtaining a copy of
6
# this software and associated documentation files (the "Software"), to deal in
7
# the Software without restriction, including without limitation the rights to
8
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
# the Software, and to permit persons to whom the Software is furnished to do so,
10
# subject to the following conditions:
11
#
12
# The above copyright notice and this permission notice shall be included in all
13
# copies or substantial portions of the Software.
14
#
15
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
#
22

23
from . import _sixel
4✔
24
from libsixel_wheel import *
4✔
25

26
class Encoder(object):
4✔
27

28
    def __init__(self):
4✔
29
        self._encoder = sixel_encoder_new()
4✔
30
        self._closed = False
4✔
31

32
    def close(self):
4✔
33
        if self._closed:
4✔
34
            return
4✔
35

36
        sixel_encoder_unref(self._encoder)
4✔
37
        self._closed = True
4✔
38

39
    def __enter__(self):
4✔
40
        return self
4✔
41

42
    def __exit__(self, exc_type, exc_value, traceback):
4✔
43
        self.close()
4✔
44

45
    def __del__(self):
4✔
46
        try:
4✔
47
            self.close()
4✔
48
        except Exception:
×
49
            # Avoid raising from __del__ to keep interpreter shutdown quiet.
50
            pass
×
51

52
    def setopt(self, flag, arg=None):
4✔
53
        if self._closed:
4✔
54
            raise RuntimeError("encoder has been closed")
4✔
55
        sixel_encoder_setopt(self._encoder, flag, arg)
4✔
56

57
    def encode(self, filename="-"):
4✔
58
        if self._closed:
4✔
59
            raise RuntimeError("encoder has been closed")
×
60
        sixel_encoder_encode(self._encoder, filename)
4✔
61

62
    def encode_bytes(self, buf, width, height, pixelformat, palette):
4✔
63
        if self._closed:
4✔
64
            raise RuntimeError("encoder has been closed")
×
65
        sixel_encoder_encode_bytes(self._encoder, buf, width, height, pixelformat, palette)
4✔
66

67

68
if __name__ == '__main__':
4✔
69
    import sys
×
70
    arg1 = "-" if len(sys.argv) < 2 else sys.argv[1]
×
71
    Encoder().test(arg1)
×
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