Merge part of the trunk changes into the p3yk branch. This merges from 43030
(branch-creation time) up to 43067. 43068 and 43069 contain a little swapping action between re.py and sre.py, and this mightily confuses svn merge, so later changes are going in separately. This merge should break no additional tests. The last-merged revision is going in a 'last_merge' property on '.' (the branch directory.) Arbitrarily chosen, really; if there's a BCP for this, I couldn't find it, but we can easily change it afterwards ;)
This commit is contained in:
parent
d858f70617
commit
a977329b6f
|
@ -24,8 +24,19 @@ It defines the following functions:
|
||||||
\begin{funcdesc}{register}{search_function}
|
\begin{funcdesc}{register}{search_function}
|
||||||
Register a codec search function. Search functions are expected to
|
Register a codec search function. Search functions are expected to
|
||||||
take one argument, the encoding name in all lower case letters, and
|
take one argument, the encoding name in all lower case letters, and
|
||||||
return a tuple of functions \code{(\var{encoder}, \var{decoder}, \var{stream_reader},
|
return a \class{CodecInfo} object having the following attributes:
|
||||||
\var{stream_writer})} taking the following arguments:
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \code{name} The name of the encoding;
|
||||||
|
\item \code{encoder} The stateless encoding function;
|
||||||
|
\item \code{decoder} The stateless decoding function;
|
||||||
|
\item \code{incrementalencoder} An incremental encoder class or factory function;
|
||||||
|
\item \code{incrementaldecoder} An incremental decoder class or factory function;
|
||||||
|
\item \code{streamwriter} A stream writer class or factory function;
|
||||||
|
\item \code{streamreader} A stream reader class or factory function.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
The various functions or classes take the following arguments:
|
||||||
|
|
||||||
\var{encoder} and \var{decoder}: These must be functions or methods
|
\var{encoder} and \var{decoder}: These must be functions or methods
|
||||||
which have the same interface as the
|
which have the same interface as the
|
||||||
|
@ -33,7 +44,17 @@ return a tuple of functions \code{(\var{encoder}, \var{decoder}, \var{stream_rea
|
||||||
Codec Interface). The functions/methods are expected to work in a
|
Codec Interface). The functions/methods are expected to work in a
|
||||||
stateless mode.
|
stateless mode.
|
||||||
|
|
||||||
\var{stream_reader} and \var{stream_writer}: These have to be
|
\var{incrementalencoder} and \var{incrementalencoder}: These have to be
|
||||||
|
factory functions providing the following interface:
|
||||||
|
|
||||||
|
\code{factory(\var{errors}='strict')}
|
||||||
|
|
||||||
|
The factory functions must return objects providing the interfaces
|
||||||
|
defined by the base classes \class{IncrementalEncoder} and
|
||||||
|
\class{IncrementalEncoder}, respectively. Incremental codecs can maintain
|
||||||
|
state.
|
||||||
|
|
||||||
|
\var{streamreader} and \var{streamwriter}: These have to be
|
||||||
factory functions providing the following interface:
|
factory functions providing the following interface:
|
||||||
|
|
||||||
\code{factory(\var{stream}, \var{errors}='strict')}
|
\code{factory(\var{stream}, \var{errors}='strict')}
|
||||||
|
@ -58,13 +79,13 @@ return \code{None}.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{lookup}{encoding}
|
\begin{funcdesc}{lookup}{encoding}
|
||||||
Looks up a codec tuple in the Python codec registry and returns the
|
Looks up the codec info in the Python codec registry and returns a
|
||||||
function tuple as defined above.
|
\class{CodecInfo} object as defined above.
|
||||||
|
|
||||||
Encodings are first looked up in the registry's cache. If not found,
|
Encodings are first looked up in the registry's cache. If not found,
|
||||||
the list of registered search functions is scanned. If no codecs tuple
|
the list of registered search functions is scanned. If no \class{CodecInfo}
|
||||||
is found, a \exception{LookupError} is raised. Otherwise, the codecs
|
object is found, a \exception{LookupError} is raised. Otherwise, the
|
||||||
tuple is stored in the cache and returned to the caller.
|
\class{CodecInfo} object is stored in the cache and returned to the caller.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
To simplify access to the various codecs, the module provides these
|
To simplify access to the various codecs, the module provides these
|
||||||
|
@ -85,6 +106,22 @@ function.
|
||||||
Raises a \exception{LookupError} in case the encoding cannot be found.
|
Raises a \exception{LookupError} in case the encoding cannot be found.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
|
\begin{funcdesc}{getincrementalencoder}{encoding}
|
||||||
|
Lookup up the codec for the given encoding and return its incremental encoder
|
||||||
|
class or factory function.
|
||||||
|
|
||||||
|
Raises a \exception{LookupError} in case the encoding cannot be found or the
|
||||||
|
codec doesn't support an incremental encoder.
|
||||||
|
\end{funcdesc}
|
||||||
|
|
||||||
|
\begin{funcdesc}{getincrementaldecoder}{encoding}
|
||||||
|
Lookup up the codec for the given encoding and return its incremental decoder
|
||||||
|
class or factory function.
|
||||||
|
|
||||||
|
Raises a \exception{LookupError} in case the encoding cannot be found or the
|
||||||
|
codec doesn't support an incremental decoder.
|
||||||
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{getreader}{encoding}
|
\begin{funcdesc}{getreader}{encoding}
|
||||||
Lookup up the codec for the given encoding and return its StreamReader
|
Lookup up the codec for the given encoding and return its StreamReader
|
||||||
class or factory function.
|
class or factory function.
|
||||||
|
@ -188,6 +225,18 @@ If \var{output} is not given, it defaults to \var{input}.
|
||||||
an encoding error occurs.
|
an encoding error occurs.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
|
\begin{funcdesc}{iterencode}{iterable, encoding\optional{, errors}}
|
||||||
|
Uses an incremental encoder to iteratively encode the input provided by
|
||||||
|
\var{iterable}. This function is a generator. \var{errors} (as well as
|
||||||
|
any other keyword argument) is passed through to the incremental encoder.
|
||||||
|
\end{funcdesc}
|
||||||
|
|
||||||
|
\begin{funcdesc}{iterdecode}{iterable, encoding\optional{, errors}}
|
||||||
|
Uses an incremental decoder to iteratively decode the input provided by
|
||||||
|
\var{iterable}. This function is a generator. \var{errors} (as well as
|
||||||
|
any other keyword argument) is passed through to the incremental encoder.
|
||||||
|
\end{funcdesc}
|
||||||
|
|
||||||
The module also provides the following constants which are useful
|
The module also provides the following constants which are useful
|
||||||
for reading and writing to platform dependent files:
|
for reading and writing to platform dependent files:
|
||||||
|
|
||||||
|
@ -292,6 +341,109 @@ function interfaces of the stateless encoder and decoder:
|
||||||
empty object of the output object type in this situation.
|
empty object of the output object type in this situation.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
|
The \class{IncrementalEncoder} and \class{IncrementalDecoder} classes provide
|
||||||
|
the basic interface for incremental encoding and decoding. Encoding/decoding the
|
||||||
|
input isn't done with one call to the stateless encoder/decoder function,
|
||||||
|
but with multiple calls to the \method{encode}/\method{decode} method of the
|
||||||
|
incremental encoder/decoder. The incremental encoder/decoder keeps track of
|
||||||
|
the encoding/decoding process during method calls.
|
||||||
|
|
||||||
|
The joined output of calls to the \method{encode}/\method{decode} method is the
|
||||||
|
same as if the all single inputs where joined into one, and this input was
|
||||||
|
encoded/decoded with the stateless encoder/decoder.
|
||||||
|
|
||||||
|
|
||||||
|
\subsubsection{IncrementalEncoder Objects \label{incremental-encoder-objects}}
|
||||||
|
|
||||||
|
The \class{IncrementalEncoder} class is used for encoding an input in multiple
|
||||||
|
steps. It defines the following methods which every incremental encoder must
|
||||||
|
define in order to be compatible to the Python codec registry.
|
||||||
|
|
||||||
|
\begin{classdesc}{IncrementalEncoder}{\optional{errors}}
|
||||||
|
Constructor for a \class{IncrementalEncoder} instance.
|
||||||
|
|
||||||
|
All incremental encoders must provide this constructor interface. They are
|
||||||
|
free to add additional keyword arguments, but only the ones defined
|
||||||
|
here are used by the Python codec registry.
|
||||||
|
|
||||||
|
The \class{IncrementalEncoder} may implement different error handling
|
||||||
|
schemes by providing the \var{errors} keyword argument. These
|
||||||
|
parameters are predefined:
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \code{'strict'} Raise \exception{ValueError} (or a subclass);
|
||||||
|
this is the default.
|
||||||
|
\item \code{'ignore'} Ignore the character and continue with the next.
|
||||||
|
\item \code{'replace'} Replace with a suitable replacement character
|
||||||
|
\item \code{'xmlcharrefreplace'} Replace with the appropriate XML
|
||||||
|
character reference
|
||||||
|
\item \code{'backslashreplace'} Replace with backslashed escape sequences.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
The \var{errors} argument will be assigned to an attribute of the
|
||||||
|
same name. Assigning to this attribute makes it possible to switch
|
||||||
|
between different error handling strategies during the lifetime
|
||||||
|
of the \class{IncrementalEncoder} object.
|
||||||
|
|
||||||
|
The set of allowed values for the \var{errors} argument can
|
||||||
|
be extended with \function{register_error()}.
|
||||||
|
\end{classdesc}
|
||||||
|
|
||||||
|
\begin{methoddesc}{encode}{object\optional{, final}}
|
||||||
|
Encodes \var{object} (taking the current state of the encoder into account)
|
||||||
|
and returns the resulting encoded object. If this is the last call to
|
||||||
|
\method{encode} \var{final} must be true (the default is false).
|
||||||
|
\end{methoddesc}
|
||||||
|
|
||||||
|
\begin{methoddesc}{reset}{}
|
||||||
|
Reset the encoder to the initial state.
|
||||||
|
\end{methoddesc}
|
||||||
|
|
||||||
|
|
||||||
|
\subsubsection{IncrementalDecoder Objects \label{incremental-decoder-objects}}
|
||||||
|
|
||||||
|
The \class{IncrementalDecoder} class is used for decoding an input in multiple
|
||||||
|
steps. It defines the following methods which every incremental decoder must
|
||||||
|
define in order to be compatible to the Python codec registry.
|
||||||
|
|
||||||
|
\begin{classdesc}{IncrementalDecoder}{\optional{errors}}
|
||||||
|
Constructor for a \class{IncrementalDecoder} instance.
|
||||||
|
|
||||||
|
All incremental decoders must provide this constructor interface. They are
|
||||||
|
free to add additional keyword arguments, but only the ones defined
|
||||||
|
here are used by the Python codec registry.
|
||||||
|
|
||||||
|
The \class{IncrementalDecoder} may implement different error handling
|
||||||
|
schemes by providing the \var{errors} keyword argument. These
|
||||||
|
parameters are predefined:
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \code{'strict'} Raise \exception{ValueError} (or a subclass);
|
||||||
|
this is the default.
|
||||||
|
\item \code{'ignore'} Ignore the character and continue with the next.
|
||||||
|
\item \code{'replace'} Replace with a suitable replacement character.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
The \var{errors} argument will be assigned to an attribute of the
|
||||||
|
same name. Assigning to this attribute makes it possible to switch
|
||||||
|
between different error handling strategies during the lifetime
|
||||||
|
of the \class{IncrementalEncoder} object.
|
||||||
|
|
||||||
|
The set of allowed values for the \var{errors} argument can
|
||||||
|
be extended with \function{register_error()}.
|
||||||
|
\end{classdesc}
|
||||||
|
|
||||||
|
\begin{methoddesc}{decode}{object\optional{, final}}
|
||||||
|
Decodes \var{object} (taking the current state of the decoder into account)
|
||||||
|
and returns the resulting decoded object. If this is the last call to
|
||||||
|
\method{decode} \var{final} must be true (the default is false).
|
||||||
|
\end{methoddesc}
|
||||||
|
|
||||||
|
\begin{methoddesc}{reset}{}
|
||||||
|
Reset the decoder to the initial state.
|
||||||
|
\end{methoddesc}
|
||||||
|
|
||||||
|
|
||||||
The \class{StreamWriter} and \class{StreamReader} classes provide
|
The \class{StreamWriter} and \class{StreamReader} classes provide
|
||||||
generic working interfaces which can be used to implement new
|
generic working interfaces which can be used to implement new
|
||||||
encodings submodules very easily. See \module{encodings.utf_8} for an
|
encodings submodules very easily. See \module{encodings.utf_8} for an
|
||||||
|
|
|
@ -209,6 +209,12 @@ implemented by Richard Jones and Fred Drake.}
|
||||||
% XXX write this
|
% XXX write this
|
||||||
|
|
||||||
|
|
||||||
|
%======================================================================
|
||||||
|
\section{PEP 338: Executing Modules as Scripts}
|
||||||
|
|
||||||
|
% XXX write this
|
||||||
|
|
||||||
|
|
||||||
%======================================================================
|
%======================================================================
|
||||||
\section{PEP 341: Unified try/except/finally}
|
\section{PEP 341: Unified try/except/finally}
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,15 @@ PyAPI_FUNC(int) PyCodec_Register(
|
||||||
|
|
||||||
/* Codec register lookup API.
|
/* Codec register lookup API.
|
||||||
|
|
||||||
Looks up the given encoding and returns a tuple (encoder, decoder,
|
Looks up the given encoding and returns a CodecInfo object with
|
||||||
stream reader, stream writer) of functions which implement the
|
function attributes which implement the different aspects of
|
||||||
different aspects of processing the encoding.
|
processing the encoding.
|
||||||
|
|
||||||
The encoding string is looked up converted to all lower-case
|
The encoding string is looked up converted to all lower-case
|
||||||
characters. This makes encodings looked up through this mechanism
|
characters. This makes encodings looked up through this mechanism
|
||||||
effectively case-insensitive.
|
effectively case-insensitive.
|
||||||
|
|
||||||
If no codec is found, a KeyError is set and NULL returned.
|
If no codec is found, a KeyError is set and NULL returned.
|
||||||
|
|
||||||
As side effect, this tries to load the encodings package, if not
|
As side effect, this tries to load the encodings package, if not
|
||||||
yet done. This is part of the lazy load strategy for the encodings
|
yet done. This is part of the lazy load strategy for the encodings
|
||||||
|
@ -101,6 +101,20 @@ PyAPI_FUNC(PyObject *) PyCodec_Decoder(
|
||||||
const char *encoding
|
const char *encoding
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/* Get a IncrementalEncoder object for the given encoding. */
|
||||||
|
|
||||||
|
PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
|
||||||
|
const char *encoding,
|
||||||
|
const char *errors
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Get a IncrementalDecoder object function for the given encoding. */
|
||||||
|
|
||||||
|
PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
|
||||||
|
const char *encoding,
|
||||||
|
const char *errors
|
||||||
|
);
|
||||||
|
|
||||||
/* Get a StreamReader factory function for the given encoding. */
|
/* Get a StreamReader factory function for the given encoding. */
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
|
PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
|
||||||
|
|
|
@ -72,8 +72,7 @@ class StringIO:
|
||||||
method is called repeatedly. This method returns the next input line,
|
method is called repeatedly. This method returns the next input line,
|
||||||
or raises StopIteration when EOF is hit.
|
or raises StopIteration when EOF is hit.
|
||||||
"""
|
"""
|
||||||
if self.closed:
|
_complain_ifclosed(self.closed)
|
||||||
raise StopIteration
|
|
||||||
r = self.readline()
|
r = self.readline()
|
||||||
if not r:
|
if not r:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
183
Lib/codecs.py
183
Lib/codecs.py
|
@ -73,6 +73,23 @@ BOM64_BE = BOM_UTF32_BE
|
||||||
|
|
||||||
### Codec base classes (defining the API)
|
### Codec base classes (defining the API)
|
||||||
|
|
||||||
|
class CodecInfo(tuple):
|
||||||
|
|
||||||
|
def __new__(cls, encode, decode, streamreader=None, streamwriter=None,
|
||||||
|
incrementalencoder=None, incrementaldecoder=None, name=None):
|
||||||
|
self = tuple.__new__(cls, (encode, decode, streamreader, streamwriter))
|
||||||
|
self.name = name
|
||||||
|
self.encode = encode
|
||||||
|
self.decode = decode
|
||||||
|
self.incrementalencoder = incrementalencoder
|
||||||
|
self.incrementaldecoder = incrementaldecoder
|
||||||
|
self.streamwriter = streamwriter
|
||||||
|
self.streamreader = streamreader
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<%s.%s object for encoding %s at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, id(self))
|
||||||
|
|
||||||
class Codec:
|
class Codec:
|
||||||
|
|
||||||
""" Defines the interface for stateless encoders/decoders.
|
""" Defines the interface for stateless encoders/decoders.
|
||||||
|
@ -137,6 +154,88 @@ class Codec:
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
class IncrementalEncoder(object):
|
||||||
|
"""
|
||||||
|
A IncrementalEncoder encodes an input in multiple steps. The input can be
|
||||||
|
passed piece by piece to the encode() method. The IncrementalEncoder remembers
|
||||||
|
the state of the Encoding process between calls to encode().
|
||||||
|
"""
|
||||||
|
def __init__(self, errors='strict'):
|
||||||
|
"""
|
||||||
|
Creates a IncrementalEncoder instance.
|
||||||
|
|
||||||
|
The IncrementalEncoder may use different error handling schemes by
|
||||||
|
providing the errors keyword argument. See the module docstring
|
||||||
|
for a list of possible values.
|
||||||
|
"""
|
||||||
|
self.errors = errors
|
||||||
|
self.buffer = ""
|
||||||
|
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
"""
|
||||||
|
Encodes input and returns the resulting object.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""
|
||||||
|
Resets the encoder to the initial state.
|
||||||
|
"""
|
||||||
|
|
||||||
|
class IncrementalDecoder(object):
|
||||||
|
"""
|
||||||
|
An IncrementalDecoder decodes an input in multiple steps. The input can be
|
||||||
|
passed piece by piece to the decode() method. The IncrementalDecoder
|
||||||
|
remembers the state of the decoding process between calls to decode().
|
||||||
|
"""
|
||||||
|
def __init__(self, errors='strict'):
|
||||||
|
"""
|
||||||
|
Creates a IncrementalDecoder instance.
|
||||||
|
|
||||||
|
The IncrementalDecoder may use different error handling schemes by
|
||||||
|
providing the errors keyword argument. See the module docstring
|
||||||
|
for a list of possible values.
|
||||||
|
"""
|
||||||
|
self.errors = errors
|
||||||
|
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
"""
|
||||||
|
Decodes input and returns the resulting object.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
"""
|
||||||
|
Resets the decoder to the initial state.
|
||||||
|
"""
|
||||||
|
|
||||||
|
class BufferedIncrementalDecoder(IncrementalDecoder):
|
||||||
|
"""
|
||||||
|
This subclass of IncrementalDecoder can be used as the baseclass for an
|
||||||
|
incremental decoder if the decoder must be able to handle incomplete byte
|
||||||
|
sequences.
|
||||||
|
"""
|
||||||
|
def __init__(self, errors='strict'):
|
||||||
|
IncrementalDecoder.__init__(self, errors)
|
||||||
|
self.buffer = "" # undecoded input that is kept between calls to decode()
|
||||||
|
|
||||||
|
def _buffer_decode(self, input, errors, final):
|
||||||
|
# Overwrite this method in subclasses: It must decode input
|
||||||
|
# and return an (output, length consumed) tuple
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
# decode input (taking the buffer into account)
|
||||||
|
data = self.buffer + input
|
||||||
|
(result, consumed) = self._buffer_decode(data, self.errors, final)
|
||||||
|
# keep undecoded input until the next call
|
||||||
|
self.buffer = data[consumed:]
|
||||||
|
return result
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
IncrementalDecoder.reset(self)
|
||||||
|
self.bytebuffer = ""
|
||||||
|
|
||||||
#
|
#
|
||||||
# The StreamWriter and StreamReader class provide generic working
|
# The StreamWriter and StreamReader class provide generic working
|
||||||
# interfaces which can be used to implement new encoding submodules
|
# interfaces which can be used to implement new encoding submodules
|
||||||
|
@ -666,8 +765,8 @@ def open(filename, mode='rb', encoding=None, errors='strict', buffering=1):
|
||||||
file = __builtin__.open(filename, mode, buffering)
|
file = __builtin__.open(filename, mode, buffering)
|
||||||
if encoding is None:
|
if encoding is None:
|
||||||
return file
|
return file
|
||||||
(e, d, sr, sw) = lookup(encoding)
|
info = lookup(encoding)
|
||||||
srw = StreamReaderWriter(file, sr, sw, errors)
|
srw = StreamReaderWriter(file, info.streamreader, info.streamwriter, errors)
|
||||||
# Add attributes to simplify introspection
|
# Add attributes to simplify introspection
|
||||||
srw.encoding = encoding
|
srw.encoding = encoding
|
||||||
return srw
|
return srw
|
||||||
|
@ -699,11 +798,9 @@ def EncodedFile(file, data_encoding, file_encoding=None, errors='strict'):
|
||||||
"""
|
"""
|
||||||
if file_encoding is None:
|
if file_encoding is None:
|
||||||
file_encoding = data_encoding
|
file_encoding = data_encoding
|
||||||
encode, decode = lookup(data_encoding)[:2]
|
info = lookup(data_encoding)
|
||||||
Reader, Writer = lookup(file_encoding)[2:]
|
sr = StreamRecoder(file, info.encode, info.decode,
|
||||||
sr = StreamRecoder(file,
|
info.streamreader, info.streamwriter, errors)
|
||||||
encode, decode, Reader, Writer,
|
|
||||||
errors)
|
|
||||||
# Add attributes to simplify introspection
|
# Add attributes to simplify introspection
|
||||||
sr.data_encoding = data_encoding
|
sr.data_encoding = data_encoding
|
||||||
sr.file_encoding = file_encoding
|
sr.file_encoding = file_encoding
|
||||||
|
@ -719,7 +816,7 @@ def getencoder(encoding):
|
||||||
Raises a LookupError in case the encoding cannot be found.
|
Raises a LookupError in case the encoding cannot be found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return lookup(encoding)[0]
|
return lookup(encoding).encode
|
||||||
|
|
||||||
def getdecoder(encoding):
|
def getdecoder(encoding):
|
||||||
|
|
||||||
|
@ -729,7 +826,35 @@ def getdecoder(encoding):
|
||||||
Raises a LookupError in case the encoding cannot be found.
|
Raises a LookupError in case the encoding cannot be found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return lookup(encoding)[1]
|
return lookup(encoding).decode
|
||||||
|
|
||||||
|
def getincrementalencoder(encoding):
|
||||||
|
|
||||||
|
""" Lookup up the codec for the given encoding and return
|
||||||
|
its IncrementalEncoder class or factory function.
|
||||||
|
|
||||||
|
Raises a LookupError in case the encoding cannot be found
|
||||||
|
or the codecs doesn't provide an incremental encoder.
|
||||||
|
|
||||||
|
"""
|
||||||
|
encoder = lookup(encoding).incrementalencoder
|
||||||
|
if encoder is None:
|
||||||
|
raise LookupError(encoding)
|
||||||
|
return encoder
|
||||||
|
|
||||||
|
def getincrementaldecoder(encoding):
|
||||||
|
|
||||||
|
""" Lookup up the codec for the given encoding and return
|
||||||
|
its IncrementalDecoder class or factory function.
|
||||||
|
|
||||||
|
Raises a LookupError in case the encoding cannot be found
|
||||||
|
or the codecs doesn't provide an incremental decoder.
|
||||||
|
|
||||||
|
"""
|
||||||
|
decoder = lookup(encoding).incrementaldecoder
|
||||||
|
if decoder is None:
|
||||||
|
raise LookupError(encoding)
|
||||||
|
return decoder
|
||||||
|
|
||||||
def getreader(encoding):
|
def getreader(encoding):
|
||||||
|
|
||||||
|
@ -739,7 +864,7 @@ def getreader(encoding):
|
||||||
Raises a LookupError in case the encoding cannot be found.
|
Raises a LookupError in case the encoding cannot be found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return lookup(encoding)[2]
|
return lookup(encoding).streamreader
|
||||||
|
|
||||||
def getwriter(encoding):
|
def getwriter(encoding):
|
||||||
|
|
||||||
|
@ -749,7 +874,43 @@ def getwriter(encoding):
|
||||||
Raises a LookupError in case the encoding cannot be found.
|
Raises a LookupError in case the encoding cannot be found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return lookup(encoding)[3]
|
return lookup(encoding).streamwriter
|
||||||
|
|
||||||
|
def iterencode(iterator, encoding, errors='strict', **kwargs):
|
||||||
|
"""
|
||||||
|
Encoding iterator.
|
||||||
|
|
||||||
|
Encodes the input strings from the iterator using a IncrementalEncoder.
|
||||||
|
|
||||||
|
errors and kwargs are passed through to the IncrementalEncoder
|
||||||
|
constructor.
|
||||||
|
"""
|
||||||
|
encoder = getincrementalencoder(encoding)(errors, **kwargs)
|
||||||
|
for input in iterator:
|
||||||
|
output = encoder.encode(input)
|
||||||
|
if output:
|
||||||
|
yield output
|
||||||
|
output = encoder.encode("", True)
|
||||||
|
if output:
|
||||||
|
yield output
|
||||||
|
|
||||||
|
def iterdecode(iterator, encoding, errors='strict', **kwargs):
|
||||||
|
"""
|
||||||
|
Decoding iterator.
|
||||||
|
|
||||||
|
Decodes the input strings from the iterator using a IncrementalDecoder.
|
||||||
|
|
||||||
|
errors and kwargs are passed through to the IncrementalDecoder
|
||||||
|
constructor.
|
||||||
|
"""
|
||||||
|
decoder = getincrementaldecoder(encoding)(errors, **kwargs)
|
||||||
|
for input in iterator:
|
||||||
|
output = decoder.decode(input)
|
||||||
|
if output:
|
||||||
|
yield output
|
||||||
|
output = decoder.decode("", True)
|
||||||
|
if output:
|
||||||
|
yield output
|
||||||
|
|
||||||
### Helpers for charmap-based codecs
|
### Helpers for charmap-based codecs
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,10 @@
|
||||||
|
|
||||||
Each codec module must export the following interface:
|
Each codec module must export the following interface:
|
||||||
|
|
||||||
* getregentry() -> (encoder, decoder, stream_reader, stream_writer)
|
* getregentry() -> codecs.CodecInfo object
|
||||||
The getregentry() API must return callable objects which adhere to
|
The getregentry() API must a CodecInfo object with encoder, decoder,
|
||||||
the Python Codec Interface Standard.
|
incrementalencoder, incrementaldecoder, streamwriter and streamreader
|
||||||
|
atttributes which adhere to the Python Codec Interface Standard.
|
||||||
|
|
||||||
In addition, a module may optionally also define the following
|
In addition, a module may optionally also define the following
|
||||||
APIs which are then used by the package's codec search function:
|
APIs which are then used by the package's codec search function:
|
||||||
|
@ -113,16 +114,24 @@ def search_function(encoding):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Now ask the module for the registry entry
|
# Now ask the module for the registry entry
|
||||||
entry = tuple(getregentry())
|
entry = getregentry()
|
||||||
if len(entry) != 4:
|
if not isinstance(entry, codecs.CodecInfo):
|
||||||
raise CodecRegistryError,\
|
if not 4 <= len(entry) <= 7:
|
||||||
'module "%s" (%s) failed to register' % \
|
|
||||||
(mod.__name__, mod.__file__)
|
|
||||||
for obj in entry:
|
|
||||||
if not callable(obj):
|
|
||||||
raise CodecRegistryError,\
|
raise CodecRegistryError,\
|
||||||
'incompatible codecs in module "%s" (%s)' % \
|
'module "%s" (%s) failed to register' % \
|
||||||
(mod.__name__, mod.__file__)
|
(mod.__name__, mod.__file__)
|
||||||
|
if not callable(entry[0]) or \
|
||||||
|
not callable(entry[1]) or \
|
||||||
|
(entry[2] is not None and not callable(entry[2])) or \
|
||||||
|
(entry[3] is not None and not callable(entry[3])) or \
|
||||||
|
(len(entry) > 4 and entry[4] is not None and not callable(entry[4])) or \
|
||||||
|
(len(entry) > 5 and entry[5] is not None and not callable(entry[5])):
|
||||||
|
raise CodecRegistryError,\
|
||||||
|
'incompatible codecs in module "%s" (%s)' % \
|
||||||
|
(mod.__name__, mod.__file__)
|
||||||
|
if len(entry)<7 or entry[6] is None:
|
||||||
|
entry += (None,)*(6-len(entry)) + (mod.__name__.split(".", 1)[1],)
|
||||||
|
entry = codecs.CodecInfo(*entry)
|
||||||
|
|
||||||
# Cache the codec registry entry
|
# Cache the codec registry entry
|
||||||
_cache[encoding] = entry
|
_cache[encoding] = entry
|
||||||
|
|
|
@ -17,6 +17,14 @@ class Codec(codecs.Codec):
|
||||||
encode = codecs.ascii_encode
|
encode = codecs.ascii_encode
|
||||||
decode = codecs.ascii_decode
|
decode = codecs.ascii_decode
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.ascii_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.ascii_decode(input, self.errors)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -31,5 +39,12 @@ class StreamConverter(StreamWriter,StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
|
name='ascii',
|
||||||
|
encode=Codec.encode,
|
||||||
|
decode=Codec.decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -49,6 +49,16 @@ class Codec(codecs.Codec):
|
||||||
def decode(self, input,errors='strict'):
|
def decode(self, input,errors='strict'):
|
||||||
return base64_decode(input,errors)
|
return base64_decode(input,errors)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
assert self.errors == 'strict'
|
||||||
|
return base64.encodestring(input)
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
assert self.errors == 'strict'
|
||||||
|
return base64.decodestring(input)
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -58,5 +68,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (base64_encode,base64_decode,StreamReader,StreamWriter)
|
name='base64',
|
||||||
|
encode=base64_encode,
|
||||||
|
decode=base64_decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -51,6 +51,16 @@ class Codec(codecs.Codec):
|
||||||
def decode(self, input, errors='strict'):
|
def decode(self, input, errors='strict'):
|
||||||
return bz2_decode(input, errors)
|
return bz2_decode(input, errors)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
assert self.errors == 'strict'
|
||||||
|
return bz2.compress(input)
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
assert self.errors == 'strict'
|
||||||
|
return bz2.decompress(input)
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -60,5 +70,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (bz2_encode,bz2_decode,StreamReader,StreamWriter)
|
name="bz2",
|
||||||
|
encode=bz2_encode,
|
||||||
|
decode=bz2_decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -21,30 +21,49 @@ class Codec(codecs.Codec):
|
||||||
encode = codecs.charmap_encode
|
encode = codecs.charmap_encode
|
||||||
decode = codecs.charmap_decode
|
decode = codecs.charmap_decode
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def __init__(self, errors='strict', mapping=None):
|
||||||
|
codecs.IncrementalEncoder.__init__(self, errors)
|
||||||
|
self.mapping = mapping
|
||||||
|
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input, self.errors, self.mapping)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def __init__(self, errors='strict', mapping=None):
|
||||||
|
codecs.IncrementalDecoder.__init__(self, errors)
|
||||||
|
self.mapping = mapping
|
||||||
|
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input, self.errors, self.mapping)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
|
|
||||||
def __init__(self,stream,errors='strict',mapping=None):
|
def __init__(self,stream,errors='strict',mapping=None):
|
||||||
|
|
||||||
codecs.StreamWriter.__init__(self,stream,errors)
|
codecs.StreamWriter.__init__(self,stream,errors)
|
||||||
self.mapping = mapping
|
self.mapping = mapping
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return Codec.encode(input,errors,self.mapping)
|
return Codec.encode(input,errors,self.mapping)
|
||||||
|
|
||||||
class StreamReader(Codec,codecs.StreamReader):
|
class StreamReader(Codec,codecs.StreamReader):
|
||||||
|
|
||||||
def __init__(self,stream,errors='strict',mapping=None):
|
def __init__(self,stream,errors='strict',mapping=None):
|
||||||
|
|
||||||
codecs.StreamReader.__init__(self,stream,errors)
|
codecs.StreamReader.__init__(self,stream,errors)
|
||||||
self.mapping = mapping
|
self.mapping = mapping
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return Codec.decode(input,errors,self.mapping)
|
return Codec.decode(input,errors,self.mapping)
|
||||||
|
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
|
name='charmap',
|
||||||
|
encode=Codec.encode,
|
||||||
|
decode=Codec.decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP037.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp037 generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP037.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp037',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MISC/CP1006.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1006 generated from 'MAPPINGS/VENDORS/MISC/CP1006.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1006',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP1026.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1026 generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP1026.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1026',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'python-mappings/CP1140.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1140 generated from 'python-mappings/CP1140.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1140',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1250 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1250',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1251 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1251',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1252 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1252',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1253.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1253 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1253.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1253',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1254.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1254 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1254.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1254',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1255 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1255',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1256 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1256',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1257.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1257 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1257.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1257',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1258.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp1258 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1258.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp1258',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MISC/CP424.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp424 generated from 'MAPPINGS/VENDORS/MISC/CP424.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp424',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'VENDORS/MICSFT/PC/CP437.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp437 generated from 'VENDORS/MICSFT/PC/CP437.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp437',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP500.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp500 generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP500.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp500',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'VENDORS/MICSFT/PC/CP737.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp737 generated from 'VENDORS/MICSFT/PC/CP737.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp737',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'VENDORS/MICSFT/PC/CP775.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp775 generated from 'VENDORS/MICSFT/PC/CP775.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,9 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp775',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
decoding_map = codecs.make_identity_dict(range(256))
|
decoding_map = codecs.make_identity_dict(range(256))
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp850',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp852',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp855',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MISC/CP856.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp856 generated from 'MAPPINGS/VENDORS/MISC/CP856.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp856',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp857',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp860',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp861',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp862',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp863',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp864',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp865',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp866',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp869',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP874.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp874 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP874.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp874',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP875.TXT' with gencodec.py.
|
""" Python Character Mapping Codec cp875 generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP875.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='cp875',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -49,6 +49,16 @@ class Codec(codecs.Codec):
|
||||||
def decode(self, input,errors='strict'):
|
def decode(self, input,errors='strict'):
|
||||||
return hex_decode(input,errors)
|
return hex_decode(input,errors)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
assert self.errors == 'strict'
|
||||||
|
return binascii.b2a_hex(input)
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
assert self.errors == 'strict'
|
||||||
|
return binascii.a2b_hex(input)
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -58,5 +68,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (hex_encode,hex_decode,StreamReader,StreamWriter)
|
name='hex',
|
||||||
|
encode=hex_encode,
|
||||||
|
decode=hex_decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -14,13 +14,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_map)
|
return codecs.charmap_decode(input,errors,decoding_map)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_map)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -30,8 +36,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='hp-roman8',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -194,6 +194,14 @@ class Codec(codecs.Codec):
|
||||||
|
|
||||||
return u".".join(result)+trailing_dot, len(input)
|
return u".".join(result)+trailing_dot, len(input)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return Codec().encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return Codec().decode(input, self.errors)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -203,5 +211,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='idna',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-1.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_1 generated from 'MAPPINGS/ISO8859/8859-1.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-1',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-10.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_10 generated from 'MAPPINGS/ISO8859/8859-10.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-10',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-11.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_11 generated from 'MAPPINGS/ISO8859/8859-11.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-11',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-13.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_13 generated from 'MAPPINGS/ISO8859/8859-13.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-13',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-14.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_14 generated from 'MAPPINGS/ISO8859/8859-14.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-14',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-15.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_15 generated from 'MAPPINGS/ISO8859/8859-15.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-15',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-16.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_16 generated from 'MAPPINGS/ISO8859/8859-16.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-16',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-2.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_2 generated from 'MAPPINGS/ISO8859/8859-2.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-2',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-3.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_3 generated from 'MAPPINGS/ISO8859/8859-3.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-3',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-4.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_4 generated from 'MAPPINGS/ISO8859/8859-4.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-4',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-5.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_5 generated from 'MAPPINGS/ISO8859/8859-5.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-5',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-6.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_6 generated from 'MAPPINGS/ISO8859/8859-6.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-6',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-7.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_7 generated from 'MAPPINGS/ISO8859/8859-7.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-7',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-8.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_8 generated from 'MAPPINGS/ISO8859/8859-8.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-8',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-9.TXT' with gencodec.py.
|
""" Python Character Mapping Codec iso8859_9 generated from 'MAPPINGS/ISO8859/8859-9.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='iso8859-9',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MISC/KOI8-R.TXT' with gencodec.py.
|
""" Python Character Mapping Codec koi8_r generated from 'MAPPINGS/VENDORS/MISC/KOI8-R.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='koi8-r',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'python-mappings/KOI8-U.TXT' with gencodec.py.
|
""" Python Character Mapping Codec koi8_u generated from 'python-mappings/KOI8-U.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='koi8-u',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -17,6 +17,14 @@ class Codec(codecs.Codec):
|
||||||
encode = codecs.latin_1_encode
|
encode = codecs.latin_1_encode
|
||||||
decode = codecs.latin_1_decode
|
decode = codecs.latin_1_decode
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.latin_1_encode(input,self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.latin_1_decode(input,self.errors)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -31,5 +39,12 @@ class StreamConverter(StreamWriter,StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
|
name='iso8859-1',
|
||||||
|
encode=Codec.encode,
|
||||||
|
decode=Codec.decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-arabic',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/CENTEURO.TXT' with gencodec.py.
|
""" Python Character Mapping Codec mac_centeuro generated from 'MAPPINGS/VENDORS/APPLE/CENTEURO.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-centeuro',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/CROATIAN.TXT' with gencodec.py.
|
""" Python Character Mapping Codec mac_croatian generated from 'MAPPINGS/VENDORS/APPLE/CROATIAN.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-croatian',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/CYRILLIC.TXT' with gencodec.py.
|
""" Python Character Mapping Codec mac_cyrillic generated from 'MAPPINGS/VENDORS/APPLE/CYRILLIC.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-cyrillic',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/FARSI.TXT' with gencodec.py.
|
""" Python Character Mapping Codec mac_farsi generated from 'MAPPINGS/VENDORS/APPLE/FARSI.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-farsi',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/GREEK.TXT' with gencodec.py.
|
""" Python Character Mapping Codec mac_greek generated from 'MAPPINGS/VENDORS/APPLE/GREEK.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-greek',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/ICELAND.TXT' with gencodec.py.
|
""" Python Character Mapping Codec mac_iceland generated from 'MAPPINGS/VENDORS/APPLE/ICELAND.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-iceland',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -14,13 +14,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_map)
|
return codecs.charmap_decode(input,errors,decoding_map)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_map)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -30,8 +36,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-latin2',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/ROMAN.TXT' with gencodec.py.
|
""" Python Character Mapping Codec mac_roman generated from 'MAPPINGS/VENDORS/APPLE/ROMAN.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-roman',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/ROMANIAN.TXT' with gencodec.py.
|
""" Python Character Mapping Codec mac_romanian generated from 'MAPPINGS/VENDORS/APPLE/ROMANIAN.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-romanian',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/TURKISH.TXT' with gencodec.py.
|
""" Python Character Mapping Codec mac_turkish generated from 'MAPPINGS/VENDORS/APPLE/TURKISH.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='mac-turkish',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -18,6 +18,13 @@ class Codec(codecs.Codec):
|
||||||
encode = codecs.mbcs_encode
|
encode = codecs.mbcs_encode
|
||||||
decode = codecs.mbcs_decode
|
decode = codecs.mbcs_decode
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.mbcs_encode(input,self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.mbcs_decode(input,self.errors)[0]
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -32,5 +39,12 @@ class StreamConverter(StreamWriter,StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
|
name='mbcs',
|
||||||
|
encode=Codec.encode,
|
||||||
|
decode=Codec.decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -15,6 +15,14 @@ class Codec(codecs.Codec):
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
return codecs.charmap_decode(input,errors,decoding_map)
|
return codecs.charmap_decode(input,errors,decoding_map)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_map)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -24,7 +32,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
return codecs.CodecInfo(
|
||||||
|
name='palmos',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_map)
|
return codecs.charmap_decode(input,errors,decoding_map)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_map)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -30,8 +36,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='ptcp154',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -197,18 +197,27 @@ def punycode_decode(text, errors):
|
||||||
### Codec APIs
|
### Codec APIs
|
||||||
|
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
def encode(self,input,errors='strict'):
|
|
||||||
|
|
||||||
|
def encode(self,input,errors='strict'):
|
||||||
res = punycode_encode(input)
|
res = punycode_encode(input)
|
||||||
return res, len(input)
|
return res, len(input)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
if errors not in ('strict', 'replace', 'ignore'):
|
if errors not in ('strict', 'replace', 'ignore'):
|
||||||
raise UnicodeError, "Unsupported error handling "+errors
|
raise UnicodeError, "Unsupported error handling "+errors
|
||||||
res = punycode_decode(input, errors)
|
res = punycode_decode(input, errors)
|
||||||
return res, len(input)
|
return res, len(input)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return punycode_encode(input)
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
if errors not in ('strict', 'replace', 'ignore'):
|
||||||
|
raise UnicodeError, "Unsupported error handling "+errors
|
||||||
|
return punycode_decode(input, errors)
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -218,5 +227,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='punycode',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -46,6 +46,14 @@ class Codec(codecs.Codec):
|
||||||
def decode(self, input,errors='strict'):
|
def decode(self, input,errors='strict'):
|
||||||
return quopri_decode(input,errors)
|
return quopri_decode(input,errors)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return quopri_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return quopri_decode(input, self.errors)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec, codecs.StreamWriter):
|
class StreamWriter(Codec, codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -55,4 +63,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
# encodings module API
|
# encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
return (quopri_encode, quopri_decode, StreamReader, StreamWriter)
|
return codecs.CodecInfo(
|
||||||
|
name='quopri',
|
||||||
|
encode=quopri_encode,
|
||||||
|
decode=quopri_decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -17,6 +17,14 @@ class Codec(codecs.Codec):
|
||||||
encode = codecs.raw_unicode_escape_encode
|
encode = codecs.raw_unicode_escape_encode
|
||||||
decode = codecs.raw_unicode_escape_decode
|
decode = codecs.raw_unicode_escape_decode
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.raw_unicode_escape_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.raw_unicode_escape_decode(input, self.errors)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -26,5 +34,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
|
name='raw-unicode-escape',
|
||||||
|
encode=Codec.encode,
|
||||||
|
decode=Codec.decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -14,13 +14,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_map)
|
return codecs.charmap_decode(input,errors,decoding_map)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_map)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -30,8 +36,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='rot-13',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
||||||
### Decoding Map
|
### Decoding Map
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,14 @@ class Codec(codecs.Codec):
|
||||||
encode = codecs.escape_encode
|
encode = codecs.escape_encode
|
||||||
decode = codecs.escape_decode
|
decode = codecs.escape_decode
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.escape_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.escape_decode(input, self.errors)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -19,5 +27,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
|
name='string-escape',
|
||||||
|
encode=Codec.encode,
|
||||||
|
decode=Codec.decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" Python Character Mapping Codec generated from 'python-mappings/TIS-620.TXT' with gencodec.py.
|
""" Python Character Mapping Codec tis_620 generated from 'python-mappings/TIS-620.TXT' with gencodec.py.
|
||||||
|
|
||||||
"""#"
|
"""#"
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_encode(input,errors,encoding_map)
|
return codecs.charmap_encode(input,errors,encoding_map)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
|
|
||||||
return codecs.charmap_decode(input,errors,decoding_table)
|
return codecs.charmap_decode(input,errors,decoding_table)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='tis-620',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
### Decoding Table
|
### Decoding Table
|
||||||
|
|
|
@ -16,10 +16,18 @@ import codecs
|
||||||
class Codec(codecs.Codec):
|
class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
raise UnicodeError, "undefined encoding"
|
raise UnicodeError("undefined encoding")
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
raise UnicodeError, "undefined encoding"
|
raise UnicodeError("undefined encoding")
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
raise UnicodeError("undefined encoding")
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
raise UnicodeError("undefined encoding")
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
@ -30,5 +38,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
|
name='undefined',
|
||||||
|
encode=Codec().encode,
|
||||||
|
decode=Codec().decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -17,6 +17,14 @@ class Codec(codecs.Codec):
|
||||||
encode = codecs.unicode_escape_encode
|
encode = codecs.unicode_escape_encode
|
||||||
decode = codecs.unicode_escape_decode
|
decode = codecs.unicode_escape_decode
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.unicode_escape_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.unicode_escape_decode(input, self.errors)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -26,5 +34,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
|
name='unicode-escape',
|
||||||
|
encode=Codec.encode,
|
||||||
|
decode=Codec.decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -17,6 +17,14 @@ class Codec(codecs.Codec):
|
||||||
encode = codecs.unicode_internal_encode
|
encode = codecs.unicode_internal_encode
|
||||||
decode = codecs.unicode_internal_decode
|
decode = codecs.unicode_internal_decode
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.unicode_internal_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return codecs.unicode_internal_decode(input, self.errors)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -26,5 +34,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
|
name='unicode-internal',
|
||||||
|
encode=Codec.encode,
|
||||||
|
decode=Codec.decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
)
|
||||||
|
|
|
@ -15,6 +15,47 @@ encode = codecs.utf_16_encode
|
||||||
def decode(input, errors='strict'):
|
def decode(input, errors='strict'):
|
||||||
return codecs.utf_16_decode(input, errors, True)
|
return codecs.utf_16_decode(input, errors, True)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def __init__(self, errors='strict'):
|
||||||
|
codecs.IncrementalEncoder.__init__(self, errors)
|
||||||
|
self.encoder = None
|
||||||
|
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
if self.encoder is None:
|
||||||
|
result = codecs.utf_16_encode(input, self.errors)[0]
|
||||||
|
if sys.byteorder == 'little':
|
||||||
|
self.encoder = codecs.utf_16_le_encode
|
||||||
|
else:
|
||||||
|
self.encoder = codecs.utf_16_be_encode
|
||||||
|
return result
|
||||||
|
return self.encoder(input, self.errors)[0]
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
codecs.IncrementalEncoder.reset(self)
|
||||||
|
self.encoder = None
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
|
||||||
|
def __init__(self, errors='strict'):
|
||||||
|
codecs.BufferedIncrementalDecoder.__init__(self, errors)
|
||||||
|
self.decoder = None
|
||||||
|
|
||||||
|
def _buffer_decode(self, input, errors, final):
|
||||||
|
if self.decoder is None:
|
||||||
|
(output, consumed, byteorder) = \
|
||||||
|
codecs.utf_16_ex_decode(input, errors, 0, final)
|
||||||
|
if byteorder == -1:
|
||||||
|
self.decoder = codecs.utf_16_le_decode
|
||||||
|
elif byteorder == 1:
|
||||||
|
self.decoder = codecs.utf_16_be_decode
|
||||||
|
elif consumed >= 2:
|
||||||
|
raise UnicodeError("UTF-16 stream does not start with BOM")
|
||||||
|
return (output, consumed)
|
||||||
|
return self.decoder(input, self.errors, final)
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
codecs.BufferedIncrementalDecoder.reset(self)
|
||||||
|
self.decoder = None
|
||||||
|
|
||||||
class StreamWriter(codecs.StreamWriter):
|
class StreamWriter(codecs.StreamWriter):
|
||||||
def __init__(self, stream, errors='strict'):
|
def __init__(self, stream, errors='strict'):
|
||||||
self.bom_written = False
|
self.bom_written = False
|
||||||
|
@ -52,5 +93,12 @@ class StreamReader(codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (encode,decode,StreamReader,StreamWriter)
|
name='utf-16',
|
||||||
|
encode=encode,
|
||||||
|
decode=decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -15,6 +15,13 @@ encode = codecs.utf_16_be_encode
|
||||||
def decode(input, errors='strict'):
|
def decode(input, errors='strict'):
|
||||||
return codecs.utf_16_be_decode(input, errors, True)
|
return codecs.utf_16_be_decode(input, errors, True)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.utf_16_be_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
|
||||||
|
_buffer_decode = codecs.utf_16_be_decode
|
||||||
|
|
||||||
class StreamWriter(codecs.StreamWriter):
|
class StreamWriter(codecs.StreamWriter):
|
||||||
encode = codecs.utf_16_be_encode
|
encode = codecs.utf_16_be_encode
|
||||||
|
|
||||||
|
@ -24,5 +31,12 @@ class StreamReader(codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (encode,decode,StreamReader,StreamWriter)
|
name='utf-16-be',
|
||||||
|
encode=encode,
|
||||||
|
decode=decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -15,15 +15,28 @@ encode = codecs.utf_16_le_encode
|
||||||
def decode(input, errors='strict'):
|
def decode(input, errors='strict'):
|
||||||
return codecs.utf_16_le_decode(input, errors, True)
|
return codecs.utf_16_le_decode(input, errors, True)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.utf_16_le_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
|
||||||
|
_buffer_decode = codecs.utf_16_le_decode
|
||||||
|
|
||||||
class StreamWriter(codecs.StreamWriter):
|
class StreamWriter(codecs.StreamWriter):
|
||||||
encode = codecs.utf_16_le_encode
|
encode = codecs.utf_16_le_encode
|
||||||
|
|
||||||
class StreamReader(codecs.StreamReader):
|
class StreamReader(codecs.StreamReader):
|
||||||
decode = codecs.utf_16_le_decode
|
decode = codecs.utf_16_le_decode
|
||||||
|
|
||||||
|
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (encode,decode,StreamReader,StreamWriter)
|
name='utf-16-le',
|
||||||
|
encode=encode,
|
||||||
|
decode=decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -13,6 +13,14 @@ class Codec(codecs.Codec):
|
||||||
encode = codecs.utf_7_encode
|
encode = codecs.utf_7_encode
|
||||||
decode = codecs.utf_7_decode
|
decode = codecs.utf_7_decode
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.utf_7_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
|
||||||
|
def _buffer_decode(self, input, errors, final):
|
||||||
|
return codecs.utf_7_decode(input, self.errors)
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -22,5 +30,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
|
name='utf-7',
|
||||||
|
encode=Codec.encode,
|
||||||
|
decode=Codec.decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -15,6 +15,13 @@ encode = codecs.utf_8_encode
|
||||||
def decode(input, errors='strict'):
|
def decode(input, errors='strict'):
|
||||||
return codecs.utf_8_decode(input, errors, True)
|
return codecs.utf_8_decode(input, errors, True)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return codecs.utf_8_encode(input, self.errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
|
||||||
|
_buffer_decode = codecs.utf_8_decode
|
||||||
|
|
||||||
class StreamWriter(codecs.StreamWriter):
|
class StreamWriter(codecs.StreamWriter):
|
||||||
encode = codecs.utf_8_encode
|
encode = codecs.utf_8_encode
|
||||||
|
|
||||||
|
@ -24,5 +31,12 @@ class StreamReader(codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (encode,decode,StreamReader,StreamWriter)
|
name='utf-8',
|
||||||
|
encode=encode,
|
||||||
|
decode=decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -22,6 +22,42 @@ def decode(input, errors='strict'):
|
||||||
(output, consumed) = codecs.utf_8_decode(input, errors, True)
|
(output, consumed) = codecs.utf_8_decode(input, errors, True)
|
||||||
return (output, consumed+prefix)
|
return (output, consumed+prefix)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def __init__(self, errors='strict'):
|
||||||
|
codecs.IncrementalEncoder.__init__(self, errors)
|
||||||
|
self.first = True
|
||||||
|
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
if self.first:
|
||||||
|
self.first = False
|
||||||
|
return codecs.BOM_UTF8 + codecs.utf_8_encode(input, errors)[0]
|
||||||
|
else:
|
||||||
|
return codecs.utf_8_encode(input, errors)[0]
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
codecs.IncrementalEncoder.reset(self)
|
||||||
|
self.first = True
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
|
||||||
|
def __init__(self, errors='strict'):
|
||||||
|
codecs.BufferedIncrementalDecoder.__init__(self, errors)
|
||||||
|
self.first = True
|
||||||
|
|
||||||
|
def _buffer_decode(self, input, errors, final):
|
||||||
|
if self.first and codecs.BOM_UTF8.startswith(input): # might be a BOM
|
||||||
|
if len(input) < 3:
|
||||||
|
# not enough data to decide if this really is a BOM
|
||||||
|
# => try again on the next call
|
||||||
|
return (u"", 0)
|
||||||
|
(output, consumed) = codecs.utf_8_decode(input[3:], errors, final)
|
||||||
|
self.first = False
|
||||||
|
return (output, consumed+3)
|
||||||
|
return codecs.utf_8_decode(input, errors, final)
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
codecs.BufferedIncrementalDecoder.reset(self)
|
||||||
|
self.first = True
|
||||||
|
|
||||||
class StreamWriter(codecs.StreamWriter):
|
class StreamWriter(codecs.StreamWriter):
|
||||||
def reset(self):
|
def reset(self):
|
||||||
codecs.StreamWriter.reset(self)
|
codecs.StreamWriter.reset(self)
|
||||||
|
@ -53,5 +89,12 @@ class StreamReader(codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (encode,decode,StreamReader,StreamWriter)
|
name='utf-8-sig',
|
||||||
|
encode=encode,
|
||||||
|
decode=decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -96,9 +96,18 @@ class Codec(codecs.Codec):
|
||||||
|
|
||||||
def encode(self,input,errors='strict'):
|
def encode(self,input,errors='strict'):
|
||||||
return uu_encode(input,errors)
|
return uu_encode(input,errors)
|
||||||
|
|
||||||
def decode(self,input,errors='strict'):
|
def decode(self,input,errors='strict'):
|
||||||
return uu_decode(input,errors)
|
return uu_decode(input,errors)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
return uu_encode(input, errors)[0]
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
return uu_decode(input, errors)[0]
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -108,5 +117,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (uu_encode,uu_decode,StreamReader,StreamWriter)
|
name='uu',
|
||||||
|
encode=uu_encode,
|
||||||
|
decode=uu_decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -50,6 +50,16 @@ class Codec(codecs.Codec):
|
||||||
def decode(self, input, errors='strict'):
|
def decode(self, input, errors='strict'):
|
||||||
return zlib_decode(input, errors)
|
return zlib_decode(input, errors)
|
||||||
|
|
||||||
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||||
|
def encode(self, input, final=False):
|
||||||
|
assert self.errors == 'strict'
|
||||||
|
return zlib.compress(input)
|
||||||
|
|
||||||
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||||
|
def decode(self, input, final=False):
|
||||||
|
assert self.errors == 'strict'
|
||||||
|
return zlib.decompress(input)
|
||||||
|
|
||||||
class StreamWriter(Codec,codecs.StreamWriter):
|
class StreamWriter(Codec,codecs.StreamWriter):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -59,5 +69,12 @@ class StreamReader(Codec,codecs.StreamReader):
|
||||||
### encodings module API
|
### encodings module API
|
||||||
|
|
||||||
def getregentry():
|
def getregentry():
|
||||||
|
return codecs.CodecInfo(
|
||||||
return (zlib_encode,zlib_decode,StreamReader,StreamWriter)
|
name='zlib',
|
||||||
|
encode=zlib_encode,
|
||||||
|
decode=zlib_decode,
|
||||||
|
incrementalencoder=IncrementalEncoder,
|
||||||
|
incrementaldecoder=IncrementalDecoder,
|
||||||
|
streamreader=StreamReader,
|
||||||
|
streamwriter=StreamWriter,
|
||||||
|
)
|
||||||
|
|
|
@ -1058,13 +1058,16 @@ class Logger(Filterer):
|
||||||
file name, line number and function name.
|
file name, line number and function name.
|
||||||
"""
|
"""
|
||||||
f = currentframe().f_back
|
f = currentframe().f_back
|
||||||
while 1:
|
rv = "(unknown file)", 0, "(unknown function)"
|
||||||
|
while hasattr(f, "f_code"):
|
||||||
co = f.f_code
|
co = f.f_code
|
||||||
filename = os.path.normcase(co.co_filename)
|
filename = os.path.normcase(co.co_filename)
|
||||||
if filename == _srcfile:
|
if filename == _srcfile:
|
||||||
f = f.f_back
|
f = f.f_back
|
||||||
continue
|
continue
|
||||||
return filename, f.f_lineno, co.co_name
|
rv = (filename, f.f_lineno, co.co_name)
|
||||||
|
break
|
||||||
|
return rv
|
||||||
|
|
||||||
def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None):
|
def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -0,0 +1,431 @@
|
||||||
|
"""runpy.py - locating and running Python code using the module namespace
|
||||||
|
|
||||||
|
Provides support for locating and running Python scripts using the Python
|
||||||
|
module namespace instead of the native filesystem.
|
||||||
|
|
||||||
|
This allows Python code to play nicely with non-filesystem based PEP 302
|
||||||
|
importers when locating support scripts as well as when importing modules.
|
||||||
|
"""
|
||||||
|
# Written by Nick Coghlan <ncoghlan at gmail.com>
|
||||||
|
# to implement PEP 338 (Executing Modules as Scripts)
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import imp
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"run_module",
|
||||||
|
]
|
||||||
|
|
||||||
|
try:
|
||||||
|
_get_loader = imp.get_loader
|
||||||
|
except AttributeError:
|
||||||
|
# get_loader() is not provided by the imp module, so emulate it
|
||||||
|
# as best we can using the PEP 302 import machinery exposed since
|
||||||
|
# Python 2.3. The emulation isn't perfect, but the differences
|
||||||
|
# in the way names are shadowed shouldn't matter in practice.
|
||||||
|
import os.path
|
||||||
|
import marshal # Handle compiled Python files
|
||||||
|
|
||||||
|
# This helper is needed in order for the PEP 302 emulation to
|
||||||
|
# correctly handle compiled files
|
||||||
|
def _read_compiled_file(compiled_file):
|
||||||
|
magic = compiled_file.read(4)
|
||||||
|
if magic != imp.get_magic():
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
compiled_file.read(4) # Skip timestamp
|
||||||
|
return marshal.load(compiled_file)
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
|
class _AbsoluteImporter(object):
|
||||||
|
"""PEP 302 importer wrapper for top level import machinery"""
|
||||||
|
def find_module(self, mod_name, path=None):
|
||||||
|
if path is not None:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
file, filename, mod_info = imp.find_module(mod_name)
|
||||||
|
except ImportError:
|
||||||
|
return None
|
||||||
|
suffix, mode, mod_type = mod_info
|
||||||
|
if mod_type == imp.PY_SOURCE:
|
||||||
|
loader = _SourceFileLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
elif mod_type == imp.PY_COMPILED:
|
||||||
|
loader = _CompiledFileLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
elif mod_type == imp.PKG_DIRECTORY:
|
||||||
|
loader = _PackageDirLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
elif mod_type == imp.C_EXTENSION:
|
||||||
|
loader = _FileSystemLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
else:
|
||||||
|
loader = _BasicLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
return loader
|
||||||
|
|
||||||
|
|
||||||
|
class _FileSystemImporter(object):
|
||||||
|
"""PEP 302 importer wrapper for filesystem based imports"""
|
||||||
|
def __init__(self, path_item=None):
|
||||||
|
if path_item is not None:
|
||||||
|
if path_item != '' and not os.path.isdir(path_item):
|
||||||
|
raise ImportError("%s is not a directory" % path_item)
|
||||||
|
self.path_dir = path_item
|
||||||
|
else:
|
||||||
|
raise ImportError("Filesystem importer requires "
|
||||||
|
"a directory name")
|
||||||
|
|
||||||
|
def find_module(self, mod_name, path=None):
|
||||||
|
if path is not None:
|
||||||
|
return None
|
||||||
|
path_dir = self.path_dir
|
||||||
|
if path_dir == '':
|
||||||
|
path_dir = os.getcwd()
|
||||||
|
sub_name = mod_name.rsplit(".", 1)[-1]
|
||||||
|
try:
|
||||||
|
file, filename, mod_info = imp.find_module(sub_name,
|
||||||
|
[path_dir])
|
||||||
|
except ImportError:
|
||||||
|
return None
|
||||||
|
if not filename.startswith(path_dir):
|
||||||
|
return None
|
||||||
|
suffix, mode, mod_type = mod_info
|
||||||
|
if mod_type == imp.PY_SOURCE:
|
||||||
|
loader = _SourceFileLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
elif mod_type == imp.PY_COMPILED:
|
||||||
|
loader = _CompiledFileLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
elif mod_type == imp.PKG_DIRECTORY:
|
||||||
|
loader = _PackageDirLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
elif mod_type == imp.C_EXTENSION:
|
||||||
|
loader = _FileSystemLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
else:
|
||||||
|
loader = _BasicLoader(mod_name, file,
|
||||||
|
filename, mod_info)
|
||||||
|
return loader
|
||||||
|
|
||||||
|
|
||||||
|
class _BasicLoader(object):
|
||||||
|
"""PEP 302 loader wrapper for top level import machinery"""
|
||||||
|
def __init__(self, mod_name, file, filename, mod_info):
|
||||||
|
self.mod_name = mod_name
|
||||||
|
self.file = file
|
||||||
|
self.filename = filename
|
||||||
|
self.mod_info = mod_info
|
||||||
|
|
||||||
|
def _fix_name(self, mod_name):
|
||||||
|
if mod_name is None:
|
||||||
|
mod_name = self.mod_name
|
||||||
|
elif mod_name != self.mod_name:
|
||||||
|
raise ImportError("Loader for module %s cannot handle "
|
||||||
|
"module %s" % (self.mod_name, mod_name))
|
||||||
|
return mod_name
|
||||||
|
|
||||||
|
def load_module(self, mod_name=None):
|
||||||
|
mod_name = self._fix_name(mod_name)
|
||||||
|
mod = imp.load_module(mod_name, self.file,
|
||||||
|
self.filename, self.mod_info)
|
||||||
|
mod.__loader__ = self # for introspection
|
||||||
|
return mod
|
||||||
|
|
||||||
|
def get_code(self, mod_name=None):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_source(self, mod_name=None):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def is_package(self, mod_name=None):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self.file:
|
||||||
|
self.file.close()
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
|
class _FileSystemLoader(_BasicLoader):
|
||||||
|
"""PEP 302 loader wrapper for filesystem based imports"""
|
||||||
|
def get_code(self, mod_name=None):
|
||||||
|
mod_name = self._fix_name(mod_name)
|
||||||
|
return self._get_code(mod_name)
|
||||||
|
|
||||||
|
def get_data(self, pathname):
|
||||||
|
return open(pathname, "rb").read()
|
||||||
|
|
||||||
|
def get_filename(self, mod_name=None):
|
||||||
|
mod_name = self._fix_name(mod_name)
|
||||||
|
return self._get_filename(mod_name)
|
||||||
|
|
||||||
|
def get_source(self, mod_name=None):
|
||||||
|
mod_name = self._fix_name(mod_name)
|
||||||
|
return self._get_source(mod_name)
|
||||||
|
|
||||||
|
def is_package(self, mod_name=None):
|
||||||
|
mod_name = self._fix_name(mod_name)
|
||||||
|
return self._is_package(mod_name)
|
||||||
|
|
||||||
|
def _get_code(self, mod_name):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _get_filename(self, mod_name):
|
||||||
|
return self.filename
|
||||||
|
|
||||||
|
def _get_source(self, mod_name):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _is_package(self, mod_name):
|
||||||
|
return False
|
||||||
|
|
||||||
|
class _PackageDirLoader(_FileSystemLoader):
|
||||||
|
"""PEP 302 loader wrapper for PKG_DIRECTORY directories"""
|
||||||
|
def _is_package(self, mod_name):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class _SourceFileLoader(_FileSystemLoader):
|
||||||
|
"""PEP 302 loader wrapper for PY_SOURCE modules"""
|
||||||
|
def _get_code(self, mod_name):
|
||||||
|
return compile(self._get_source(mod_name),
|
||||||
|
self.filename, 'exec')
|
||||||
|
|
||||||
|
def _get_source(self, mod_name):
|
||||||
|
f = self.file
|
||||||
|
f.seek(0)
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
|
class _CompiledFileLoader(_FileSystemLoader):
|
||||||
|
"""PEP 302 loader wrapper for PY_COMPILED modules"""
|
||||||
|
def _get_code(self, mod_name):
|
||||||
|
f = self.file
|
||||||
|
f.seek(0)
|
||||||
|
return _read_compiled_file(f)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_importer(path_item):
|
||||||
|
"""Retrieve a PEP 302 importer for the given path item
|
||||||
|
|
||||||
|
The returned importer is cached in sys.path_importer_cache
|
||||||
|
if it was newly created by a path hook.
|
||||||
|
|
||||||
|
If there is no importer, a wrapper around the basic import
|
||||||
|
machinery is returned. This wrapper is never inserted into
|
||||||
|
the importer cache (None is inserted instead).
|
||||||
|
|
||||||
|
The cache (or part of it) can be cleared manually if a
|
||||||
|
rescan of sys.path_hooks is necessary.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
importer = sys.path_importer_cache[path_item]
|
||||||
|
except KeyError:
|
||||||
|
for path_hook in sys.path_hooks:
|
||||||
|
try:
|
||||||
|
importer = path_hook(path_item)
|
||||||
|
break
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
importer = None
|
||||||
|
sys.path_importer_cache[path_item] = importer
|
||||||
|
if importer is None:
|
||||||
|
try:
|
||||||
|
importer = _FileSystemImporter(path_item)
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
return importer
|
||||||
|
|
||||||
|
|
||||||
|
def _get_path_loader(mod_name, path=None):
|
||||||
|
"""Retrieve a PEP 302 loader using a path importer"""
|
||||||
|
if path is None:
|
||||||
|
path = sys.path
|
||||||
|
absolute_loader = _AbsoluteImporter().find_module(mod_name)
|
||||||
|
if isinstance(absolute_loader, _FileSystemLoader):
|
||||||
|
# Found in filesystem, so scan path hooks
|
||||||
|
# before accepting this one as the right one
|
||||||
|
loader = None
|
||||||
|
else:
|
||||||
|
# Not found in filesystem, so use top-level loader
|
||||||
|
loader = absolute_loader
|
||||||
|
else:
|
||||||
|
loader = absolute_loader = None
|
||||||
|
if loader is None:
|
||||||
|
for path_item in path:
|
||||||
|
importer = _get_importer(path_item)
|
||||||
|
if importer is not None:
|
||||||
|
loader = importer.find_module(mod_name)
|
||||||
|
if loader is not None:
|
||||||
|
# Found a loader for our module
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# No path hook found, so accept the top level loader
|
||||||
|
loader = absolute_loader
|
||||||
|
return loader
|
||||||
|
|
||||||
|
def _get_package(pkg_name):
|
||||||
|
"""Retrieve a named package"""
|
||||||
|
pkg = __import__(pkg_name)
|
||||||
|
sub_pkg_names = pkg_name.split(".")
|
||||||
|
for sub_pkg in sub_pkg_names[1:]:
|
||||||
|
pkg = getattr(pkg, sub_pkg)
|
||||||
|
return pkg
|
||||||
|
|
||||||
|
def _get_loader(mod_name, path=None):
|
||||||
|
"""Retrieve a PEP 302 loader for the given module or package
|
||||||
|
|
||||||
|
If the module or package is accessible via the normal import
|
||||||
|
mechanism, a wrapper around the relevant part of that machinery
|
||||||
|
is returned.
|
||||||
|
|
||||||
|
Non PEP 302 mechanisms (e.g. the Windows registry) used by the
|
||||||
|
standard import machinery to find files in alternative locations
|
||||||
|
are partially supported, but are searched AFTER sys.path. Normally,
|
||||||
|
these locations are searched BEFORE sys.path, preventing sys.path
|
||||||
|
entries from shadowing them.
|
||||||
|
For this to cause a visible difference in behaviour, there must
|
||||||
|
be a module or package name that is accessible via both sys.path
|
||||||
|
and one of the non PEP 302 file system mechanisms. In this case,
|
||||||
|
the emulation will find the former version, while the builtin
|
||||||
|
import mechanism will find the latter.
|
||||||
|
Items of the following types can be affected by this discrepancy:
|
||||||
|
imp.C_EXTENSION
|
||||||
|
imp.PY_SOURCE
|
||||||
|
imp.PY_COMPILED
|
||||||
|
imp.PKG_DIRECTORY
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
loader = sys.modules[mod_name].__loader__
|
||||||
|
except (KeyError, AttributeError):
|
||||||
|
loader = None
|
||||||
|
if loader is None:
|
||||||
|
imp.acquire_lock()
|
||||||
|
try:
|
||||||
|
# Module not in sys.modules, or uses an unhooked loader
|
||||||
|
parts = mod_name.rsplit(".", 1)
|
||||||
|
if len(parts) == 2:
|
||||||
|
# Sub package, so use parent package's path
|
||||||
|
pkg_name, sub_name = parts
|
||||||
|
if pkg_name and pkg_name[0] != '.':
|
||||||
|
if path is not None:
|
||||||
|
raise ImportError("Path argument must be None "
|
||||||
|
"for a dotted module name")
|
||||||
|
pkg = _get_package(pkg_name)
|
||||||
|
try:
|
||||||
|
path = pkg.__path__
|
||||||
|
except AttributeError:
|
||||||
|
raise ImportError(pkg_name +
|
||||||
|
" is not a package")
|
||||||
|
else:
|
||||||
|
raise ImportError("Relative import syntax is not "
|
||||||
|
"supported by _get_loader()")
|
||||||
|
else:
|
||||||
|
# Top level module, so stick with default path
|
||||||
|
sub_name = mod_name
|
||||||
|
|
||||||
|
for importer in sys.meta_path:
|
||||||
|
loader = importer.find_module(mod_name, path)
|
||||||
|
if loader is not None:
|
||||||
|
# Found a metahook to handle the module
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# Handling via the standard path mechanism
|
||||||
|
loader = _get_path_loader(mod_name, path)
|
||||||
|
finally:
|
||||||
|
imp.release_lock()
|
||||||
|
return loader
|
||||||
|
|
||||||
|
|
||||||
|
# This helper is needed due to a missing component in the PEP 302
|
||||||
|
# loader protocol (specifically, "get_filename" is non-standard)
|
||||||
|
def _get_filename(loader, mod_name):
|
||||||
|
try:
|
||||||
|
get_filename = loader.get_filename
|
||||||
|
except AttributeError:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return get_filename(mod_name)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Done with the import machinery emulation, on with the code!
|
||||||
|
|
||||||
|
def _run_code(code, run_globals, init_globals,
|
||||||
|
mod_name, mod_fname, mod_loader):
|
||||||
|
"""Helper for _run_module_code"""
|
||||||
|
if init_globals is not None:
|
||||||
|
run_globals.update(init_globals)
|
||||||
|
run_globals.update(__name__ = mod_name,
|
||||||
|
__file__ = mod_fname,
|
||||||
|
__loader__ = mod_loader)
|
||||||
|
exec code in run_globals
|
||||||
|
return run_globals
|
||||||
|
|
||||||
|
def _run_module_code(code, init_globals=None,
|
||||||
|
mod_name=None, mod_fname=None,
|
||||||
|
mod_loader=None, alter_sys=False):
|
||||||
|
"""Helper for run_module"""
|
||||||
|
# Set up the top level namespace dictionary
|
||||||
|
if alter_sys:
|
||||||
|
# Modify sys.argv[0] and sys.module[mod_name]
|
||||||
|
temp_module = imp.new_module(mod_name)
|
||||||
|
mod_globals = temp_module.__dict__
|
||||||
|
saved_argv0 = sys.argv[0]
|
||||||
|
restore_module = mod_name in sys.modules
|
||||||
|
if restore_module:
|
||||||
|
saved_module = sys.modules[mod_name]
|
||||||
|
imp.acquire_lock()
|
||||||
|
try:
|
||||||
|
sys.argv[0] = mod_fname
|
||||||
|
sys.modules[mod_name] = temp_module
|
||||||
|
try:
|
||||||
|
_run_code(code, mod_globals, init_globals,
|
||||||
|
mod_name, mod_fname, mod_loader)
|
||||||
|
finally:
|
||||||
|
sys.argv[0] = saved_argv0
|
||||||
|
if restore_module:
|
||||||
|
sys.modules[mod_name] = saved_module
|
||||||
|
else:
|
||||||
|
del sys.modules[mod_name]
|
||||||
|
finally:
|
||||||
|
imp.release_lock()
|
||||||
|
# Copy the globals of the temporary module, as they
|
||||||
|
# may be cleared when the temporary module goes away
|
||||||
|
return mod_globals.copy()
|
||||||
|
else:
|
||||||
|
# Leave the sys module alone
|
||||||
|
return _run_code(code, {}, init_globals,
|
||||||
|
mod_name, mod_fname, mod_loader)
|
||||||
|
|
||||||
|
|
||||||
|
def run_module(mod_name, init_globals=None,
|
||||||
|
run_name=None, alter_sys=False):
|
||||||
|
"""Execute a module's code without importing it
|
||||||
|
|
||||||
|
Returns the resulting top level namespace dictionary
|
||||||
|
"""
|
||||||
|
loader = _get_loader(mod_name)
|
||||||
|
if loader is None:
|
||||||
|
raise ImportError("No module named " + mod_name)
|
||||||
|
code = loader.get_code(mod_name)
|
||||||
|
if code is None:
|
||||||
|
raise ImportError("No code object available for " + mod_name)
|
||||||
|
filename = _get_filename(loader, mod_name)
|
||||||
|
if run_name is None:
|
||||||
|
run_name = mod_name
|
||||||
|
return _run_module_code(code, init_globals, run_name,
|
||||||
|
filename, loader, alter_sys)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Run the module specified as the next command line argument
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print >> sys.stderr, "No module specified for execution"
|
||||||
|
else:
|
||||||
|
del sys.argv[0] # Make the requested module sys.argv[0]
|
||||||
|
run_module(sys.argv[0], run_name="__main__", alter_sys=True)
|
|
@ -1136,9 +1136,6 @@ class _ExpectedSkips:
|
||||||
s = _expectations[sys.platform]
|
s = _expectations[sys.platform]
|
||||||
self.expected = set(s.split())
|
self.expected = set(s.split())
|
||||||
|
|
||||||
# this isn't a regularly run unit test, it is always skipped
|
|
||||||
self.expected.add('test_hashlib_speed')
|
|
||||||
|
|
||||||
if not os.path.supports_unicode_filenames:
|
if not os.path.supports_unicode_filenames:
|
||||||
self.expected.add('test_pep277')
|
self.expected.add('test_pep277')
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,13 @@ class TestGenericStringIO(unittest.TestCase):
|
||||||
f.close()
|
f.close()
|
||||||
self.assertEqual(f.closed, True)
|
self.assertEqual(f.closed, True)
|
||||||
|
|
||||||
|
def test_isatty(self):
|
||||||
|
f = self.MODULE.StringIO()
|
||||||
|
self.assertRaises(TypeError, f.isatty, None)
|
||||||
|
self.assertEqual(f.isatty(), False)
|
||||||
|
f.close()
|
||||||
|
self.assertRaises(ValueError, f.isatty)
|
||||||
|
|
||||||
def test_iterator(self):
|
def test_iterator(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
unless = self.failUnless
|
unless = self.failUnless
|
||||||
|
@ -87,6 +94,8 @@ class TestGenericStringIO(unittest.TestCase):
|
||||||
eq(line, self._line + '\n')
|
eq(line, self._line + '\n')
|
||||||
i += 1
|
i += 1
|
||||||
eq(i, 5)
|
eq(i, 5)
|
||||||
|
self._fp.close()
|
||||||
|
self.assertRaises(ValueError, self._fp.next)
|
||||||
|
|
||||||
class TestStringIO(TestGenericStringIO):
|
class TestStringIO(TestGenericStringIO):
|
||||||
MODULE = StringIO
|
MODULE = StringIO
|
||||||
|
|
|
@ -5,8 +5,6 @@ from test.test_support import verify, verbose
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
warnings.filterwarnings("ignore", ".* 'pre' .*", DeprecationWarning,
|
|
||||||
r'pre$')
|
|
||||||
warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning,
|
warnings.filterwarnings("ignore", ".* regsub .*", DeprecationWarning,
|
||||||
r'^regsub$')
|
r'^regsub$')
|
||||||
warnings.filterwarnings("ignore",
|
warnings.filterwarnings("ignore",
|
||||||
|
@ -122,7 +120,6 @@ class AllTest(unittest.TestCase):
|
||||||
self.check_all("poplib")
|
self.check_all("poplib")
|
||||||
self.check_all("posixpath")
|
self.check_all("posixpath")
|
||||||
self.check_all("pprint")
|
self.check_all("pprint")
|
||||||
self.check_all("pre") # deprecated
|
|
||||||
self.check_all("profile")
|
self.check_all("profile")
|
||||||
self.check_all("pstats")
|
self.check_all("pstats")
|
||||||
self.check_all("pty")
|
self.check_all("pty")
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue