ó
§Zc           @   se  d  d l  Z  d  d l Z d  d l Z e j j Z d d l m Z m Z m	 Z	 m
 Z
 m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z e j Z e j  Z  e j! Z! e j" Z" e j# Z# e j$ Z$ e j% Z% e j& Z& e  j' d d f k r6e( Z) e* Z+ n e, Z) e- Z+ d e. f d „  ƒ  YZ/ d „  Z0 d S(	   iÿÿÿÿNi   (   t	   TYPE_NONEt   TYPE_INTERFACEt	   TYPE_CHARt
   TYPE_UCHARt   TYPE_BOOLEANt   TYPE_INTt	   TYPE_UINTt	   TYPE_LONGt
   TYPE_ULONGt
   TYPE_INT64t   TYPE_UINT64t	   TYPE_ENUMt
   TYPE_FLAGSt
   TYPE_FLOATt   TYPE_DOUBLEt   TYPE_STRINGt   TYPE_POINTERt
   TYPE_BOXEDt
   TYPE_PARAMt   TYPE_OBJECTt   TYPE_PYOBJECTt
   TYPE_GTYPEt	   TYPE_STRVt   TYPE_VARIANTi   i    t   Propertyc        
   B   sÎ  e  Z d  Z i e e 6e e 6e e 6e	 e
 6e e 6e e 6Z i d e 6d e 6d e 6e e 6e e	 6e e 6e e 6d e 6Z i e e 6e e 6d e 6d  e 6e e 6e e	 6e e 6e e 6Z i	 d e 6d e 6d e 6d e 6d e 6d e 6d e 6d e 6d e	 6Z d e  f d	 „  ƒ  YZ! d! d! d! d! d d e# j$ d! d! d
 „	 Z% d „  Z& d „  Z' d „  Z( d „  Z) d „  Z* d „  Z+ d „  Z, d „  Z- d „  Z. d „  Z/ d „  Z0 d „  Z1 d „  Z2 d „  Z3 d „  Z4 d „  Z5 RS("   sÄ  Creates a new Property which when used in conjunction with
    GObject subclass will create a Python property accessor for the
    GObject ParamSpec.

    :param callable getter:
        getter to get the value of the property
    :param callable setter:
        setter to set the value of the property
    :param type type:
        type of property
    :param default:
        default value, must match the property type.
    :param str nick:
        short description
    :param str blurb:
        long description
    :param GObject.ParamFlags flags:
        parameter flags
    :keyword minimum:
        minimum allowed value (int, float, long only)
    :keyword maximum:
        maximum allowed value (int, float, long only)

    .. code-block:: python

         class MyObject(GObject.Object):
             prop = GObject.Property(type=str)

         obj = MyObject()
         obj.prop = 'value'

         obj.prop  # now is 'value'

    The API is similar to the builtin :py:func:`property`:

    .. code-block:: python

        class AnotherObject(GObject.Object):
            value = 0

            @GObject.Property
            def prop(self):
                'Read only property.'
                return 1

            @GObject.Property(type=int)
            def propInt(self):
                'Read-write integer property.'
                return self.value

            @propInt.setter
            def propInt(self, value):
                self.value = value
    i    i   i?   i   i@   t    g        t   __metaclass__c           B   s   e  Z d  „  Z RS(   c         C   s   d S(   Ns   <class 'GObject.Property'>(    (   t   self(    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   __repr__˜   s    (   t   __name__t
   __module__R   (    (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR   —   s   c
   
      C   sÔ  d  |  _ | d  k r t } n  |  j | ƒ |  _ |  j | ƒ |  _ |  j ƒ  t | t	 ƒ sj t
 d ƒ ‚ n  | |  _ t | t	 ƒ s‘ t
 d ƒ ‚ n  | |  _ | |  _ | |  _ | rÅ | rÅ |  j } n< | rÞ | rÞ |  j } n# | r| r|  j } |  j } n  |  j | ƒ | |  _ | d  k	 rZ| |  j ƒ  k  rft
 d |  j |  j ƒ  f ƒ ‚ qfn |  j ƒ  } | |  _ |	 d  k	 r²|	 |  j ƒ  k r¾t
 d |  j |  j ƒ  f ƒ ‚ q¾n |  j ƒ  }	 |	 |  _ d  |  _ d  S(   Ns   nick must be a strings   blurb must be a strings+   Minimum for type %s cannot be lower than %ds,   Maximum for type %s cannot be higher than %d(   t   Nonet   namet   objectt   _type_from_pythont   typet   _get_defaultt   defaultt   _check_defaultt
   isinstancet   _basestringt	   TypeErrort   nickt   blurbt   __doc__t   flagst   _readonly_settert   _writeonly_gettert   _default_gettert   _default_settert   gettert   fsett   _get_minimumt   minimumt   _get_maximumt   maximumt   _exc(
   R   R2   t   setterR#   R%   R*   R+   R-   R5   R7   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   __init__›   sL    		
								c         C   s#   d |  j  p d t j |  j ƒ f S(   Ns   <GObject Property %s (%s)>s   (uninitialized)(   R    t   _gobjectt	   type_nameR#   (   R   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR   Ó   s    c         C   sx   | d  k r |  Sd  |  _ y |  j | ƒ } Wn! t k
 rO t j ƒ  d  } n X|  j rt |  j } d  |  _ | ‚ n  | S(   N(   R   R8   t   fgett	   Exceptiont	   tracebackt	   print_exc(   R   t   instancet   klasst   valuet   exc(    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   __get__Ø   s    	

				c         C   sY   | d  k r t ‚ n  d  |  _ | j |  j | ƒ |  j rU |  j } d  |  _ | ‚ n  d  S(   N(   R   R)   R8   t   set_propertyR    (   R   RA   RC   RD   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   __set__ñ   s    					c         C   s   |  j  | ƒ S(   s;   Allows application of the getter along with init arguments.(   R2   (   R   R=   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   __call__ü   s    c         C   s1   | j  r$ | j  |  _ | j  |  _  n  | |  _ |  S(   s8   Set the getter function to fget. For use as a decorator.(   R,   R+   R=   (   R   R=   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR2      s
    		c         C   s(   | |  _  |  j s$ |  j j |  _ n  |  S(   s8   Set the setter function to fset. For use as a decorator.(   R3   R    R=   R   (   R   R3   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR9   	  s    		c         C   sÆ   | |  j  k r |  j  | St | t ƒ r] t | t j t j t j t j t j	 f ƒ r] | j
 S| t t t t t t t t t t t t t t t t t t t t t t  f k r¯ | St! d | f ƒ ‚ d  S(   Ns   Unsupported type: %r("   t   _type_from_pytype_lookupR'   R#   t
   issubclassR;   t   GObjectt   GEnumt   GFlagst   GBoxedt
   GInterfacet	   __gtype__R    R   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R)   (   R   t   type_(    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR"     s"    		c         C   s&   | d  k	 r | S|  j j |  j d  ƒ S(   N(   R   t   _default_lookupt   getR#   (   R   R%   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR$   '  s    c         C   s!  |  j  } |  j } | t k rF | t t f k rF t d | f ƒ ‚ n×| t k rp | d  k	 rt d ƒ ‚ qn­| t k rš | d  k	 rt d ƒ ‚ qnƒt	 j
 | t ƒ rõ | d  k rÇ t d ƒ ‚ qt	 j
 | | ƒ st d | | f ƒ ‚ qn(t	 j
 | t ƒ r5t	 j
 | | ƒ st d | | f ƒ ‚ qnè t	 j
 | t ƒ rÀ| d  k	 rÀt | t ƒ s{t d t | ƒ ƒ ‚ n  xŸ | D]7 } t  | ƒ t t f k r‚t d t | ƒ ƒ ‚ q‚q‚Wn] t	 j
 | t ƒ r| d  k	 rt | d	 ƒ st	 j
 | t ƒ rt d
 | | f ƒ ‚ qn  d  S(   Ns%   default must be True or False, not %rs)   object types does not have default valuess(   GType types does not have default valuess%   enum properties needs a default values'   enum value %s must be an instance of %rs(   flags value %s must be an instance of %rs   Strv value %s must be a lists'   Strv value %s must contain only stringsRP   s*   variant value %s must be an instance of %r(   R#   R%   R   t   Truet   FalseR)   R   R   R   R;   t	   type_is_aR   R   R   R'   t   listt   reprt   strt   bytesR   t   hasattr(   R   t   ptypeR%   t   val(    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR&   ,  s>    		 #c         C   s   |  j  j |  j d  ƒ S(   N(   t   _min_value_lookupRS   R#   R   (   R   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR4   M  s    c         C   s   |  j  j |  j d  ƒ S(   N(   t   _max_value_lookupRS   R#   R   (   R   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR6   P  s    c         C   s   t  | d |  j | ƒ d  S(   Nt   _property_helper_(   t   setattrR    (   R   RA   RC   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR1   W  s    c         C   s   t  | d |  j |  j ƒ S(   NR`   (   t   getattrR    R%   (   R   RA   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR0   Z  s    c         C   s)   t  d |  j t | ƒ j f ƒ |  _ d  S(   Ns   %s property of %s is read-only(   R)   R    R#   R   R8   (   R   RA   RC   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR.   ]  s    c         C   s)   t  d |  j t | ƒ j f ƒ |  _ d  S(   Ns   %s property of %s is write-only(   R)   R    R#   R   R8   (   R   RA   (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR/   a  s    c      	   C   s  |  j  } | t t t t t t t t f k rH |  j	 |  j
 |  j f } n¢ | t k s | t k s | j t ƒ s | j t ƒ s | j t ƒ rœ |  j f } nN | t t f k r· d } n3 | j t ƒ sÕ | j t ƒ rÞ d } n t | ƒ ‚ |  j  |  j |  j f | |  j f S(   N(    (    (   R#   R   R   R   R   R	   R
   R   R   R5   R7   R%   R   R   t   is_aR   R   R   R   R   R   R   t   NotImplementedErrorR*   R+   R-   (   R   R\   t   args(    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   get_pspec_argsi  s    			l            lûÿÿÿ         l            l   ÿÿÿÿ l            l   ÿÿÿÿ N(6   R   R   R,   R   t   _longR   t   intR   t   boolR   t   floatR   RY   R   R!   RI   R   R   R
   t
   G_MAXFLOATR   t   G_MAXDOUBLEt   G_MININTt	   G_MINLONGR	   R^   t	   G_MAXUINTt
   G_MAXULONGt   G_MAXINTt	   G_MAXLONGR_   RR   R#   R   R   R;   t   PARAM_READWRITER:   R   RE   RG   RH   R2   R9   R"   R$   R&   R4   R6   R1   R0   R.   R/   Rf   (    (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyR   3   sp   6



6							
			!						c            sv  ˆ  j  j d i  ƒ } g  } x¨ ˆ  j  j ƒ  D]— \ } } t | t ƒ r+ | j s[ | | _ n  | j | k rŸ | | j | j ƒ  k r‰ q+ n  t d | j ƒ ‚ n  | j ƒ  | | j <| j | ƒ q+ q+ W| sÐ d S| ˆ  _	 d ˆ  j  k s÷ d ˆ  j  k rHxN | D]C } | j
 | j k s(| j | j k rþ t d ˆ  j f ƒ ‚ qþ qþ Wn  d „  } | ˆ  _ ‡  f d †  } | ˆ  _ d S(	   s“   
    Scans the given class for instances of Property and merges them
    into the classes __gproperties__ dict if it exists or adds it if not.
    t   __gproperties__s0   Property %s was already found in __gproperties__Nt   do_get_propertyt   do_set_propertys   GObject subclass %r defines do_get/set_property and it also uses a property with a custom setter or getter. This is not allowedc         S   s%   | j  j d d ƒ } t |  | d  ƒ S(   Nt   -t   _(   R    t   replaceRb   R   (   R   t   pspecR    (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   obj_get_property¢  s    c            sD   | j  j d d ƒ } t ˆ  | d  ƒ } | r@ | j |  | ƒ n  d  S(   NRw   Rx   (   R    Ry   Rb   R   R3   (   R   Rz   RC   R    t   prop(   t   cls(    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   obj_set_property§  s    (   t   __dict__RS   t   itemsR'   R   R    Rf   t
   ValueErrort   appendRt   R=   R0   R3   R1   R)   R   Ru   Rv   (   R}   t   gpropertiest   propsR    R|   R{   R~   (    (   R}   s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   install_properties|  s2    		$		(1   t   sysR?   t   gi._git   git   _giR;   t
   _constantsR    R   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   Rk   Rl   Rm   Rq   Ro   Rn   Rr   Rp   t   version_infoRY   R(   Rh   Rg   t
   basestringt   longR!   R   R…   (    (    (    s8   /usr/lib64/python2.7/site-packages/gi/_propertyhelper.pyt   <module>   s(   š									ÿ J