Skip to content

Commit

Permalink
Merge branch 'release/0.2.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
heuer committed Feb 18, 2018
2 parents 839def2 + 53ab899 commit 4a892b7
Show file tree
Hide file tree
Showing 25 changed files with 159 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changes
=======

0.2.6 -- 2017-02-18
-------------------
* Updated and fixed docs
* Added PyPy 3 to test environment


0.2.5 -- 2017-02-14
-------------------
* Added experimental support for Structured Append (divide content into max.
Expand Down
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ Segno -- Python QR Code and Micro QR Code encoder

Segno is a QR Code and Micro QR Code encoder which has no further dependencies.

This package implements ISO/IEC 18004:2006(E) / ISO/IEC 18004:2015(E) "QR Code bar
code symbology specification" and produces Micro QR Codes and QR Codes with
nearly no effort.
This package implements ISO/IEC 18004:2015(E) "QR Code bar code symbology
specification" and produces Micro QR Codes and QR Codes with nearly no effort.
It supports the Structured Append mode which splits a message across several
QR Codes.

Segno provides several serialization formats like Scalable Vector Graphics (SVG),
Encapsulated PostScript (EPS), Portable Network Graphics (PNG),
Expand Down Expand Up @@ -39,7 +40,7 @@ The command line script prints the QR Code to the terminal::
To serialize the QR Code, use the "output" argument::

$ segno -o=raincoat.svg "Famous Blue Raincoat"
$ segno --scale=10 --color=darkblue --border=0 --output=fire.svg "Who by Fire"
$ segno --scale=10 --color=darkblue --border=0 --output=fire.svg "Who by Fire"
$ segno --scale=10 --background=transparent --output=miracle.png "Waiting for the Miracle"


Expand Down
2 changes: 2 additions & 0 deletions docs/_static/black-magic-woman.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/_static/boom-boom.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/diamond.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/_static/dontgiveup.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/excited.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/hotel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/micro-qr-layla-version-m4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/micro-qr-little-wing-terminal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/money-talks.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/_static/private-investigations.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/qr-heart-of-gold-error-h.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/qr-heart-of-gold-error-l.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/qr-layla-version-5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/qr-little-wing-terminal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/_static/satellite.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docs/_static/thrill-gone.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
000000000000000000000000000000000
000000000000000000000000000000000
000000000000000000000000000000000
000000000000000000000000000000000
000011111110101110110011111110000
000010000010111011110010000010000
000010111010100010010010111010000
000010111010111011000010111010000
000010111010100010110010111010000
000010000010001111011010000010000
000011111110101010101011111110000
000000000000110101001000000000000
000001101011000000111010111110000
000010010101000100001110000110000
000000001111000101000100111110000
000000000100010000001100110100000
000011101011001000001010000000000
000001000000100010011110010110000
000010001111000101001011101110000
000001110000100000010101100100000
000010001011110111101111111110000
000000000000110001011000100000000
000011111110110011011010101110000
000010000010001011111000100110000
000010111010101100101111100010000
000010111010010110101001111000000
000010111010101101101011101010000
000010000010111011001111100100000
000011111110010011011110110110000
000000000000000000000000000000000
000000000000000000000000000000000
000000000000000000000000000000000
000000000000000000000000000000000
Binary file added docs/_static/white-room.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 95 additions & 4 deletions docs/command-line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ Output the QR Code to the terminal::

$ segno "Little wing"

.. image:: _static/qr-little-wing-terminal.png
:alt: QR Code for "Little wing".


Same content, but as Micro QR Code (M4)::

$ segno --micro "Little wing"

.. image:: _static/micro-qr-little-wing-terminal.png
:alt: Micro QR Code for "Little wing".


Version
^^^^^^^
Expand All @@ -36,12 +42,20 @@ enforces version 5::
$ segno -v=5 Layla


.. image:: _static/qr-layla-version-5.png
:alt: QR Code version 5 for "Layla".


Micro QR Code::

$ segno -v m4 Layla
$ segno --version M4 Layla


.. image:: _static/micro-qr-layla-version-m4.png
:alt: Micro QR Code version M4 for "Layla".


Error correction level
^^^^^^^^^^^^^^^^^^^^^^

Expand All @@ -52,19 +66,51 @@ it::
$ segno -e=h "Heart of Gold"


"Heart of Gold" using error level "L":

.. image:: _static/qr-heart-of-gold-error-l.png
:alt: QR Code "Heart of Gold" using error level L


"Heart of Gold" using error level "H":

.. image:: _static/qr-heart-of-gold-error-h.png
:alt: QR Code "Heart of Gold" using error level H


QR Code serialization
^^^^^^^^^^^^^^^^^^^^^

Printing the QR Codes to the terminal is nice but the ``output`` parameter
serializes the QR Code in one of the supported file formats::

$ segno --output=white-room.png "White Room"

.. image:: _static/white-room.png
:alt: QR Code "White Room".

::

$ segno -o=satellite.svg "Satellite Of Love"

.. image:: _static/satellite.svg
:alt: QR Code "Satellite Of Love".


::

$ segno --output=mrs.eps "Mrs. Robinson"
$ segno --output=dedodo.pdf "De Do Do Do, De Da Da Da"
$ segno --output=tin-pan-alley.svgz "Tin Pan Alley"


::

$ segno --output=thrill-gone.txt "The Thrill Is Gone"

.. include:: _static/thrill-gone.txt
:literal:


Scaling QR Codes
^^^^^^^^^^^^^^^^
Expand All @@ -73,8 +119,18 @@ If the resulting QR Code is too small, ``scale`` can be used to create a more
appropriate output::

$ segno --scale=10 --output=money-talks.png "Money Talks"

.. image:: _static/money-talks.png
:alt: QR Code "Money Talks".

::

$ segno -s 10 --output=private-investigations.svg Private Investigations

.. image:: _static/private-investigations.svg
:alt: QR Code "Private Investigations".


If the serializer does not support a scaling factor (i.e. text output), this
parameter is ignored.

Expand All @@ -86,21 +142,56 @@ The generated QR Codes will have a recommended quiet zone / border around the
symbol. To change the size of the border, ``border`` can be utilized::

$ segno --border=0 --output=black-magic-woman.svg "Black Magic Woman"

.. image:: _static/black-magic-woman.svg
:alt: QR Code "Black Magic Woman" using quiet zone of zero.

::

$ segno --border=10 --output=diamond.png "Shine On You Crazy Diamond"
$ segno --b 0 --output=boom-boom.svg Boom Boom

.. image:: _static/diamond.png
:alt: QR Code "Shine On You Crazy Diamond" using quiet zone of ten.


::

$ segno -b=30 --output=boom-boom.svg Boom Boom

.. image:: _static/boom-boom.svg
:alt: QR Code "Boom Boom" using quiet zone of 30.


Colors
^^^^^^

Usually, all QR Codes are serialized in black and white. Use ``color``
to change the color of the dark modules and ``background`` to change the
color of the light modules. If the color or background should be transparent,
set the value to "transparent"::
color of the light modules.

Change the foreground color to darkblue::

$ segno --color=darkblue --output=excited.png "So Excited"

.. image:: _static/excited.png
:alt: QR Code "So Excited" with foreground color "darkblue"


Change the background color to transparent::

$ segno --background=transparent --output=hotel.png "Hotel California"
$ segno --color=transparent --output=dontgiveup.svg "Don't Give Up"

.. image:: _static/hotel.png
:alt: QR Code "Hotel California" with background color "transparent"


Change the foreground color to darkblue and background to yellow::

$ segno --color=darkblue --background=yellow --output=dontgiveup.svg "Don't Give Up"

.. image:: _static/dontgiveup.svg
:alt: QR Code "Don't Give Up" with foreground color "transparent"


If the serializer does not support ``color`` or ``background``, these arguments
are ignored.
Expand Down
10 changes: 7 additions & 3 deletions docs/structured-append.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Structured Append
=================

The Structured Append mode can be used to split a message accross several
The Structured Append mode can be used to split a message across several
QR Codes (it's not available for Micro QR Codes).

Segno provides a special factory function to create a sequence of (up to 16)
QR Codes.
Segno provides a special factory function, :py:func:`segno.make_sequence`, to
create a sequence of (up to 16) QR Codes. The function returns instances of
:py:class:`segno.QRCodeSequence`.


Structured Append by QR Code version
Expand Down Expand Up @@ -55,3 +56,6 @@ QR Code version is automatically determined by the number of symbols.
>>> seq = segno.make_sequence('Day after day, alone on the hill', symbol_count=2)
>>> [qr.designator for qr in seq]
['2-Q', '2-Q']
>>> seq = segno.make_sequence('Day after day, alone on the hill', symbol_count=6)
>>> [qr.designator for qr in seq]
['1-Q', '1-Q', '1-H', '1-H', '1-H', '1-H']
2 changes: 1 addition & 1 deletion segno/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
except NameError: # pragma: no cover
str_type = str

__version__ = '0.2.5'
__version__ = '0.2.6'

__all__ = ('make', 'make_qr', 'make_micro', 'make_sequence', 'QRCode',
'QRCodeSequence', 'QRCodeError', 'ErrorLevelError', 'ModeError',
Expand Down
6 changes: 0 additions & 6 deletions segno/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,12 +1764,6 @@ def __new__(cls, number, total, parity):
:param int total: Total symbol count ``[2 .. 15]``
:param int parity: Parity data.
"""
if not (0 <= number < 16):
raise ValueError('Invalid Structured Append sequence number: {0}'.format(number))
if total > 15 or number > total:
raise ValueError('Invalid Structured Append symbol count: {0}'.format(total))
if parity < 0:
raise ValueError('Invalid Structured Append parity data')
return super(_StructuredAppendInfo, cls).__new__(cls, (consts.MODE_STRUCTURED_APPEND, number, total, parity))

mode = property(itemgetter(0))
Expand Down
5 changes: 1 addition & 4 deletions segno/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def as_svg_data_uri(matrix, version, scale=1, border=None, color='#000',

def write_svg_debug(matrix, version, out, scale=15, border=None,
fallback_color='fuchsia', color_mapping=None,
add_legend=True): # pragma: no cover
add_legend=True):
"""\
Internal SVG serializer which is useful to debugging purposes.
Expand Down Expand Up @@ -332,9 +332,6 @@ def to_float(c):
raise ValueError('Invalid color "{0}". Not in range 0 .. 1'
.format(c))
return c
if not 0 <= c <= 255:
raise ValueError('Invalid color "{0}". Not in range 0 .. 255'
.format(c))
return 1/255.0 * c if c != 1 else c

return tuple([to_float(i) for i in colors.color_to_rgb(clr)])
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = pypy, py26, py27, py34, py36, docs
envlist = pypy, pypy3, py26, py27, py34, py36, docs


[testenv:docs]
Expand Down

0 comments on commit 4a892b7

Please sign in to comment.