%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�u�c*��d�dZddlZddlZddlZddlZddlZddlmZGd�d�Z	Gd�d�Z
y)zo
Implementation of the XDG Recent File Storage Specification
http://standards.freedesktop.org/recent-file-spec
�N)�ParsingErrorc�D�eZdZd�Zd
d�Zd�Zd
d�Zdd�Zdd�Zd�Z	d	�Z
y)
�RecentFilesc� �g|_d|_y)N�)r�filename��selfs �1/usr/lib/python3/dist-packages/xdg/RecentFiles.py�__init__zRecentFiles.__init__s�������
�Nc���|s3tjjtjd�d�}	tj
jj|�}||_
|jD]�}|jtj
j j"k(s�5|j$dk(s�E|jD]U}|jtj
j j"k(s�5|j$dk(s�E|j'|��W��|j)�y#t$r
td|��tjjj$r
td|��wxYw)ziParse a list of recently used files.
        
        filename defaults to ``~/.recently-used``.
        �HOMEz.recently-used�File not foundzNot a valid .menu filer�
RecentItemN)�os�path�join�getenv�xml�dom�minidom�parse�IOErrorr�parsers�expat�
ExpatErrorr�
childNodes�nodeType�Node�ELEMENT_NODE�tagName�_RecentFiles__parseRecentItem�sort)r
r�doc�child�recents     rrzRecentFiles.parses ��
��w�w�|�|�B�I�I�f�$5�7G�H�H�	C��'�'�/�/�'�'��1�C�!��
��^�^�	?�E��~�~������!:�!:�:��=�=�M�1�"'�"2�"2�?��!�?�?�c�g�g�l�l�.G�.G�G�%�~�~��=� $� 6� 6�v� >�?�	?�	
�	�	����	;��/��:�:��{�{� � �+�+�	C��7��B�B�	C�s�)D/�/AE7c�V�t�}|jj|�|jD�]t}|jt
jjjk(s�6|jdk(r|jdj|_�d|jdk(r|jdj|_��|jdk(r(t|jdj�|_��|jdk(rd|_��|jdk(s��|jD]v}|jt
jjjk(s�5|jdk(s�E|j j|jdj��x��wy)	N�URIrz	Mime-Type�	Timestamp�PrivateT�Groups�Group)�
RecentFiler�appendrrrrr r!r"�	nodeValuer)�MimeType�intr*�Prviater,)r
�itemr'�	attribute�groups     r�__parseRecentItemzRecentFiles.__parseRecentItem*sI�����������'����	T�I��!�!�S�W�W�\�\�%>�%>�>��$�$��-�!*�!5�!5�a�!8�!B�!B�F�J��&�&�+�5�&/�&:�&:�1�&=�&G�&G�F�O��&�&�+�5�'*�9�+?�+?��+B�+L�+L�'M�F�$��&�&�)�3�%)�F�N��&�&�(�2�!*�!5�!5�T�� �>�>�S�W�W�\�\�-F�-F�F�$�}�}��7� &�
�
� 4� 4�U�5E�5E�a�5H�5R�5R� S�T�	Tr
c��|s|jstd|��|s|j}t|d�5}tj|tj
�|j
d�|j
d�|jD�]%}|j
d�|j
dtjjj|j�z�|j
d|jz�|j
d|jz�|jd	k(r|j
d
�t!|j"�dkDrG|j
d�|j"D]}|j
d
|z��|j
d�|j
d���(|j
d�tj|tj$�ddd�y#1swYyxYw)z�Write the list of recently used files to disk.
        
        If the instance is already associated with a file, filename can be
        omitted to save it there again.
        r�wz<?xml version="1.0"?>
z<RecentFiles>
z  <RecentItem>
z    <URI>%s</URI>
z    <Mime-Type>%s</Mime-Type>
z    <Timestamp>%s</Timestamp>
Tz    <Private/>
rz
    <Groups>
z      <Group>%s</Group>
z    </Groups>
z  </RecentItem>
z</RecentFiles>
N)rr�open�fcntl�lockf�LOCK_EX�writerr�sax�saxutils�escaper)r1r*r+�lenr,�LOCK_UN)r
r�f�rr6s     rr>zRecentFiles.write?s�����
�
��/��:�:���}�}�H�
�(�C�
 �	*�A��K�K��5�=�=�)�
�G�G�-�.�
�G�G�%�&��%�%�
-�����*�+����-����0@�0@�0G�0G����0N�N�O����9�A�J�J�F�G����9�A�K�K�G�H��9�9��$��G�G�.�/��q�x�x�=�1�$��G�G�,�-�!"���E����� ;�e� C�D�E��G�G�-�.����+�,�
-�
�G�G�&�'��K�K��5�=�=�)�)	*�	*�	*�s�F1G/�/G8c�T�g}d}|jD]�}|r-|D]'}||jvs�|j|�|dz
}�)nU|r.|D](}||jk(s�|j|�|dz
}�*n%|jdk(r|j|�|dz
}|dk7s��||k(s��|S|S)z�Get a list of recently used files.
        
        The parameters can be used to filter by mime types, by group, or to
        limit the number of items returned. By default, the entire list is
        returned, except for items marked private.
        r�F)rr,r/r1r+)	r
�	mimetypes�groups�limit�tmp�ir4r6�mimetypes	         r�getFileszRecentFiles.getFiles`s�����
���$�$�	�D��#��E�����+��
�
�4�(��Q����� )��H��4�=�=�0��
�
�4�(��Q����
�<�<�5�(��J�J�t�$���F�A���z�a�5�j���
�%	�$�
r
c���||jvr+|jj|�}|j|}nWt|j�dk(r|jj�t	�}|jj|�||_||_ttj��|_
||_|r||_|j�y)z}Add a recently used file.
        
        item should be the URI of the file, typically starting with ``file:///``.
        i�N)r�indexrB�popr.r/r)r1r2�timer*r+r,r$)r
r4rMrI�privaterPr's       r�addFilezRecentFiles.addFile}s����4�#�#�#��$�$�*�*�4�0�E��%�%�e�,�F��4�#�#�$��+�� � �$�$�&��\�F����#�#�F�+���
�"����t�y�y�{�+��� ����"�F�M��	�	�r
c�X�||jvr|jj|�yy)z<Remove a recently used file, by URI, from the list.
        N)r�remove)r
r4s  r�
deleteFilezRecentFiles.deleteFile�s+���4�#�#�#����#�#�D�)�$r
c�l�|jj�|jj�y�N)rr$�reverser	s rr$zRecentFiles.sort�s&����������� � �"r
rY)NNr)NF)�__name__�
__module__�__qualname__rrr#r>rNrTrWr$�r
rrr
s,����6T�**�B�:�4*�#r
rc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)r.c�J�d|_d|_d|_d|_g|_y)NrF)r)r1r*r+r,r	s rrzRecentFile.__init__�s%�������
���������r
c�B�t|j|j�SrY)�cmpr*�r
�others  r�__cmp__zRecentFile.__cmp__�s���4�>�>�5�?�?�3�3r
c�4�|j|jkSrY)r*rcs  r�__lt__zRecentFile.__lt__�s���~�~����/�/r
c�2�|jt|�k(SrY)r)�strrcs  r�__eq__zRecentFile.__eq__�s���x�x�3�u�:�%�%r
c��|jSrY)r)r	s r�__str__zRecentFile.__str__�s���x�x�r
N)r[r\r]rrergrjrlr^r
rr.r.�s���4�0�&�r
r.)�__doc__�xml.dom.minidomr�xml.sax.saxutilsrrRr;�xdg.Exceptionsrrr.r^r
r�<module>rqs/���
)���'�U#�U#�p�r

Zerion Mini Shell 1.0