How to use the segno.make_qr 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_qrcode.py View on Github external
def test_save_eps_filename():
    qr = segno.make_qr('test')
    with tempfile.NamedTemporaryFile('w', suffix='.eps', delete=False) as f:
        fn = f.name
    qr.save(fn)
    expected = '%!PS-Adobe-3.0 EPSF-3.0'
    with open(fn, mode='r') as f:
        val = f.read(len(expected))
    os.unlink(fn)
    assert expected == val
github heuer / segno / tests / test_qrcode.py View on Github external
def test_save_png_filestream():
    qr = segno.make_qr('test')
    with tempfile.NamedTemporaryFile('wb', suffix='.png', delete=False) as f:
        fn = f.name
        qr.save(f)
    expected = b'\211PNG\r\n\032\n'  # PNG magic number
    with open(fn, mode='rb') as f:
        val = f.read(len(expected))
    os.unlink(fn)
    assert expected == val
github heuer / segno / tests / test_png.py View on Github external
def test_color_rgba2():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='png', dark='#000', light='#0000ffcc')
    assert _has_palette(out.getvalue())
    assert _has_transparency(out.getvalue())
github heuer / segno / tests / test_pdf.py View on Github external
def test_illegal_color_float():
    color = (.1, 1.1, .1)
    qr = segno.make_qr('test')
    out = io.BytesIO()
    with pytest.raises(ValueError):
        qr.save(out, kind='pdf', dark=color)
github heuer / segno / tests / test_svg.py View on Github external
def test_write_svg_color_rgb():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='svg', dark=(76, 131, 205))
    xml_str = out.getvalue()
    assert xml_str.startswith(b'
github heuer / segno / tests / test_tex.py View on Github external
def test_write_tex_omit_url2():
    qr = segno.make_qr('test', error='m', boost_error=False)
    out = io.StringIO()
    qr.save(out, kind='tex', border=4)
    assert r'\href' not in out.getvalue()
github heuer / segno / tests / test_svg.py View on Github external
def test_viewbox():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='svg', omitsize=True)
    root = _parse_xml(out)
    assert 'viewBox' in root.attrib
    assert 'height' not in root.attrib
    assert 'width' not in root.attrib
github heuer / segno / tests / test_png.py View on Github external
def test_greyscale_trans2():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='png', dark=None, light='white')
    assert not _has_palette(out.getvalue())
    assert _has_transparency(out.getvalue())
github heuer / segno / sandbox / benchmarks.py View on Github external
def png_segno(data='QR Code Symbol'):
    """Segno PNG 1-M"""
    segno.make_qr(data, error='m').save('out/segno_%s.png' % data, scale=10, addad=False)
github heuer / segno / segno / helpers.py View on Github external
def make_geo(lat, lng):
    """\
    Returns a QR Code which encodes geographic location using the ``geo`` URI
    scheme.

    :param float lat: Latitude
    :param float lng: Longitude
    :rtype: segno.QRCode
    """
    return segno.make_qr(make_geo_data(lat, lng))