• 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

81.25
/python/libsixel/decoder.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 Decoder(object):
4✔
27

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

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

36
        sixel_decoder_unref(self._decoder)
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
        """Set decoder options mirroring the sixel2png CLI flags.
54

55
        The dequantizer switch understands the Kornel preset shown
56
        below so callers can enable palette reconstruction explicitly:
57

58
            +-------------+---------------------------+
59
            | k_undither  | Kornel's undither filter  |
60
            +-------------+---------------------------+
61

62
        Pass the string as ``arg`` alongside the ``'d'`` flag to
63
        activate the smoothing step during decode.
64
        """
65
        if self._closed:
4✔
66
            raise RuntimeError("decoder has been closed")
4✔
67
        sixel_decoder_setopt(self._decoder, flag, arg)
4✔
68

69
    def decode(self, infile=None):
4✔
70
        if self._closed:
4✔
71
            raise RuntimeError("decoder has been closed")
×
72
        sixel_decoder_decode(self._decoder, infile)
4✔
73

74

75
if __name__ == '__main__':
4✔
76
    import sys
×
77
    arg2 = "-" if len(sys.argv) < 3 else sys.argv[2]
×
78
    Decoder().test(arg1, arg2)
×
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