ó
f#ñ]c           @   s   d  „  Z  d S(   c         C   s`  i d d 6d d 6d d 6d d 6d d 6} |  j ƒ  } |  j d ƒ t t t |  j d ƒ ƒ ƒ \ } } } } | j | | | | f ƒ } | sÏ | j | | | d f ƒ } | sÏ | j | | d d f ƒ } qÏ n  | ræ |  j | ƒ | Sd d l } |  j d ƒ |  j d ƒ }	 d }
 | j	 |
 | j
 ƒ } | j |	 ƒ } |  j | ƒ | rX| j d ƒ Sd Sd S(   s   Attempts to detect the character encoding of the xml file
    given by a file object fp. fp must not be a codec wrapped file
    object!

    The return value can be:
        - if detection of the BOM succeeds, the codec name of the
        corresponding unicode charset is returned

        - if BOM detection fails, the xml declaration is searched for
        the encoding attribute and its value returned. the "<"
        character has to be the very first in the file then (it's xml
        standard after all).

        - if BOM and xml declaration fail, None is returned. According
        to xml 1.0 it should be utf_8 then, but it wasn't detected by
        the means offered here. at least one can be pretty sure that a
        character coding including most of ASCII is used :-/
    t	   utf_32_bei    iþ   iÿ   t	   utf_32_let	   utf_16_bet	   utf_16_let   utf_8iï   i»   i¿   i   iÿÿÿÿNi   s‹  
    ^<\?xml             # w/o BOM, xmldecl starts with <?xml at the first byte
    .+?                 # some chars (version info), matched minimal
    encoding=           # encoding attribute begins
    ["']                # attribute start delimiter
    (?P<encstr>         # what's matched in the brackets will be named encstr
     [^"']+              # every character not delimiter (not overly exact!)
    )                   # closes the brackets pair for the named group
    ["']                # attribute end delimiter
    .*?                 # some chars optionally (standalone decl or whitespace)
    \?>                 # xmldecl end
    t   encstr(   i    i    iþ   iÿ   (   iÿ   iþ   i    i    (   iþ   iÿ   NN(   iÿ   iþ   NN(   iï   i»   i¿   N(   t   Nonet   tellt   seekt   tuplet   mapt   ordt   readt   gett   ret   compilet   VERBOSEt   searcht   group(   t   fpt   bomDictt   oldFPt   byte1t   byte2t   byte3t   byte4t   bomDetectionR   t   buffert   xmlDeclPatternt	   xmlDeclREt   match(    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/activestate.pyt   detectXMLEncoding   s6    
*!
N(   R   (    (    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/pyxb/utils/activestate.pyt   <module>   s    