Skip to content

Commit

Permalink
Update README.md for more information
Browse files Browse the repository at this point in the history
  • Loading branch information
fritz0705 committed Dec 1, 2013
1 parent 55800e1 commit 3c6ecab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
8 changes: 8 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Copyright (c) 2013 Fritz Grimpen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

31 changes: 23 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Flynn from Breaking Bad
#######################

Flynn (his real name is Walter Junior), is a protagonist in Breaking Bad and the son of
Flynn (his real name is Walter White Jr.), is a protagonist in Breaking Bad and the son of
Walter White (a. k. a. Heisenberg).

Flynn is also a Python library providing CBOR [RFC7049] encoding and decoding with a
Expand All @@ -10,22 +10,37 @@ traditional buffered and a streaming interface.
Usage
=====

Flynn provides the high-level API provided by the flynn module and the low-level
encoding and decoding APIs which are provided by flynn.encoder and flynn.decoder.
The Flynn API is really simple and inspired by existing Python serialisation
modules like json and pickle. The flynn module has four methods called dumps,
dump, loads and load, where dumps will return the serialised input as bytes
string, while dump will write the serialised input to a file descriptor. The
same applies to loads and load.

>>> flynn.dumps([1, [2, 3]])
b'\x82\x01\x82\x02\x03'
>>> flynn.dumph([1, [2, 3]])
'8201820203'
>>> flynn.loads(b'\x82\x01\x82\x02\x03')
[1, [2, 3]]
>>> flynn.loadh('8201820203')
[1, [2, 3]]

Furthermore, Flynn supports generators and other iterables as input for
streaming support:

>>> flynn.dumps(range(5))
b'\x9f\x00\x01\x02\x03\x04\xff'
>>> flynn.loads(b'\x9f\x00\x01\x02\x03\x04\xff')
[0, 1, 2, 3, 4]

Or to generate a map using an iterable:

>>> flynn.dumps((((a, a) for a in range(5)), "map"))
b'\xbf\x00\x00\x01\x01\x02\x02\x03\x03\x04\x04\xff'
>>> flynn.loads(b'\xbf\x00\x00\x01\x01\x02\x02\x03\x03\x04\x04\xff')
{0: 0, 1: 1, 2: 2, 3: 3, 4: 4}

Copyright / License
===================

© 2013 Fritz Conrad Grimpen

The code is licensed under a BSD-style license. The full license text is available at http://grimpen.org/license.txt
The code is licensed under the MIT license, provided in the COPYING file of the
Flynn distribution.

0 comments on commit 3c6ecab

Please sign in to comment.