ó
Z_Sc           @   sÅ  d  Z  d d l Z e j d d k r)d d l m Z m Z m Z m Z m Z m	 Z	 d d l
 Z
 e Z e Z e j Z e j Z d „  Z d „  Z d „  Z d	 „  Z e Z d
 „  Z d d l Z d „  Z d d l m Z d d l m Z m Z m Z m Z d d l  m! Z! m" Z" d d l# m$ Z$ d „  Z% nGd d l& m Z m Z m Z m% Z% d d l' m Z m Z m Z d d l& m( Z d d l& m) Z	 d d l* m Z e j Z d „  Z d „  Z d „  Z d „  Z e Z d „  Z d „  Z y d d l+ m Z Wn! e, k
 rd d l m Z n Xd d l- m Z m Z d d l. m Z d d l m Z d d l. m! Z! m" Z" d d l- m$ Z$ e j/ d k r‹d  „  Z0 n6 e j d d k r±d d! l1 m0 Z0 n d d! l2 m0 Z0 d S("   s  Python 3 compatibility tools (PRIVATE).

We currently have lines like this under Python 2 in order
to use iterator based zip, map and filter:

    from future_builtins import zip

There is no similar option for range yet, other than:

    range = xrange
    input = raw_input

or:

    from __builtin__ import xrange as range
    from __builtin__ import raw_input as input

Under Python 3 this imports need to be removed. Also, deliberate
importing of built in functions like open changes from Python 2:

    from __builtin__ import open

to this under Python 3:

    from builtins import open

Instead, we can do this under either Python 2 or 3:

    from Bio._py3k import open
    from Bio._py3k import zip

Once we drop support for Python 2, the whole of Bio._py3k will
go away.
iÿÿÿÿNi    i   (   t   opent   zipt   mapt   filtert   ranget   inputc         C   s
   |  j  ƒ  S(   N(   t   decode(   t   b(    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt   <lambda>:   s    c         C   s
   |  j  ƒ  S(   N(   t   encode(   t   s(    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR   ;   s    c         C   s$   t  |  t ƒ r |  St j |  ƒ d S(   s9   Turn byte string or unicode string into a unicode string.i    (   t
   isinstancet   strt   codecst   latin_1_decode(   R
   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt   _as_unicode=   s    c         C   s$   t  |  t ƒ r |  St j |  ƒ d S(   sw   Turn byte string or unicode string into a bytes string.

        The Python 2 version returns a (byte) string.
        i    (   R   t   bytesR   t   latin_1_encode(   R
   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt	   _as_bytesE   s    c         C   s   t  |  t ƒ S(   sX   Check if the value is an integer.

        Note there are no longs on Python 3.
        (   R   t   int(   t   i(    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt   _is_int_or_longR   s    c         C   s    d t  f d „  ƒ  Y} | |  ƒ S(   s;   Treat a binary (bytes) handle like a text (unicode) handle.t   EvilHandleHackc           B   sJ   e  Z d  „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         S   s   | |  _  d  S(   N(   t   _handle(   t   selft   handle(    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt   __init__d   s    c         S   s   t  |  j j | ƒ ƒ S(   N(   t
   _as_stringR   t   read(   R   t   length(    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR   g   s    c         S   s   t  |  j j ƒ  ƒ S(   N(   R   R   t   readline(   R   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR   j   s    c         s   s#   x |  j  D] } t | ƒ Vq
 Wd  S(   N(   R   R   (   R   t   line(    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt   __iter__m   s    c         S   s   |  j  j ƒ  S(   N(   R   t   close(   R   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR!   q   s    c         S   s   |  j  j | ƒ S(   N(   R   t   seek(   R   t   pos(    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR"   t   s    c         S   s   |  j  j ƒ  S(   N(   R   t   tell(   R   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR$   w   s    N(
   t   __name__t
   __module__R   t   NoneR   R   R    R!   R"   R$   (    (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR   c   s   					(   t   object(   R   R   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt   _binary_to_string_handle[   s    (   t   StringIO(   t   urlopent   Requestt   urlretrievet   urlparse(   t	   urlencodet   quote(   t	   HTTPErrorc         C   s   |  | k |  | k  S(   N(    (   t   aR   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt   cmpˆ   s    (   R    t
   basestringt   unicodeR3   (   R   R   R   (   t   xrange(   t	   raw_input(   t	   maketransc         C   s   |  S(   N(    (   R   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR   ˜   s    c         C   s
   t  |  ƒ S(   N(   R   (   R
   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR   ™   s    c         C   s   t  |  t ƒ r |  S|  j ƒ  S(   s>   Turn a (byte) string or a unicode string into a (byte) string.(   R   R5   R   (   R
   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR   ›   s    c         C   s
   t  |  ƒ S(   s>   Turn a (byte) string or a unicode string into a (byte) string.(   R   (   R
   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR   ¢   s    c         C   s   t  |  t t f ƒ S(   s)   Check if the value is an integer or long.(   R   R   t   long(   R   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR   ¨   s    c         C   s   |  S(   s)   Treat a binary handle like a text handle.(    (   R   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyR)   ¬   s    (   R+   R,   (   R-   (   R.   t   win32c         C   sa   d d  l  } | j |  d | j d | j d | j d t d t ƒ} | j ƒ  \ } } | j d ƒ S(   Niÿÿÿÿt   stdint   stdoutt   stderrt   universal_newlinest   shells   
(   t
   subprocesst   Popent   PIPEt   STDOUTt   Truet   Falset   communicatet   rstrip(   t   cmdR@   t   childR<   R=   (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt	   getoutputÔ   s    				(   RJ   (3   t   __doc__t   syst   version_infot   builtinsR    R   R   R   R   R   R   R   R4   R5   R8   t   dictt   itemst	   iteritemst   _bytes_to_stringt   _string_to_bytesR   R   R   R   t   ioR)   R*   t   urllib.requestR+   R,   R-   R.   t   urllib.parseR/   R0   t   urllib.errorR1   R3   t   __builtin__t   future_builtinsR6   R7   t   stringt	   cStringIOt   ImportErrort   urllib2t   urllibt   platformRJ   R@   t   commands(    (    (    s7   /home/psgendb/BIRCHDEV/pkg/weblogo-3.4/corebio/_py3k.pyt   <module>&   s`   .								%""							