Ñò "Hc@s@dZddkZddkZeideiƒZd„ZdS(s*Parse a Python source code encoding stringiÿÿÿÿNs([ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)c Csõyæ|d}|itiƒ}|o|ttiƒ}nti|ƒ}|pVyddk}|i|ƒWntt fj oq©X|d}ti|ƒ}n|o|ot dƒ‚ndS|o|i dƒSdSWndSXdS(s&Deduce the encoding of a source file from magic comment. It does this in the same way as the `Python interpreter`__ .. __: http://docs.python.org/ref/encodings.html The ``lines`` argument should be a list of the first 2 lines of the source code. (From Jeff Dairiki) iiÿÿÿÿNis\python refuses to compile code with both a UTF8 byte-order-mark and a magic encoding commenttutf_8( t startswithtcodecstBOM_UTF8tlentPYTHON_MAGIC_COMMENT_retmatchtparsertsuitet ImportErrort SyntaxErrortgrouptNone(tlinestline1thas_bomtmRtline2((sA/usr/lib/python2.6/site-packages/weberror/util/source_encoding.pytparse_encodings0     (t__doc__RtretcompiletVERBOSERR(((sA/usr/lib/python2.6/site-packages/weberror/util/source_encoding.pyts