%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__/cupshelpers.cpython-312.pyc

�

Hf6x����ddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZGd�d�Zd�Z
d	�ZGd
�d�ZGd�d
e�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedk(re�yy)�N�)�_debugprint)�config)�reducec��eZdZddgZd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
dd�Zdd�Zd�Zd�Zd�Zd�Zd�Zdd�Zdd�Zdd�Zd�Zy
)�Printer�options�localc���||_||_g|_t|�dkD}d}|r#|jdi|��|j
rd}nd}|r|j
�d|_y)z�
        @param name: printer name
        @type name: string
        @param connection: CUPS connection
        @type connection: CUPS.Connection object
        @param kw: printer attributes
        @type kw: dict indexed by string
        rTFN�)�name�
connection�
class_members�len�update�is_class�
getAttributes�_ppd)�selfr
r�kw�have_kw�fetch_attrss      �9/usr/lib/python3/dist-packages/cupshelpers/cupshelpers.py�__init__zPrinter.__init__sg����	�$�������r�(�Q�,������D�K�K��2���}�}�"��#������!���	�c�\�|j� tj|j�yy�N)r�os�unlink�rs r�__del__zPrinter.__del__9s!���9�9� ��I�I�d�i�i� �!rc� �d|jzS)Nz<cupshelpers.Printer "%s">)r
r s r�__repr__zPrinter.__repr__=s��-��	�	�9�9rc��d�}d}t|�}tjD]f}|j|�s�|||d�}||jvr�/|dk(rd}t||t
|jtt|�z���hy)Nc�"�|j�Sr)�lower)�strs r�_ascii_lowerz+Printer._expand_flags.<locals>._ascii_lowerBs���9�9�;�r�
CUPS_PRINTER_�classr)	r�cups�__dict__�
startswith�_flags_blacklist�setattr�bool�type�getattr)rr(�prefix�
prefix_lengthr
�	attr_names      r�
_expand_flagszPrinter._expand_flags@s���	 �!���F��
��M�M�	?�D����v�&� ��m�n�!5�6���� 5� 5�5�x���'�Z����i��T�Y�Y���t�)<�<�=�?�	?rc�@�|jdd�|_|jtjk7|_|jdd�|_|jdd�|_|jdd�|_|jdd�|_|jd	d�|_	|jd
d�|_
|jdd�|_t|j�tk7r|jg|_|j�|j�|j|_|`|jdg�|_t|j�tk7r|jg|_|jj!�||_y)
z�
        Update object from printer attributes.

        @param kw: printer attributes
        @type kw: dict indexed by string
        z
printer-staterz
device-uri�zprinter-infozprinter-is-sharedNzprinter-locationzprinter-make-and-modelzprinter-typezprinter-uri-supportedzmember-names)�get�stater+�IPP_PRINTER_STOPPED�enabled�
device_uri�info�	is_shared�location�make_and_modelr1�
uri_supported�listr6�
not_sharedr�sort�other_attributes)rrs  rrzPrinter.updateSsN���V�V�O�Q�/��
��z�z�T�%=�%=�=����&�&��r�2����F�F�>�2�.��	���� 3�T�:������1�2�6��
� �f�f�%=�r�B����F�F�>�1�-��	��V�V�$;�R�@�����#�#�$��,�"&�"4�"4�!5�D�������>�>�!�!%���0�D�N��O��V�V�N�B�7�����#�#�$��,�"&�"4�"4�!5�D�������"� "��rc��|jj|j�}i|_i|_dddgfdgd�fd�|_|j
�D]�\}}|jd�r�|dtd�}|dvr�+|j|d	zd�xs |j
j|d�xsd
}t|t�r
td�|�}||j|<|d	z|vs��||d	z}||f|j
|<��|jd	�r��|dk7s��|d
k7s��|dk7s��|jd�r��||j|<��|jdd�\|_|_|jddg�|_|jd
d�|_|jddg�|_|jdd
�xsd|_|jddg�|_d|_g|_d|vr|d|_d|_nd|vr
|d|_dj/|j,�|_|j2di|��y)z�
        Fetch further attributes for the printer.

        Normally only a small set of attributes is fetched.  This
        method is for fetching more.
        �False�True�none)rJ�singlezsingle-thick�doublezdouble-thick)�	landscapezpage-borderz-defaultN)z
job-sheets�printer-error-policy�printer-op-policyz
notify-eventszdocument-formatznotify-lease-durationz
-supportedr8c��|dz|zS)N�,r)�x�ys  r�<lambda>z'Printer.getAttributes.<locals>.<lambda>�s���3��q��rzjob-sheets-defaultrNrOzrequesting-user-name-)rJrJzjob-sheets-supportedzprinter-error-policy-supported�defaultzprinter-op-policy-supportedTzrequesting-user-name-allowedFzrequesting-user-name-deniedz, r)r�getPrinterAttributesr
�
attributesrF�possible_attributes�items�endswithrr9�
isinstancerCrr-�job_sheet_start�
job_sheet_end�job_sheets_supported�error_policy�error_policy_supported�	op_policy�op_policy_supported�
default_allow�except_users�join�except_users_stringr)r�attrs�key�valuer
�	supporteds      rrzPrinter.getAttributesosv�����4�4�T�Y�Y�?����� "���"�V�W�$5�6�#�&?�@�$�� � �+�+�-�	3�J�C���|�|�J�'��,�S��_�,�-���5�5�
�!�I�I�d�\�&9�4�@�� �4�4�8�8��t�D�����u�d�+�"�$8�%�@�E�(-�����%���$��-� %�d�<�&7� 8�I�6;�Y�5G�D�,�,�T�2��l�l�L�1��-�-��/�/��,�,��n�n�&=�>�-2��%�%�c�*�=	3�@49�9�9� �"2�44�0���d�0�$)�I�I�.D�v�h�$O��!�!�I�I�&<�f�E���&+�i�i�,�v�h�'8��#����#6��;�H�y���#(�9�9�)�I�;�$8�� �"������)�U�2� %�&D� E�D��!&�D��
*�e�
3� %�&C� D�D��#'�9�9�T�->�->�#?�� ������u�rc���|jdjd�sy|jddd}|jd�d}|jd�d}|dk(rd}|S)	zc
        Find out which server defines this printer.

        @returns: server URI or None
        rzipp://N��/�:zlocalhost.localdomain�	localhost)rBr-�split)r�uris  r�	getServerzPrinter.getServer�sn���!�!�!�$�/�/��9��� � ��#�A�B�'���i�i��n�Q����i�i��n�Q����)�)��C��
rc��d}|j�J	|jj|j�|_t	j
|j�}|�+|j�t	j
|j�}|S#tj$r0}|j\}}|tjk(rd}n�Yd}~�md}~wwxYw)z�
        Obtain the printer's PPD.

        @returns: cups.PPD object, or False for raw queues
        @raise cups.IPPError: IPP error
        NF)	rr�getPPDr
r+�PPD�IPPError�args�
IPP_NOT_FOUND)r�result�emargs�e�ms     rrtzPrinter.getPPD�s������9�9��
� �O�O�2�2�4�9�9�=��	����4�9�9�-���>�d�i�i�3��X�X�t�y�y�)�F��
���=�=�
������A���*�*�*�"�F����
�s�A	B�C�&C�Cc��t|t�rCtjtj�}|dk7rt|�j
|d�}|jj|j||�y)z�
        Set a printer's option.

        @param name: option name
        @type name: string
        @param value: option value
        @type value: option-specific
        �.N)
r[�float�locale�nl_langinfo�	RADIXCHARr'�replacer�addPrinterOptionDefaultr
)rr
ri�	radixchars    r�	setOptionzPrinter.setOption�s\���u�e�$��*�*�F�,<�,<�=�I��C���U��+�+�Y��<�����/�/��	�	�4��Grc�P�|jj|j|�y)zh
        Unset a printer's option.

        @param name: option name
        @type name: string
        N)r�deletePrinterOptionDefaultr
)rr
s  r�unsetOptionzPrinter.unsetOption�s��	
���2�2�4�9�9�d�CrNc���|r&|jj|j�y|r(|jj|j|��y|jj|j�y)z�
        Set the printer's enabled state.

        @param on: whether it will be enabled
        @type on: bool
        @param reason: reason for this state
        @type reason: string
        ��reasonN)r�
enablePrinterr
�disablePrinter�r�onr�s   r�
setEnabledzPrinter.setEnabled�sQ����O�O�)�)�$�)�)�4�����.�.�t�y�y��.�H����.�.�t�y�y�9rc���|r&|jj|j�y|r(|jj|j|��y|jj|j�y)z�
        Set the printer's accepting state.

        @param on: whether it will be accepting
        @type on: bool
        @param reason: reason for this state
        @type reason: string
        r�N)r�
acceptJobsr
�
rejectJobsr�s   r�setAcceptingzPrinter.setAcceptingsQ����O�O�&�&�t�y�y�1�����*�*�4�9�9�V�*�D����*�*�4�9�9�5rc�P�|jj|j|�y)zy
        Set the printer's shared state.

        @param on: whether it will be accepting
        @type on: bool
        N)r�setPrinterSharedr
)rr�s  r�	setSharedzPrinter.setShareds��	
���(�(����B�7rc�P�|jj|j|�y)zs
        Set the printer's error policy.

        @param policy: error policy
        @type policy: string
        N)r�setPrinterErrorPolicyr
�r�policys  r�setErrorPolicyzPrinter.setErrorPolicys��	
���-�-�d�i�i��@rc�P�|jj|j|�y)z{
        Set the printer's operation policy.

        @param policy: operation policy
        @type policy: string
        N)r�setPrinterOpPolicyr
r�s  r�setOperationPolicyzPrinter.setOperationPolicy's��	
���*�*�4�9�9�f�=rc�R�|jj|j||�y)z�
        Set the printer's job sheets.

        @param start: start sheet
        @type start: string
        @param end: end sheet
        @type end: string
        N)r�setPrinterJobSheetsr
)r�start�ends   r�setJobSheetszPrinter.setJobSheets0s��	
���+�+�D�I�I�u�c�Brc���t|t�rw|j�}|D�cgc]}|jd���}}g}|D]}|j|��|D�cgc]}|j	���}}|D�cgc]}|s�|��	}}|r'|j
j
|j|�y|j
j|j|�ycc}wcc}wcc}w)z�
        Set access control list.

        @param allow: whether to allow by default, otherwise deny
        @type allow: bool
        @param except_users: exception list
        @type except_users: string list
        rQN)	r[r'rp�extend�stripr�setPrinterUsersDeniedr
�setPrinterUsersAllowed)r�allowrd�users�u�_fs      r�	setAccesszPrinter.setAccess;s����l�C�(� �&�&�(�E�+0�1�a�Q�W�W�S�\�1�E�1��L��
'���#�#�A�&�
'�/;�<�!�A�G�G�I�<�L�<�)5�<�2��B�<�L�<���O�O�1�1�$�)�)�\�J��O�O�2�2�4�9�9�l�K��2��=��<s�C�C�:C"�C"c���g}		gd�}|jj|��}|j�D]g\}}	|d}||j
d�dzd}||jk7r�3|rd|vs�:|ddk(s�C|j|�|��Wt|�|k(s�f|S|S#t$r|jj�}Y��wxYw#tj$r|cYSwxYw#Y��xYw)	z�
        Find out whether jobs are queued for this printer.

        @param only_tests: whether to restrict search to test pages
        @type only_tests: bool
        @returns: list of job IDs
        )�job-id�job-printer-uri�job-name)�requested_attributesr�rmrNr�z	Test Page)
r�getJobs�	TypeErrorr+rvrY�rindexr
�appendr)	r�
only_tests�limit�ret�r�jobs�idrgrqs	         r�
jobsQueuedzPrinter.jobsQueuedRs����	�
2�=�����.�.�Q�.�G������	�I�B��
��-�.���#�*�*�c�*�Q�.�/�0���d�i�i�����u�$��z�"�k�1��
�
�B���$��c��e�);���
�!	� �
��-�
2����.�.�1��
2���}�}�	��J�	��
��s4� B!�C%�!#C�C
�C�C
�
C"�!C"�%C)c�"�g}		gd�}|jjd|��}|j�D]�\}}	|d}||j
d�dzd}||jk7r�3|jd	tj�tjkr�e|j|�|��yt|�|k(s��|S|S#t$r|jjd��}Y��wxYw#tj$r|cYSwxYw#Y��xYw)
zo
        Find out whether there are preserved jobs for this printer.

        @return: list of job IDs
        )r�r��	job-state�	completed)�
which_jobsr�)r�r�rmrNr�)
rr�r�r+rvrYr�r
r9�IPP_JOB_PENDING�IPP_JOB_COMPLETEDr�r)rr�r�r�r�r�rgrqs        r�
jobsPreservedzPrinter.jobsPreservedws/����		�
H�>�����.�.�;�EF�/�H������
	�I�B��
��-�.���#�*�*�c�*�Q�.�/�0���d�i�i����	�	�;��/�/�1�37�3I�3I�J���J�J��O�� �S�#�Y�%�%7���
�
	��
��+�
H����.�.�;�.�G��
H���}�}�	��J�	��
��s4�!C�D
�%C,�)C/�+C,�,C/�/D�D�
Dc�(�|jd|��S)zl
        Find out whether test jobs are queued for this printer.

        @returns: list of job IDs
        T)r�r�)r�)rr�s  r�testsQueuedzPrinter.testsQueued�s�����4�u��=�=rc	��|jj|j�tj�5}	d}|jj||j
���|jd�|j�D�cgc]}|jd���}}d}d}|D]I}|jd�s�|j!d�d	}	|	|jk7r
d
|ddz||<d}|d	z
}�K|r�|jd�|j#|D�cgc]}|j%d���c}�|j'�|j)�|jd�	|jj+||j
���|cddd�S#tj$rW}|j\}|tjtjfvr
Yd}~ddd�ytj|��d}~wwxYwcc}wcc}w#tj$rYddd�ywxYw#1swYyxYw)
z9
        Set this printer as the system default.
        z/admin/conf/lpoptions)�fdNFrzUTF-8zDefault � rzDest �T)r�
setDefaultr
�tempfile�
TemporaryFile�getFile�filenor+�	HTTPErrorrw�HTTP_NOT_FOUND�HTTP_AUTHORIZATION_CANCELED�seek�	readlines�decoder-rp�
writelines�encode�truncate�flush�putFile)
r�f�resourcer{�s�line�lines�changed�ir
s
          r�setAsDefaultzPrinter.setAsDefault�s���	
���"�"�4�9�9�-��
#�
#�
&�$	�!�
)�2�����'�'��Q�X�X�[�'�A�
�F�F�A�J�78�{�{�~�G�t�d�k�k�'�*�G�E�G��G��A��
���?�?�J�/��:�:�s�+�A�.�D��t�y�y�(�#*�T�!�"�X�#5��a��"&����F�A�
������
�����H�����G� 4�H�I��
�
�
����
�����
�!��O�O�+�+�X�!�(�(�+�+�F��I$	�$	���>�>�
)��v�v�����,�,�d�.N�.N�O�O� �$	�$	��n�n�a�(�(��
)��H��I���~�~�!� �E$	�$	�B!��C$	�$	�s}�H9�-F!�)#H9�H�$H9�AH9�H
�28H9�++H�H9�!H�40H�$H9�1H�H�
H9�H6�+H9�5H6�6H9�9Ir)FN)�__name__�
__module__�__qualname__r.rr!r#r6rrrrrtr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrs��!�7�+���4!�:�?�&#�8B�H
��0H� D�:�"6�"8�A�>�	C�L�.#�J!�F>�,rrc���|j�}|j�}|j�D]@\}}t||fi|��}|||<||vs�|||_|jj��B|S)z�
    Obtain a list of printers.

    @param connection: CUPS connection
    @type connection: CUPS.Connection object
    @returns: L{Printer} list
    )�getPrinters�
getClassesrYrrrE)r�printers�classesr
�printers     rr�r��s����%�%�'�H��#�#�%�G�!���)�)�
��g��$�
�6�g�6�� �����7�?�$+�D�M�G�!��!�!�&�&�(�)��Orc���i}|jd�}|D]M}|jd�dk(r�|jdd�\}}|j�||j�<�Od|vr|jd|d�d|vr|jd|d�d	|vr|jd
|d	�dD]}|j|d��|d
dk(rg|d
<|S|d
jd
�|d
<|S)z�
    Parse an IEEE 1284 Device ID, so that it may be indexed by field name.

    @param id: IEEE 1284 Device ID, without the two leading length bytes
    @type id: string
    @returns: dict indexed by field name
    �;rn���r�MANUFACTURER�MFG�MODEL�MDLzCOMMAND SET�CMD)	r�r�r��CLS�DES�SN�S�P�Jr8rQ)rp�findr��
setdefault)r��id_dict�pieces�piecer
ris      r�
parseDeviceIDr�s���G�
�X�X�c�]�F��/���:�:�c�?�b� ���k�k�#�a�(���e�!&������
�
�
��	/�
�� ����5�'�.�"9�:��'�����5�'�'�"2�3�������5�'�-�"8�9�H�%�����4��$�%��u�~��������N�!���-�-�c�2�����Nrc�"�eZdZdZd�Zd�Zd�Zy)�Devicez.
    This class represents a CUPS device.
    c��||_|jdd�|_|jdd�|_|jdd�|_|jdd�|_|jdd�|_|jd�}|d|_t|�d	k(|_
t|j
�|_|jd
�}|dk7r3|jjdd�s||d
zd|jd<yyy)z~
        @param uri: device URI
        @type uri: string
        @param kw: device attributes
        @type kw: dict
        zdevice-classr8zdevice-infozdevice-make-and-modelz	device-idzdevice-locationrnrrzserial=r�r��N)rqr9�device_classr>rAr�r@rpr1rrrr�r�)rrqr�
uri_piecesr�s     rrzDevice.__init__s�������F�F�>�2�6����F�F�=�"�-��	� �f�f�%<�b�A����&�&��b�)������0�"�5��
��Y�Y�s�^�
���]��	��J���*��
�%�d�g�g�.����H�H�Y�����7�4�<�<�+�+�T�"�5�!$�Q��U�V��D�L�L���6�7rc� �d|jzS)Nz<cupshelpers.Device "%s">)rqr s rr#zDevice.__repr__s��,�t�x�x�7�7rc���|�y|j|jk7r|jryy|j}|dk(rb|jjd�dk7rd}nA|jjd�dk7rd}n |jjd	�dk7rd
}|dk(r.|jj	�jd�dk7rd
}|j}|dk(rb|jjd�dk7rd}nA|jjd�dk7rd}n |jjd	�dk7rd
}|dk(r.|jj	�jd�dk7rd
}|js�||k7r�|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|dk(ry|d
k(ry|d
k(ry|dk(ry|dk(ry|dk(ry|dk(ry|d
k(ry|d
k(ryt|j�t|j�k}|s|j|jk}|S)z9
        Compare devices by order of preference.
        TF�dnssdz._ippr��dnssdiz._pdl-datastream�dnssdsz	._printer�dnssdl�usb�fax�usbfax�serial�parallel�hp�hpfax�ipps�ipp�socket�lpd)rr1rqr�r&r0r�r>)r�other�stype�otyperys     r�__lt__z
Device.__lt__!s����=���=�=�E�N�N�*��~�~����	�	���G���x�x�}�}�W�%��+� �������1�2�b�8� �������{�+�r�1� ���E�>��x�x�~�~��$�$�U�+�r�1� ���
�
���G���y�y�~�~�g�&�"�,� ������� 2�3�r�9� ��������,��2� ���E�>��y�y��� �%�%�e�,��2� ���}�}�%�5�.��� ���� ���
�"���
�"����}����}������������ ���� ������������~����~���� ���� ���� ���� ���� ���� ����~����~����~����~���� ���� ���d�g�g���e�h�h��/����Y�Y����+�F��
rN)r�r�r��__doc__rr#rrrrrr�s���-�48�^rrc��eZdZd�Zd�Zy)�_GetDevicesCallc���d|vr7|jd�|_|j|d<|jdi|��Sd|_|jdi|��}|j||�S)N�
reply_handlerr)r9�_client_reply_handler�_reply_handler�
getDevices)rr�kwdsrys    r�callz_GetDevicesCall.call�sq���d�"�)-���?�)C�D�&�$(�$7�$7�D��!�(�:�(�(�1�D�1�1�%)��"�&��&�&�/�$�/���"�"�J��7�7rc��|j�D]G\}}t|fi|��}|||<|jdk7s�'|jdk(s�7|j|_�I|jr|j	||�y|S)Nr8)rYrr>rAr")rr�devicesrq�data�devices      rr#z_GetDevicesCall._reply_handler�sx�� ����	4�I�C���C�(�4�(�F�!�G�C�L��{�{�b� �V�%:�%:�b�%@�(.����%�		4��%�%��&�&�
�G�<��NrN)r�r�r�r&r#rrrrr�s��8�
rrc�:�t�}|j||�S)z�
    Obtain a list of available CUPS devices.

    @param connection: CUPS connection
    @type connection: cups.Connection object
    @returns: a list of L{Device} objects
    @raise cups.IPPError: IPP Error
    )rr&)rr�ops   rr$r$�s��
�	�B�
�7�7�J��#�#rc��|j|�|j|�|j��|j|�yy)a
    Set a new printer enabled, accepting jobs, and (if necessary) the
    default printer.

    @param connection: CUPS connection
    @type connection: cups.Connection object
    @param name: printer name
    @type name: string
    @raise cups.IPPError: IPP error
    N)r�r��
getDefaultr�)rr
s  r�activateNewPrinterr/�sD�����d�#����4� �����'����t�$�(rc
����fd���fd�}||�D]�}|jdk(r�|j|j�}|s�1|j|jk(s�K|j}|jD]T}|d|k(s�|j|j|�t
dt|j��dt|�����V��y)z�
    Copy default options between PPDs.

    @param ppd1: source PPD
    @type ppd1: cups.PPD object
    @param ppd2: destination PPD
    @type ppd2: cups.PPD object
    c�v��|jdd}|jD]}|j�|���|Sr)r	�	subgroupsr�)�groupr	�g�getPPDGroupOptionss   �rr5z*copyPPDOptions.<locals>.getPPDGroupOptions�s;����-�-��"�����	2�A��N�N�-�a�0�1�	2��rc3�R�K�|jD]}�|�D]}|����y�wr)�optionGroups)�ppdr3�optionr5s   �r�iteratePPDOptionsz)copyPPDOptions.<locals>.iteratePPDOptions�s5������"�"���,�U�3�
���\�
��s�$'�
PageRegion�choicezset z = N)�keyword�
findOption�ui�	defchoice�choices�
markOptionr�repr)�ppd1�ppd2r:r9�
new_optionrir<r5s       @r�copyPPDOptionsrG�s������
$�D�)�
A���>�>�\�)���_�_�V�^�^�4�
��&�)�)�Z�]�]�2��$�$�E�$�,�,�
A���(�#�U�*��O�O�J�$6�$6��>��$�
�8J�8J�2K�26��,�"@�A�
A�
Arc��d}gd�}|D]
}||k(s�	d}�	td�}|D]�}|jd�r�|j�j�jd�rd}�E|j�j�jd�rd}�u|j�dk7s��n|j	�	|jd	|�t
d
|z�y#Y�&xYw#t
d|z�YyxYw)
z�
    Set the PPD page size according to locale.

    @param ppd: PPD
    @type ppd: cups.PPD object
    @param language: language, as given by the first element of
    locale.setlocale
    @type language: string
    �A4)�C�POSIX�en�en_US�en_CA�fr_CA�Letterz/etc/papersize�#�a4�letterr8�PageSizezset PageSize = %sz*Failed to set PageSize (%s not available?)N)�openr-r�r&�closerBr)r8�language�sizerS�eachr�r�s       r�setPPDPageSizerZ�s����D�
>�F�����t���D��


��"�#���	�D����s�#���z�z�|�!�!�#�.�.�t�4�������#�#�%�0�0��:��������#��	�	
���	�J����
�D�)��(�4�/�0��
���
J��A�D�H�I�s�BC"�-C"� C)�"C&�)C;c�f��dd�}g��fd�}dx}}|jd�}|�ro|jjdd�}|jdd�}|jd	d
�}|jdd�}|jd
�dk7s|jd�dk7rd}|j	d�}|D]�}|j�j	d�}	|	D]�}
|
j�j	d�}|d}||�}|s	||��:tjj|�dk(s�]t|�}d}
d}|
|ks�r||
}|j|�r!|t|�d}||�}|s||���|
dz
}
|
|kr�B��|r��n|s|�stjd��\}}t
j|�|j|�t
j|dtj �t
j"|dd��}d}|D]�}|j|�s�|t|�dj�jd�}	|j	d�\}}}||t$j&dz�}|r�s|t$j&dz|z����S#Y��xYw) z�
    Check that all relevant executables for a PPD are installed.

    @param ppd: PPD
    @type ppd: cups.PPD object
    @returns: string list, representing missing executables
    c�t�|dk(ry|jd�}|dk7r|d|}t|�dk(ry|ddk(rCtj|tj�rtd|z�|Std	|z�y|jd
�dk7ry|dvry|j
d�D]}|jtjj�tjjz|z}tj|tj�s�otd|z�|cSt|�d
|���y)N�-�builtin�%r�r�truermz	%s: foundz
%s: NOT found�=)'rnr~�[�alias�bind�break�cd�continue�declare�echo�else�eval�exec�exit�export�fi�if�kill�letr
�popd�printf�pushd�pwd�read�readonly�set�shift�shopt�source�test�then�trapr1�ulimit�umask�unalias�unset�waitrnz: NOT found in )
r�rr�access�X_OKrrp�rstrip�path�sep)r
r��p�	component�files     r�	pathcheckz%missingExecutables.<locals>.pathcheck	s���3�;���I�I�s�O����7����8�D���:��?����7�c�>��y�y�$����(��[�4�/�0����_�t�3�4���9�9�c�?�b� ���2�2�����S�)�	�I��#�#�R�W�W�[�[�1�B�G�G�K�K�?�$�F�D��y�y�$����(��[�4�/�0���		�
	�d�D�9�:�rc�^��|jd�}|dk7r|d|}�j|�y)Nr_r�)r�r�)�exer��exes_to_installs  �r�add_missingz'missingExecutables.<locals>.add_missing/s0����H�H�c�N����7��b�q�'�C�����$rN�FoomaticRIPCommandLinez&&
r8z&quot;�"z&lt;�<z&gt;�>�(r��&r��|r�r�gsrz-sIjsServer=T)�text�rtzutf-8)�encodingz*cupsFilter:z/filter:/usr/lib64/cups/filterz/filter/)z
/usr/bin:/bin)�findAttrrir�r�rpr�rr��basenamerr-r��mkstempr�writeFd�lseek�SEEK_SET�fdopenr�cupsserverbindir)r8r�r�r��exepath�attr�cmdline�pipes�pipe�cmds�cmdrw�argn�argi�search�arg�tmpfd�tmpfnamer�r��mimetype�costr�s                      @r�missingExecutablesr��s����"�H�O�%���C�'��<�<�1�2�D���*�*�$�$�f�b�1���/�/�8�S�1���/�/�6�3�/���/�/�6�3�/���L�L�#��"�$��L�L�#��"�$��G��
�
�s�#���	�D��:�:�=�&�&��,�D��
"���y�y�|�)�)�3�/���1�g��#�S�/�����%��
�7�7�#�#�W�-��5���:�D��D�+�F���+�"�4�j���>�>�6�2�"%�c�6�l�m�"4�C�&/��o�G�#*� +�S� 1�!���	����+�
"�6��?	�B�c�%�,�,�4�8����
�	�	�8�����U��
���%��B�K�K�(��I�I�u�d�W�5�����	M�D�����'��C��L�M�*�0�0�3�9�9�3�?���,0�J�J��,<�)�X�t�S�$�S�%+�%<�%<�@>�&>�?�����!8�!8�:�!E��!K�L�	M������s�J,�,J0c� �t|�}g|fS)z�
    Check that all relevant executables for a PPD are installed.

    @param ppd: PPD
    @type ppd: cups.PPD object
    @returns: string list pair, representing missing packages and
    missing executables
    )r�)r8�executabless  r�missingPackagesAndExecutablesr��s��%�S�)�K����rc��tj�}t|�j�D]"}t	|j
|j��$yr)r+�
Connectionr$�values�printrqr�)�cr*s  r�_mainr��s<������A��Q�-�&�&�(�+��
�v�z�z�6�>�>�*�+r�__main__)r+�pprintrr��re�stringr�r8rr�	functoolsrrr�rr�objectrr$r/rGrZr�r�r�r�rrr�<module>r�s���,.�-�-�
����r�r�h
�$�:@�@�D�f��.
$�%�$A�@&J�PA�F
�+��Z��	�G�r

Zerion Mini Shell 1.0