ó
ž^Yc           @@  s\  d  Z  d d l m Z d d l Z d d l m Z y e j Z Wn e k
 r[ e j	 Z n Xd Z
 d Z d Z e e
 k r d	 Z n e e k r d
 Z n d	 Z y
 e Z Wn e k
 rÁ e Z n Xe e k rÚ d   Z n	 d   Z y e e f Z Wn e k
 re f Z n Xe Z e d  Z e d  Z d   Z d   Z d   Z d	 e d  Z d S(   s   Python compatibility wrappers.i    (   t   absolute_importN(   t   packi   i?   i   i   i@   i    c         C@  s   |  j  d  S(   Nt   latin1(   t   encode(   t   s(    (    s(   /tmp/pip-build-kpPAdC/rsa/rsa/_compat.pyt   byte_literal5   s    c         C@  s   |  S(   N(    (   R   (    (    s(   /tmp/pip-build-kpPAdC/rsa/rsa/_compat.pyR   8   s    t    t    c         C@  s   t  |  t  S(   s˝   
    Determines whether the given value is a byte string.

    :param obj:
        The value to test.
    :returns:
        ``True`` if ``value`` is a byte string; ``False`` otherwise.
    (   t
   isinstancet   bytes(   t   obj(    (    s(   /tmp/pip-build-kpPAdC/rsa/rsa/_compat.pyt   is_bytesH   s    	c         C@  s   t  |  t  S(   sˇ   
    Determines whether the given value is an integer.

    :param obj:
        The value to test.
    :returns:
        ``True`` if ``value`` is an integer; ``False`` otherwise.
    (   R   t   integer_types(   R
   (    (    s(   /tmp/pip-build-kpPAdC/rsa/rsa/_compat.pyt
   is_integerT   s    	c         C@  s   t  d |   S(   sd  
    Converts a number between 0 and 255 (both inclusive) to a base-256 (byte)
    representation.

    Use it as a replacement for ``chr`` where you are expecting a byte
    because this will work on all current versions of Python::

    :param num:
        An unsigned integer between 0 and 255 (both inclusive).
    :returns:
        A single byte.
    t   B(   R   (   t   num(    (    s(   /tmp/pip-build-kpPAdC/rsa/rsa/_compat.pyt   byte`   s    c         C@  s   d } d } d } d } | d k rL | d k rL |  | k rL d d | d f S|  | k rh d d	 | d
 f S|  | k r d d | d f Sd d | d f Sd S(   sD  
    Returns alignment details for the given number based on the platform
    Python is running on.

    :param num:
        Unsigned integral number.
    :param force_arch:
        If you don't want to use 64-bit unsigned chunks, set this to
        anything other than 64. 32-bit chunks will be preferred then.
        Default 64 will be used when on a 64-bit machine.
    :param _machine_word_size:
        (Internal) The machine word size used for alignment.
    :returns:
        4-tuple::

            (word_bits, word_bytes,
             max_uint, packing_format_type)
    l   ˙˙˙˙ I˙˙˙˙    i˙˙  i˙   i@   i   t   Qi    i   t   Li   i   t   Hi   R   N(    (   R   t
   force_archt   _machine_word_sizet
   max_uint64t
   max_uint32t
   max_uint16t	   max_uint8(    (    s(   /tmp/pip-build-kpPAdC/rsa/rsa/_compat.pyt   get_word_alignmentp   s    $l            l   ˙˙˙˙ I       i˙˙˙i   i˙  (   t   __doc__t
   __future__R    t   syst   structR   t   maxsizet   MAX_INTt   AttributeErrort   maxintt	   MAX_INT64t	   MAX_INT32t	   MAX_INT16t   MACHINE_WORD_SIZEt   unicodet   unicode_typet	   NameErrort   strR   t   intt   longR   t   bt	   ZERO_BYTEt
   EMPTY_BYTER   R   R   R   (    (    (    s(   /tmp/pip-build-kpPAdC/rsa/rsa/_compat.pyt   <module>   sD   		

				