How to use the segno.cli.main 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_cli_colorful.py View on Github external
def test_greyscale():
    fn = _make_tmp_png_filename()
    res = cli.main(['--quiet-zone=white', '--output={0}'.format(fn), 'test'])
    with open(fn, 'rb') as f:
        data = io.BytesIO(f.read())
    os.unlink(fn)
    assert 0 == res
    reader = PNGReader(file=data)
    reader.preamble()
    assert reader.greyscale
github heuer / segno / tests / test_legacy_color_background.py View on Github external
def test_background_cli():
    content = 'The Beatles'
    qr = segno.make(content, micro=False)
    out_new = io.BytesIO()
    qr.save(out_new, kind='png', scale=10, light=None)
    f = tempfile.NamedTemporaryFile('w', suffix='.png', delete=False)
    f.close()
    fn = f.name
    with pytest.deprecated_call():
        cli.main(['--background=transparent', '--scale=10', '--output={0}'.format(fn), content])
    with open(fn, 'rb') as f:
        content_cli = f.read()
    os.unlink(fn)
    assert out_new.getvalue() == content_cli
github heuer / segno / tests / test_issue39_unquoted.py View on Github external
def test_output():
    out = io.BytesIO()
    segno.make_qr('Good Times', error='M').save(out, kind='png', scale=10, dark='red')
    f = tempfile.NamedTemporaryFile('w', suffix='.png', delete=False)
    f.close()
    cli.main(['-e=M', '--scale=10', '--dark=red', '--output={0}'.format(f.name), 'Good Times'])
    f = open(f.name, 'rb')
    content = f.read()
    f.close()
    os.unlink(f.name)
    assert out.getvalue() == content
github heuer / segno / tests / test_issue45_cli_returncodes.py View on Github external
def test_issue_45_no_error():
    assert 0 == cli.main(['--version=1', '--seq', '"This is a test, test test test test"'])
github heuer / segno / tests / test_issue39_unquoted.py View on Github external
def test_output2():
    out = io.BytesIO()
    segno.make_qr('Good Times', error='M').save(out, kind='png', scale=10, dark='red')
    f = tempfile.NamedTemporaryFile('w', suffix='.png', delete=False)
    f.close()
    cli.main(['-e=M', '--scale=10', '--dark=red', '--output={0}'.format(f.name), 'Good', 'Times'])
    f = open(f.name, 'rb')
    content = f.read()
    f.close()
    os.unlink(f.name)
    assert out.getvalue() == content
github heuer / segno / tests / test_legacy_color_background.py View on Github external
def test_color_cli():
    content = 'The Beatles'
    qr = segno.make(content, micro=False)
    out_new = io.BytesIO()
    qr.save(out_new, kind='png', scale=10, dark='blue')
    f = tempfile.NamedTemporaryFile('w', suffix='.png', delete=False)
    f.close()
    fn = f.name
    with pytest.deprecated_call():
        cli.main(['--color=blue', '--scale=10', '--output={0}'.format(fn), content])
    with open(fn, 'rb') as f:
        content_cli = f.read()
    os.unlink(fn)
    assert out_new.getvalue() == content_cli
github heuer / segno / tests / test_cli.py View on Github external
def test_svgclass3():
    fname = _make_tmp_svg_filename()
    res = cli.main(['--output={0}'.format(fname), 'test'])
    assert 0 == res
    with open(fname, 'rb') as f:
        data = io.BytesIO(f.read())
    root = _parse_xml(data)
    assert root is not None
    assert root.get('class') is not None
    res = cli.main(['--svgclass', '', '--output={0}'.format(fname), 'test'])
    assert 0 == res
    with open(fname, 'rb') as f:
        data = io.BytesIO(f.read())
    os.unlink(fname)
    root = _parse_xml(data)
    assert root is not None
    assert root.get('class') is None
github heuer / segno / tests / test_cli.py View on Github external
def test_sequence_output():
    directory = tempfile.mkdtemp()
    assert 0 == len(os.listdir(directory))
    cli.main(['--seq', '-v=1', '-e=m', '-o=' + os.path.join(directory, 'test.svg'), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'])
    number_of_files = len(os.listdir(directory))
    shutil.rmtree(directory)
    assert 4 == number_of_files