[Python-ideas] Query available codecs and error handlers

M.-A. Lemburg mal at egenix.com
Fri Aug 29 09:33:47 CEST 2014


On 29.08.2014 07:45, Steven D'Aprano wrote:
> Unless I am badly misinformed, there is no way to programmatically check 
> what codecs and error handlers are available. I propose two functions in 
> the codecs module:
> 
> get_codecs()
> get_error_handlers()
> 
> which each return a set of the available codec, or error handler, names.

Question is: how would you implement these ?

The codec registry uses lookup functions to find codecs, so we'd
have to extend those lookup functions to also support reporting
known installed codecs.

For the stdlib encodings package we could simply put a list into
the package, e.g. encodings.available_codecs returning a dictionary
of mappings from codec name to CodecInfo tuples and then extend
the CodecInfo with some extra information such as supported
error handlers, alternative names and information about the
supported input/output types.

At the moment, the available codecs are documented here:

https://docs.python.org/3.5/library/codecs.html?highlight=codecs#standard-encodings

It's probably a good idea to add information about supported
error handlers to that list.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Aug 29 2014)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2014-08-27: Released eGenix PyRun 2.0.1 ...       http://egenix.com/go62
2014-09-19: PyCon UK 2014, Coventry, UK ...                21 days to go
2014-09-27: PyDDF Sprint 2014 ...                          29 days to go

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/


More information about the Python-ideas mailing list