%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/orca/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/orca/__pycache__/ax_hypertext.cpython-312.pyc

�

g
f ���dZdZdZdZdZdZddlZddlZddlm	Z	ddl
Z
e
jd	d
�ddlm
Z
dd
lmZddlmZGd�d�Zy)a�
Utilities for obtaining information about accessible hypertext and hyperlinks
These utilities are app-type- and toolkit-agnostic. Utilities that might have
different implementations or results depending on the type of app (e.g. terminal,
chat, web) or toolkit (e.g. Qt, Gtk) should be in script_utilities.py file(s).

N.B. There are currently utilities that should never have custom implementations
that live in script_utilities.py files. These will be moved over time.
z$Id$z
$Revision$z$Date$zCopyright (c) 2024 Igalia, S.L.�LGPL�N)�urlparse�Atspiz2.0)r�)�debug)�AXObjectc��eZdZdZed��Zed��Zed��Zed��Zed
d��Z	ed��Z
ed��Zedd	��Zed
��Z
ed��Zy)�AXHypertextzNUtilities for obtaining information about accessible hypertext and hyperlinks.c�N�tj|�sy	tjj	|�}d|d|�d�g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z(Returns the number of hyperlinks in obj.rz+AXHypertext: Exception in _get_link_count: TNzAXHypertext:zreports z hyperlinks)
r�supports_hypertextr�	Hypertext�get_n_links�	Exceptionr�printMessage�
LEVEL_INFO�printTokens)�obj�count�error�msg�tokenss     �3/usr/lib/python3/dist-packages/orca/ax_hypertext.py�_get_link_countzAXHypertext._get_link_count3s����*�*�3�/��	��O�O�/�/��4�E�!�#��%���'D�E��
���%�*�*�F�D�9�����	�?��w�G�C����u�/�/��d�;���	�s�A'�'	B$�0*B�B$c���tj|�sy	tjj	||�}|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z4Returns the hyperlink object at the specified index.Nz.AXHypertext: Exception in _get_link_at_index: T)	rrrr
�get_linkrrrr)r�index�linkrrs     r�_get_link_at_indexzAXHypertext._get_link_at_indexEsp���*�*�3�/��	��?�?�+�+�C��7�D�����	�B�5�'�J�C����u�/�/��d�;���	�s� :�	A7�*A2�2A7c��g}ttj|��D]k}tj||�}|tj	|�cxkr|ks$n|tj|�cxkr|ks�Xn�[|j
|��mdt|��d�|d|�d|��g}tjtj|d�|S)zIReturns all the hyperlinks in obj who started within the specified range.�
AXHypertext: � hyperlinks found inzbetween start: z
 and end: T)�ranger
rr�get_link_start_offset�get_link_end_offset�append�lenrrr)r�start_offset�
end_offset�links�irrs       r�get_all_links_in_rangez"AXHypertext.get_all_links_in_rangeUs������{�2�2�3�7�8�	#�A��1�1�#�q�9�D��{�@�@��F�S��S���!@�!@��!F�T�*�T����T�"�		#�"�#�e�*��-A�B�C�#�L�>��J�<�H�J��
���%�*�*�F�D�9���c��g}ttj|��D],}tj||�}|��|j	|��.dt|��d�|g}t
jtj|d�|S)z,Returns a list of all the hyperlinks in obj.r r!T)	r"r
rrr%r&rrr)rr)r*rrs     r�
get_all_linkszAXHypertext.get_all_linkses������{�2�2�3�7�8�	#�A��1�1�#�q�9�D������T�"�	#�
"�#�e�*��-A�B�C�H��
���%�*�*�F�D�9��r,c�f�	tjj|�}tjj	||�}d|d|�d|��g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z;Returns the URI associated with obj at the specified index.z(AXHypertext: Exception in get_link_uri: TN�zAXHypertext: URI ofz	at index z is )
r�
Accessible�
get_hyperlink�	Hyperlink�get_urirrrrr)rrr�urirrrs       r�get_link_urizAXHypertext.get_link_uriss���	��#�#�1�1�#�6�D��/�/�)�)�$��6�C�(��	�%���S�E�.J�K��
���%�*�*�F�D�9��
���	�<�U�G�D�C����u�/�/��d�;���	�s�?A3�3	B0�<*B+�+B0c���t|tj�r|}ntjj	|�}|�*d|g}tjt
j|d�y	tjj|�}d|d|��g}tjt
j|d�|S#t$r4}d|��}tjt
j|d�Yd}~yd}~wwxYw)z7Returns the start offset of obj in the associated text.N�'AXHypertext: Couldn't get hyperlink forT���z1AXHypertext: Exception in get_link_start_offset: zAXHypertext: Start offset of�is )�
isinstancerr3r1r2rrr�get_start_indexrr�rrr�offsetrrs      rr#z!AXHypertext.get_link_start_offset�s����c�5�?�?�+��D��#�#�1�1�#�6�D��<�?��E�F����e�.�.���=��	��_�_�4�4�T�:�F�1�#��V�H�~�F��
���%�*�*�F�D�9��
���	�E�e�W�M�C����u�/�/��d�;���	���*B8�8	C5�*C0�0C5c���t|tj�r|}ntjj	|�}|�*d|g}tjt
j|d�y	tjj|�}d|d|��g}tjt
j|d�|S#t$r4}d|��}tjt
j|d�Yd}~yd}~wwxYw)z5Returns the end offset of obj in the associated text.Nr8Tr9z/AXHypertext: Exception in get_link_end_offset: zAXHypertext: End offset ofr:)r;rr3r1r2rrr�
get_end_indexrrr=s      rr$zAXHypertext.get_link_end_offset�s����c�5�?�?�+��D��#�#�1�1�#�6�D��<�?��E�F����e�.�.���=��	��_�_�2�2�4�8�F�/��s�6�(�^�D��
���%�*�*�F�D�9��
���	�C�E�7�K�C����u�/�/��d�;���	�r?c�r�tj||�}|syt|�}tjj|j�}|r9tjj
|�d}tjdd|�}d|d|�d�g}tjtj|d�|S)	z>Strip directory and suffix off of the URL associated with obj.r0rz[-_]� zAXHypertext: Basename for linkzis '�'T)r
r6r�os�path�basename�splitext�re�subrrr)rr�remove_extensionr5�
parsed_urirGrs       r�get_link_basenamezAXHypertext.get_link_basename�s����&�&�s�E�2�����c�]�
��G�G�$�$�Z�_�_�5����w�w�'�'��1�!�4�H��v�v�g�s�H�5�H�2�C�4��z��9K�L��
���%�*�*�F�D�9��r,c�R�tj|�sy	tjj	||�}|dkrytj||�}|�y	tjj|d�}d|�d�|d|g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)zAReturns the embedded-object child of obj at the specified offset.Nz/AXHypertext: Exception in get_child_at_offset: TrzAXHypertext: Child at offset z in�is)rrrr
�get_link_indexrrrrr
rr3�
get_objectr)rr>rrrr�childrs        r�get_child_at_offsetzAXHypertext.get_child_at_offset�s���*�*�3�/��	��O�O�2�2�3��?�E��1�9���-�-�c�5�9���<��	��O�O�.�.�t�Q�7�E�2�&���=�s�D�%�P��
���%�*�*�F�D�9����+�	�C�E�7�K�C����u�/�/��d�;���	���	�C�E�7�K�C����u�/�/��d�;���	�s/� B)� C)�)	C&�2*C!�!C&�)	D&�2*D!�!D&c�~�tjtj|��sytj	|�S)zHReturns the offset of the embedded-object obj in the text of its parent.r9)r�
supports_text�
get_parentr
r#)rs r�get_character_offset_in_parentz*AXHypertext.get_character_offset_in_parent�s1���%�%�h�&9�&9�#�&>�?���0�0��5�5r,N)r)rF)�__name__�
__module__�__qualname__�__doc__�staticmethodrrr+r.r6r#r$rMrSrW�r,rr
r
0s���X�����"�
��
��
��
������
��
�����0����0����"����>�6��6r,r
)r[�__id__�__version__�__date__�
__copyright__�__license__rErI�urllib.parser�gi�require_version�
gi.repositoryrr0r�	ax_objectrr
r]r,r�<module>rhsX��*�������1�
���	�	�!�	�����7�E�"����~6�~6r,

Zerion Mini Shell 1.0