%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�QDb�J���ddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddl
mZdgZ
dZd�ZGd	�d
ej �ZGd�d�Zd�Zy)
�N)�XML�)�Device��_debugprint�OpenPrintingg.@c���|j�}|jdd�}|jd�}|dk7r)|jdd�}|jd�}|dk7r�)|S)N�
� z  ���)�strip�replace�find)�text�result�is   �:/usr/lib/python3/dist-packages/cupshelpers/openprinting.py�_normalize_spacer s`��
�Z�Z�]�F�
�^�^�T�3�
'�F����T��A�
�r�'�����s�+���K�K�����r�'��M�c� �eZdZdd�Zd�Zd�Zy)�_QueryThreadNc���tjj|�||_||_||_||_d|_|jd�td|z�y)NrT�+%s)
�	threading�Thread�__init__�parent�
parameters�callback�	user_datar�	setDaemonr)�selfrrrr s     rrz_QueryThread.__init__*sQ�����!�!�4�(����$��� ��
�"������������U�T�\�"rc� �td|z�y�Nz-%sr�r"s r�__del__z_QueryThread.__del__5����U�T�\�"rc���d}ddd�}tjj|j��d|jj
d�d|jj
d��}d|jj�|�d	|��|_d
|_d}	tjj|j|��}tjj|t�
�5}|j�|_d}ddd�t!d|z�|j"�(|j#||j$|j�yy#1swY�LxYw#tj�|_Y�lxYw)Nz
/query.cgiz!application/x-www-form-urlencodedz
text/plain)zContent-type�Acceptz&uilanguage=rz&locale=zhttps://�?rr)�headers��timeoutz%s: query complete)�urllib�parse�	urlencoderr�language�base_url�urlr�request�Request�urlopen�
HTTPS_TIMEOUT�read�sys�exc_inforrr )r"�
query_commandr+�params�status�req�resps       r�runz_QueryThread.run8s+��%�
�#F�)�+���<�<�)�)�4�?�?�;��;�;�'�'��*��;�;�'�'��*�,��)-���(<�(<�m�V�T��������	)��.�.�(�(����7�(�C�C����'�'��]�'�C�
�t�"�i�i�k�����
�	�)�D�0�1��=�=�$��M�M�6�4�>�>�4�;�;�?�%�
�
��	)��,�,�.�D�K�s%�AE�$E�<E�E�E�E0�N)�__name__�
__module__�__qualname__rr&r@�rrrr)s��	#�#�@rrc�8�eZdZdd�Zd�Zd�Zdd�Zdd�Zd	d�Zy)
rNc�.�|� ddl}	|j|j�}||_d|_d|_d|_td|j�d|j�d|j���td|z�y#|j$rd}Y�pwxYw)	z�
        @param language: language, as given by the first element of
        locale.setlocale().
        @type language: string
        Nr�Czwww.openprinting.orgrzOpenPrinting: Init rr)	�locale�	getlocale�LC_MESSAGES�Errorr1r2�onlyfree�onlymanufacturerr)r"r1rIs   rrzOpenPrinting.__init__Ts������
�!�+�+�F�,>�,>�?��!��
�/��
���
� !����d�m�m�T�]�]�TX�Ti�Ti�j�k��U�T�\�"���<�<�
���
�s�B�B�Bc� �td|z�yr$rr%s rr&zOpenPrinting.__del__lr'rc�"�	d|_y#YyxYw)zU
        Cancel an operation.

        @param handle: query/operation handle
        N)r)r"�handles  r�cancelOperationzOpenPrinting.cancelOperationos��	�"�F�O��	��s�
�c�B�t||||�}|j�|S)ad
        Run a web query for a driver.

        @type parameters: dict
        @param parameters: URL parameters
        @type callback: function
        @param callback: callback function, taking (integer, user_data, string)
        parameters with the first parameter being the status code, zero for
        success
        @return: query handle
        )r�start)r"rrr �
the_threads     r�webQueryzOpenPrinting.webQuery{s&��"�4��X�y�I�
������rc�l�d�}d|dd�}tdt|�z�|j||||f�S)an
        Search for printers using a search term.

        @type searchterm: string
        @param searchterm: search term
        @type callback: function
        @param callback: callback function, taking (integer, user_data, string)
        parameters with the first parameter being the status code, zero for
        success
        @return: query handle
        c�P�|\}}|dk7r||||�yd}i}	t|�}|jd�D]v}|jd�}|jd�}	|jd�}
|��9|	��<|
��?|j}|	j}|
j}
|s�f|s�i|
s�l|dz|
z||<�x	t
dt|�z�	||||�y#d}t	j
�}Y�=xYw#t	j
�\}}}tj|d�	�}t|�r|dt|�dz
}tj||�}tj|�D]}t|j���t|dj��YyxYw)
Nr�printer�id�make�modelrrz5searchPrinters/parse_result: OpenPrinting entries: %s)�limit)r�findallrrr9r:r�repr�	traceback�
extract_tb�len�format_exception_only�	format_tb�printr
)r=�datarrr �printers�rootrYrZr[r\�idtxt�maketxt�modeltxt�type�value�tb�tblast�extxt�lines                    r�parse_resultz1OpenPrinting.searchPrinters.<locals>.parse_result�s���$(�!�X�y���{��&�)�V�4���F��H�
+��F�|�� $�|�|�Y�7�	G�G� ���t�,�B�"�<�<��0�D�#�L�L�'�2�E��~�$�*:�u�?P� "����"&�)�)��#(�:�:�� �W��.5��m�h�.F�H�U�O�	G�
�P�SW�X`�Sa�a�b�

*��&�)�X�6��

+����<�<�?���

*�$'�L�L�O�!��u�b�"�-�-�r��>����<�#�$5�S�&�\�A�%5�6�F�!�7�7��u�E��%�/�/��3�*�D��4�:�:�=�)�*��u�Q�x�~�~�(�)�s=�AC�0C�3C�6&C�C� C�#
C�	
C1�C.�1B2F%rg�xml)rlrY�formatz)searchPrinters: Querying OpenPrinting: %s)rr_rV)r"�
searchtermrr rrr<s      r�searchPrinterszOpenPrinting.searchPrinters�sF��&	*�R&�(�"�%��	�@�4��<�O�P��}�}�V�\�H�i�3H�I�Irc��d�}t|t�r|j}tj�}|dk(rtj
�ddk(rd}dddd|dt
|j�t
|j�|dd	�
}|r|j|�td
t|�z�|j||||f�S)ah
        Obtain a list of printer drivers.

        @type model: string or cupshelpers.Device
        @param model: foomatic printer model string or a cupshelpers.Device
        object
        @type callback: function
        @param callback: callback function, taking (integer, user_data, string)
        parameters with the first parameter being the status code, zero for
        success
        @type extra_options: string -> string dictionary
        @param extra_options: Additional search options, see
        http://www.linuxfoundation.org/en/OpenPrinting/Database/Query
        @return: query handle
        c	�D�|\}}|dk7r
||||�	|jdd��jd�}t|�}i}|jd�D�]w}|jjd�}|��"i}	dD];}
|j
|
�}|��|j��$t|j�|	|
<�=|j
d�}|�|j�|j|	d<d|	vs|	d�r|j
d	�}|�_|j}|�Q	tjj|t�
�5}
|
j�jd�|	d<ddd�d
D]}|j
|�du|	|<�|	d|	d<g}|j
d�}|��|jd�D]{}i}|j�t|j�|d<nd|d<|jjd�|d<|jjd�|d<|j|��}|r||	d<d|	vsd|	vr���|j
d�}|�=i}dD]%}
|j
|
�}|��|j||
<�'|r||	|j <i}|j
d�}|��t#|�D]�}i}|jd�D]�}i}dD]%}
|j
|
�}|��|j||
<�'|j
d�}|�9t#|�D]+}|j|j%di�|j <�-|||jd<��|||j <��|r||	d<g}|j
d�}|�+t#|�D]}|j|j��|r||	d<|	||<tdt'|�z���z|d||�y#1swY���xYw#td|z�Y���xYw#|d|t)j*��YyxYw) NrzUTF-8r)�errors�driverrZ)�namer3�supplier�license�shortdescription�licensetext�licenselinkr,zutf-8zCannot retrieve %s)�nonfreesoftware�recommended�patents�thirdpartysupplied�manufacturersuppliedr��freesoftware�supportcontacts�supportcontactr{�r3�level�
functionality)r�lineart�graphics�photo�speed�packages�package)�realversion�version�releaser3�pkgsys�fingerprint�repositories�file�ppdsz2listDrivers/parse_result: OpenPrinting entries: %sr)�decode�encoderr^�attrib�getrrrr.r4r6r7r8r�append�tag�list�
setdefaultr_r9r:)r=rfrrr rh�driversrzrZ�dict�	attribute�element�license_urlr?�booleanr��	container�scr�r�r��arch�rpmsr��rpmr�r�r��eachs                             rrrz.OpenPrinting.listDrivers.<locals>.parse_result�s���$(�!�X�y���{��&�)�V�4�Z
9����w�y��A�H�H��Q���F�|����V#�l�l�H�5�hg�F����*�*�D�1�B��z� ��D�&;�N�	�"(�+�+�y�"9��"�.�7�<�<�3K�.>����.M�D��O�	N�%�k�k�=�9�G��*�w�|�|�/G�.5�l�l��]�+�(�D�0��M�*�2�"(�+�+�}�"=��"�.�*1�,�,�K�*�6�!=�)/���)?�)?��Ub�)?�)c�%Z�gk�>B�i�i�k�>P�>P�QX�>Y��]�(;�%Z�$<�J��)/���W�(=�T�(I��W�
�J�04�4E�/F�+F�D��(�&(�O� &���->� ?�I� �,�"+�"3�"3�5E�"F�	D�B�-/�N�!�w�w�2�$4�b�g�g�$>�!/�v� 6�:<��v� 6�46�I�I�M�M�5�4I�N�5�1�68�i�i�m�m�W�6M�N�7�3�+�2�2�N�C�	D�'�2A��.�/��T�)�U�$�->� � &���_� =�I� �,�(*�
�*<�H�I�&/�n�n�i�&@�G�&�2�;B�<�<�
�i� 8�	H�
)�2?�D����/�!�H� &���Z� 8�I� �,�$(��O�6�D�#%�D�+/�<�<��+C�C��&(��2A�!F�I�/6�l�l�I�.F�G�'.�':�9@����I��!F�07�|�|�^�/L��#/�#;�26�|�2D�%e��Y_�Yd�Yd����~�r�(J�6�:�:�(V�%e�@C��W�^�^�F�%;� <�C�26�H�T�X�X�.�#6�& �+3��Z�(��D� &���V� 4�I� �,�$(��O�4�D� �K�K����3�4��'+��V��"&�G�B�K��!U�X\�]d�Xe�!e�f�Qhg�R�!�Y��0�g%Z�%Z��!=�$/�0D�0;�1<�%=��b
9��!�Y�����8�sX�A<O?�O?� A2O?�%O)�8#O�O)�#DO?�,A5O?�"C9O?�O&	�!O)�)O<�9O?�?P�x86_64r�32bit�i386r��1rs)
rl�moreinfo�
showprinterid�onlynewestdriverpackages�
architectures�noobsoletesrMrNrYrtz&listDrivers: Querying OpenPrinting: %s)
�
isinstancerrZ�platform�machine�architecture�strrMrN�updaterr_rV)r"r\rr �
extra_optionsrrr�r<s        r�listDriverszOpenPrinting.listDrivers�s���"_	9�B�e�V�$��H�H�E��'�'�)��
�8�#��(=�(=�(?��(B�g�(M�!�L�$�"�$'�/2�$0�"%�"�D�M�M�2�'*�D�,A�,A�'B�#�"�	$����M�M�-�(��=��V��L�M��}�}�V�\�H�i�3H�I�IrrA)NN)	rBrCrDrr&rRrVrvr�rErrrrSs$��#�0#�
�� :J�xJJrc�����ddlm�ddlm�ddl��j	�G���fd�d�}|�}�j�y)Nr)�Gdk)�Gtkc�B��eZdZ�fd�Z�fd�Z�fd�Z��fd�Z�fd�Zy)�_simple_gui.<locals>.QueryAppc���t�|_�jddd��|_|jj	�j
�jjdddd�|jjd�|jjjd	��jjd
d�}|jjj|ddd�|jd��j�|_|j|jd
d
d��j!�}�j#�|_|j'|j$�|j|ddd�|jj)d|j*�|jj-�y)
NzOpenPrinting query applicationT)�title�
transient_for�modal�Search�
�List���Fr�response)r�openprinting�Dialog�main�add_buttons�STOCK_CLOSE�ResponseType�CLOSE�set_border_width�vbox�set_spacing�VBox�new�
pack_start�Entry�entry�ScrolledWindow�TextView�tv�add�connectr��show_all)r"r��swr�s   �rrz&_simple_gui.<locals>.QueryApp.__init__�sK��� ,��D���
�
�*J�26�d�#�D�D�I��I�I�!�!�3�?�?�C�4D�4D�4J�4J�#+�R�#)�2�
/�
�I�I�&�&��*��I�I�N�N�&�&��*��8�8�<�<���*�D��I�I�N�N�%�%�t�T�4��;��!�!�1�%�����D�J��O�O�T�Z�Z���q�9��#�#�&�B��l�l�o�D�G��F�F�D�G�G���O�O�R��t�Q�/��I�I���z�4�=�=�9��I�I���!rc���|�jjk(s|�jjk(r�j�|dk(r>|jj|jj�|j�|dk(r?|jj|jj�|j�yy)Nr�r�)r�r��DELETE_EVENT�	main_quitr�rvr��get_text�search_printers_callbackr��list_drivers_callback)r"�dialogr�r�s   �rr�z&_simple_gui.<locals>.QueryApp.response�s�����C�,�,�2�2�2��C�,�,�9�9�9��
�
� ��2�~��!�!�0�0�$�*�*�2E�2E�2H�26�2O�2O�Q��2�~��!�!�-�-�t�z�z�/B�/B�/E�/3�/I�/I�K�rc����|dk7r|d�d}|j�D]
}||dzz
}��j�|jj�j	|��j�y)Nrrr�r
)�values�
threads_enterr��
get_buffer�set_text�
threads_leave)r"r=r rgrrYr�s      �rr�z6_simple_gui.<locals>.QueryApp.search_printers_callback�sp�����{��q�k�!��D�#�?�?�-�
'����$��&��
'���� ��G�G���!�*�*�D�1���� rc����|dk7r|d��j|�}�j�|jj�j	|��j�y)Nrr)�pformatr�r�r�r�r�)r"r=r r�rr��pprints     ��rr�z3_simple_gui.<locals>.QueryApp.list_drivers_callback�sU�����{��a�j� ��>�>�7�+�D���� ��G�G���!�*�*�D�1���� rc�����j�|jj�jt	|��tdd�j
t	|���j�y)Nz
result.xml�w)r�r�r�r�r��open�writer�)r"r=r rr�s    �r�query_callbackz,_simple_gui.<locals>.QueryApp.query_callback�sS������ ��G�G���!�*�*�C��L�9��,��$�*�*�C��L�9���� rN)rBrCrDrr�r�r�r�)r�r�r�s���r�QueryAppr��s���	"�*	K�		!�	!�	!rr�)�
gi.repositoryr�r�r��threads_initr�)r��qr�r�r�s  @@@r�_simple_guir��s5���!�!������<!�<!�|	�
�A��H�H�Kr)�urllib.requestr.�urllib.parse�urllib.errorr�rr`r9�xml.etree.ElementTreerr�rr�__all__r7rrrrr�rErr�<module>rsY��,R�Q�Q�
�%����
���
��(@�I�$�$�(@�T~J�~J�@
Dr

Zerion Mini Shell 1.0