Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install fnord.easycodec

How to install fnord.easycodec

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install fnord.easycodec
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
0.2 Available View build log
Linux (64-bit)
0.2 Failed View build log
 
License
lgpl
Dependencies
Depended by
Imports
Lastest release
version 0.2 on Aug 26th, 2013

Installation

Install the distribution from source:

$ python setup.py install

Or install with easy_install:

$ easy_install fnord.easycodec

Usage

This package can be used to easily create and register codecs.

Use the decorator encoder to create an encode-function:

>>> from fnord.easycodec import encoder
>>> @encoder("my_codec")
... def my_encode(message):
...     ...

(my_codec is the name of the codec.)

Use the decorator decoder to create a decode-function:

>>> from fnord.easycodec import decoder
>>> @decoder("my_codec")
... def my_decode(message):
...     ...

Use the factory CodecRegistration to create an object that can be returned by a codec's search-function:

>>> from fnord.easycodec import CodecRegistration, AUTO
>>> registration = CodecRegistration(
...     "my_codec", my_encode, my_decode,
...     streamwriter=AUTO, streamreader=AUTO)

This factory takes the following parameters:

name:The name of the codec. Required.
encode:The encode-function. Required.
decode:The decode-function. Required.
incrementalencoder:
 The incremental encoder. Optional.
incrementaldecoder:
 The incremental decoder. Optional.
streamwriter:The stream-writer. Optional.
streamreader:The stream-reader. Optional.

If one of the optional parameters has the value AUTO assigned, an appropriate object will be generated and used.

Use the factory CodecSearch to create a search-function for a codec. The parameters are the same as for CodecRegistration:

>>> from fnord.easycodec import CodecSearch
>>> search = CodecSearch(
...     "my_codec", my_encode, my_decode,
...     streamwriter=AUTO, streamreader=AUTO)

This function can then be used to register the codec:

>>> import codecs
>>> codecs.register(search)

Contributors

Changelog

0.2 (2013-08-17)
  • Fixed parameters to constructor for exception UnicodeDecodeError [Bert Vanderbauwhede]
0.1 (2013-08-11)
  • Package created using templer [Bert Vanderbauwhede]
  • First implementation [Bert Vanderbauwhede]

Subscribe to package updates

Last updated Aug 26th, 2013

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.