Your IP : 216.73.216.84
3
��<_�:�@s�ddlZddlZddlmZddlmZmZmZmZm Z m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZejZejZejZej Z ej!Z!ej"Z"ej#Z#ej$Z$ej%d
kr�e&Z'e(Z)ne*Z'e+Z)Gdd�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@sNeZdZdZeeeeee e
eee
eeiZedededeeeeeeeeed/iZeeeeed1ed3eeeeeeeeiZedededededede
dededi Z Gd 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�@�gc@seZdZdd�ZdS)zProperty.__metaclass__cCsdS)Nz<class 'GObject.Property'>�)�selfr"r"�'/usr/lib64/python3.6/_propertyhelper.py�__repr__�szProperty.__metaclass__.__repr__N)�__name__�
__module__�__qualname__r%r"r"r"r$�
__metaclass__�sr)Nc
Cs<d|_|dkrt}|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|�||_|dk r�||j�kr�t d|j|j�f��n|j�}||_| dk �r$| |j�k�r,t d|j|j�f��n|j�} | |_d|_dS)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/r4r5r7r?rAr"r"r$�__init__�sL
zProperty.__init__cCsd|jp
dtj|j�fS)Nz<GObject Property %s (%s)>z(uninitialized))r*rZ type_namer-)r#r"r"r$r%�szProperty.__repr__cCs\|dkr|Sd|_y|j|�}Wn tk
r@tj�d}YnX|jrX|j}d|_|�|S)N)rB�fget� Exception� traceback� print_exc)r#�instance�klass�value�excr"r"r$�__get__�s
zProperty.__get__cCs:|dkrt�d|_|j|j|�|jr6|j}d|_|�dS)N)r3rBZset_propertyr*)r#rIrKrLr"r"r$�__set__�szProperty.__set__cCs
|j|�S)z;Allows application of the getter along with init arguments.)r<)r#rEr"r"r$�__call__�szProperty.__call__cCs |jr|j|_|j|_||_|S)z8Set the getter function to fget. For use as a decorator.)r6r5rE)r#rEr"r"r$r<�s
zProperty.gettercCs||_|js|jj|_|S)z8Set the setter function to fset. For use as a decorator.)r=r*rEr&)r#r=r"r"r$rCs
zProperty.settercCs�||jkr|j|St|t�rBt|tjtjtjtjtj f�rB|j
S|ttt
ttttttttttttttttttt fkrz|St!d|f��dS)NzUnsupported type: %r)"�_type_from_pytype_lookupr1r-�
issubclassrZGObjectZGEnumZGFlagsZGBoxedZ
GInterface� __gtype__rrrrr r
rrrr
rrrrrrrrrrrrr3)r#Ztype_r"r"r$r,s"
zProperty._type_from_pythoncCs|dk r|S|jj|jd�S)N)�_default_lookup�getr-)r#r/r"r"r$r.&szProperty._get_defaultcCs||j}|j}|tkr.|d
kr.td|f���nJ|tkrJ|dk rFtd���n.|tkrf|dk rbtd���ntj|t�r�|dkr�td��ntj||�s�td||f��n�tj|t �r�tj||�s�td||f��n�tj|t
�o�|dk �r2t|t��s�td t
|���xx|D](}t|�ttfk�rtd
t|����qWnFtj|t��rx|dk �rxt|d��shtj|t��rxtd||f��dS)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 stringsrRz*variant value %s must be an instance of %r)TF)r-r/rr3rrrZ type_is_arrrr1�list�repr�str�bytesr�hasattr)r#�ptyper/�valr"r"r$r0+s>
zProperty._check_defaultcCs|jj|jd�S)N)�_min_value_lookuprTr-)r#r"r"r$r>LszProperty._get_minimumcCs|jj|jd�S)N)�_max_value_lookuprTr-)r#r"r"r$r@OszProperty._get_maximumcCst|d|j|�dS)N�_property_helper_)�setattrr*)r#rIrKr"r"r$r;VszProperty._default_settercCst|d|j|j�S)Nr^)�getattrr*r/)r#rIr"r"r$r:YszProperty._default_gettercCstd|jt|�jf�|_dS)Nz%s property of %s is read-only)r3r*r-r&rB)r#rIrKr"r"r$r8\szProperty._readonly_settercCstd|jt|�jf�|_dS)Nz%s property of %s is write-only)r3r*r-r&rB)r#rIr"r"r$r9`szProperty._writeonly_getterc Cs�|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||jfS)N)r-r r
rrr
rrrr?rAr/rrZis_arrrrrrr�NotImplementedErrorr4r5r7)r#rZ�argsr"r"r$�get_pspec_argshs
zProperty.get_pspec_argsll����ll����ll����)6r&r'r(r6�_longr�intr �boolr�floatrrWrr+rrPr
rrr�
G_MAXFLOAT�G_MAXDOUBLE�G_MININT� G_MINLONGr
r\� G_MAXUINT�
G_MAXULONG�G_MAXINT� G_MAXLONGr]rSr-r)rZPARAM_READWRITErDr%rMrNrOr<rCr,r.r0r>r@r;r:r8r9rcr"r"r"r$r2sh66
!rcs�jjdi�}g}xp�jj�D]b\}}t|t�r|js<||_|j|krh||j|j�krZqtd|j��|j�||j<|j|�qW|s�dS|�_ d�jks�d�jkr�x4|D],}|j
|jks�|j|j
kr�td�jf��q�Wdd�}|�_�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 allowedcSs|jjdd�}t||d�S)N�-�_)r*�replacer`)r#�pspecr*r"r"r$�obj_get_property�sz,install_properties.<locals>.obj_get_propertycs.|jjdd�}t�|d�}|r*|j||�dS)Nrsrt)r*rur`r=)r#rvrKr*�prop)�clsr"r$�obj_set_property�sz,install_properties.<locals>.obj_set_property)�__dict__rT�itemsr1rr*rc�
ValueError�appendrprEr:r=r;r3r&rqrr)ryZgpropertiesZpropsr*rxrwrzr")ryr$�install_properties{s2
r)rr)/�sysrGr!rZ
_constantsrrrrrr r
rrr
rrrrrrrrrrrrrrrhrirjrnrlrkrorm�version_inforWr2rerdZ
basestringZlongr+rrr"r"r"r$�<module>s(h
K
?>