Edit File: _propertyhelper.cpython-36.pyc
3 ��<_�:������������������@���s����d�dl�Z�d�dlZddlmZ�ddlmZmZmZmZm Z m Z mZmZm Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ�ejZejZejZej Z ej!Z!ej"Z"ej#Z#ej$Z$e�j%d kr�e&Z'e(Z)ne*Z'e+Z)G�dd��de,�Z-dd ��Z.dS�)�����N����)�_gi)� TYPE_NONE�TYPE_INTERFACE� TYPE_CHAR� TYPE_UCHAR�TYPE_BOOLEAN�TYPE_INT� TYPE_UINT� TYPE_LONG� TYPE_ULONG� TYPE_INT64�TYPE_UINT64� TYPE_ENUM� TYPE_FLAGS� TYPE_FLOAT�TYPE_DOUBLE�TYPE_STRING�TYPE_POINTER� TYPE_BOXED� TYPE_PARAM�TYPE_OBJECT� TYPE_PYOBJECT� TYPE_GTYPE� TYPE_STRV�TYPE_VARIANT����c���������������@���sN��e�Zd�ZdZeeeeee e eee eeiZedededee�ee�eeeeed/iZeeeeed1ed3eeeeeeeeiZedededededede dededi Z G�d d ��d e!�Z"dddddde#j$ddf dd �Z%dd��Z&dd��Z'dd��Z(dd��Z)dd��Z*dd��Z+dd��Z,dd��Z-dd��Z.d d!��Z/d"d#��Z0d$d%��Z1d&d'��Z2d(d)��Z3d*d+��Z4d,d-��Z5dS�)4�Propertya���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 r��������?���r����@�����g��������c���������������@���s���e�Zd�Zdd��ZdS�)zProperty.__metaclass__c�������������C���s���dS�)Nz<class 'GObject.Property'>��)�selfr"���r"����'/usr/lib64/python3.6/_propertyhelper.py�__repr__����s����zProperty.__metaclass__.__repr__N)�__name__� __module__�__qualname__r%���r"���r"���r"���r$���� __metaclass__����s���r)���Nc ������� ������C���s<��d�|�_�|d�krt}|�j|�|�_|�j|�|�_|�j���t|t�sDt d��||�_ t|t�s\t d��||�_||�_||�_ |r�|�r�|�j}n*|r�|�r�|�j}n|�r�|�r�|�j}|�j}|�j|��||�_|d�k r�||�j��k�r�t d|�j|�j��f���n|�j��}||�_| d�k �r$| |�j��k�r,t d|�j|�j��f���n|�j��} | |�_d�|�_d�S�)Nznick must be a stringzblurb must be a stringz+Minimum for type %s cannot be lower than %dz,Maximum for type %s cannot be higher than %d)�name�object�_type_from_python�type�_get_default�default�_check_default� isinstance�_basestring� TypeError�nick�blurb�__doc__�flags�_readonly_setter�_writeonly_getter�_default_getter�_default_setter�getter�fset�_get_minimum�minimum�_get_maximum�maximum�_exc) r#���r<����setterr-���r/���r4���r5���r7���r?���rA���r"���r"���r$����__init__����sL���� zProperty.__init__c�������������C���s���d|�j�p dtj|�j�f�S�)Nz<GObject Property %s (%s)>z(uninitialized))r*���r���Z type_namer-���)r#���r"���r"���r$���r%�������s����zProperty.__repr__c�������������C���s\���|d�kr|�S�d�|�_�y|�j|�}W�n �tk r@���tj���d�}Y�nX�|�j�rX|�j�}d�|�_�|�|S�)N)rB����fget� Exception� traceback� print_exc)r#����instance�klass�value�excr"���r"���r$����__get__����s���� zProperty.__get__c�������������C���s:���|d�krt��d�|�_|j|�j|��|�jr6|�j}d�|�_|�d�S�)N)r3���rB���Zset_propertyr*���)r#���rI���rK���rL���r"���r"���r$����__set__����s����zProperty.__set__c�������������C���s ���|�j�|�S�)z;Allows application of the getter along with init arguments.)r<���)r#���rE���r"���r"���r$����__call__����s����zProperty.__call__c�������������C���s ���|j�r|j�|�_|j�|�_�||�_|�S�)z8Set the getter function to fget. For use as a decorator.)r6���r5���rE���)r#���rE���r"���r"���r$���r<�������s ����zProperty.getterc�������������C���s���||�_�|�js|�jj|�_|�S�)z8Set the setter function to fset. For use as a decorator.)r=���r*���rE���r&���)r#���r=���r"���r"���r$���rC�����s���� zProperty.setterc�������������C���s����||�j�kr|�j�|�S�t|t�rBt|tjtjtjtjtj f�rB|j S�|ttt ttttttttttttttttttt fkrz|S�t!d|f���d�S�)NzUnsupported type: %r)"�_type_from_pytype_lookupr1���r-���� issubclassr���ZGObjectZGEnumZGFlagsZGBoxedZ GInterface� __gtype__r���r���r���r���r ���r ���r���r���r���r ���r���r���r���r���r���r���r���r���r���r���r���r���r3���)r#���Ztype_r"���r"���r$���r,�����s"���� zProperty._type_from_pythonc�������������C���s���|d�k r|S�|�j�j|�jd��S�)N)�_default_lookup�getr-���)r#���r/���r"���r"���r$���r.���&��s����zProperty._get_defaultc�������������C���s|��|�j�}|�j}|tkr.|d kr.td|f����nJ|tkrJ|d�k rFtd���n.|tkrf|d�k rbtd���ntj|t�r�|d�kr�td��ntj||�s�td||f���n�tj|t �r�tj||�s�td||f���n�tj|t �o�|d�k �r2t|t���s�td t |����xx|D�](}t�|�ttfk�rtd t|�����qW�nFtj|t��rx|d�k �rxt|d���shtj|t���rxtd||f���d�S�)NTFz%default must be True or False, not %rz)object types does not have default valuesz(GType types does not have default valuesz%enum properties needs a default valuez'enum value %s must be an instance of %rz(flags value %s must be an instance of %rzStrv value %s must be a listz'Strv value %s must contain only stringsrR���z*variant value %s must be an instance of %r)TF)r-���r/���r���r3���r���r���r���Z type_is_ar���r���r���r1����list�repr�str�bytesr����hasattr)r#����ptyper/����valr"���r"���r$���r0���+��s>���� zProperty._check_defaultc�������������C���s���|�j�j|�jd��S�)N)�_min_value_lookuprT���r-���)r#���r"���r"���r$���r>���L��s����zProperty._get_minimumc�������������C���s���|�j�j|�jd��S�)N)�_max_value_lookuprT���r-���)r#���r"���r"���r$���r@���O��s����zProperty._get_maximumc�������������C���s���t�|d|�j�|��d�S�)N�_property_helper_)�setattrr*���)r#���rI���rK���r"���r"���r$���r;���V��s����zProperty._default_setterc�������������C���s���t�|d|�j�|�j�S�)Nr^���)�getattrr*���r/���)r#���rI���r"���r"���r$���r:���Y��s����zProperty._default_getterc�������������C���s���t�d|�jt|�jf��|�_d�S�)Nz%s property of %s is read-only)r3���r*���r-���r&���rB���)r#���rI���rK���r"���r"���r$���r8���\��s����zProperty._readonly_setterc�������������C���s���t�d|�jt|�jf��|�_d�S�)Nz%s property of %s is write-only)r3���r*���r-���r&���rB���)r#���rI���r"���r"���r$���r9���`��s����zProperty._writeonly_getterc���������� ���C���s����|�j�}|ttttttttfkr0|�j |�j |�jf}nl|tks^|t ks^|jt�s^|jt�s^|jt�rh|�jf}n4|ttfkrzf�}n"|jt�s�|jt�r�f�}nt|��|�j�|�j|�jf|�|�jf�S�)N)r-���r ���r ���r���r���r ���r���r���r���r?���rA���r/���r���r���Zis_ar���r���r���r���r���r���r����NotImplementedErrorr4���r5���r7���)r#���rZ����argsr"���r"���r$����get_pspec_argsh��s���� zProperty.get_pspec_argsl������������l�������������l������������l��������l������������l��������)6r&���r'���r(���r6����_longr����intr ����boolr����floatr���rW���r���r+���r���rP���r ���r���r���r���� G_MAXFLOAT�G_MAXDOUBLE�G_MININT� G_MINLONGr ���r\���� G_MAXUINT� G_MAXULONG�G_MAXINT� G_MAXLONGr]���rS���r-���r)���r���ZPARAM_READWRITErD���r%���rM���rN���rO���r<���rC���r,���r.���r0���r>���r@���r;���r:���r8���r9���rc���r"���r"���r"���r$���r���2���sh���66 !r���c����������������s�����j�jdi��}g�}xp��j�j��D�]b\}}t|t�r|js<||_|j|krh||j�|j��krZqtd|j���|j��||j<�|j|��qW�|s�dS�|��_ d��j�ks�d��j�kr�x4|D�],}|j |jks�|j|j kr�td��jf���q�W�dd��}|��_��fd d �}|��_dS�)z� Scans the given class for instances of Property and merges them into the classes __gproperties__ dict if it exists or adds it if not. �__gproperties__z0Property %s was already found in __gproperties__N�do_get_property�do_set_propertyzGObject 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�jdd�}t|�|d��S�)N�-�_)r*����replacer`���)r#����pspecr*���r"���r"���r$����obj_get_property���s����z,install_properties.<locals>.obj_get_propertyc����������������s.���|j�jdd�}t��|d��}|r*|j|�|��d�S�)Nrs���rt���)r*���ru���r`���r=���)r#���rv���rK���r*����prop)�clsr"���r$����obj_set_property���s����z,install_properties.<locals>.obj_set_property)�__dict__rT����itemsr1���r���r*���rc���� ValueError�appendrp���rE���r:���r=���r;���r3���r&���rq���rr���)ry���ZgpropertiesZpropsr*���rx���rw���rz���r"���)ry���r$����install_properties{��s2���� r���)r���r���)/�sysrG���r!���r���Z _constantsr���r���r���r���r���r ���r ���r���r���r ���r���r���r���r���r���r���r���r���r���r���r���r���r���r���rh���ri���rj���rn���rl���rk���ro���rm����version_inforW���r2���re���rd���Z basestringZlongr+���r���r���r"���r"���r"���r$����<module>���s(���h ��K