How to use the segno.encoder function in segno

To help you get started, we’ve selected a few segno examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heuer / segno / tests / test_utils_iterverbose.py View on Github external
def test_finder_pattern_dark_qr():
    qr = encoder.encode('A', micro=False)
    res = []
    for row in utils.matrix_iter_verbose(qr.matrix, qr.version, border=0):
        res.append(bytearray([(0x2, 0x1)[v == consts.TYPE_FINDER_PATTERN_DARK] for v in row]))
    expected = read_matrix('v1-finder-dark')
    assert expected == res
github heuer / segno / tests / test_issue33_microcode.py View on Github external
def test_format_info_figure25():
    # 7.9.1 QR Code symbols (page 55)
    version = 1
    mask_pattern = 5
    error = consts.ERROR_LEVEL_M
    # 100000011001110
    assert 0x40ce == encoder.calc_format_info(version, error, mask_pattern)
github heuer / segno / tests / test_issue35_maskcheck.py View on Github external
def test_normalize_mask_not_int(version, mask):
    with pytest.raises(ValueError) as ex:
        encoder.normalize_mask(mask, version < 1)
    assert 'Invalid data mask' in str(ex.value)
github heuer / segno / tests / test_issue4.py View on Github external
def test_issue_4():
    qr = encoder.encode(0)
    assert consts.VERSION_M1 == qr.version
    assert qr.error is None
github heuer / segno / segno / __init__.py View on Github external
If set to ``True`` the algorithm generates a Micro QR Code or
            raises an exception if the `mode` is not compatible or the `content`
            is too large for Micro QR Codes.
    :type micro: bool or None
    :param bool boost_error: Indicates if the error correction level may be
            increased if it does not affect the version (default: ``True``).
            If set to ``True``, the :paramref:`error `
            parameter is interpreted as minimum error level. If set to ``False``,
            the resulting (Micro) QR Code uses the provided `error` level
            (or the default error correction level, if error is ``None``)
    :raises: :py:exc:`ValueError` or :py:exc:`DataOverflowError`: In case the
             data does not fit into a (Micro) QR Code or it does not fit into
             the provided :paramref:`version`.
    :rtype: QRCode
    """
    return QRCode(encoder.encode(content, error, version, mode, mask, encoding,
                                 eci, micro, boost_error=boost_error))
github heuer / segno / segno / __init__.py View on Github external
def mode(self):
        """\
        String indicating the mode ("numeric", "alphanumeric", "byte", "kanji").
        May be ``None`` if multiple modes are used.

        :rtype: str or None
        """
        if self._mode is not None:
            return encoder.get_mode_name(self._mode)
        return None
github heuer / segno / segno / __init__.py View on Github external
def error(self):
        """\
        Error correction level; either a string ("L", "M", "Q", "H") or ``None``
        if the QR Code provides no error correction (Micro QR Code version M1)

        :rtype: str
        """
        if self._error is None:
            return None
        return encoder.get_error_name(self._error)