How to use the segno.make_sequence 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_structured_append.py View on Github external
def test_dataoverflow_error():
    data = 'A' * 4296 * 16  # Version 40: max. 4296 alphanumeric chars * 16 symbols
    data = data[:-4]  # Remove some chars taking some SA overhead into account
    seq = segno.make_sequence(data, version=40)
    assert 16 == len(seq)
    data += 'B'
    with pytest.raises(segno.DataOverflowError) as ex:
        segno.make_sequence(data, version=40)
    assert 'does not fit' in str(ex.value)
github heuer / segno / tests / test_structured_append.py View on Github external
def test_dataoverflow():
    data = 'A' * 4296  # Version 40: max. 4296 alphanumeric chars
    seq = segno.make_sequence(data, version=40)
    assert 1 == len(seq)
    data += 'B'
    seq = segno.make_sequence(data, version=40)
    assert 2 == len(seq)
github heuer / segno / tests / test_structured_append.py View on Github external
def test_illegal_symbolcount(symbol_count):
    with pytest.raises(ValueError):
        segno.make_sequence('I read the news today oh boy / About a lucky man who made the grade', symbol_count=symbol_count)
github heuer / segno / tests / test_structured_append.py View on Github external
def test_dataoverflow_error():
    data = 'A' * 4296 * 16  # Version 40: max. 4296 alphanumeric chars * 16 symbols
    data = data[:-4]  # Remove some chars taking some SA overhead into account
    seq = segno.make_sequence(data, version=40)
    assert 16 == len(seq)
    data += 'B'
    with pytest.raises(segno.DataOverflowError) as ex:
        segno.make_sequence(data, version=40)
    assert 'does not fit' in str(ex.value)
github heuer / segno / tests / test_structured_append.py View on Github external
def test_int():
    data = int('1' * 42)
    seq = segno.make_sequence(data, version=1)
    assert 2 == len(seq)
github heuer / segno / tests / test_structured_append.py View on Github external
def test_save_multiple():
    directory = tempfile.mkdtemp()
    assert 0 == len(os.listdir(directory))
    seq = segno.make_sequence('ABCDEFGHIJKLMN'
                              'OPQRSTUVWXYZ0123'
                              '456789ABCDEFGHIJ'
                              'KLMNOPQRSTUVWXYZ', version=1, error='m')
    assert 4 == len(seq)
    seq.save(os.path.join(directory, 'test.svg'))
    number_of_files = len(os.listdir(directory))
    shutil.rmtree(directory)
    assert 4 == number_of_files
github heuer / segno / tests / test_structured_append.py View on Github external
def test_save_terminal_multiple():
    out_multiple = io.StringIO()
    data = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    seq = segno.make_sequence(data, version=1, error='m')
    assert 4 == len(seq)
    seq.terminal(out_multiple)
    out_single = io.StringIO()
    for qr in seq:
        qr.terminal(out_single)
    assert out_single.getvalue() == out_multiple.getvalue()
github heuer / segno / tests / test_structured_append.py View on Github external
def test_boosterror2():
    seq = segno.make_sequence('I read the news today oh boy / About a lucky man who made the grade', symbol_count=4)
    assert 4 == len(seq)
    assert '2-Q' == seq[0].designator
    assert '2-Q' == seq[1].designator
    assert '2-Q' == seq[2].designator
    assert '2-Q' == seq[3].designator
github heuer / segno / tests / test_structured_append.py View on Github external
def test_boosterror():
    seq = segno.make_sequence('I read the news today oh boy / About a lucky man who made the grade', version=2)
    assert 3 == len(seq)
    assert 'M' == seq[0].error
    assert 'M' == seq[1].error
    assert 'M' == seq[2].error
github heuer / segno / segno / cli.py View on Github external
def make_code(config):
    """\
    Creates the (Micro) QR Code (Sequence).

    Configuration parameters used for creating the Micro QR Code, QR Code
    or QR Code Sequence are removed from the configuration.

    :param config: Configuration, see :py:func:`build_config`
    :return: :py:class:`segno.QRCode` or :py:class:`segno.QRCodeSequence`.
    """
    make = segno.make
    kw = dict(mode=config.pop('mode'), error=config.pop('error'),
              version=config.pop('version'), mask=config.pop('pattern'),
              boost_error=config.pop('boost_error'))
    if config.pop('seq'):
        make = segno.make_sequence
        kw['symbol_count'] = config.pop('symbol_count')
    else:
        kw['micro'] = config.pop('micro')
    return make(' '.join(config.pop('content')), **kw)