Back to index

python3.2  3.2.2
Functions | Variables
listcodecs Namespace Reference

Functions

def listcodecs

Variables

int _debug = 0
tuple names = listcodecs(encodings.__path__[0])

Detailed Description

List all available codec modules.

(c) Copyright 2005, Marc-Andre Lemburg (mal@lemburg.com).

Licensed to PSF under a Contributor Agreement.

Function Documentation

def listcodecs.listcodecs (   dir)

Definition at line 13 of file listcodecs.py.

00013 
00014 def listcodecs(dir):
00015     names = []
00016     for filename in os.listdir(dir):
00017         if filename[-3:] != '.py':
00018             continue
00019         name = filename[:-3]
00020         # Check whether we've found a true codec
00021         try:
00022             codecs.lookup(name)
00023         except LookupError:
00024             # Codec not found
00025             continue
00026         except Exception as reason:
00027             # Probably an error from importing the codec; still it's
00028             # a valid code name
00029             if _debug:
00030                 print('* problem importing codec %r: %s' % \
00031                       (name, reason))
00032         names.append(name)
00033     return names
00034 


Variable Documentation

Definition at line 11 of file listcodecs.py.

tuple listcodecs.names = listcodecs(encodings.__path__[0])

Definition at line 36 of file listcodecs.py.