Hello community, here is the log from the commit of package python-qrcode for openSUSE:Factory checked in at 2017-06-05 18:51:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-qrcode (Old) and /work/SRC/openSUSE:Factory/.python-qrcode.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-qrcode" Mon Jun 5 18:51:03 2017 rev:3 rq:501164 version:5.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-qrcode/python-qrcode.changes 2015-09-02 00:35:44.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-qrcode.new/python-qrcode.changes 2017-06-05 18:51:35.406663000 +0200 @@ -1,0 +2,13 @@ +Mon Jun 5 12:38:43 UTC 2017 - [email protected] + +- convert to singlespec +- make binary python3-only +- enable tests +- add proper requirements (fixes boo#1040540) +- update to 5.3 + * better support for tty output in python3 + * --error-correction option + * fix incomplete block table for QR version 15 + * fix BaseImage.get_image + +------------------------------------------------------------------- Old: ---- qrcode-5.1.tar.gz New: ---- qrcode-5.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-qrcode.spec ++++++ --- /var/tmp/diff_new_pack.cnJ2NZ/_old 2017-06-05 18:51:40.465949839 +0200 +++ /var/tmp/diff_new_pack.cnJ2NZ/_new 2017-06-05 18:51:40.469949276 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-qrcode # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,24 +16,26 @@ # +%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-qrcode -Version: 5.1 +Version: 5.3 Release: 0 Summary: QR Code image generator License: BSD-3-Clause Group: Development/Languages/Python Url: https://github.com/lincolnloop/python-qrcode -Source: http://pypi.python.org/packages/source/q/qrcode/qrcode-%{version}.tar.gz -BuildRequires: python-devel -BuildRequires: python-setuptools -Requires(post): update-alternatives -Requires(postun): update-alternatives +Source: https://files.pythonhosted.org/packages/source/q/qrcode/qrcode-%{version}.tar.gz +BuildRequires: %{python_module Pillow} +BuildRequires: %{python_module mock} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module setuptools} +BuildRequires: fdupes +BuildRequires: python-rpm-macros +Requires: python-setuptools +Recommends: python-Pillow BuildRoot: %{_tmppath}/%{name}-%{version}-build -%if 0%{?suse_version} && 0%{?suse_version} <= 1110 -%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} -%else BuildArch: noarch -%endif +%python_subpackages %description This module uses the Python Imaging Library (PIL) to allow for the generation @@ -41,54 +43,24 @@ %prep %setup -q -n qrcode-%{version} +# drop shebang from console_scripts +sed -i '1s@^#!.*@@' qrcode/console_scripts.py %build -python setup.py build +%python_build %install -python setup.py install --prefix=%{_prefix} --root=%{buildroot} +%python_install +%fdupes %{buildroot}%{_prefix} -# Prepare for update-alternatives usage -mkdir -p %{buildroot}%{_sysconfdir}/alternatives -mv -v %{buildroot}%{_bindir}/qr %{buildroot}%{_bindir}/qr-%{py_ver} -# rename man page too -mv -v %{buildroot}%{_mandir}/man1/qr.1 %{buildroot}%{_mandir}/man1/qr-%{py_ver}.1 - -ln -s -f %{_sysconfdir}/alternatives/qr %{buildroot}%{_bindir}/qr -ln -s -f %{_sysconfdir}/alternatives/qr.1%{?ext_man} %{buildroot}%{_mandir}/man1/qr.1%{?ext_man} - -# create a dummy targets for /etc/alternatives -touch %{buildroot}%{_sysconfdir}/alternatives/qr -touch %{buildroot}%{_sysconfdir}/alternatives/qr.1%{?ext_man} - -# Fix warning about missing +x mode -chmod +x %{buildroot}%{python_sitelib}/qrcode/console_scripts.py - -%pre -# Since /usr/bin/qr became ghosted to be used with update-alternatives, we have to get rid -# of the old binary resulting from the non-update-alternativies-ified package: -[ -h %{_bindir}/qr ] || rm -f %{_bindir}/qr -[ -h %{_mandir}/man1/qr.1%{?ext_man} ] || rm -f %{_mandir}/man1/qr.1%{?ext_man} - -%post -%_sbindir/update-alternatives \ - --install %{_bindir}/qr qr %{_bindir}/qr-%{py_ver} 30 \ - --slave %{_mandir}/man1/qr.1%{?ext_man} qr.1%{?ext_man} %{_mandir}/man1/qr-%{py_ver}.1%{?ext_man} - -%postun -if [ $1 -eq 0 ] ; then - %_sbindir/update-alternatives --remove qr %{_bindir}/qr-%{py_ver} -fi +%check +%python_exec -m pytest qrcode -%files +%files %{python_files} %defattr(-,root,root,-) %doc CHANGES.rst LICENSE README.rst -%{_bindir}/qr -%{_bindir}/qr-%{py_ver} -%{_mandir}/man1/qr.1%{?ext_man} -%{_mandir}/man1/qr-%{py_ver}.1%{?ext_man} -%ghost %{_sysconfdir}/alternatives/qr -%ghost %{_sysconfdir}/alternatives/qr.1%{?ext_man} +%python3_only %{_bindir}/qr +%python3_only %{_mandir}/man1/qr.1%{?ext_man} %{python_sitelib}/* %changelog ++++++ qrcode-5.1.tar.gz -> qrcode-5.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/CHANGES.rst new/qrcode-5.3/CHANGES.rst --- old/qrcode-5.1/CHANGES.rst 2014-10-22 02:25:58.000000000 +0200 +++ new/qrcode-5.3/CHANGES.rst 2016-05-18 06:23:00.000000000 +0200 @@ -2,6 +2,45 @@ Change log ========== +Version 5.3 +=========== + +* Fix incomplete block table for QR version 15. Thanks Rodrigo Queiro for the + report and Jacob Welsh for the investigation and fix. + +* Avoid unnecessary dependency for non MS platforms, thanks to Noah Vesely. + +* Make ``BaseImage.get_image()`` actually work. + + +Version 5.2 +=========== + +* Add ``--error-correction`` option to qr script. + +* Fix script piping to stdout in Python 3 and reading non-UTF-8 characters in + Python 3. + +* Fix script piping in Windows. + +* Add some useful behind-the-curtain methods for tinkerers. + +* Fix terminal output when using Python 2.6 + +* Fix terminal output to display correctly on MS command line. + +Version 5.2.1 +------------- + +* Small fix to terminal output in Python 3 (and fix tests) + +Version 5.2.2 +------------- + +* Revert some terminal changes from 5.2 that broke Python 3's real life tty + code generation and introduce a better way from Jacob Welsh. + + Version 5.1 =========== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/PACKAGING.rst new/qrcode-5.3/PACKAGING.rst --- old/qrcode-5.1/PACKAGING.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/qrcode-5.3/PACKAGING.rst 2016-01-24 23:50:46.000000000 +0100 @@ -0,0 +1,25 @@ +Packaging quick reminder +======================== + +Ensure version numbers in ``setup.py`` and ``doc/qr.1`` have been updated. + +1. Check twine and wheel are up to date:: + + pip install --upgrade twine wheel + +2. Delete contents of ``dist/``:: + + rm -r dist + +3. Package it up:: + + python setup.py sdist bdist_wheel + +4. Sign it:: + + gpg --detach-sign -a dist/*.gz + gpg --detach-sign -a dist/*.whl + +5. Upload it:: + + twine upload dist/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/PKG-INFO new/qrcode-5.3/PKG-INFO --- old/qrcode-5.1/PKG-INFO 2014-10-22 02:31:03.000000000 +0200 +++ new/qrcode-5.3/PKG-INFO 2016-05-18 06:24:23.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: qrcode -Version: 5.1 +Version: 5.3 Summary: QR Code image generator Home-page: https://github.com/lincolnloop/python-qrcode Author: Lincoln Loop @@ -153,6 +153,45 @@ Change log ========== + Version 5.3 + =========== + + * Fix incomplete block table for QR version 15. Thanks Rodrigo Queiro for the + report and Jacob Welsh for the investigation and fix. + + * Avoid unnecessary dependency for non MS platforms, thanks to Noah Vesely. + + * Make ``BaseImage.get_image()`` actually work. + + + Version 5.2 + =========== + + * Add ``--error-correction`` option to qr script. + + * Fix script piping to stdout in Python 3 and reading non-UTF-8 characters in + Python 3. + + * Fix script piping in Windows. + + * Add some useful behind-the-curtain methods for tinkerers. + + * Fix terminal output when using Python 2.6 + + * Fix terminal output to display correctly on MS command line. + + Version 5.2.1 + ------------- + + * Small fix to terminal output in Python 3 (and fix tests) + + Version 5.2.2 + ------------- + + * Revert some terminal changes from 5.2 that broke Python 3's real life tty + code generation and introduce a better way from Jacob Welsh. + + Version 5.1 =========== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/doc/qr.1 new/qrcode-5.3/doc/qr.1 --- old/qrcode-5.1/doc/qr.1 2014-10-22 02:28:19.000000000 +0200 +++ new/qrcode-5.3/doc/qr.1 2016-05-18 06:23:52.000000000 +0200 @@ -1,9 +1,9 @@ .\" Manpage for qr -.TH QR 1 "25 Jun 2013" "5.1" "Python QR tool" +.TH QR 1 "25 Jun 2013" "5.3" "Python QR tool" .SH NAME qr \- script to create QR codes at the command line .SH SYNOPSIS -qr [\-\-help] [\-\-factory=FACTORY] [\-\-optimize=OPTIMIZE] [data] +qr [\-\-help] [\-\-factory=FACTORY] [\-\-optimize=OPTIMIZE] [\-\-error\-correction=LEVEL] [data] .SH DESCRIPTION This script uses the python qrcode module. It can take data from stdin or from the commandline and generate a QR code. Normally it will output the QR code as ascii art to the terminal. If the output is piped to a file, it will output the image (default type of PNG). @@ -32,6 +32,13 @@ .RE .PP +\fB\ \-\-error\-correction=LEVEL\fR +.RS 4 +The error correction level to use. Choices are L (7%), +M (15%, default), Q (25%), and H (30%). +.RE + +.PP \fB\ data\fR .RS 4 The data from which the QR code will be generated. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode/base.py new/qrcode-5.3/qrcode/base.py --- old/qrcode-5.1/qrcode/base.py 2014-10-22 01:24:21.000000000 +0200 +++ new/qrcode-5.3/qrcode/base.py 2016-05-18 06:18:05.000000000 +0200 @@ -117,7 +117,7 @@ [5, 109, 87, 1, 110, 88], [5, 65, 41, 5, 66, 42], [5, 54, 24, 7, 55, 25], - [11, 36, 12], + [11, 36, 12, 7, 37, 13], # 16 [5, 122, 98, 1, 123, 99], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode/console_scripts.py new/qrcode-5.3/qrcode/console_scripts.py --- old/qrcode-5.1/qrcode/console_scripts.py 2014-10-22 02:06:45.000000000 +0200 +++ new/qrcode-5.3/qrcode/console_scripts.py 2016-05-18 06:18:05.000000000 +0200 @@ -7,7 +7,12 @@ """ import sys import optparse +import os import qrcode +# The next block is added to get the terminal to display properly on MS platforms +if sys.platform.startswith(('win', 'cygwin')): + import colorama + colorama.init() default_factories = { 'pil': 'qrcode.image.pil.PilImage', @@ -17,10 +22,15 @@ 'svg-path': 'qrcode.image.svg.SvgPathImage', } +error_correction = { + 'L': qrcode.ERROR_CORRECT_L, + 'M': qrcode.ERROR_CORRECT_M, + 'Q': qrcode.ERROR_CORRECT_Q, + 'H': qrcode.ERROR_CORRECT_H, +} -def main(args=sys.argv[1:]): - qr = qrcode.QRCode() +def main(args=sys.argv[1:]): parser = optparse.OptionParser(usage=__doc__.strip()) parser.add_option( "--factory", help="Full python path to the image factory class to " @@ -31,8 +41,16 @@ "--optimize", type=int, help="Optimize the data by looking for chunks " "of at least this many characters that could use a more efficient " "encoding method. Use 0 to turn off chunk optimization.") + parser.add_option( + "--error-correction", type='choice', + choices=sorted(error_correction.keys()), default='M', + help="The error correction level to use. Choices are L (7%), " + "M (15%, default), Q (25%), and H (30%).") opts, args = parser.parse_args(args) + qr = qrcode.QRCode( + error_correction=error_correction[opts.error_correction]) + if opts.factory: module = default_factories.get(opts.factory, opts.factory) if '.' not in module: @@ -46,18 +64,32 @@ if args: data = args[0] else: - data = sys.stdin.read() + # Use sys.stdin.buffer if available (Python 3) avoiding + # UnicodeDecodeErrors. + stdin_buffer = getattr(sys.stdin, 'buffer', sys.stdin) + data = stdin_buffer.read() if opts.optimize is None: qr.add_data(data) else: qr.add_data(data, optimize=opts.optimize) - if image_factory is None and sys.stdout.isatty(): + if image_factory is None and os.isatty(sys.stdout.fileno()): qr.print_ascii(tty=True) return img = qr.make_image(image_factory=image_factory) - img.save(sys.stdout) + + sys.stdout.flush() + # Use sys.stdout.buffer if available (Python 3), avoiding + # UnicodeDecodeErrors. + stdout_buffer = getattr(sys.stdout, 'buffer', None) + if not stdout_buffer: + if sys.platform == 'win32': # pragma: no cover + import msvcrt + msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) + stdout_buffer = sys.stdout + + img.save(stdout_buffer) if __name__ == "__main__": diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode/image/base.py new/qrcode-5.3/qrcode/image/base.py --- old/qrcode-5.1/qrcode/image/base.py 2014-10-22 01:29:35.000000000 +0200 +++ new/qrcode-5.3/qrcode/image/base.py 2016-03-15 20:28:57.000000000 +0100 @@ -39,6 +39,12 @@ """ return None + def get_image(self, **kwargs): + """ + Return the image class for further processing. + """ + return self._img + def check_kind(self, kind, transform=None): """ Get the image type. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode/image/pil.py new/qrcode-5.3/qrcode/image/pil.py --- old/qrcode-5.1/qrcode/image/pil.py 2014-10-22 01:24:47.000000000 +0200 +++ new/qrcode-5.3/qrcode/image/pil.py 2016-01-24 22:27:11.000000000 +0100 @@ -18,18 +18,33 @@ kind = "PNG" def new_image(self, **kwargs): - img = Image.new("1", (self.pixel_size, self.pixel_size), "white") + back_color = kwargs.get("fill_color", "white") + fill_color = kwargs.get("back_color", "black") + + if fill_color.lower() != "black" or back_color.lower() != "white": + if back_color.lower() == "transparent": + mode = "RGBA" + back_color = None + else: + mode = "RGB" + else: + mode = "1" + + img = Image.new(mode, (self.pixel_size, self.pixel_size), back_color) + self.fill_color = fill_color self._idr = ImageDraw.Draw(img) return img def drawrect(self, row, col): box = self.pixel_box(row, col) - self._idr.rectangle(box, fill="black") + self._idr.rectangle(box, fill=self.fill_color) - def save(self, stream, kind=None): - if kind is None: - kind = self.kind - self._img.save(stream, kind) + def save(self, stream, format=None, **kwargs): + if format is None: + format = kwargs.get("kind", self.kind) + if "kind" in kwargs: + del kwargs["kind"] + self._img.save(stream, format=format, **kwargs) def __getattr__(self, name): return getattr(self._img, name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode/main.py new/qrcode-5.3/qrcode/main.py --- old/qrcode-5.1/qrcode/main.py 2014-10-22 00:54:04.000000000 +0200 +++ new/qrcode-5.3/qrcode/main.py 2016-03-15 20:28:37.000000000 +0100 @@ -17,12 +17,19 @@ "Invalid version (was %s, expected 1 to 40)" % version) +def _check_box_size(size): + if int(size) <= 0: + raise ValueError( + "Invalid box size (was %s, expected larger than 0)" % size) + + class QRCode: def __init__(self, version=None, error_correction=constants.ERROR_CORRECT_M, box_size=10, border=4, image_factory=None): + _check_box_size(box_size) self.version = version and int(version) self.error_correction = int(error_correction) self.box_size = int(box_size) @@ -86,7 +93,7 @@ self.setup_position_probe_pattern(0, 0) self.setup_position_probe_pattern(self.modules_count - 7, 0) self.setup_position_probe_pattern(0, self.modules_count - 7) - self.sutup_position_adjust_pattern() + self.setup_position_adjust_pattern() self.setup_timing_pattern() self.setup_type_info(test, mask_pattern) @@ -201,7 +208,14 @@ """ if out is None: import sys - out = sys.stdout + if sys.version_info < (2, 7): + # On Python versions 2.6 and earlier, stdout tries to encode + # strings using ASCII rather than stdout.encoding, so use this + # workaround. + import codecs + out = codecs.getwriter(sys.stdout.encoding)(sys.stdout) + else: + out = sys.stdout if tty and not out.isatty(): raise OSError("Not a tty") @@ -244,6 +258,7 @@ If the data has not been compiled yet, make it first. """ + _check_box_size(self.box_size) if self.data_cache is None: self.make() @@ -275,7 +290,7 @@ continue self.modules[6][c] = (c % 2 == 0) - def sutup_position_adjust_pattern(self): + def setup_position_adjust_pattern(self): pos = util.pattern_position(self.version) for i in range(len(pos)): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode/tests/test_qrcode.py new/qrcode-5.3/qrcode/tests/test_qrcode.py --- old/qrcode-5.1/qrcode/tests/test_qrcode.py 2014-10-22 02:17:26.000000000 +0200 +++ new/qrcode-5.3/qrcode/tests/test_qrcode.py 2016-03-15 20:28:37.000000000 +0100 @@ -1,4 +1,6 @@ +import warnings import six +import sys import qrcode import qrcode.util import qrcode.image.svg @@ -10,6 +12,7 @@ pymaging_png = None import qrcode +from qrcode.image.base import BaseImage from qrcode.exceptions import DataOverflowError from qrcode.util import ( QRData, MODE_NUMBER, MODE_ALPHA_NUM, MODE_8BIT_BYTE) @@ -20,6 +23,11 @@ except ImportError: import unittest +try: + from unittest import mock +except ImportError: + import mock + UNICODE_TEXT = u'\u03b1\u03b2\u03b3' @@ -98,6 +106,22 @@ img = qr.make_image() img.save(six.BytesIO()) + def test_qrcode_bad_factory(self): + self.assertRaises( + TypeError, qrcode.QRCode, image_factory='not_BaseImage') + self.assertRaises( + AssertionError, qrcode.QRCode, image_factory=dict) + + def test_qrcode_factory(self): + + class MockFactory(BaseImage): + drawrect = mock.Mock() + + qr = qrcode.QRCode(image_factory=MockFactory) + qr.add_data(UNICODE_TEXT) + qr.make_image() + self.assertTrue(MockFactory.drawrect.called) + def test_render_svg(self): qr = qrcode.QRCode() qr.add_data(UNICODE_TEXT) @@ -127,7 +151,10 @@ qr = qrcode.QRCode() qr.add_data(UNICODE_TEXT) img = qr.make_image(image_factory=qrcode.image.pure.PymagingImage) - img.save(six.BytesIO()) + with warnings.catch_warnings(): + if six.PY3: + warnings.simplefilter('ignore', DeprecationWarning) + img.save(six.BytesIO()) @unittest.skipIf(not pymaging_png, "Requires pymaging") def test_render_pymaging_png_bad_kind(self): @@ -167,6 +194,16 @@ data_obj = qrcode.util.QRData(data) self.assertEqual(repr(data_obj), repr(data)) + def test_print_ascii_stdout(self): + qr = qrcode.QRCode() + stdout_encoding = sys.stdout.encoding + with mock.patch('sys.stdout') as fake_stdout: + # Python 2.6 needs sys.stdout.encoding to be a real string. + sys.stdout.encoding = stdout_encoding + fake_stdout.isatty.return_value = None + self.assertRaises(OSError, qr.print_ascii, tty=True) + self.assertTrue(fake_stdout.isatty.called) + def test_print_ascii(self): qr = qrcode.QRCode(border=0) f = six.StringIO() @@ -186,6 +223,13 @@ u'\xa0\u2584\u2584\u2584\u2584\u2584\xa0') self.assertEqual(printed[:len(expected)], expected) + def test_print_tty_stdout(self): + qr = qrcode.QRCode() + with mock.patch('sys.stdout') as fake_stdout: + fake_stdout.isatty.return_value = None + self.assertRaises(OSError, qr.print_tty) + self.assertTrue(fake_stdout.isatty.called) + def test_print_tty(self): qr = qrcode.QRCode() f = six.StringIO() @@ -202,6 +246,25 @@ WHITE_BLOCK + ' '*7 + WHITE_BLOCK) self.assertEqual(printed[:len(expected)], expected) + def test_get_matrix(self): + qr = qrcode.QRCode(border=0) + qr.add_data('1') + self.assertEqual(qr.get_matrix(), qr.modules) + + def test_get_matrix_border(self): + qr = qrcode.QRCode(border=1) + qr.add_data('1') + matrix = [row[1:-1] for row in qr.get_matrix()[1:-1]] + self.assertEqual(matrix, qr.modules) + + def test_negative_size_at_construction(self): + self.assertRaises(ValueError, qrcode.QRCode, box_size=-1) + + def test_negative_size_at_usage(self): + qr = qrcode.QRCode() + qr.box_size = -1 + self.assertRaises(ValueError, qr.make_image) + class ShortcutTest(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode/tests/test_script.py new/qrcode-5.3/qrcode/tests/test_script.py --- old/qrcode-5.1/qrcode/tests/test_script.py 2014-10-22 02:09:30.000000000 +0200 +++ new/qrcode-5.3/qrcode/tests/test_script.py 2016-01-24 23:11:35.000000000 +0100 @@ -1,3 +1,4 @@ +import sys try: import unittest2 as unittest except ImportError: @@ -10,6 +11,10 @@ from qrcode.console_scripts import main +def bad_read(): + raise UnicodeDecodeError('utf-8', b'0x80', 0, 1, 'invalid start byte') + + class ScriptTest(unittest.TestCase): @mock.patch('os.isatty', lambda *args: True) @@ -26,11 +31,23 @@ @mock.patch('os.isatty', lambda *args: True) @mock.patch('qrcode.main.QRCode.print_ascii') def test_stdin(self, mock_print_ascii): - mock_stdin = mock.Mock() - mock_stdin.configure_mock(**{'read.return_value': 'testtext'}) - with mock.patch('sys.stdin', mock_stdin) as stdin: + mock_stdin = mock.Mock(sys.stdin) + stdin_buffer = getattr(mock_stdin, 'buffer', mock_stdin) + stdin_buffer.read.return_value = 'testtext' + with mock.patch('sys.stdin', mock_stdin): + main([]) + self.assertTrue(stdin_buffer.read.called) + mock_print_ascii.assert_called_with(tty=True) + + @unittest.skipIf(sys.version_info[0] < 3, 'Python 3') + @mock.patch('os.isatty', lambda *args: True) + @mock.patch('qrcode.main.QRCode.print_ascii') + def test_stdin_py3_unicodedecodeerror(self, mock_print_ascii): + mock_stdin = mock.Mock(sys.stdin) + mock_stdin.buffer.read.return_value = 'testtext' + mock_stdin.read.side_effect = bad_read + with mock.patch('sys.stdin', mock_stdin): main([]) - self.assertTrue(stdin.read.called) mock_print_ascii.assert_called_with(tty=True) @mock.patch('os.isatty', lambda *args: True) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode.egg-info/PKG-INFO new/qrcode-5.3/qrcode.egg-info/PKG-INFO --- old/qrcode-5.1/qrcode.egg-info/PKG-INFO 2014-10-22 02:31:03.000000000 +0200 +++ new/qrcode-5.3/qrcode.egg-info/PKG-INFO 2016-05-18 06:24:23.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: qrcode -Version: 5.1 +Version: 5.3 Summary: QR Code image generator Home-page: https://github.com/lincolnloop/python-qrcode Author: Lincoln Loop @@ -153,6 +153,45 @@ Change log ========== + Version 5.3 + =========== + + * Fix incomplete block table for QR version 15. Thanks Rodrigo Queiro for the + report and Jacob Welsh for the investigation and fix. + + * Avoid unnecessary dependency for non MS platforms, thanks to Noah Vesely. + + * Make ``BaseImage.get_image()`` actually work. + + + Version 5.2 + =========== + + * Add ``--error-correction`` option to qr script. + + * Fix script piping to stdout in Python 3 and reading non-UTF-8 characters in + Python 3. + + * Fix script piping in Windows. + + * Add some useful behind-the-curtain methods for tinkerers. + + * Fix terminal output when using Python 2.6 + + * Fix terminal output to display correctly on MS command line. + + Version 5.2.1 + ------------- + + * Small fix to terminal output in Python 3 (and fix tests) + + Version 5.2.2 + ------------- + + * Revert some terminal changes from 5.2 that broke Python 3's real life tty + code generation and introduce a better way from Jacob Welsh. + + Version 5.1 =========== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode.egg-info/SOURCES.txt new/qrcode-5.3/qrcode.egg-info/SOURCES.txt --- old/qrcode-5.1/qrcode.egg-info/SOURCES.txt 2014-10-22 02:31:03.000000000 +0200 +++ new/qrcode-5.3/qrcode.egg-info/SOURCES.txt 2016-05-18 06:24:23.000000000 +0200 @@ -1,8 +1,10 @@ CHANGES.rst LICENSE MANIFEST.in +PACKAGING.rst README.rst TESTING.rst +setup.cfg setup.py doc/qr.1 qrcode/__init__.py @@ -16,6 +18,7 @@ qrcode.egg-info/SOURCES.txt qrcode.egg-info/dependency_links.txt qrcode.egg-info/entry_points.txt +qrcode.egg-info/pbr.json qrcode.egg-info/requires.txt qrcode.egg-info/top_level.txt qrcode/image/__init__.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode.egg-info/pbr.json new/qrcode-5.3/qrcode.egg-info/pbr.json --- old/qrcode-5.1/qrcode.egg-info/pbr.json 1970-01-01 01:00:00.000000000 +0100 +++ new/qrcode-5.3/qrcode.egg-info/pbr.json 2016-01-24 23:08:59.000000000 +0100 @@ -0,0 +1 @@ +{"git_version": "a2e3516", "is_release": false} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/qrcode.egg-info/requires.txt new/qrcode-5.3/qrcode.egg-info/requires.txt --- old/qrcode-5.1/qrcode.egg-info/requires.txt 2014-10-22 02:31:03.000000000 +0200 +++ new/qrcode-5.3/qrcode.egg-info/requires.txt 2016-05-18 06:24:23.000000000 +0200 @@ -1 +1 @@ -six \ No newline at end of file +six diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/setup.cfg new/qrcode-5.3/setup.cfg --- old/qrcode-5.1/setup.cfg 2014-10-22 02:31:03.000000000 +0200 +++ new/qrcode-5.3/setup.cfg 2016-05-18 06:24:23.000000000 +0200 @@ -1,3 +1,6 @@ +[bdist_wheel] +universal = 1 + [egg_info] tag_build = tag_date = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qrcode-5.1/setup.py new/qrcode-5.3/setup.py --- old/qrcode-5.1/setup.py 2014-10-22 02:28:04.000000000 +0200 +++ new/qrcode-5.3/setup.py 2016-05-18 06:23:35.000000000 +0200 @@ -3,6 +3,7 @@ import io import os from setuptools import setup, find_packages +import sys def long_description(): @@ -18,9 +19,15 @@ return '\n\n'.join(content) +# Colorama is needed for proper terminal support on MS platforms +if sys.platform.startswith(('win', 'cygwin')): + dependencies = ['six', 'colorama'] +else: + dependencies = ['six'] + setup( name='qrcode', - version='5.1', + version='5.3', url='https://github.com/lincolnloop/python-qrcode', description='QR Code image generator', license='BSD', @@ -34,7 +41,7 @@ 'qr = qrcode.console_scripts:main', ], }, - install_requires=['six'], + install_requires=dependencies, data_files=[('share/man/man1', ['doc/qr.1'])], include_package_data=True, classifiers=[
