%PDF- %PDF-
Mini Shell

Mini Shell

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

�

g
f�$����dZdZdZdZdZdZddlZddlZddlZddl	Z	e	jdd	�dd
lmZddl
mZdd
l
mZddlmZddlmZddlmZddlmZGd�d�Zy)a�
Utilities for obtaining document-related information about accessible objects.
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$zGCopyright (c) 2024 Igalia, S.L.Copyright (c) 2024 GNOME Foundation Inc.�LGPL�N�Atspiz2.0)r�)�debug)�messages)�AXCollection)�AXObject)�AXTable)�AXUtilitiesc�(�eZdZdZiZej�Zed��Z	ed��Z
ed��Zed��Zed��Z
ed��Zed��Zed	��Zed
��Zed��Zed��Zed
��Zed��Zed��Zedd��Zy)�
AXDocumentzNUtilities for obtaining document-related information about accessible objects.c��	tjd�d}tjtj|d�t
jj��[)z*Clears any data we have cached for objectsT�<z!AXDocument: Clearing local cache.)�time�sleepr�printMessage�
LEVEL_INFOr
�LAST_KNOWN_PAGE�clear)�msgs �2/usr/lib/python3/dist-packages/orca/ax_document.py�_clear_stored_datazAXDocument._clear_stored_data<sF����J�J�r�N�5�C����u�/�/��d�;��&�&�,�,�.�	�c�z�tjtj��}d|_|j�y)z3Starts thread to periodically clear cached details.)�targetTN)�	threading�Threadr
r�daemon�start)�threads r�start_cache_clearing_threadz&AXDocument.start_cache_clearing_threadFs*���!�!��)F�)F�G����
����rc��tj|�sytjj	t|��}|tj
|�k7}|r-d|d|��g}tjtj|d�|S)z)Returns True if the current page changed.FzAXDocument: Previous page ofzwas T)
r	�supports_documentr
r�get�hash�_get_current_pager�printTokensr)�document�old_page�result�tokenss    r�did_page_changezAXDocument.did_page_changeNsw���)�)�(�3���-�-�1�1�$�x�.�A���Z�9�9�(�C�C���4�h�$�x�j�@Q�R�F����e�.�.���=��
rc�L�tj|�sy	tjj	|�}d|d|��g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)�%Returns the current page of document.rz,AXDocument: Exception in _get_current_page: TNzAXDocument: Current page of�is )
r	r#r�Document�get_current_page_number�	Exceptionrrrr')r(�page�errorrr+s     rr&zAXDocument._get_current_page]s����)�)�(�3��	��>�>�9�9�(�C�D�0��S���<�H��
���%�*�*�F�D�9�����	�@���H�C����u�/�/��d�;���	���A&�&	B#�/*B�B#c��tj|�sytj|�}|tjt|�<|S)r.r)r	r#r
r&rr%)r(r3s  r�get_current_pagezAXDocument.get_current_pageos>���)�)�(�3���+�+�H�5��59�
�"�"�4��>�2��rc�L�tj|�sy	tjj	|�}d|d|��g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)z#Returns the page count of document.rz)AXDocument: Exception in get_page_count: TNzAXDocument: Page count ofr/)
r	r#rr0�get_page_countr2rrrr')r(�countr4rr+s     rr9zAXDocument.get_page_countzs����)�)�(�3��	��N�N�1�1�(�;�E�.�x�3�u�g��G��
���%�*�*�F�D�9�����	�=�e�W�E�C����u�/�/��d�;���	�r5c�N�tj|�sy	tjj	|�}d|d|�d�g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)zReturns the locale of document.�z%AXDocument: Exception in get_locale: TNzAXDocument: Locale ofzis '�')
r	r#rr0�
get_localer2rrrr'�r(r*r4rr+s     rr>zAXDocument.get_locale�s����)�)�(�3��	��^�^�.�.�x�8�F�*�8�t�F�8�1�5E�F��
���%�*�*�F�D�9��
���	�9�%��A�C����u�/�/��d�;���	�s�A'�'	B$�0*B�B$c�N�tj|�siS	tjj	|�}d|d|g}t
jtj|d�|S#t
$r6}d|��}t
jtj|d�icYd}~Sd}~wwxYw)z8Returns a dict with the document-attributes of document.z/AXDocument: Exception in _get_attributes_dict: TNzAXDocument: Attributes ofzare:)
r	r#rr0�get_document_attributesr2rrrr'r?s     r�_get_attributes_dictzAXDocument._get_attributes_dict�s����)�)�(�3��I�	��^�^�;�;�H�E�F�.�x���H��
���%�*�*�F�D�9��
���	�C�E�7�K�C����u�/�/��d�;��I��	�s�A%�%	B$�.+B�B$�B$c��tj|�sytj|�}|j	d|j	dd��S)�Returns the uri of document.r<�DocURL�URI�r	r#r
rBr$�r(�
attributess  r�get_urizAXDocument.get_uri�sA���)�)�(�3���4�4�X�>�
��~�~�h�
���u�b�(A�B�Brc�|�tj|�sytj|�}|j	dd�S)rDr<�MimeTyperGrHs  r�
get_mime_typezAXDocument.get_mime_type�s6���)�)�(�3���4�4�X�>�
��~�~�j�"�-�-rc�2�tj|�dk(S)z2Returns True if document is a plain-text document.z
text/plain)r
rM)r(s r�
is_plain_textzAXDocument.is_plain_text�s���'�'��1�\�A�Arc��tj|�}|dk(ry|dk(r$tj|�jd�Sy)z+Returns True if document is a PDF document.zapplication/pdfTz	text/htmlz.pdfF)r
rMrJ�endswith)r(�	mime_types  r�is_pdfzAXDocument.is_pdf�sG���,�,�X�6�	��)�)����#��%�%�h�/�8�8��@�@�rc�~�tjjtj	|��}|j
S)z/Returns the fragment portion of document's uri.)�urllib�parse�urlparser
rJ�fragment)r(r*s  r�get_document_uri_fragmentz$AXDocument.get_document_uri_fragment�s-�����&�&�z�'9�'9�(�'C�D�����rc�J�ddddddd�}tjjtjjtjjtjj
tjjg}tj|��}tj||�}|D]�}tj|�r|dxxdz
cc<�&tj|�r|dxxdz
cc<�Itj|�r#tj|�s|dxxdz
cc<��tj |�r1tj"|�r|dxxdz
cc<��|d	xxdz
cc<��tj$|�s��|d
xxdz
cc<��|S)zAReturns a dictionary of object counts used in a document summary.r)�forms�	landmarks�headings�tables�unvisited_links�
visited_links)�rolesr]rr[r^r`r_r\)r�Role�HEADING�LINK�TABLE�FORM�LANDMARKr�create_match_rule�get_all_matchesr�
is_heading�is_form�is_tabler
�is_layout_table�is_link�
is_visited�is_landmark)r(r*ra�rule�matches�objs      r�_get_object_countszAXDocument._get_object_counts�s]��� ���%&�#$�&�����#�#���������!�!���������$�$�	&���-�-�E�:���.�.�x��>���
	)�C��%�%�c�*��z�"�a�'�"��$�$�S�)��w��1�$���%�%�c�*�7�3J�3J�3�3O��x� �A�%� ��$�$�S�)��)�)�#�.��?�+�q�0�+��,�-��2�-��(�(��-��{�#�q�(�#�
	)��
rc�"�g}tj|�}|jtj|jdd�|��|jtj|jdd�|��|jtj|jdd�|��|jtj|jdd�|��|jtj|jdd�|��|jtj|jdd�|��ttd�|��}|sy	tjd
j|�zS)zNReturns a string summarizing the document's structure and objects of interest.r\rr]r[r^r`r_c��|S)N�)�xs r�<lambda>z1AXDocument.get_document_summary.<locals>.<lambda>
s��q�rr<z, )r
rt�appendr�
landmarkCountr$�headingCount�	formCount�
tableCount�visitedLinkCount�unvisitedLinkCount�list�filter�PAGE_SUMMARY_PREFIX�join)r(�
only_if_foundr*�countss    r�get_document_summaryzAXDocument.get_document_summarys&�����.�.�x�8���
�
�h�,�,�V�Z�Z��Q�-G��W�X��
�
�h�+�+�F�J�J�z�1�,E�}�U�V��
�
�h�(�(����G�Q�)?��O�P��
�
�h�)�)�&�*�*�X�q�*A�=�Q�R��
�
�h�/�/��
�
�?�A�0N�P]�^�_��
�
�h�1�1�&�*�*�=N�PQ�2R�Ta�b�c��f�[�&�1�2�����+�+�d�i�i��.?�?�?rN)T)�__name__�
__module__�__qualname__�__doc__rr�Lock�_lock�staticmethodrr!r,r&r7r9r>rBrJrMrOrSrYrtr�rwrrr
r
6sI��X��O��I�N�N��E��/��/�������������"��������"����"����"�C��C��.��.��B��B�
���������"��"�H�@��@rr
)r��__id__�__version__�__date__�
__copyright__�__license__rrrU�gi�require_version�
gi.repositoryrr<rr�
ax_collectionr�	ax_objectr	�ax_tabler
�ax_utilitiesrr
rwrr�<module>r�sh��,�������;�
�����
�	�����7�E�"����'���%�[@�[@r

Zerion Mini Shell 1.0