403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.156
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/orca/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/orca/__pycache__/label_inference.cpython-310.pyc
o

S�b%U�@s>dZdZdZdZdZdZddlZdd	lmZGd
d�d�Z	dS)zDHeuristic means to infer the functional/displayed label of a widget.z$Id$z
$Revision$z$Date$z$Copyright (C) 2011-2013 Igalia, S.L.�LGPL�N�)�debugc@s�eZdZdd�Zd9dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zd:dd�Z
dd�Zd;dd�Zd<dd �Zd=d"d#�Zd>d%d&�Zd>d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd?d6d7�Zd8S)@�LabelInferencecCs||_i|_i|_i|_dS)z�Creates an instance of the LabelInference class.

        Arguments:
        - script: the script with which this instance is associated.
        N)�_script�
_lineCache�
_extentsCache�_isWidgetCache)�self�script�r�6/usr/lib/python3/dist-packages/orca/label_inference.py�__init__$s
zLabelInference.__init__TcCs�t�tjd|d�|sdgfS|r&|���tj�s&t�tjdd�dgfSdg}}|s>|�|�\}}t�tjd|d�|rE|�|�rX|�	|�pK|\}}t�tjd|d�|sk|�
|�\}}t�tjd|d�|s~|�|�\}}t�tjd|d�|s�|�|�\}}t�tjd	|d�|s�|j
g}}t�tjd
|d�|r�|��}|�dd�}|s�|j|d
d�\}}t�tjd|d�|��||fS)z�Attempt to infer the functional/displayed label of obj.

        Arguments
        - obj: the unlabeled widget
        - focusedOnly: If True, only infer if the widget has focus.

        Returns the text which we think is the label, or None.
        zINFER label for: %sTNzINFER - object not focusedzINFER - Text Left: %szINFER - Text Right: %szINFER - Table: %szINFER - Text Above: %szINFER - Text Below: %szINFER - Name: %s�
� ��)�	proximityz+INFER - Text Left with proximity of 200: %s)r�println�
LEVEL_INFO�getState�contains�pyatspi�
STATE_FOCUSED�inferFromTextLeft�_preferRight�inferFromTextRight�inferFromTable�inferFromTextAbove�inferFromTextBelow�name�strip�replace�
clearCache)r
�obj�focusedOnly�result�objectsrrr
�infer0sB

zLabelInference.infercCsi|_i|_i|_dS)z5Dumps whatever we've stored for performance purposes.N)rrr	�r
rrr
r"fs
zLabelInference.clearCachecCstjtjg}|��|vS)zeReturns True if we should prefer text on the right, rather than the
        left, for the object obj.)r�ROLE_CHECK_BOX�ROLE_RADIO_BUTTON�getRole)r
r#�onRightRolesrrr
rmszLabelInference._preferRightcC�tjtjtjg}|��|vS)zeReturns True if we should not permit inference based on text to
        the right for the object obj.�r�ROLE_COMBO_BOX�	ROLE_LIST�
ROLE_LIST_BOXr+�r
r#�rolesrrr
�
_preventRightt�
�zLabelInference._preventRightcCr-)zZReturns True if we should prefer text above, rather than below for
        the object obj.r.r2rrr
�
_preferTop~r5zLabelInference._preferTopcCstjtjg}|��|vS)zZReturns True if we should not permit inference based on text below
        the object obj.)r�
ROLE_ENTRY�ROLE_PASSWORD_TEXTr+r2rrr
�
_preventBelow�s�zLabelInference._preventBelowc	s�|sdS�fdd��z�fdd�|D�}Wnttfy+t�tjd|d�YdSwdd�|D�}t|�d	kr;dSz|��}Wn
tyKYdSw|�d
d��	�}|�
�jj�d	kr_dSdS)z�Returns True if the given object has 'simple' contents, such as text
        without embedded objects or a single embedded object without text.Fcs|o	�jj�|�S�N)r�	utilities�isStaticTextLeaf)�xr(rr
�<lambda>��z0LabelInference._isSimpleObject.<locals>.<lambda>csg|]}�|�r|�qSrr)�.0�child)�isMatchrr
�
<listcomp>��z2LabelInference._isSimpleObject.<locals>.<listcomp>zDead Accessible in %sTcSsg|]}|��tjkr|�qSr)r+r�	ROLE_LINK�r@r=rrr
rC�srr���)
�LookupError�RuntimeErrorrrr�len�	queryText�NotImplementedError�getTextr �countr�EMBEDDED_OBJECT_CHARACTER)r
r#�children�text�stringr)rBr
r
�_isSimpleObject�s*��zLabelInference._isSimpleObjectcCs.|sdStjtjg}|��|vrdS|�|�S)zBReturns True if the given object should not be treated as a label.T)r�ROLE_HEADING�ROLE_LIST_ITEMr+�	_isWidget)r
r#�nonLabelTextRolesrrr
�_cannotLabel�s
zLabelInference._cannotLabelcCs�|sdS|j�t|��}|dur|Stjtjtjtjtjtj	tj
tjtjtj
tjg}|��|v}|s<|���tj�r<d}||jt|�<|S)z-Returns True if the given object is a widget.FNT)r	�get�hashrr)r*�ROLE_TOGGLE_BUTTONr/r0r1�	ROLE_MENU�ROLE_MENU_ITEMr7r8�ROLE_PUSH_BUTTONr+rr�STATE_EDITABLE)r
r#�rv�widgetRoles�isWidgetrrr
rV�s,�zLabelInference._isWidgetrrGc
Cs6|sdS|j�t|�||f�}|r|Sd}|jj�|�}|rNtjtjg}|�	�|vrN|dkrGz|j
}Wnd|}t�tj
|d�|YS|�||d�}|drV|ds�z	|���d�}	Wn%tytd|}t�tj
|d�Ynd	|}t�tj
|d�Yn
|	j|	j|	j|	jf}||jt|�||f<|S)
z�Returns (x, y, width, height) of the text at the given offsets
        if the object implements accessible text, or just the extents of
        the object if it doesn't implement accessible text.)rrrrrGz/ERROR: Exception getting character count for %sTr��z3INFO: %s does not implement the component interfacez'ERROR: Exception getting extents for %s)rrYrZrr;�queryNonEmptyTextrr7r8r+�characterCountrrr�getRangeExtents�queryComponent�
getExtentsrLr=�y�width�height)
r
r#�startOffset�	endOffsetr`�extentsrQ�skipTextExtents�msg�extrrr
�_getExtents�s<
zLabelInference._getExtentscCsx|�|�s	dgfS|�|�rdgfS|jjj|dd�}dd�|D�}tt|j|��r.dgfSdd�|D�}d�|�|fS)z>Gets the functional label text associated with the object obj.NF)�useCachecS�g|]}|d�qS�rr�r@�contentrrr
rCr?z;LabelInference._createLabelFromContents.<locals>.<listcomp>cSru�rdrrwrrr
rCr?�)	rSrXrr;�getObjectContentsAtOffset�list�filterrV�join)r
r#�contentsr&�stringsrrr
�_createLabelFromContentss

z'LabelInference._createLabelFromContentscCsd|j�t|��}|r|St|�}|�|�r!|jj�|�\}}|j}|jj�||dd�}||j|<|S)zeGet the (obj, startOffset, endOffset, string) tuples for the line
        containing the object, obj.TF)	rrYrZrVrr;�getHyperlinkRange�parent�getLineContentsAtOffset)r
r#�startr`�key�endrrr
�_getLineContentss

zLabelInference._getLineContents�Kcsl|���}|���}�fdd�|D�}z	|�|d�}Wn
ty)t|�}Ynw|d|�}d}tt|�ddd�D]"}	||	\}
}}}
|�|
�}|d|dksX|�|
�r^|	d}nq<||d�}|rk|dsodgfS|d\}
}}}|�|
||�}|d|d|d}d|kr�|kr�ndgfSdd�|D�}d	�|���}|r�|d
d�|D�fSdgfS)aLAttempt to infer the functional/displayed label of obj by
        looking at the contents of the current line, which are to the
        left of this object

        Arguments
        - obj: the unlabeled widget
        - proximity: pixels expected for a match

        Returns the text which we think is the label, or None.
        c�g|]
}|d�kr|�qSrvr�r@�o�r#rr
rC3�z4LabelInference.inferFromTextLeft.<locals>.<listcomp>rrrGNrccSruryrrwrrr
rCJr?rzcSrurvrrwrrr
rCMr?)	rsr��index�
IndexErrorrJ�rangerXr~r )r
r#rrorrxr��onLeftr��i�lObj�lStart�lEnd�lString�lExtentsr�rR�distancer�r%rr�r
r%s<

�
��z LabelInference.inferFromTextLeft�csl|���r	dgfS|���}|���}�fdd�|D�}z	|�|d�}Wn
ty2t|�}Ynw|tt|�|d�d�}t|�}t|�D]\}	}
|�|
d�rd|�	��s^dgfS|	d}nqH|d|�}|rq|dsudgfS|d\}}}}
|�|||�}|d|d|d}||ks�|�	��r�dd�|D�}d�
|���}|r�|d	d�|D�fSdgfS)
aMAttempt to infer the functional/displayed label of obj by
        looking at the contents of the current line, which are to the
        right of this object

        Arguments
        - obj: the unlabeled widget
        - proximity: pixels expected for a match

        Returns the text which we think is the label, or None.
        Ncr�rvrr�r�rr
rCbr�z5LabelInference.inferFromTextRight.<locals>.<listcomp>rrrccSruryrrwrrr
rCyr?rzcSrurvrrwrrr
rC|r?)r4rsr�r�r�rJ�min�	enumeraterXrr~r )r
r#rrorrxr��onRightr�r��item�rObjr�rR�rExtentsr�r�r%rr�r
rQs>


�
�z!LabelInference.inferFromTextRight�cs:|���}�fdd�|D�}z	|�|d�}Wn
ty$dgfYSw|dkr-dgfS|jj�|dd|ddd�\}}|�||�}t|�dkrPdgfS|d\}}	}
}|�|�radgfS|��r�|�	||	|
�\}}
}}|�	��\}}}}||
|}d|kr�|kr�ndgfS||kr�|��|gfSdgfS)�HAttempt to infer the functional/displayed label of obj by
        looking at the contents of the line above the line containing
        the object obj.

        Arguments
        - obj: the unlabeled widget
        - proximity: pixels expected for a match

        Returns the text which we think is the label, or None.
        cr�rvrr�r�rr
rC�r�z5LabelInference.inferFromTextAbove.<locals>.<listcomp>rNrT)
r�r�r�rr;�previousContextrJrXr rs)r
r#r�thisLinerxr��prevObj�
prevOffset�prevLiner�r�rRr=rjrkrl�objX�objY�objWidth�	objHeightr�rr�r
r�s6
��
�z!LabelInference.inferFromTextAbovecsH|���r	dgfS|���}�fdd�|D�}z	|�|d�}Wn
ty-dgfYSw|dkr6dgfS|jj�|dd|dddd�\}}|�||�}t|�dkr[dgfS|d\}}	}
}|�|�rldgfS|�	�r�|�
||	|
�\}}
}}|�
��\}}}}|
||}d|kr�|kr�ndgfS|�	�|gfSdgfS)	r�Ncr�rvrr�r�rr
rC�r�z5LabelInference.inferFromTextBelow.<locals>.<listcomp>rrGrcrT)r9r�r�r�rr;�nextContextrJrXr rs)r
r#rr�rxr��nextObj�
nextOffset�nextLiner�r�rRr=rjrkrlr�r�r�r�r�rr�r
r�s8

��
�z!LabelInference.inferFromTextBelowcC�(|sdS|��tjkr
dS|�|�dkS)NFT�table)r+r�
ROLE_TABLE�_getTag�r
r#rrr
�_isTable��
zLabelInference._isTablecCr�)NFT�tr)r+r�ROLE_TABLE_ROWr�r�rrr
�_isRow�r�zLabelInference._isRowcCs(|sdS|��tjkr
dS|�|�dvS)NFT)�td�th)r+r�ROLE_TABLE_CELLr�r�rrr
�_isCell�r�zLabelInference._isCellcCsVdt�|�vr	tS|dks|dkrdS|��}||jks!||jkr#dS|���||�S)N�Tabler)r�listInterfaces�NOne�
queryTable�nRows�nColumns�getAccessibleAt)r
r��rowindex�colindex�ifacerrr
�_getCellFromTable�sz LabelInference._getCellFromTablecCs&d|kr|jkr||SdSdS)Nr)�
childCount)r
�rowr�rrr
�_getCellFromRow�s�zLabelInference._getCellFromRowcCs|jj�|�}|�d�S)N�tag)rr;�objectAttributesrY)r
r#�attrsrrr
r�s
zLabelInference._getTag�2c's�t��|j�}|�|�sdgfS|�j�jjfvrdgfSt�||j�}|s*dgfSd}}}}t�||j�}	|jj�	|�\}
��dkrk|�
||
�d�}|�
||
�d�}|�
||
d��}|�
||
d��}n@|	r�|j|	kr�|��}|�|	|d�}|�|	|d�}|	��}
|
dkr�|�|	j|
d|�}|
d|j
kr�|�|	j|
d|�}|r�|���s�|�|�\}}
|r�|��|
fS|���\}}}}|r�|���s�|�|�\}}}}|||}||ks�|���r�|�|�\}}
|r�|��|
fSd}}|�r|�|�\}}|�r|����r|��|fS|�r%|����s%|�|�\}}|�rZ|�rZ|�|�\}}}}|�|�\}} }!}"|||}#| ||}$|#|$k�rT|��|fS|��|fS|�rc|��|fS|�rl|��|fSz|���Wnt�y�dgfYSw�fdd�t�j�D�}%|%�r�tt|j|%���r�dgfS�dk�r�dgfS��fdd�td�j�D�}&dd�|&D�}&�fd	d�|&D��r�dgfS|�|%��\}}
|�r�|��|
fSdgfS)
anAttempt to infer the functional/displayed label of obj by looking
        at the contents of the surrounding table cells. Note that this approach
        assumes a simple table in which the widget is the sole occupant of its
        cell.

        Arguments
        - obj: the unlabeled widget

        Returns the text which we think is the label, or None.
        NrGrrcsg|]}��d|��qSrv�r��r@r�)r�rr
rC]rDz1LabelInference.inferFromTable.<locals>.<listcomp>csg|]}��|���qSrr�r�)r�r�rr
rCdrDcSsg|]}|dur|�qSr:rrFrrr
rCerDcs*g|]}|jr|d�����kr|�qSrv)r�r+rFr�rr
rCfs*)r�findAncestorr�rSr�r�r�rr;�coordinatesForCellr��getIndexInParentr�r�rr�r rsr4r6r9r�rLr�r�r|r}rVr�)'r
r#�proximityForRight�cell�grid�cellLeft�	cellRight�	cellAbove�	cellBelow�gridrowr��	cellindex�label�sourcesr�r�r�r�r=rjrkrlr��
labelAbove�
labelBelow�sourcesAbove�sourcesBelow�aboveX�aboveY�
aboveWidth�aboveHeight�belowX�belowY�
belowWidth�belowHeight�dAbove�dBelow�firstRow�cellsr)r�r#r�r
rs�

�
zLabelInference.inferFromTableN)T)rrGrv)r�)r�)r�)r�)�__name__�
__module__�__qualname__rr'r"rr4r6r9rSrXrVrsr�r�rrrrr�r�r�r�r�r�rrrrr
r"s2
6

	
*


,
/
(+			
r)
�__doc__�__id__�__version__�__date__�
__copyright__�__license__rrzrrrrrr
�<module>s

Youez - 2016 - github.com/yon3zu
LinuXploit