• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python segno.make_qr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中segno.make_qr函数的典型用法代码示例。如果您正苦于以下问题:Python make_qr函数的具体用法?Python make_qr怎么用?Python make_qr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了make_qr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_output2

def test_output2():
    out = io.BytesIO()
    segno.make_qr('Good Times', error='M').save(out, kind='png', scale=10, color='red')
    f = tempfile.NamedTemporaryFile('w', suffix='.png', delete=False)
    f.close()
    cli.main(['-e=M', '--scale=10', '--color=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
开发者ID:heuer,项目名称:segno,代码行数:11,代码来源:test_issue39_unquoted.py


示例2: test_background_set

def test_background_set():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='pdf', background='yellow')
    graphic = _find_graphic(out)
    assert 'rg' in graphic
    assert 're' in graphic
开发者ID:heuer,项目名称:segno,代码行数:7,代码来源:test_pdf.py


示例3: test_background_none

def test_background_none():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='pdf')
    graphic = _find_graphic(out)
    assert 'rg' not in graphic
    assert 're' not in graphic
开发者ID:heuer,项目名称:segno,代码行数:7,代码来源:test_pdf.py


示例4: test_scale_float

def test_scale_float():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    scale = 1.34
    scale_cmd = '{0} 0 0 {0} 0 0 cm'.format(scale)
    qr.save(out, kind='pdf', scale=scale, compresslevel=0)
    assert scale_cmd in _find_graphic(out)
开发者ID:heuer,项目名称:segno,代码行数:7,代码来源:test_pdf.py


示例5: test_default_scale

def test_default_scale():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    scale = 1
    scale_cmd = '{0} 0 0 {0} 0 0 cm'.format(scale)
    qr.save(out, kind='pdf', compresslevel=0)
    assert scale_cmd not in _find_graphic(out)
开发者ID:heuer,项目名称:segno,代码行数:7,代码来源:test_pdf.py


示例6: test_data_svg_minimal_encoding

def test_data_svg_minimal_encoding():
    qr = segno.make_qr('A')
    val = qr.svg_data_uri(encode_minimal=True)
    assert val
    expected = "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='"
    assert expected == val[:len(expected)]
    assert val.endswith('%3C/svg%3E')
开发者ID:heuer,项目名称:segno,代码行数:7,代码来源:test_data_uri.py


示例7: test_write_xpm_indicator

def test_write_xpm_indicator():
    qr = segno.make_qr('test', error='m', boost_error=False)
    out = io.StringIO()
    qr.save(out, kind='xpm')
    expected = '/* XPM */\n'
    val = out.getvalue()
    assert expected == val[:len(expected)]
开发者ID:heuer,项目名称:segno,代码行数:7,代码来源:test_xpm.py


示例8: test_no_line_class_empty_str

def test_no_line_class_empty_str():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='svg', lineclass='')
    root = _parse_xml(out)
    path_el = _get_path(root)
    assert 'class' not in path_el.attrib
开发者ID:heuer,项目名称:segno,代码行数:7,代码来源:test_svg.py


示例9: test_custom_svg_class

def test_custom_svg_class():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='svg', svgclass='test-class')
    root = _parse_xml(out)
    assert 'class' in root.attrib
    assert 'test-class' == root.attrib.get('class')
开发者ID:heuer,项目名称:segno,代码行数:7,代码来源:test_svg.py


示例10: create

def create(content, error='H', version=None, mode=None, encoding=None):

    def translate_error(pyqrcode_error):
        try:
            if pyqrcode_error.upper() in ('L', 'M', 'Q', 'H'):
                return pyqrcode_error
        except AttributeError:
            pass
        try:
            return _ERROR_LEVEL[pyqrcode_error]
        except KeyError:
            raise ValueError('Unknown error level "{0}"'.format(pyqrcode_error))

    def translate_mode(pyqrcode_mode):
        mode = pyqrcode_mode
        try:
            mode = pyqrcode_mode.lower()
        except AttributeError:
            pass
        return mode if mode != 'binary' else 'byte'

    return PyQRCode(segno.make_qr(content, error=translate_error(error),
                                  version=version,
                                  mode=translate_mode(mode),
                                  encoding=encoding, boost_error=False),
                    content, encoding)
开发者ID:heuer,项目名称:segno-mimos,代码行数:26,代码来源:__init__.py


示例11: test_data_svg_no_charset

def test_data_svg_no_charset():
    qr = segno.make_qr('A')
    val = qr.svg_data_uri(omit_charset=True)
    assert val
    expected = "data:image/svg+xml,%3Csvg%20xmlns%3D%27"
    assert expected == val[:len(expected)]
    assert val.endswith('%3C%2Fsvg%3E')
开发者ID:heuer,项目名称:segno,代码行数:7,代码来源:test_data_uri.py


示例12: test_svgid

def test_svgid():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    ident = 'svgid'
    qr.save(out, kind='svg', svgid=ident)
    root = _parse_xml(out)
    assert 'id' in root.attrib
    assert ident == root.attrib['id']
开发者ID:heuer,项目名称:segno,代码行数:8,代码来源:test_svg.py


示例13: test_write_svg_background_rgba_svg2

def test_write_svg_background_rgba_svg2():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='svg', background='#0000ffcc', svgversion=2.0)
    assert b'fill-opacity' not in out.getvalue()
    root = _parse_xml(out)
    path = _get_path(root)
    assert path.attrib['fill'].startswith('rgba')
开发者ID:heuer,项目名称:segno,代码行数:8,代码来源:test_svg.py


示例14: test_dpi

def test_dpi():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='png', dpi=300)
    out.seek(0)
    assert b'pHYs' in out.getvalue()
    # pHYs 11811 (11811 meters = 300 dpi / 0.0254)
    assert b'\x70\x48\x59\x73\x00\x00\x2E\x23\x00\x00\x2E\x23\x01\x78\xA5\x3F\x76' in out.getvalue()
开发者ID:heuer,项目名称:segno,代码行数:8,代码来源:test_png.py


示例15: test_write_txt

def test_write_txt():
    # Test with default options
    qr = segno.make_qr('test', error='m', boost_error=False)
    out = io.StringIO()
    qr.save(out, kind='txt', border=0)
    expected = '11111110011'
    val = out.getvalue()
    assert expected == val[:len(expected)]
开发者ID:heuer,项目名称:segno,代码行数:8,代码来源:test_txt.py


示例16: test_svgversion

def test_svgversion():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    version = 1.0
    qr.save(out, kind='svg', svgversion=version)
    root = _parse_xml(out)
    assert 'version' in root.attrib
    assert str(version) == root.attrib['version']
开发者ID:heuer,项目名称:segno,代码行数:8,代码来源:test_svg.py


示例17: test_save_png_buffer

def test_save_png_buffer():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='png')
    out.seek(0)
    expected = b'\211PNG\r\n\032\n'  # PNG magic number
    val = out.read(len(expected))
    assert expected == val
开发者ID:heuer,项目名称:segno,代码行数:8,代码来源:test_qrcode.py


示例18: test_viewbox

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
开发者ID:heuer,项目名称:segno,代码行数:8,代码来源:test_svg.py


示例19: test_title3

def test_title3():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='svg', title='点')
    root = _parse_xml(out)
    title_el = _get_title(root)
    assert title_el is not None
    assert '点' == title_el.text
开发者ID:heuer,项目名称:segno,代码行数:8,代码来源:test_svg.py


示例20: test_scale

def test_scale():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='svg', scale=2)
    root = _parse_xml(out)
    path = _get_path(root)
    assert path is not None
    assert 'scale(2)' in path.attrib['transform']
开发者ID:heuer,项目名称:segno,代码行数:8,代码来源:test_svg.py



注:本文中的segno.make_qr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ibm_float.ibm2ieee函数代码示例发布时间:2022-05-27
下一篇:
Python library.get_refs_in_string函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap